Pular para o conteúdo

// Security by tool

Claude Code agent security

6 minUpdated July 25, 2026By Ler em português

Quick answer

Claude Code is a strong code agent, but an agent that reads external context is an attack surface, and it had real CVEs. The InversePrompt pair (CVE-2025-54794, path restriction bypass, and CVE-2025-54795, command execution via injection) showed the pattern; CVE-2025-55284 exfiltrated the API key by encoding it into a DNS subdomain; CVE-2025-59536 ran a shell automatically when opening Claude Code in an untrusted directory; and the CVE-2026-35020/21/22 chain linked command injection into credential exfiltration.

All were fixed, but the lesson is permanent: opening an agent in a repo from an unknown source, or letting it read an external issue/PR/dependency, gives untrusted context the chance to become a command. The defense is not trusting the model; it is least privilege, a trusted directory and reviewing what it executes.

Where the risk shows up

The agent risk is on the dev machine; the code risk is in the app. Both need care.

Risk with Claude Code
VectorCVE / patternDefense
Injection escapes path restrictionCVE-2025-54794 (7.7)Trusted directory, least privilege
Command execution via injectionCVE-2025-54795 (8.7)Review what the agent executes
API key exfil via DNSCVE-2025-55284Secrets out of the agent context
Shell on opening an untrusted dirCVE-2025-59536 (8.7)Do not open an unknown repo directly

How RET reviews a Claude Code flow

RET looks at the agent’s permission boundary (what it can read, execute and in which directory) and the code it generated in the sensitive flows. It checks whether secrets live outside the agent context, whether auto-execution is limited, and whether what it wrote protects access, billing and data.

The Promptbook has a playbook to review both the agent config and the generated code, forcing the AI itself to flag where it had too much permission. When the flow is critical, Risk Review does the human read.

  • Least privilege: what the agent reads and executes, and where.
  • Secrets out of the context (the CVEs exfiltrated API keys).
  • Review of the generated code in the flows that touch data and money.

You may already be exposed if

Signals that call for care with Claude Code.

  • You open a repo from an unknown source directly in the agent.
  • You leave a secret (API key, token) accessible in the agent context.
  • Auto-execution of commands is on with no review.
  • You do not update the CLI (the CVEs were fixed in newer versions).

Want to know whether this happens in your system?

Manual pentest for web applications, APIs and apps, from R$9,500, with the Sprint run within 7 business days. We refund 50% if we find no flaw.

See price and timeline for my case

Frequently asked questions

Is Claude Code insecure?

Not by definition, but like every agent that reads external context, it had real CVEs for injection and exfiltration (InversePrompt, API-key exfil). Fixed in newer versions. The protection is least privilege, a trusted directory and secrets out of the context, not faith in the model.

Is updating the CLI enough?

Updating closes the known CVEs and is essential. But the pattern remains: do not open an unknown repo directly, limit auto-execution and keep secrets out of the agent context. The permission architecture matters more than the version.

How do I review the code Claude Code generated?

The Promptbook gives you prompts to force the AI to walk the flows and flag risk; Risk Review does the human read when access is critical. The review applies to any agent, the name changes, not the principle.

Who runs the review at RET?

Gabriel Lima Ferreira, founder and lead pentester, with an authorized scope and reproducible evidence.

Keep reading