Strands Agents: Local Privilege Escalation via Symlink Attack in Default Session File Storage
Published Sources: OSV
What is affected, what to do
The available sources name no fixed version. Check the vendor guidance in the references below.
Not sure whether and how you are affected? Ask a question about this vulnerability
Metrics
—
Priority
No value is available for this vulnerability.
—
CVSS v3
No value is available for this vulnerability.
—
EPSS score
No value is available for this vulnerability.
Show all metrics
- Severity
- Not rated
Priority (0–325)
The priority score is a consolidated metric that condenses several individual signals into a single, action-guiding ranking: technical severity (CVSS), exploitation likelihood (EPSS), known-exploited status (KEV) and the context of the affected asset. The aim is to answer the only truly important question in vulnerability management: what first?
Read in glossary- 30.00 Methodology
Exploit maturity
An exploit is code or a technique that specifically uses a concrete vulnerability to force unintended behaviour — such as executing code or escalating privileges. It is the tool that turns a theoretical flaw into a practical attack.
Read in glossary- no public PoC known
KEV status
The KEV catalogue is a list maintained by the US authority CISA of vulnerabilities for which active exploitation in the wild has been confirmed. It answers not the question „how severe?“ but „is it already being attacked?“ — thereby sharply prioritising patching.
Read in glossary- —
- Published
Classification under NIS2 and CRA
Rule-based classification from exploitation status and severity. It does not replace a case-by-case assessment.
NIS2
NIS2 is EU Directive (EU) 2022/2555 to raise the level of cybersecurity across the Union. It substantially broadens obligations compared with the first NIS directive: more sectors, mandatory risk management, staged reporting duties and personal accountability of senior management.
Read in glossary- Handle the vulnerability in regular vulnerability handling under Art. 21(2)(e) NIS2.
CRA
The CRA is EU Regulation (EU) 2024/2847 setting horizontal cybersecurity requirements for „products with digital elements“ — from industrial controllers and software to connected consumer devices. For the first time manufacturers must ensure security across the entire product lifecycle, handle vulnerabilities and provide security updates.
Read in glossary- From 11.12.2027, Annex I Part II CRA requires manufacturers of affected products with digital elements to handle vulnerabilities without delay and provide security updates.
ISO/IEC 27001
ISO/IEC 27001 is the internationally leading standard for an information security management system (ISMS). It describes a risk-based, process-oriented framework to systematically plan, implement, review and improve information security.
Read in glossary- Control A.8.8, management of technical vulnerabilities: assess relevance to your systems, plan remediation and keep evidence.
Description
Summary
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.
Vulnerability Details
Component: strands-py/src/strands/session/file_session_manager.py
Root Cause:
- Default storage directory is
tempfile.gettempdir() + "/strands/sessions/"(line 58) — resolves to/tmp/strands/sessions/on Linux/macOS - The
_write_file()method (lines 116-123) writes to a predictable.tmppath 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.tmppath causes writes to an arbitrary target file- No integrity verification (HMAC/signature) on session files — tampered data is loaded as-is
Attack Vectors
1. Arbitrary File Overwrite (Local Privilege Escalation)
- Attacker pre-creates
/tmp/strands/sessions/session_<id>/(or monitors for new directories via inotify) - Attacker creates a symlink:
session.json.tmp→/home/victim/.bashrc(or any writable file) - Victim application writes session data → follows symlink → overwrites target file with JSON content
- Attacker achieves code execution on next shell login (or targets
.ssh/authorized_keys, cron files, etc.)
2. Persistent Prompt Injection via Session Tampering
- Attacker writes crafted message files into the session directory
- Victim application restores the session → loads attacker-controlled conversation history
- Injected messages instruct the agent to execute attacker commands on every future interaction
- No integrity check prevents this — the SDK trusts all session files at face value
Impact
- Arbitrary file overwrite — local attacker can write attacker-controlled content to any file writable by the victim process
- Local privilege escalation — via overwriting shell configs, SSH keys, cron jobs, or systemd user services
- Persistent agent compromise — via session data injection, the agent follows attacker instructions indefinitely
Reproduction
import os, json, tempfile, shutil
# Setup: simulate the vulnerable write pattern
session_dir = "/tmp/strands/sessions/session_test/"
os.makedirs(session_dir, exist_ok=True)
# Attacker: create symlink at the .tmp write path
target_file = "/tmp/symlink_attack_proof.txt"
with open(target_file, "w") as f:
f.write("ORIGINAL - should not be overwritten\n")
symlink_path = os.path.join(session_dir, "session.json.tmp")
if os.path.exists(symlink_path):
os.unlink(symlink_path)
os.symlink(target_file, symlink_path)
# Victim: FileSessionManager._write_file() equivalent
with open(symlink_path, "w", encoding="utf-8", newline="\n") as f:
json.dump({"session_id": "test", "injected": True}, f, indent=2)
# Verify: target file overwritten
with open(target_file) as f:
print(f"Target file content: {f.read()}")
# Output: {"session_id": "test", "injected": true}
# Cleanup
os.unlink(symlink_path)
os.unlink(target_file)
shutil.rmtree(session_dir)
Suggested Fix
- Use a user-private default directory —
~/.strands/sessions/or$XDG_DATA_HOME/strands/sessions/instead of/tmp/ - Use
os.open()withO_NOFOLLOW | O_CREAT | O_WRONLY— refuses to follow symlinks - Use
tempfile.mkstemp()for atomic writes instead of predictable.tmpsuffix - Verify directory ownership matches the current user before writing
- Add optional integrity verification (HMAC) on session files to detect tampering