Repository navigation
persistence: write cache files owner-only (0700 dir, 0600 file) - #1206
Merged
Merged
Conversation
internal/persistence wrote its per-repo cache files with os.MkdirAll(dir, 0o755) and os.Create(path) — a world-readable 0644 file inside a world-accessible 0755 directory. The caches hold the agent's recent query strings (combo.gob.gz) and agent-written session notes/memories (notes.gob.gz, memories.gob.gz), which can contain sensitive content such as query text or pasted keys. On a shared machine any local user could read them. Add persistDir/persistFile helpers that create directories 0700 and files 0600 (owner-only) and use them in every Save* (combo, frecency, notes, memories, feedback, keyword). Flags are otherwise unchanged (os.O_RDWR|O_CREATE|O_TRUNC), so callers behave identically; the sqlite sidecar cache, which stores repo-derived indexed graph data no more sensitive than the repo itself, is left unchanged.
zzet
force-pushed
the
fix/persistence-cache-perms
branch
from
October 31, 2026 13:54
ff5bfba to
9aae5dd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The daemon's per-repo cache files in
internal/persistence— recent queries(
combo.gob.gz), agent-written session notes (notes.gob.gz), memories(
memories.gob.gz), frecency, feedback and keyword caches — were written withos.MkdirAll(dir, 0o755)andos.Create(path)(default 0644). That is aworld-readable file inside a world-accessible directory.
combostores theagent's actual recent query strings and
notes/memoriesstore free-text theagent wrote; either can contain sensitive content (query text, pasted keys,
etc.). On a shared machine any local user could read them.
Fix
Add
persistDir/persistFilehelpers that create directories0700andfiles
0600(owner-only) and use them in everySave*(combo, frecency,notes, memories, feedback, keyword). The flags are otherwise unchanged
(
os.O_RDWR|O_CREATE|O_TRUNC), so callers behave identically. Cache data isnow owner-only at rest.
The sqlite sidecar cache (repo-derived indexed graph data, no more sensitive
than the already-world-readable repo) is intentionally left unchanged.
Test
TestPersistCacheModescallsSaveNotesend-to-end and asserts the directoryis
0700and the cache file is0600. The persistence suite passes unchanged.