fleetlint Policy for a fleet of repositories
v0.11 (latest)
Getting started

ci/no-pipe-to-shell

Downloads are not piped into a shell

Severitywarning
Tiers1, 2
Stacksany
Scoperoot
Kindexpr
Sourcelibrary v0.8.0
Selected byfleetlint-recommended@v0.8.0

Requirement

CI scripts (Actions run steps, GitLab scripts) and Dockerfile/Containerfile instructions never pipe a download into a shell (curl ... | sh, wget -O- ... | bash, sh -c "$(curl ...)", bash <(curl ...)). Tools come from a pinned action, a package manager or a downloaded file whose checksum is verified before it runs.

Why

Whatever the server returns at that moment runs with the job’s secrets or ends up in the image, with nothing pinned and nothing verified.

Applies when

workflows().size() > 0 || tracked().exists(p, p.matches("(^|/)((Dockerfile|Containerfile)[^/]*|[^/]+\\.(Dockerfile|Containerfile|dockerfile|containerfile))$"))

Check

For each item in:

[r'((?:curl|wget)\b[^|#\n]*\|\s*(?:sudo\s+(?:-\S+\s+)*)?(?:ba|z|da|k)?sh\b|(?:ba|z|da|k)?sh\s+(?:-c\s+)?["\x27]?(?:<\(|\$\()\s*(?:curl|wget)\b)'].map(re,
  workflows().map(w, grep(w, re)).flatten()
  + grep("Dockerfile*", re) + grep("Containerfile*", re)
  + grep("*.Dockerfile", re) + grep("*.Containerfile", re)
  + grep("*.dockerfile", re) + grep("*.containerfile", re)).flatten()
item.text.startsWith("#") || item.path.endsWith(".dockerignore") || item.path.endsWith(".containerignore")

Fix

Download the installer or release archive to a file, verify its sha256 against a pinned value, then run it; or install through a pinned action or the package manager.

Agent instruction: Replace each flagged pipe with: download to a file, sha256sum -c against a pinned checksum (Renovate-annotated), then execute or extract; keep the installed version unchanged.

Sources


Generated by fleetlint docs from catalog v0.8.0.