CVE-2026-25725: Claude Code has Sandbox Escape via Persistent Configuration Injection in settings.json
Claude Code before 2.1.2 let code inside its bubblewrap sandbox escape by creating `.claude/settings.json` when that file did not exist at startup. Hooks such as `SessionStart` written there ran with host privileges on the next restart. Fixed in 2.1.2.
Published Feb 6, 2026 · Analysis Nov 1, 2026
What an attacker can do
The bubblewrap sandbox mounted the .claude directory as writable and marked .claude/settings.local.json read-only. It did not protect .claude/settings.json if that file was missing when Claude Code started. Code running in the sandbox could therefore create settings.json and add persistent hooks, for example a SessionStart command.
Hooks are executed by Claude Code itself on the host, outside the sandbox. When the user restarted Claude Code, the injected command ran with the user's full privileges. That turns a contained process into persistent host code execution, and it survives restarts until the file is removed.
The attacker needs code running inside the sandbox first. That usually comes from a prompt injection or a malicious repository that makes the agent run a command, and the sandbox was supposed to contain that. The user must restart the tool, which the CVSS 4.0 vector marks as passive user interaction (7.7). Projects that already had a .claude/settings.json at startup were not in the described state.
Who is affected
@anthropic-ai/claude-code before 2.1.2, when you use the bubblewrap sandbox (Linux) and the project's .claude/settings.json did not exist when the session started. Auto-update users received the fix. Pinned versions and container images may still be old.
claude --version
npm ls -g @anthropic-ai/claude-code@anthropic-ai/claude-code
- Ecosystem
- npm
- Affected
- < 2.1.2
- Fixed in
- 2.1.2
- Check
npm ls @anthropic-ai/claude-code
How to fix it
Upgrade to 2.1.2 or later:
npm install -g @anthropic-ai/claude-code@latestThe advisory names no workaround. As a precaution on older versions, make sure .claude/settings.json exists before you start sandboxed sessions in a project, and review any hooks it holds before restarting after an untrusted run.
How to tell if you were hit
Check each project's .claude/settings.json for a hooks section you did not write, especially SessionStart entries with shell commands, curl or encoded payloads. Compare the file's creation time with your sandboxed sessions. If you find one, remove it and treat the host as compromised from the first restart after its creation. Beam records agent shell commands and file access, and its rules flag risky ones, so a new write to .claude/settings.json in a session is visible in its record.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Claude Code's bubblewrap sandboxing mechanism failed to properly protect the .claude/settings.json configuration file when it did not exist at startup. While the parent directory was mounted as writable and .claude/settings.local.json was explicitly protected with read-only constraints, settings.json was not protected if it was missing. This allowed malicious code running inside the sandbox to create this file and inject persistent hooks (such as SessionStart commands) that would execute with host privileges when Claude Code was restarted.
Users on standard Claude Code auto-update received this fix automatically. Users performing manual updates are advised to update to the latest version.
Claude Code thanks hackerone.com/edbr for reporting this issue!
Questions
- Does CVE-2026-25725 affect macOS?
The advisory describes the bubblewrap sandbox, which is the Linux mechanism. It does not say anything about other platforms.
- When does the injected code run?
At the next Claude Code restart, when the
SessionStartor other hook in the newsettings.jsonis executed with host privileges.- What is the fixed version?
2.1.2. All versions before it are affected.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More Claude Code vulnerabilities
All Claude Code entriesCVE-2026-88968
Claude Code: TOCTOU Race in Edit Tool Allows File Writes Outside the Workspace
high7.7Nov 9, 2026CVE-2026-86063
Claude Code: Plugin Hash Pin Bypass Allows Bypass of Hash Pinning
high7.5Oct 15, 2026CVE-2026-55607
Claude Code: Sandbox Escape via Git Worktree Path Confusion Allows Unsandboxed Code Execution
high7.7Jul 24, 2026CVE-2026-46406
@anthropic-ai/claude-code has an Insecure Temporary File in /copy Command that Enables Response Disclosure and Symlink-Based File Write
medium4.4Jun 25, 2026CVE-2026-54316
Claude Code: Out-of-Band Data Exfiltration via Pre-Approved HuggingFace Domain in WebFetch
medium9.1Jun 17, 2026CVE-2026-40068
Claude Code: Trust Dialog Bypass via Git Worktree Spoofing Allows Arbitrary Code Execution
high7.7Apr 24, 2026
