fix: reject symlinks during persona memory bulk sync#91
Merged
Conversation
PersonaBackend.push_all walked local_root with path.is_file(), which follows symlinks — a symlink planted in the synced memory dir (e.g. via prompt-injection shell access) would have its target read and uploaded to the persona blob, exfiltrating arbitrary file contents (SSH keys, tokens) into cloud storage. push_one already resolves + containment-checks, and pull_all rejects traversal-shaped keys; push_all was the one sync path with no guard. Reject all symlinks explicitly and add the same resolve/relative_to containment check, making the three sync methods consistent. Ports an unmerged fix from the retired pre-rename entraclaw repo.
brandwe
added a commit
that referenced
this pull request
Jun 26, 2026
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
PersonaBackend.push_allnow rejects symlinks underlocal_rootand records them as errors, instead of silently following themresolve()+relative_to(root)containment check on each uploaded path, matching the guards already present inpush_oneandpull_alllocal_rootis not uploadedThe gap
push_alliteratedlocal_root.rglob("*")and filtered withpath.is_file()— which follows symlinks. A symlink planted in the synced memory dir (~/.claude/projects/<slug>/memory/) would pass the filter, andpath.read_text()would read the symlink target and upload it to theclaude_memory/blob prefix.That is a silent exfiltration path on an automated background sync: e.g. prompt-injection with shell access runs
ln -s ~/.ssh/id_rsa .../memory/notes.md, and the next sync ships the private key to cloud storage.The sibling methods were already hardened —
push_oneresolves and containment-checks its path, andpull_allrejects traversal-shaped keys.push_allwas the only sync path with no symlink/containment guard; this closes that inconsistency.Severity
Defense-in-depth. Exploitation requires something able to write into the memory dir (injection-driven shell, or a misbehaving hook), so it is not a standalone RCE — but it is a silent, automated channel that turns local file-write into cloud exfiltration, which is squarely in scope for this project.
Provenance
Ports an unmerged fix originally written on the retired pre-rename
entraclawrepo, adapted to the currententrabotmodule path.Validation
uv run --python 3.12 --extra dev python -m pytest tests/storage/test_persona.py -q— 19 passed (incl. new symlink test)uv run --python 3.12 --extra dev ruff check src/entrabot/storage/persona.py tests/storage/test_persona.py— cleanNote:
ruff format --checkreports pre-existing drift intest_persona.pyoutside this change; left untouched to keep the diff minimal (consistent with #87).