Skip to content

fix(security): prevent directory traversal in response cache and isolate storage - #2321

Merged
dan-petty merged 6 commits into
mainfrom
fix/1014-response-cache-directory-traversal
Oct 26, 2026
Merged

dan-petty merged 6 commits into
mainfrom
fix/1014-response-cache-directory-traversal

Conversation

@dan-petty

@dan-petty dan-petty commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Confine the LLM response cache strictly to files named <cache_dir>/<requested_key>.json and validate that cache keys match llm_ followed by 64 hex characters before accessing the filesystem. Delete stored entries on disk whose key field differs from the requested key. Re-root cache resolution under <DATA_DIR>/cache/llm through settings, removing ai.cache.dir. Delete rejected entries upon client lookup, avoid caching empty model responses, and enforce required fields and extra="forbid" on ModelProposal.

Closes #1014

Change: openspec/changes/archive/2026-10-26-1014-response-cache-directory-traversal/

Fail-to-pass verification

Verified with devops ci fail-to-pass --base origin/main:

  • tests.test_ai_client_structured::test_model_proposal_schema_forbids_extra_and_requires_fields
  • tests.test_response_cache::test_ai_cache_status_and_clear_read_settings
  • tests.test_response_cache::test_check_chat_cache_deletes_rejected_entry
  • tests.test_response_cache::test_loaded_entry_with_mismatched_key_is_not_served_and_deleted
  • tests.test_response_cache::test_response_cache_resolves_under_data_cache_dir
  • tests.test_response_cache::test_empty_content_with_thinking_is_not_cached
  • tests.test_response_cache::test_cache_delete_removes_entry_from_memory_and_disk
  • tests.test_response_cache::test_cache_refuses_malformed_keys_before_file_access

Validate response cache keys before any disk lookup or write operation.
Reject malformed keys, directory traversal patterns, and absolute paths.
Ensure disk entries match their filename key before use.
Remove obsolete dir field from response cache configuration.
Derive the response cache location directly from the data cache directory.
Ensure the singleton cache instance initializes from user configuration.
Ensure clients with disabled caching isolate themselves from global state.
…esponses

Delete cached entries from memory and disk when validator rejects content.
Do not cache empty or whitespace responses that contain thinking blocks.
Enforce strict schema validation and required fields in ModelProposal.
Update review group analysis tests to inspect isolated cache directory.
Update telemetry instruments test to use valid cache key format.
Avoid hardcoded temporary directory path in response cache test.
Archive OpenSpec change 1014-response-cache-directory-traversal.
Promote the llm-response-cache specification.
@dan-petty
dan-petty marked this pull request as ready for review October 26, 2026 18:53
@dan-petty
dan-petty merged commit 1967695 into main Oct 26, 2026
18 of 19 checks passed
@dan-petty
dan-petty deleted the fix/1014-response-cache-directory-traversal branch October 26, 2026 18:54
dan-petty pushed a commit that referenced this pull request Oct 26, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.6.5](v0.6.4...v0.6.5)
(2026-10-26)


### Bug Fixes

* **ai:** analyze pr previews under --dry-run and contacts no service
([#2327](#2327))
([c402b6d](c402b6d))
* **dashboard:** reject unknown tab option values and remove refresh_all
([#2310](#2310))
([27f8c60](27f8c60)),
closes [#1904](#1904)
* **deps:** renovate updates the image tags in k8s/ manifests
([#2325](#2325))
([b0ebce0](b0ebce0))
* **devcontainer:** isolate image build metadata from workspace settings
([#2309](#2309))
([7672c71](7672c71))
* **output:** remove duplicated check marks from success messages
([#2313](#2313))
([db7c3c4](db7c3c4))
* **review:** record coverage gaps on base read failures and accept
empty diffs
([#2326](#2326))
([a307ac0](a307ac0))
* **roadmap:** the roadmap runs on a rebuilt board, because GitHub
refuses to add 149 issues to board 2
([#2320](#2320))
([48c78ca](48c78ca))
* **security:** cloudflared 2026.10.4 replaces 2026.9.3, which trusts
eight compromised eMudhra certificates
([#2324](#2324))
([e6750be](e6750be))
* **security:** prevent directory traversal in response cache and
isolate storage
([#2321](#2321))
([1967695](1967695))
* **telemetry:** send project gauges through OTLP only
([#2288](#2288))
([#2315](#2315))
([aeaa52e](aeaa52e))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(security): the response cache writes only inside its own directory and is never read from the tree under review

1 participant