Skip to content

fix(security): add bws_cache.json to file_safety read guard - #34421

Merged
teknium1 merged 1 commit into
mainfrom
hermes/sec-tier1-32130
May 29, 2026
Merged

fix(security): add bws_cache.json to file_safety read guard#34421
teknium1 merged 1 commit into
mainfrom
hermes/sec-tier1-32130

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #32092 (@AhmetArif0). Clean cherry-pick — applies to current main.

What it fixes

PR #31968 added a disk-persistent Bitwarden Secrets cache at <hermes_home>/cache/bws_cache.json containing plaintext secret values (API keys, DB passwords pulled from BSM projects). The file is chmod 0600, but agent/file_safety.get_read_block_error() was never updated to deny it — so the agent's read_file tool could harvest decrypted secrets directly while sibling stores (.env, auth.json, .anthropic_oauth.json, mcp-tokens/) were guarded.

Mechanism

Single exact-name entry appended to the credential_file_names tuple in agent/file_safety.py. Matches the existing shape (auth/google_oauth.json, .env, etc.). Per-name loop builds (hd / name).resolve() against each hermes_dir (HERMES_HOME + global root), exact path equality — other cache/* files (images, audio, documents) remain readable.

Validation

  • 54/54 tests pass: test_file_safety.py + test_file_safety_credentials.py + test_file_safety_cross_profile.py
  • E2E with plaintext-secrets bws_cache.json + legit screenshot.png/document.pdf in same cache dir: bws_cache blocked, image+document readable, .env still blocked

Closes #32092.

The Bitwarden Secrets Manager disk cache introduced in #31968 stores
plaintext secret values at <hermes_home>/cache/bws_cache.json to avoid
re-fetching across back-to-back CLI invocations. The file was not added
to get_read_block_error()'s credential_file_names list, leaving the
agent able to read it directly via the read_file tool.

Add os.path.join("cache", "bws_cache.json") to credential_file_names
so both HERMES_HOME and the global root are covered, matching the
existing pattern used for auth.json, .anthropic_oauth.json, etc.

Other files under cache/ (images, documents, audio) are unaffected —
the check is an exact-file match, not a prefix match.

Verified: 11/11 exploit/regression scenarios pass; 38/38 existing
file_safety tests pass.
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/sec-tier1-32130 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9419 on HEAD, 9419 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4890 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@teknium1
teknium1 merged commit 4126da6 into main May 29, 2026
23 checks passed
@teknium1
teknium1 deleted the hermes/sec-tier1-32130 branch May 29, 2026 06:31
@alt-glitch alt-glitch added P1 High — major feature broken, no workaround type/security Security vulnerability or hardening tool/file File tools (read, write, patch, search) labels May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High — major feature broken, no workaround tool/file File tools (read, write, patch, search) type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants