NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · Claude Code

CVE-2026-25722: Claude Code Vulnerable to Command Injection via Directory Change Bypasses Write Protection

highCVSS 4.0 7.7GHSA-66q4-vfjg-2qhh

Claude Code before 2.0.57 did not validate directory changes combined with writes. Using `cd` to move into a protected folder such as `.claude` let a command create or change files there without asking the user. Reliable exploitation needs untrusted content in the context window. Fixed in 2.0.57.

Published Feb 6, 2026 · Analysis Nov 1, 2026

What an attacker can do

Claude Code protects some locations, such as the .claude folder, by asking for confirmation before writing there. The check looked at the write target but not at a preceding cd in the same command. A command that first changes into .claude and then writes a file used a relative path that slipped past the protection, so the file was created or modified silently.

The attacker needs a way to put untrusted content in front of the model: a malicious repository file, README, issue text, web page or tool result carrying a prompt injection. The model then issues the cd plus write command. No exploit code runs on its own. The user has to be working in the session (CVSS 4.0 marks passive user interaction). The .claude folder holds settings, hooks and commands, so writing there can turn into persistent command execution on the next session, which explains the high impact ratings. The advisory does not say more than that.

Who is affected

@anthropic-ai/claude-code versions before 2.0.57. Users on standard auto-update received the fix automatically. Manual installs, pinned versions and containers that bake in an old version need checking.

claude --version
npm ls -g @anthropic-ai/claude-code

@anthropic-ai/claude-code

Ecosystem
npm
Affected
< 2.0.57
Fixed in
2.0.57
Check
npm ls @anthropic-ai/claude-code

How to fix it

Upgrade to 2.0.57 or later:

npm install -g @anthropic-ai/claude-code@latest

Auto-update users already have it. The advisory gives no workaround. Until you update, avoid opening untrusted repositories or feeding untrusted content to Claude Code, and keep approval prompts on for commands you did not expect.

How to tell if you were hit

Inspect the .claude directories of your projects and home folder for files you did not create: new or changed settings.json, settings.local.json, hooks or commands, checking modification times against your sessions. Review shell command history from Claude Code sessions for cd into .claude followed by a write. Beam records the shell commands and file access of agents, and its rules flag risky ones, so a write into .claude shows in its record.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

Claude Code failed to properly validate directory changes when combined with write operations to protected folders. By using the cd command to navigate into sensitive directories like .claude, it was possible to bypass write protection and create or modify files without user confirmation. Reliably exploiting this required the ability to add untrusted content into a Claude Code context window.

Users on standard Claude Code auto-update received this fix automatically. Users performing manual updates are advised to update to the latest version.

About Claude Code thanks hackerone.com/nil221 for reporting this issue!

Questions

Does CVE-2026-25722 need me to approve anything?

The bug is that the write happened without the confirmation prompt that should have appeared for a protected folder. The attacker still has to get untrusted content into the context window.

Am I safe if I use auto-update?

Yes, the advisory says standard auto-update users received the fix automatically. Confirm with claude --version that you are at 2.0.57 or later.

Why is `.claude` a target?

It is the protected folder named in the advisory. It holds Claude Code configuration, so a write there can change how the tool behaves later.

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 entries