Security: Mode tracker flag file write also vulnerable to symlink-based overwrite#71
Merged
JuliusBrussee merged 1 commit intoJuliusBrussee:mainfrom Apr 15, 2026
Conversation
The UserPromptSubmit hook similarly writes to `~/.claude/.caveman-active` without checking whether the path is a symlink. This duplicates the same local file-clobber risk in another execution path. Affected files: caveman-mode-tracker.js Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
10 tasks
JuliusBrussee
added a commit
that referenced
this pull request
Apr 15, 2026
…ession Writes were hardened via safeWriteFlag (PRs #70/#71) but readers still trusted whatever the flag contained. A local attacker with write access to ~/.claude/ could symlink the flag at a secret file and have the per-turn reinforcement inject its bytes into model context, or the statuslines echo ANSI escapes to the terminal on every keystroke. - caveman-config.js: new readFlag() — lstat symlink refuse, 64-byte cap, O_NOFOLLOW, VALID_MODES whitelist. Returns null on any anomaly. - caveman-mode-tracker.js: per-turn reinforcement routes through readFlag() instead of fs.readFileSync. - caveman-statusline.sh / .ps1: symlink + size refuse, strip to [a-z0-9-], whitelist-validate before rendering. - compress.py (3 synced copies): is_sensitive_path() denylist refuses .env*, .netrc, keys/certs, ~/.ssh|.aws|.gnupg|.kube|.docker, and any basename containing secret/credential/password/apikey/token/privatekey (separator-insensitive). Fails loudly before read — no silent exfil of credentials to the Anthropic API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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 UserPromptSubmit hook similarly writes to
~/.claude/.caveman-activewithout checking whether the path is a symlink. This duplicates the same local file-clobber risk in another execution path.Severity:
mediumFile:
hooks/caveman-mode-tracker.jsSolution
Apply the same hardening as in the activation hook: validate path components with
lstat, refuse symlinks, and write with restrictive permissions and atomic replace semantics.Changes
hooks/caveman-mode-tracker.js(modified)Testing