fix(security): contain private session artifacts - #1249
Open
sethkarten wants to merge 4 commits into
Open
Conversation
sethkarten
force-pushed
the
sethkarten/security-private-files
branch
2 times, most recently
from
August 11, 2026 18:58
a43daa3 to
d948433
Compare
sethkarten
force-pushed
the
sethkarten/security-private-files
branch
from
August 11, 2026 19:11
d948433 to
344d4e3
Compare
sethkarten
force-pushed
the
sethkarten/security-private-files
branch
from
August 11, 2026 19:16
344d4e3 to
62618aa
Compare
sethkarten
force-pushed
the
sethkarten/security-private-files
branch
from
August 11, 2026 19:21
39b3b0e to
3f63142
Compare
sethkarten
force-pushed
the
sethkarten/security-private-files
branch
from
August 11, 2026 19:27
3f63142 to
6c0e62c
Compare
sethkarten
force-pushed
the
sethkarten/security-private-files
branch
3 times, most recently
from
August 11, 2026 19:38
5d6f2b8 to
351dd9a
Compare
sethkarten
force-pushed
the
sethkarten/security-private-files
branch
from
August 11, 2026 19:39
351dd9a to
ac475fd
Compare
sethkarten
force-pushed
the
sethkarten/security-private-files
branch
from
August 11, 2026 19:41
ac475fd to
697a920
Compare
sethkarten
force-pushed
the
sethkarten/security-private-files
branch
from
August 11, 2026 19:43
697a920 to
fc0988a
Compare
sethkarten
force-pushed
the
sethkarten/security-private-files
branch
from
August 11, 2026 19:45
fc0988a to
0327faf
Compare
sethkarten
force-pushed
the
sethkarten/security-private-files
branch
from
August 11, 2026 19:49
0327faf to
762f947
Compare
sethkarten
force-pushed
the
sethkarten/security-private-files
branch
2 times, most recently
from
August 11, 2026 19:55
ce6aea4 to
7f86590
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7f86590. Configure here.
sethkarten
force-pushed
the
sethkarten/security-private-files
branch
2 times, most recently
from
August 11, 2026 20:08
b813e92 to
ec933cf
Compare
sethkarten
force-pushed
the
sethkarten/security-private-files
branch
2 times, most recently
from
August 11, 2026 20:15
4040af1 to
7b0751d
Compare
sethkarten
force-pushed
the
sethkarten/security-private-files
branch
from
August 11, 2026 20:21
7b0751d to
da27926
Compare
sethkarten
force-pushed
the
sethkarten/security-private-files
branch
from
August 11, 2026 20:22
da27926 to
6006f3d
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.

Summary
This is the private-storage portion extracted from #1159 and proposed directly against current
main.Risk
Medium. The change intentionally rejects unsafe pre-existing paths and symlinks. Existing regular files remain supported and are repaired to private modes where appropriate. User-selected HTML export directories are not chmodded; the emitted file itself remains private.
Provenance
The two commits preserve
cherry picked fromtrailers for original commitsb0ce5adf20ec8c891dd44e8b39bdb0ab453a5ebaand4ede067b97f803957af36aefe16487e15851c363from #1159. No MCP/provider changes are included.Validation
npm run checknpx vitest --run test/suite/regressions/1105-session-storage-security.test.ts test/suite/regressions/1105-named-sinks-security.test.ts test/kernel-state-snapshot.test.ts test/interactive-mode-debug-command.test.ts— 31 passedPYTHONPATH=prime-agent-runtime/src python3 -m unittest prime-agent-runtime/test/test_harness.py— 36 passedgit diff --check origin/main...HEADReview focus
Please focus on path containment, symlink/non-regular-file rejection, POSIX mode repair, Windows fallbacks, and the intentionally different parent-directory policy for user-selected HTML exports.
Note
High Risk
Touches auth credential storage and session/artifact persistence with fail-closed symlink and permission checks. Existing permissive or symlinked paths will hard-error, and Windows loses persistent
/refineharness storage.Overview
Hardens private persistence so session, auth, harness, snapshot, export, editor, and debug sinks reject traversal IDs, symlinks, and non-regular files, and write with atomic
O_NOFOLLOWopens plus0o600/0o700modes.Adds a shared
private-fileshelper and routes sensitive writers through it. Session IDs are validated and artifact paths are confined to their root; unsafe existing sinks fail closed rather than being followed or repaired into attacker-controlled targets.Windows fails closed for persistent harness storage and
/refine(in-memory sessions remain). Kernel snapshot save/restore and the Python harness get matching no-follow/atomic private writes.Reviewed by Cursor Bugbot for commit 6006f3d. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Harden session and artifact storage against symlink attacks and unsafe file permissions
private-filesutility module with helpers for atomic, permission-hardened (0600/0700) file and directory operations that reject symlinks and non-regular files viaO_NOFOLLOW.prime-agent-runtime), returning in-memory state with explicit errors on mutation attempts.Macroscope summarized 6006f3d.