{"answers":{"affected":"2 open source packages ship an affected version, including strands-agents.","exploited":"There is no known exploitation of GHSA-3w55-933p-8pv5 in the wild and no public exploit code.","fix":"Upgrade strands-agents to 1.48.0 or later.","what":"GHSA-3w55-933p-8pv5 is a vulnerability in strands-agents, published on 27 Oct 2026."},"fix_prompt":"Check this codebase for GHSA-3w55-933p-8pv5 and fix it if it is affected.\n\nWhat it is: GHSA-3w55-933p-8pv5 is a vulnerability in strands-agents, published on 27 Oct 2026. \nExploitation: There is no known exploitation of GHSA-3w55-933p-8pv5 in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- strands-agents (PyPI): affected all versions; fixed in 1.48.0\n- strands-agents (PyPI): affected all versions; fixed in 1.48.0\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/GHSA-3w55-933p-8pv5/ (Markdown: https://insights.sbomify.com/GHSA-3w55-933p-8pv5/index.md)","id":"GHSA-3w55-933p-8pv5","markdown":"https://insights.sbomify.com/GHSA-3w55-933p-8pv5/index.md","name":"GHSA-3w55-933p-8pv5","record":{"aliases":[],"analysis":null,"analysis_generated_by":null,"assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"description":"## Summary\n\nThe `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.\n\n## Vulnerability Details\n\n**Component:** `strands-py/src/strands/session/file_session_manager.py`\n\n**Root Cause:**\n1. Default storage directory is `tempfile.gettempdir() + \"/strands/sessions/\"` (line 58) — resolves to `/tmp/strands/sessions/` on Linux/macOS\n2. The `_write_file()` method (lines 116-123) writes to a predictable `.tmp` path without symlink protection:\n   ```python\n   tmp = f\"{path}.tmp\"\n   with open(tmp, \"w\", encoding=\"utf-8\", newline=\"\\n\") as f:\n       json.dump(data, f, indent=2, ensure_ascii=False)\n   os.replace(tmp, path)\n   ```\n3. `open()` follows symlinks — a pre-placed symlink at the `.tmp` path causes writes to an arbitrary target file\n4. No integrity verification (HMAC/signature) on session files — tampered data is loaded as-is\n\n## Attack Vectors\n\n### 1. Arbitrary File Overwrite (Local Privilege Escalation)\n1. Attacker pre-creates `/tmp/strands/sessions/session_\u003cid\u003e/` (or monitors for new directories via inotify)\n2. Attacker creates a symlink: `session.json.tmp` → `/home/victim/.bashrc` (or any writable file)\n3. Victim application writes session data → follows symlink → overwrites target file with JSON content\n4. Attacker achieves code execution on next shell login (or targets `.ssh/authorized_keys`, cron files, etc.)\n\n### 2. Persistent Prompt Injection via Session Tampering\n1. Attacker writes crafted message files into the session directory\n2. Victim application restores the session → loads attacker-controlled conversation history\n3. Injected messages instruct the agent to execute attacker commands on every future interaction\n4. No integrity check prevents this — the SDK trusts all session files at face value\n\n## Impact\n\n- **Arbitrary file overwrite** — local attacker can write attacker-controlled content to any file writable by the victim process\n- **Local privilege escalation** — via overwriting shell configs, SSH keys, cron jobs, or systemd user services\n- **Persistent agent compromise** — via session data injection, the agent follows attacker instructions indefinitely\n\n## Reproduction\n\n```python\nimport os, json, tempfile, shutil\n\n# Setup: simulate the vulnerable write pattern\nsession_dir = \"/tmp/strands/sessions/session_test/\"\nos.makedirs(session_dir, exist_ok=True)\n\n# Attacker: create symlink at the .tmp write path\ntarget_file = \"/tmp/symlink_attack_proof.txt\"\nwith open(target_file, \"w\") as f:\n    f.write(\"ORIGINAL - should not be overwritten\\n\")\n\nsymlink_path = os.path.join(session_dir, \"session.json.tmp\")\nif os.path.exists(symlink_path):\n    os.unlink(symlink_path)\nos.symlink(target_file, symlink_path)\n\n# Victim: FileSessionManager._write_file() equivalent\nwith open(symlink_path, \"w\", encoding=\"utf-8\", newline=\"\\n\") as f:\n    json.dump({\"session_id\": \"test\", \"injected\": True}, f, indent=2)\n\n# Verify: target file overwritten\nwith open(target_file) as f:\n    print(f\"Target file content: {f.read()}\")\n    # Output: {\"session_id\": \"test\", \"injected\": true}\n\n# Cleanup\nos.unlink(symlink_path)\nos.unlink(target_file)\nshutil.rmtree(session_dir)\n```\n\n## Suggested Fix\n\n1. **Use a user-private default directory** — `~/.strands/sessions/` or `$XDG_DATA_HOME/strands/sessions/` instead of `/tmp/`\n2. **Use `os.open()` with `O_NOFOLLOW | O_CREAT | O_WRONLY`** — refuses to follow symlinks\n3. **Use `tempfile.mkstemp()`** for atomic writes instead of predictable `.tmp` suffix\n4. **Verify directory ownership** matches the current user before writing\n5. **Add optional integrity verification** (HMAC) on session files to detect tampering","ecosystems":["PyPI"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":true,"headline":"Strands Agents: Local Privilege Escalation via Symlink Attack in Default Session File Storage","id":"GHSA-3w55-933p-8pv5","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"PyPI","product":null,"products":[],"type":null,"year":"2026"},"n_packages":2,"n_references":null,"packages":[{"ecosystem":"PyPI","fixed":["1.48.0"],"introduced":["0"],"last_affected":[],"package":"strands-agents","purl":null,"source":"GHSA-3w55-933p-8pv5"},{"ecosystem":"PyPI","fixed":["1.48.0"],"introduced":["0"],"last_affected":[],"package":"strands-agents","purl":"pkg:pypi/strands-agents","source":"GHSA-3w55-933p-8pv5"}],"products":null,"published":"2026-10-27","related":[],"sources":[{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":null,"url":"https://insights.sbomify.com/GHSA-3w55-933p-8pv5/"}