Repository navigation
Conversation
|
@coderabbitai review @kauansb (issue reporter) — this is part 1 of your #157915: the allowlisted-reader name-matching half ( How the bug was detected: compared How it was fixed: one anchored arm in How it was tested: 2 new tests — Verify it yourself: |
_is_secret_file_arg knew .netrc/.pgpass/.env and config.yaml-under-.hermes, but auth.json, .anthropic_oauth.json and auth/google_oauth.json were not on any list — 'cat ~/.hermes/auth.json' reached the model context in cleartext while the same read of config.yaml was redacted (NousResearch#157915). The stores now match via the same inventory the file tools hard-deny (agent/file_safety._CREDENTIAL_FILE_NAMES), anchored like config.yaml: a .hermes segment, $HERMES_HOME or the resolved Hermes home, so a project's own auth.json is unaffected. secret_file=True re-enables the JSON assignment pass, so the token values are masked. Fixes NousResearch#157915 (part 1: allowlisted-reader name matching)
2904649 to
57785eb
Compare
|
@teknium1 — cordial ping on this one too, whenever bandwidth allows. It closes the cleartext half of #157915: Same note as its siblings: the first-time-contributor CI runs across today's five PRs are queued in Thanks for the incredible merge pace on this repo — it's what makes contributing here worth the care. 🙏 |
TL;DR for the reviewer
cat ~/.hermes/auth.jsonreached the model context in cleartext whilecat ~/.hermes/config.yamlwas redacted:_is_secret_file_argknew.env/rc files,.netrc-class stores, andconfig.yaml-under-.hermes— but Hermes' own credential stores (auth.json,.anthropic_oauth.json,auth/google_oauth.json,webhook_subscriptions.json, secret-cache stores) were on no list. This is the issue's part 1 (allowlisted-reader name matching); parts 2 (non-allowlisted readers) and 3 (egress heuristic) are deliberately left out to keep the blast radius minimal.One-line diff summary: one anchored arm in
_is_secret_file_arg, driven by the same inventory the file tools hard-deny — imported, not copied.Related issue & credit
Fixes #157915 (part 1) — reported by @kauansb (whose follow-up comment independently confirmed the content-shape gap).
Root cause
agent/redact.py:1678-1684:_FILE_READ_COMMANDSreaders gateredact_terminal_output's secret-file pass via_command_reads_secret_file→_is_secret_file_arg. That matcher (before) matched:.env/.envrc/shell rcs — any pathHOME_CREDENTIAL_FILES(.netrc,.pgpass, …) — any pathconfig.yaml— only under.hermes/$HERMES_HOME/ resolved Hermes home…while
agent/file_safety.py:468-470(_CREDENTIAL_FILE_NAMES) maintains the authoritative list of Hermes-home credential stores for the file tools — a listredact.pynever consulted. Net effect: the most credential-dense file in~/.hermeswas the one file the terminal redactor didn't classify.The change (
agent/redact.py, +16/−3)_CREDENTIAL_FILE_NAMES as _HERMES_CREDENTIAL_STORE_NAMESfromagent.file_safety— single source of truth, the two lists cannot drift._is_secret_file_arg, anchored exactly likeconfig.yaml: matches only with a.hermessegment,$HERMES_HOME, or the resolved Hermes home (the resolved-home arm covers native Windows homes with no.hermessegment). A project's ownauth.jsonnever matches. Multi-segment entries (auth/google_oauth.json) match on their trailing path components.secret_file=Truere-enables are pre-existing (issue redact: read_file/search_files return opaque secrets from config.yaml / shell rc files in cleartext (missing file-read half of #110228) #110567's machinery), and masking uses the non-reusable sentinel per the [Bug]: redact_sensitive_text corrupts API keys in config files when read via read_file/search_files, causing 401 #35519 write-back policy.Risks & mitigations
.hermes/$HERMES_HOME/resolved home only); negative test asserts/home/user/myapp/auth.jsonstays untouched.secret_filemasking already uses non-reusable sentinels.python -c/jqreaders, egress heuristic) explicitly not attempted here — each deserves its own measured false-positive review.How to cross-review
uv run pytest tests/agent/test_redact.py tests/agent/test_redact_credential_stores.py tests/hermes_cli/test_credential_store_lists.py -q→ 315 + 53 passed. The last file pinsSECRET_CACHE_STORES/HOME_ENV_FILEScontents, so inventory drift would fail there too.python -c "from agent.redact import redact_terminal_output as r; print(r('{\"api_key\": \"sk-or-v1-abc123def456ghi789jkl\"}', 'cat ~/.hermes/auth.json'))"→ token masked. Same call with'cat /home/user/myapp/auth.json'→ unchanged.config.yamlarm directly below the new code — same anchors by design.Verification evidence
uv sync --group dev --group test --frozen; ast-grep post-check; no nested control flow; no inline regexes.Checklist