Skip to content

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

Open
necoweb3 wants to merge 1 commit into
NousResearch:mainfrom
necoweb3:fix/file-safety-bws-cache-enc-read-guard
Open

fix(security): add bws_cache.enc.json to file_safety read guard#70403
necoweb3 wants to merge 1 commit into
NousResearch:mainfrom
necoweb3:fix/file-safety-bws-cache-enc-read-guard

Conversation

@necoweb3

Copy link
Copy Markdown
Contributor

Summary

Adds <hermes_home>/cache/bws_cache.enc.json to agent/file_safety.py::get_read_block_error(), bringing read-denial protection into full parity with the write-denial rules in build_write_denied_paths().

Why

PR #31968 and PR #34421 introduced Bitwarden Secrets Manager disk cache handling. While bws_cache.json was added to get_read_block_error(), and bws_cache.enc.json was added to build_write_denied_paths() and web_server.py, bws_cache.enc.json was omitted from get_read_block_error().

As a result, read_file("<hermes_home>/cache/bws_cache.enc.json") evaluated to None (allowed), leaving a read-side credential protection gap for the Bitwarden encrypted cache file.

Key Changes

  • File Safety Guard: Appended os.path.join("cache", "bws_cache.enc.json") to credential_file_names in agent/file_safety.py::get_read_block_error().
  • Tests: Added tests/agent/test_file_safety_bws_enc.py to verify that reads to bws_cache.enc.json are denied alongside bws_cache.json, while other cache files remain readable.

Test

python -m pytest tests/agent/test_file_safety_bws_enc.py tests/agent/test_file_safety.py -q --timeout-method=thread

@alt-glitch alt-glitch added type/security Security vulnerability or hardening P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint area/auth Authentication, OAuth, credential pools needs-repro Bug needs reproduction steps sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data labels Jul 24, 2026
@teknium1 teknium1 added the sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users label Jul 30, 2026

@GottZ GottZ left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was generated by AI during triage.

Summary

Three PRs address the Bitwarden cache read-guard gap: #32092 and #34421 add the exact-path guard for the plaintext bws_cache.json, while #70403 extends the same protection to the separately omitted encrypted bws_cache.enc.json and adds regression coverage.

Related pull requests

  • #32092 [closed] related — (+4/-0) — superseded by merged salvage #34421: Adds an exact-path read denial for the plaintext cache/bws_cache.json without blocking unrelated cache files; it remains relevant as the original implementation and authorship source.
  • #34421 [merged] related — (+4/-0) — merged reference implementation: Salvages #32092 verbatim and closes the plaintext-cache gap by adding cache/bws_cache.json to the credential read-block list.
  • #70403 related — (+47/-0) — merge: Addresses the remaining encrypted-cache gap by blocking cache/bws_cache.enc.json on reads and adds focused tests covering encrypted/plaintext parity and continued access to unrelated cache files.

Duplicates

#32092 and #34421 implement the same bws_cache.json guard; #34421 is the merged salvage of #32092. #70403 is not a duplicate because it protects the distinct bws_cache.enc.json path and adds regression tests.

Suggested consolidation

Merge #70403#34421 already landed the plaintext-cache protection, while #70403 closes the analogous read-side omission for the encrypted cache and verifies both paths. #32092 can remain closed as superseded by merged #34421; no additional duplicate closure is needed.

Cross-PR triage: Reviewed 3 pull requests and 0 issues in this complex. Each diff was read against this issue; Assessment working set: 4 kB of PR diffs, 5 kB of issue/PR text, 2 kB of discussion (3 comments), 0 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint needs-repro Bug needs reproduction steps P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants