Introduction
It was a sunny day, everything felt pretty casual, and then I heard my manager say: “Let’s research Claude Code.”
Yes, please.
And that’s where our story begins: we started digging into Claude Code. Our goal was to examine Claude Code’s flow from installation to first use and assess any security risks.
In this paper, we examine how a low-privileged local user could pre-create another user’s predictable Claude Code temporary directory before that user’s first run. The attacker could then retain access to task-output files Claude Code later created there and modify an output file before Claude Code read it as part of its context, potentially influencing its subsequent actions. We examine the conditions required for the attack, its demonstrated impact, and Anthropic’s fix.
Who Should Read This?
- Security and detection engineers assessing agentic developer tooling.
- DevOps and platform teams that run Claude Code on shared or multi-user hosts, jump boxes, or CI/CD runners.
- Anyone operating Claude Code as a privileged user (including root) on a machine other accounts can log into.
- Developers building AI agents, who face the same class of trust-boundary problem in their own designs.
Summary: From Temp Files to Agent Takeover, a Claude Code Vulnerability Explained
At Pentera Labs, we examined a cross-user local prompt-injection vulnerability in Claude Code that allowed a low-privileged attacker on a shared machine to tamper with task output consumed by another user’s agent session. The central problem was a filesystem trust boundary: Claude Code treated output stored in its temporary files as input to its reasoning, even when another local user could modify those files.
Before version v2.1.128, Claude Code used a predictable temporary directory, /tmp/claude-
Does it Impact My Organization?
The attack affects Claude Code versions before v2.1.128 on shared machines where another local user can pre-create the victim’s temporary directory and tamper with task output before Claude Code reads it.
Impact: Cross-User Context Poisoning and Code Execution
A lower-privileged local attacker could tamper with another user’s Claude Code task output to hide evidence, fabricate results, or manipulate the agent’s answers. Under the proof-of-concept’s permissive execution conditions, this could also trigger commands as the victim. Access to these files could expose sensitive data or disrupt the session by changing file permissions.
Remediation
Testing and bundle comparison identified Claude Code v2.1.128 as the first version containing the fix.
The fix restores the missing ownership boundary. Claude Code now verifies that its temporary directory belongs to the current user, rejects symbolic links, and enforces 0700 permissions so other local users cannot access its temporary state. Users should upgrade to the latest version.
As a separate, later observation, during one reproduction attempt on an older client we saw Claude Code’s model flag the injected instruction as a likely prompt-injection attempt and decline to act on it. We note this as point-in-time model behavior. Model behavior can affect whether an injected instruction succeeds, but the filesystem-level fix in v2.1.128 is what addresses whether another user can alter the task output in the first place. The two operate at different layers, and only the latter closes the underlying trust-boundary gap.
For AI-agent developers, the lesson is that files which can influence an agent’s responses, reasoning, tool choices, or actions should not be stored in locations another user can pre-create, own, replace, or modify.
Disclosure Timeline
The issue was found in Claude Code v2.1.91, responsibly disclosed to Anthropic, and has since been fixed.
- April 3, 2026 – Report submitted to Anthropic VDP.
- April 4, 2026 – Anthropic closed the report as Informative.
- April 6, 2026 – Additional clarification provided regarding confidentiality, integrity, and denial-of-service impact independent of –dangerously-skip-permissions.
- April 27, 2026 – Anthropic acknowledged the clarification and stated that the underlying behavior had already been tracked internally, with hardening planned.
- Subsequently – The issue was fixed by Anthropic.
Read the full report here.
