Why Claude Code Security Is Important
AI coding tools have moved from autocomplete to action. Asked to fix a failing test, Claude Code reads the repository, runs the test suite, edits the code, and opens a pull request. Developers use it for work that ranges from vibe coding a prototype to refactoring production services.
Each action runs with the developer's access. A shell command the agent runs can reach anything that the account can reach, including source code, environment variables, cloud CLIs, and SSH keys.
The agent also reads content the team didn't write, such as README files, issue threads, dependency code, and web pages. An attacker can plant instructions in any of them and aim those instructions at the model.
Anthropic acknowledges the limits in its own documentation:
"While these protections significantly reduce risk, no system is completely immune to all attacks."
Source: Anthropic, Claude Code security documentation
Claude Code security comes down to two jobs: deciding in advance what the agent may do, and checking that it stays inside those limits. It is one part of a wider AI coding security program that also covers assistants such as GitHub Copilot and Cursor.
Further reading: What Is Agentic AI Security?
Further reading: What Is Shadow AI?
Claude Code Security Risks
Claude Code acts with a person's access and treats text as instructions. Most Claude Code security risks trace back to that pairing.
Prompt Injection From Content the Agent Reads
What It Is: In a prompt injection attack, an attacker hides instructions in content the agent will read, such as a code comment, a README, an issue, a web page, or an MCP tool's output.
What It Looks Like: A comment in a cloned repository tells "the AI assistant" to run a setup script, or to post a config file to a URL as a "health check."
What It Can Lead To: The agent runs commands on the developer's machine, sends data out, or changes code outside the task. A hijacked agent can do anything the developer can.
Secrets and Source Code Leaving the Machine
What It Is: Sensitive data leaves through a prompt, a shell command, a web request, or an MCP tool call.
What It Looks Like: The agent reads a .env file while debugging, or runs a command that prints cloud credentials into its context. A hijacked agent might use curl to send a file to an outside server.
What It Can Lead To: Leaked keys, exposed customer data, and lost intellectual property.
Per Anthropic's docs, read deny rules cover Claude's built-in file tools, file commands that Claude Code recognizes in Bash such as cat and head, and redirections. They don't cover a command that reads files without naming them, such as grep -r, or a script that opens files itself. Network deny rules also match a command as written. For enforcement that doesn't depend on command text, Anthropic points to the sandbox.
Over-Broad Auto-Approval
What It Is: Teams loosen permissions for convenience until the agent can do almost anything without asking.
What It Looks Like: Someone leaves bypass mode on or adds a blanket allow rule for Bash. Months of "Yes, and don't ask again" clicks pile up in a settings file.
What It Can Lead To: Approval prompts were the last check before a harmful action. Once a team removes them, one injected instruction runs with nothing to stop it.
Malicious Project Configuration
What It Is: A repository can ship its own Claude Code setup, including .claude/settings.json with hooks and environment variables and a .mcp.json file that declares MCP servers.
What It Looks Like: A developer clones a public repo, or a CI job checks out an outside contributor's pull request, and the repo's config arrives with the code.
What It Can Lead To: Code runs on the machine before anyone reviews it. Interactive sessions show a workspace trust dialog for new folders, and Claude Code asks before it connects .mcp.json servers. Anthropic's docs note that a headless claude -p run shows neither prompt. In that mode, Claude Code runs the hooks in the repo's settings files and connects its .mcp.json servers without asking.
Anthropic does limit what a repo can change. A repo's project settings can't start a session in bypass mode, and Claude Code falls back to Manual mode if they try.
Untrusted Plugins, Skills, and MCP Servers
What It Is: Extensions that add instructions or run code inside Claude Code.
What It Looks Like: A helpful-sounding plugin from a third-party marketplace that bundles a hook, an MCP server, and a few skills, or an MCP server a developer copied from a blog post.
What It Can Lead To: Anthropic's plugin documentation states the risk:
"A Claude Code plugin you install can execute arbitrary code on your machine with your user privileges."
Source: Anthropic, Plugin security and trust documentation
Claude Code runs a plugin's hooks, background monitors, and MCP server processes outside the sandbox, and permission rules don't cover code a plugin runs on its own. Plugins can auto-update, so the files a team reviewed may differ from the files that run next week. Anthropic reviews connectors before it lists them in its directory, but says it doesn't security-audit or manage any MCP server.
Real-World Examples of Claude Code Security Issues
Researchers and vendors have published the following cases, two of them CVEs in Claude Code itself and one an attack on software installed next to it.
Path Restriction Bypass (CVE-2025-54794)
Claude Code versions below 0.2.111 checked paths with prefix matching instead of comparing full paths. An attacker could use that flaw to bypass directory limits and access files outside the working folder. The exploit needed a folder with a matching name prefix and a way to put untrusted content into Claude Code's context. Anthropic fixed it in version 0.2.111.
Source: NVD, CVE-2025-54794
Confirmation Prompt Bypass (CVE-2025-54795)
In versions below 1.0.20, a command-parsing error let an attacker skip Claude Code's confirmation prompt and run an untrusted command. This exploit also needed untrusted content in Claude Code's context window. Anthropic fixed it in version 1.0.20.
Source: NVD, CVE-2025-54795
Malicious Claude Code Extension on a Third-Party Marketplace (October 2026)
On October 29, 2026, attackers distributed a modified Claude Code VS Code extension through Cursor's extension marketplace, which mirrors Open VSX, under the extension's legitimate ID. Cursor said Anthropic didn't develop the malicious version. Palo Alto Networks' analysis lists versions 2.1.312 and 2.1.313 and reports that the code collected host information, tried to add an unauthorized SSH key, and tried to set up persistence over an exposure window of about 11 hours.
Sources: Palo Alto Networks blog, The Hacker News
Both CVEs needed untrusted content in the agent's context, which makes prompt injection the delivery path. The extension attack skipped the agent's logic and went after software installed next to it. A Claude Code security program has to cover the agent, the content it reads, and the tools around it.
How Claude Code Security Works
Claude Code works in a loop. It reads context, picks a next step, calls a tool, checks the result, and repeats until it finishes the task. Its tools read and edit files, run Bash commands, fetch web pages, and call tools on connected MCP servers. Security controls apply at four points in that loop.
1. Run Location: Claude Code runs in the terminal, in IDEs such as VS Code and JetBrains, in a desktop app, and in the browser as cloud sessions. Scripts and CI pipelines run it unattended through headless mode (claude -p) and GitHub Actions. Local sessions run on the endpoint using the developer's user account. Anthropic runs each hosted cloud session in its own isolated virtual machine.
2. Approval Rules: A session's permission mode decides which actions need the developer's approval.
- Manual mode starts read-only. Claude Code asks before it edits files or runs commands, except for a built-in set of read-only commands such as ls and git status.
- Auto mode hands approval to a separate classifier model, which reviews actions and denies the ones it judges unsafe. Anthropic's docs list it as the built-in starting mode for interactive terminal and VS Code sessions.
- Accept Edits mode approves file edits and a fixed set of file commands inside the working folder.
- Bypass permissions mode skips checks. Anthropic warns that it "offers no protection against prompt injection or unintended actions." Admins can turn it off.
Permission rules sit on top of the mode and allow, ask about, or deny specific actions. A Read(./.env) entry in the deny list keeps Claude's file tools away from a .env file.
3. Reach: Out of the box, Claude Code can reach the files in its working folder, the shell, the network (commands such as curl aren't auto-approved by default), and any MCP servers, plugins, skills, and hooks a developer has configured.
4. Runtime Monitoring and Enforcement: Security teams monitor the agent's actions, inspect prompts and tool interactions, and enforce policies that help prevent sensitive data exposure or unauthorized activity. Enterprise security controls can extend protection beyond Claude Code's built-in permissions by evaluating AI interactions and governing activity across developer endpoints.
See how Palo Alto Networks secures AI coding, from prompt to action. → Explore secure AI coding
Claude Code Hooks: A Control Point and a Risk
Hooks are commands that Claude Code runs at set points in its lifecycle. A PreToolUse hook runs before a tool call and can deny it. A UserPromptSubmit hook can reject a prompt, and a ConfigChange hook can log or reject settings changes during a session.
As a Control: A hook gives security teams a checkpoint that behaves the same way on each run, unlike a model's judgment. Teams use hooks to log tool calls, gate risky commands, and send prompts and tool output to an outside scanner before the agent continues. Admins can set allowManagedHooksOnly in managed settings so that only managed hooks, Agent SDK hooks, and hooks from plugins the organization force-enables run.
As a Risk: A command hook is a shell command. Claude Code runs it with the developer's full user permissions, outside the sandbox. A hook inside a cloned repo or a plugin is code the developer is about to run.
Treat hooks like any other code in the software supply chain: approve them through managed settings and keep unvetted ones out.
A Different Feature, Claude Inference Hooks: Claude Enterprise has a separate setting called inference hooks. An org admin configures them to send each prompt to a security endpoint, which returns allow or deny before the model reads the prompt. They cover Claude Code, Claude.ai, and Claude Cowork.
Where Claude Code's Built-In Controls End
Claude Code's native controls give each developer a solid base, and each control has a gap that security teams should plan for.
Approval Prompts Depend on Attention: Manual approval works only while the developer reads each prompt, and attention fades by the fiftieth one.
Deny Rules Match Text: Claude Code checks deny rules against commands as written, and a reworded command can slip past a text pattern. Anthropic points to the sandbox for network enforcement.
Extensions Run Outside the Sandbox: Hooks, MCP servers, and plugin processes run with the user's full permissions.
Settings Live on Each Machine: Managed settings push policy out to devices. Seeing activity across hundreds of developers requires telemetry, which Claude Code exports through OpenTelemetry to a backend the organization runs.
Each Organization Defines Its Own Sensitive Data: Each organization decides what counts as confidential, regulated, or customer data. Applying those definitions to prompts and tool output requires a control that knows the organization's policies, such as an enterprise data loss prevention (DLP) engine.
Claude Code's controls work per agent and per machine. Security teams that need fleet-wide visibility, company data policy, and runtime inspection add an enterprise security layer on top.
Claude Code Security vs. Claude Security
Anthropic also ships security tools with similar names. These tools use Claude to find flaws in code, while Claude Code security protects the agent itself.
Based on each vendor's public documentation as of November 6, 2026.
The biggest differences sit in the defaults. Claude Code's interactive sessions start in classifier-reviewed Auto mode, Codex turns the network off by default inside its OS sandbox, and Cursor ships with workspace trust switched off.
Best Practices for Claude Code Security
Admins can enforce several of these practices for the whole organization through managed settings, including the bypass-mode switch, hook and MCP server limits, and a minimum version.
1. Set Organization Policy With Managed Settings
Managed settings take the highest precedence in Claude Code's settings hierarchy, and nothing in a developer's or project's own settings overrides a managed key. Admins deliver them as a managed-settings.json file, through an MDM policy, or as server-managed settings from the claude.ai admin console.
Tip: Start with two settings. Set permissions.disableBypassPermissionsMode to "disable", and publish an approved list of MCP servers.
2. Set AI Agent Permissions With Least Privilege
Apply least privilege to AI agent permissions the same way as for a service account. Decide which permission modes teams may use, and for which work. Add deny rules for sensitive paths and commands, such as Read(./.env), Read(./secrets/**), and Bash(curl *). Review the allowed list with the /permissions command on a set schedule.
3. Sandbox the Agent and Isolate Untrusted Repos
Enable the Bash sandbox for filesystem and network isolation. For repositories the team didn't write, run the whole Claude Code process inside a dev container or virtual machine.
Tip: Treat a fresh clone like a downloaded binary. Read its .claude/ folder and .mcp.json before pointing an agent at it.
4. Lock Down Plugins, Hooks, and MCP Servers
MCP server security starts with an allowlist. Limit hooks to managed ones with allowManagedHooksOnly. Enforce an MCP allowlist with allowedMcpServers plus allowManagedMcpServersOnly, and allowlist plugin marketplaces. Before approving a plugin, read its hooks/hooks.json, .mcp.json, and bin/ folder.
5. Harden Headless and CI Runs
Headless runs skip the trust dialog. For runs against code the team didn't write, pass --setting-sources user (Anthropic's guidance) so Claude Code ignores the repo's settings and .mcp.json, or start with --bare. Pass --settings '{"disableAllHooks": true}' to turn hooks off for the run, and give CI jobs short-lived tokens with narrow scopes.
Tip: A disableAllHooks entry in user settings won't hold here. Project settings outrank user settings and can switch it back.
6. Manage the Secrets the Agent Can Reach
AI agent secrets management starts with keeping long-lived credentials out of environment variables and dotfiles. Pull secrets from a secrets manager when a task needs them, and prefer short-lived tokens. The sandbox's default settings still let commands read credential files such as ~/.ssh and ~/.aws/credentials, so add those paths to sandbox.filesystem.denyRead and back up deny rules with sandbox network limits.
7. Keep Audit Logs of Agent Activity
Export Claude Code's OpenTelemetry metrics and events to a SIEM or observability stack. Add ConfigChange hooks to audit settings changes, and review tool-call logs the same way as other privileged activity.
8. Keep Claude Code Up to Date
Anthropic fixed CVE-2025-54794 and CVE-2025-54795 in later Claude Code versions. Track releases, and set a version floor with requiredMinimumVersion in managed settings so Claude Code won't start below an approved version.
Get a personalized walkthrough of Prisma AIRS® and see how it inspects AI coding agent activity across the enterprise. → Book demo
Securing Claude Code Across the Enterprise
Claude Code's native controls help developers manage permissions, sandbox execution, and restrict access to sensitive resources. However, organizations deploying AI coding agents across multiple teams also need centralized policy enforcement, data protection, and visibility into agent activity.
Enterprise Claude Code security combines several layers of protection:
- AI runtime security: Inspect prompts and supported agent interactions to detect prompt injection, sensitive data exposure, and other AI-specific threats.
- Agentic endpoint security: Discover and govern AI coding agents, extensions, and supporting tools running on developer endpoints.
- Centralized policy enforcement: Apply consistent security controls across supported AI coding workflows and developer environments.
- Monitoring and auditability: Record agent activity and security decisions to support investigation, governance, and compliance.
Palo Alto Networks Prisma AIRS provides AI runtime security, including integration with Claude Enterprise inference hooks to evaluate prompts against enterprise security policies before model inference.
For AI coding agents running on developer endpoints, Prisma AIRS also integrates with Cortex Agentic Endpoint Security (AES). Prisma AIRS inspects supported prompts, MCP tool calls, and network interactions, while Cortex AES manages endpoint integration, enforces security decisions, and provides visibility into agent activity.
Together, these capabilities help organizations protect sensitive information, govern AI agent behavior, and extend security controls across enterprise development environments.
Learn more about securing Claude Code across the enterprise.
Claude Code Security FAQs