Repository navigation
TC CFG 009
| Severity | high |
| Harnesses | Copilot (coding agent), Cursor (cloud agents), dev containers, Devin |
| Files |
.github/workflows/copilot-setup-steps.yml, .cursor/environment.json, .devcontainer/devcontainer.json, .devcontainer/<name>/devcontainer.json, .devcontainer.json, .devin/blueprint.yaml (repository scope) |
| Rule | rules/TC-CFG-009.yaml |
A cloud agent or a dev container runs the repository's environment setup on its own, before anyone reviews what that setup downloaded. A setup command that fetches code from a source that can change, and runs it, runs whatever that source serves the next time.
Commands read:
- Copilot: the
runof each step of thecopilot-setup-stepsjob.usessteps are not read. - Cursor: the
installandstartstrings and each terminalcommandin.cursor/environment.json. - Dev containers:
initializeCommand,onCreateCommand,updateContentCommand,postCreateCommand,postStartCommand, andpostAttachCommand, as a string, an array, or an object of named commands.initializeCommandruns on the host before the container starts, so is the most sensitive lifecycle command. Anhttp(s)tarball Feature is read as acurlof its URL. - Devin: each
initializeandmaintenancecommand in.devin/blueprint.yaml, whether the section is a string or a list whose entries are strings or mappings withrun.usessteps are not read. The command is taken as written; the rule does not assume the build shell enables errexit.
Each command is read by shell.unpinned, which reports the same
risks as shell.risks (see TC-CFG-001: a fetch, a
pipe into a shell or Invoke-Expression, encoded PowerShell, or
nesting it cannot follow) unless every fetch in the command is pinned.
A command is pinned in one of two ways. A command that mixes the two is not.
-
Immutable URL. Every downloader target is
https, has no userinfo, and its host does not end in a dot. The commit has to sit where that host actually stores an immutable object:raw.githubusercontent.com/<owner>/<repo>/<sha>/,github.com/<owner>/<repo>/raw/<sha>/,github.com/<owner>/<repo>/archive/<sha>.tar.gzor.zip,codeload.github.comarchive paths (tar.gz,zip,legacy.tar.gz,legacy.zip), a gistraw/<sha>/path,cdn.jsdelivr.net/gh/<user>/<repo>@<sha>/, orgitlab.com/<group>/<project>/-/raw/<sha>/. A 40- or 64-digit hex commit on one of those paths cannot change. jsDelivr and GitLab are on the list because those exact paths address one commit, as GitHub's raw and archive paths do. Asha256:<64 hex>digest in the URL, even after an OCIblobsormanifestssegment, is not a pin: curl and wget do not verify it. Any other host, a release asset, a tag, a branch, userinfo (raw.githubusercontent.com@evil.example), or a trailing-dot host is not a pin. Nor is a path with a.or..segment, as written or percent-encoded in any case (%2e%2e,.%2E): curl and wget resolve it before the request, so<sha>/../main/fetchesmain. The host match is case-insensitive. -
Checksum verified before execution. The whole script (the step,
the string, or the payload of an exact
["sh"|"bash", "-c", script]array) parses under the checksum grammar below. The grammar is an allowlist: anything it does not list gives no checksum credit, and the fetch is reported. An unusual script that is in fact safe can be reported. That is the intended trade-off.
Every command in the script is one of these forms:
| Form | Accepted | Notes |
|---|---|---|
| Fetch |
curl -o <file> <url>, wget -O <file> <url>
|
Exactly one http(s) URL and one plain output filename: ^[A-Za-z0-9_][A-Za-z0-9._-]*$. It has no /, leading dot, or leading - (so not -q or --) and is not curlrc, _curlrc, wgetrc, .wgetrc, netrc, or _netrc, or a command the grammar runs (sha256sum, sh, ...), in any case (CURLRC and SH are rejected too, since macOS and Windows file systems ignore case). It is never a sums file. This prevents a fetch from planting curl, wget, loader, or netrc configuration. curl options: -f -s -S -L -k (clustered, -o last), --fail, --silent, --show-error, --location, --create-dirs, --compressed, --fail-with-body, --no-progress-meter, --tlsv1.2, --tlsv1.3, --http1.1, --retry, --retry-delay, --retry-max-time, --connect-timeout, --max-time, --proto, --proto-redir, --output. wget options: -q, -nv, --quiet, --no-verbose, --https-only, --tries, --timeout, --output-document. |
| Check |
sha256sum -c <sums>, shasum -a 256 -c <sums>
|
--check is the long form of -c. No other option. <sums> is a plain filename, not - or a path. It must be committed to the repository (see below), and is never fetched or run by the script. |
| Entry check | echo '<64 hex> <file>' | sha256sum -c [-] |
Or printf '<64 hex> <file>\n', or shasum -a 256 -c [-]. The text is parsed: exactly one entry, 64 hex digits, two spaces or *, and a plain filename. No echo option, no printf conversion, and no escape except a final \n. It covers only the file it names. The pipe is exactly these two commands, the check last, so it fails when the check fails without pipefail. |
| Run |
sh <file>, bash <file>
|
<file> is a plain filename the script fetched; no shell option. Arguments after it are passed to the script. |
| Errexit |
set -e, set -eu, set -euo pipefail, set -eo pipefail, set -o errexit
|
Only before every other command, each a statement of its own. A set anywhere else gives no credit. |
| Files |
mkdir <file>, rm <file>, chmod <mode> <file>
|
Every file is a plain filename. chmod mode is exactly +x, 0755, or u+x. cd is not accepted. |
Syntax:
- Statements are joined by
;, a newline, or&&. A newline may follow&&.#starts a comment at the start of a word. The only pipe is the one of an entry check. - Command names are literal: not quoted, not escaped, no path
(
/usr/bin/curl), no variable. - Unquoted words use letters, digits, and
_-./:=+,@%^. Double quotes may not hold$, a backquote,\, or!. Single quotes may hold anything. - Anything else gives no credit: another command (
trap,eval,source,.,alias,shopt,exec,true,:,npm, ...), a function, a subshell,{ },if/while/for/case,||,&, a redirection,$, a backquote, a backslash outside single quotes, a glob,~, a carriage return,cd,export, or an assignment.
Order:
-
Each run of a file comes after a check that covers it, with no fetch between the check and the run. The check stops the run when it fails: it is in the same
&&list, or the script starts withset -eand the check is a statement of its own. -
Each fetch is followed by a check that covers its file before the file is fetched again, and that fails the script: a statement of its own under
set -e, or part of the script's last statement. Every fetched file must be either the script run or the file named by an entry check; an unused fetch gives no credit. -
A sums file is never a fetch target and never run, and is not the run file. Names are compared case-insensitively here, so
curl -o i.sh ...; sha256sum -c I.SHgives no credit either. -
An entry check covers only the file it names. A plain check (
sha256sum -c <sums>) covers only the files<sums>lists, and only when<sums>is committed to the scanned repository:- it exists at the repository root as a regular file. Like the hook
scripts of
internal/scriptcheck, its parent path is resolved withStatandEvalSymlinksand must stay inside the repository. Its final component is checked withLstatand must itself be a regular file: a committed sums-file symlink, even one to a file inside the repository, gives no credit. It is then read through the repository's confined reader, at most 64 KiB; - every line is
<64 hex> <name>or<64 hex> *<name>, with an optional final newline. A blank line, a comment, a carriage return, or the BSDSHA256 (name) = ...form makes the file malformed; - the run file appears in it, exactly as the script names it.
A missing, unreadable, out-of-tree, or malformed sums file, or one that lists only other files, gives no credit. The file is looked up in the repository root, where Copilot, Cursor, and dev containers run setup. A Copilot step with a
working-directory(its own, or the job's or workflow'sdefaults.run), and adevcontainer.jsonthat setsworkspaceFolder, run elsewhere, so get no credit for a plain check. - it exists at the repository root as a regular file. Like the hook
scripts of
-
Each file the grammar fetches or runs is also checked with
Lstat. If a committed path with that filename is a symlink, the script gets no checksum credit. This prevents a downloaded script from being written through a link (including one to the sums file or outside the repository), and prevents a sums-file symlink from aliasing the downloaded script. The repository directory is inspected case-insensitively:T.SHis treated as a match fort.sh, because macOS and Windows may open it fort.sh. A symlink or non-regular case variant therefore also gets no credit. For a sums file, any alternate-cased entry (even a regular one) gets no credit, so the named sums file is unambiguous.
Copilot steps whose effective shell is fail-closed are read with a
leading set -e, so a check on its own line counts there.
Accepted:
curl -fsSLo t.sh https://get.tools.example.invalid/t.sh && sha256sum -c t.sh.sha256 && sh t.shset -euo pipefail
curl -fsSLo t.sh https://get.tools.example.invalid/t.sh
echo "<sha256> t.sh" | sha256sum -c -
sh t.shNot accepted: trap 'sh t.sh' EXIT anywhere, echo set -e, \set +e,
sha256sum() { :; }, echo "<sha256> /dev/null" | sha256sum -c,
echo "<sha256> other.sh" | sha256sum -c && sh t.sh,
printf '%s t.sh\n' <sha256> | sha256sum -c, a fetched sums file
(curl -o t.sha ...; curl -o t.sh ...; sha256sum -c t.sha; sh t.sh),
and the script as its own sums file
(curl -o t.sh ...; sha256sum -c t.sh; sh t.sh).
Never pinned: package runners (npx -y, bunx, pnpm dlx,
yarn dlx, uvx, pipx run), tags, git clone (including a later
checkout of a 40-hex sha), inline python -c or node -e network
code, a downloader whose target is a variable, and encoded or
too-deeply nested payloads.
A setup command whose fetches only write data that nothing in the same configuration file runs is not reported: a data archive extracted into a data directory, a version file used as a cache key, or a companion repository cloned next to the project. The analysis is an allowlist, and anything it cannot follow keeps the finding.
- The command has no risk but the fetch: no pipe into a shell, nothing
encoded or nested too deep. One
sh -c,bash -c, ordash -cwrapper is read through. - The whole command is simple commands joined by
;, a newline,&&,||, or&. A$, backquote, glob, subshell, function, pipe,<, here-document, or shell keyword (if,for,case, ...) anywhere gives no credit, as docd,pushd,popd,source,.,eval,exec,trap,alias,xargs, andfind. The one exception is acdbefore the first fetch, clone, or extraction, with one literal directory operand (absolute or relative) of plain segments, none of thembin,sbin,libexec,node_modules,vendor,site-packages, orhooks. It moves the whole script, so the name matching below is unchanged. Acdafter a fetch still keeps the finding. - Each fetch is a
curlorwgetof onehttp(s)URL that writes to standard output or to one literal file (-o,-O,> file,>> file, or wget's default name). The file is a relative path of plain segments (no leading.or-) with an archive (.tar.gz,.tgz,.zip, ...) or data (.json,.csv,.tsv) name, and not a manifest a tool reads without being told (package.json,composer.json,deno.json,tsconfig.json,settings.json,mcp.json, ...). Or it is agit cloneof onehttp(s)orgit://URL with only--depth,-b/--branch,--single-branch,--no-tags,--filter, and-q, into a literal directory or the one the URL names. A downloader or clone of any other form, including one behindsudoorgit -C, keeps the finding. -
tar -xorunzipmay extract an archive into a literal directory given with-Cor-d; the directory of a fetched archive counts as fetched. Extracting without a directory, or cloning or extracting intobin,sbin,libexec,node_modules,vendor,site-packages, orhooks, keeps the finding. -
cat,grep,jq,head,tail,wc,ls,sha256sum,shasum,md5sum,cmp,diff,test,mkdir,rm,echo, andprintfwithout a redirection may name what was fetched. - No other command in the script, and no other string in the same
configuration file (other steps, lifecycle commands,
uses:,with:,env,working-directory, ...), contains a fetched file or directory name, as written or as its last path segment, compared case-insensitively as a substring. Step and command names are labels and are not read, and a GitHub ActionshashFiles('...')expression only hashes its files. A glob in another command of the file keeps the finding.
Not reported:
- run: |
curl -fsSL https://example.invalid/data/testdata-1.2.tar.gz -o testdata.tar.gz
tar -xzf testdata.tar.gz -C data
- run: curl -fsS https://example.invalid/version.json >> cache-key.json{"postCreateCommand": "/bin/bash -c 'python -m pip install uv && python -m uv sync & git clone https://example.invalid/org/examples; wait'"}{"postCreateCommand": "bash -c 'cd /workspaces && git clone --depth 1 https://example.invalid/org/fixtures.git && make deps'"}Still reported: tar -xzf tool.tar.gz && ./tool/install.sh,
git clone <url> /tmp/helper then bash /tmp/helper/setup.sh,
git clone <url> helper && cd helper && make,
cd /workspaces && git clone <url> helper && cd helper && make,
curl -o tool <url> && chmod +x tool, a later step that runs
./tool/install.sh after an earlier one extracted into tool, and
curl -o package.json <url> && npm install.
-
RUNlines of a Dockerfile and OCI Feature references (ghcr.io/devcontainers/features/node:1) are not read. OCI Feature tags are not flagged. - Copilot's effective shell is the step's
shell, then the job'sdefaults.run.shell, then the workflow's, then GitHub's defaultbash --noprofile --norc -eo pipefail {0}. The built-in namesbashandshare also fail-closed (sh -e {0}). A custom template such asbash {0}is not. A step that runsset +eor anything else outside the checksum grammar gets no checksum credit. - Variables are not expanded, and the script a setup command fetches is not read.
- For fetched data that nothing runs (see above), a committed script,
build file, or manifest that a setup command runs is not read: one
that runs a fetched file or directory by name is not seen. A
committed
package.jsonthat names a fetched directory withfile:./<cloned dir>, followed bynpm install, is not inspected, so that fetch may be suppressed. - A
git cloneis not treated as a fetch when it is the last command in the script. The fetch risk is only raised when another command follows the clone. - The checksum itself is not compared with anything: the rule checks that a check runs against a hash committed to the repository, not that the hash is right.
Reported:
# .github/workflows/copilot-setup-steps.yml
jobs:
copilot-setup-steps:
runs-on: ubuntu-latest
steps:
- run: curl -fsSL https://get.tools.example.invalid/install.sh | sh{"postCreateCommand": "npx -y @vgmartinez/bootstrap"}# .devin/blueprint.yaml
initialize: |
curl https://x | shNot reported, with t.sh.sha256 committed at the repository root and
holding <sha256> t.sh:
{"install": "curl -fsSLo t.sh https://get.tools.example.invalid/t.sh && sha256sum -c t.sh.sha256 && sh t.sh"} - run: |
curl -fsSLo t.sh https://get.tools.example.invalid/t.sh
echo "<sha256> t.sh" | sha256sum -c -
sh t.sh{"postCreateCommand": "curl -fsSL https://raw.githubusercontent.com/vgmartinez/tools/0123456789abcdef0123456789abcdef01234567/install.sh | sh"}Commit the setup script to the repository and run it from there. If it
must be downloaded, fetch an https URL that names a commit,
or download it to a file and check its SHA-256 before running it,
joined with && so a mismatch stops setup: put the hash in the
command (echo '<sha256> t.sh' | sha256sum -c) or in a sums file
committed to the repository (sha256sum -c t.sh.sha256), never in a
file the setup downloads. Keep that script
to the checksum grammar: move anything else to a separate step or to a
committed script.
This wiki is generated from docs/ on main by cmd/wikigen. Do not edit it here: change docs/ and open a pull request. Apache-2.0.
Start
Commands
CI and hooks
Configuration
Adapters
- Claude Code
- Codex
- Cursor
- GitHub Copilot
- Gemini CLI
- OpenCode
- Windsurf
- Devin
- Dev Container
- Shared Files
Project