GitHub advisory · PyPI
Strands Agents: Local Privilege Escalation via Symlink Attack in Default Session File Storage
Description
The FileSessionManager defaults to storing session data in /tmp/strands/sessions/ (a world-writable directory) using predictable file paths and a write pattern (open(path + ".tmp", "w") → os.replace()) that follows symbolic links. A local attacker can exploit this to overwrite arbitrary files or inject malicious session data for persistent prompt injection.
Component: strands-py/src/strands/session/file_session_manager.py
Root Cause:
tempfile.gettempdir() + "/strands/sessions/" (line 58) — resolves to /tmp/strands/sessions/ on Linux/macOS_write_file() method (lines 116-123) writes to a predictable .tmp path without symlink protection:
tmp = f"{path}.tmp"
with open(tmp, "w", encoding="utf-8", newline="\n") as f:
json.dump(data, f, indent=2, ensure_ascii=False)
os.replace(tmp, path)
open() follows symlinks — a pre-placed symlink at the .tmp path causes writes to an arbitrary target file/tmp/strands/sessions/session_<id>/ (or monitors for new directories via inotify)session.json.tmp → /home/victim/.bashrc (or any writable file).ssh/authorized_keys, cron files, etc.)Manual fix · PyPI
pip install --upgrade "strands-agents>=1.48.0"Sources