All vulnerabilities
GHSA-3w55-933p-8pv5

strands-agents: Strands Agents: Local Privilege Escalation via Symlink Attack in Default Session File Storage

strands-agentspipLibraries & packages
CVSS
7.1High
ExploitationNo known exploitationNot in CISA KEV, which does not prove it is unexploitedCISA KEV
Exploit odds (EPSS)No scoreNo FIRST EPSS score in this snapshot yet
Fixed in1.48.0Fixed versionGitHub
Published27 Oct 2026Updated 27 Oct 2026GitHub

What fixes it

  • 1.48.0strands-agents, pipGitHub
  • 1.48.0strands-agents, PyPIOSVpip install "strands-agents>=1.48.0"

A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.

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:

  1. Default storage directory is tempfile.gettempdir() + "/strands/sessions/" (line 58) — resolves to /tmp/strands/sessions/ on Linux/macOS
  2. The _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)
  1. open() follows symlinks — a pre-placed symlink at the .tmp path causes writes to an arbitrary target file
  2. No integrity verification (HMAC/signature) on session files — tampered data is loaded as-is

Attack Vectors

1. Arbitrary File Overwrite (Local Privilege Escalation)

  1. Attacker pre-creates /tmp/strands/sessions/session_<id>/ (or monitors for new directories via inotify)
  2. Attacker creates a symlink: session.json.tmp → /home/victim/.bashrc (or any writable file)
  3. Victim application writes session data → follows symlink → overwrites target file with JSON content
  4. Attacker achieves code execution on next shell login (or targets .ssh/authorized_keys, cron files, etc.)

2. Persistent Prompt Injection via Session Tampering

  1. Attacker writes crafted message files into the session directory
  2. Victim application restores the session → loads attacker-controlled conversation history
  3. Injected messages instruct the agent to execute attacker commands on every future interaction
  4. 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

  1. Use a user-private default directory — ~/.strands/sessions/ or $XDG_DATA_HOME/strands/sessions/ instead of /tmp/
  2. **Use os.open() with O_NOFOLLOW | O_CREAT | O_WRONLY** — refuses to follow symlinks
  3. **Use tempfile.mkstemp()** for atomic writes instead of predictable .tmp suffix
  4. Verify directory ownership matches the current user before writing
  5. Add optional integrity verification (HMAC) on session files to detect tampering

Text from GitHub Advisory Database

Affected versions 52

  • strands-agents, pip< 1.48.0GitHub
  • strands-agents, PyPIfrom first release, fixed in 1.48.0OSV
  • strands-agents, PyPI0.0.1OSV
  • strands-agents, PyPI0.1.0OSV
  • strands-agents, PyPI0.1.1OSV
  • strands-agents, PyPI0.1.2OSV
  • strands-agents, PyPI0.1.3OSV
  • strands-agents, PyPI0.1.4OSV
  • strands-agents, PyPI0.1.5OSV
  • strands-agents, PyPI0.1.6OSV
  • strands-agents, PyPI0.1.7OSV
  • strands-agents, PyPI0.1.8OSV
  • strands-agents, PyPI0.1.9OSV
  • strands-agents, PyPI0.2.0OSV
  • strands-agents, PyPI0.2.1OSV
  • strands-agents, PyPI0.3.0OSV
  • strands-agents, PyPI1.0.0OSV
  • strands-agents, PyPI1.0.1OSV
  • strands-agents, PyPI1.1.0OSV
  • strands-agents, PyPI1.10.0OSV
  • strands-agents, PyPI1.11.0OSV
  • strands-agents, PyPI1.12.0OSV
  • strands-agents, PyPI1.13.0OSV
  • strands-agents, PyPI1.14.0OSV
  • strands-agents, PyPI1.15.0OSV
  • strands-agents, PyPI1.16.0OSV
  • strands-agents, PyPI1.17.0OSV
  • strands-agents, PyPI1.18.0OSV
  • strands-agents, PyPI1.19.0OSV
  • strands-agents, PyPI1.2.0OSV
  • strands-agents, PyPI1.20.0OSV
  • strands-agents, PyPI1.21.0OSV
  • strands-agents, PyPI1.22.0OSV
  • strands-agents, PyPI1.23.0OSV
  • strands-agents, PyPI1.24.0OSV
  • strands-agents, PyPI1.25.0OSV
  • strands-agents, PyPI1.26.0OSV
  • strands-agents, PyPI1.27.0OSV
  • strands-agents, PyPI1.28.0OSV
  • strands-agents, PyPI1.29.0OSV
  • strands-agents, PyPI1.3.0OSV
  • strands-agents, PyPI1.30.0OSV
  • strands-agents, PyPI1.31.0OSV
  • strands-agents, PyPI1.32.0OSV
  • strands-agents, PyPI1.33.0OSV
  • strands-agents, PyPI1.34.0OSV
  • strands-agents, PyPI1.34.1OSV
  • strands-agents, PyPI1.35.0OSV
  • strands-agents, PyPI1.36.0OSV
  • strands-agents, PyPI1.37.0OSV
  • strands-agents, PyPI1.38.0OSV
  • strands-agents, PyPI1.39.0OSV

References 5