Claude Code prompt injection protections and risk

Claude Code has layered prompt injection defenses, but several of them depend on permission mode, folder trust and sandbox settings, and Anthropic states that no system is immune. This page sets out what is built in, what you must configure, and what the published exfiltration advisory teaches.

On this page

Does Claude Code protect against prompt injection in your environment?

Claude Code includes built-in prompt injection safeguards, but they are partial and depend on the permission mode you run and how the workspace and tools are configured, so it is not a complete control and should not be approved as one. A security reviewer deciding whether staff can point Claude Code at repositories with web or MCP access should treat these defenses as risk reducers that sit alongside your own controls. The Claude Code security page states that no system is completely immune to all attacks, and it recommends running scripts and tool calls that touch external web services inside virtual machines.

The defenses that apply inside the product are spread across the surfaces where Claude Code runs. Workspace trust dialogs appear in untrusted folders, and a separate approval prompt appears for servers defined in a project's .mcp.json file, but a -p session shows neither prompt, so non-interactive runs need separate review. For most WebFetch requests, a separate model call reads the page and Claude receives only that call's answer rather than the raw page. In Manual mode, network commands such as curl and wget prompt by default, but the documentation points to sandbox network isolation for enforcement that does not depend on command text. Anthropic reviews connectors before listing them in the Anthropic Directory but does not security-audit or manage any MCP server, so vetting the servers you allow is your job.

The controls you can enforce centrally are where the Team or Enterprise plan matters. Confirm with Anthropic which managed settings, MCP allowlists and sandbox requirements are available on the plan you buy, and whether they can be made mandatory on managed machines. Residual risk remains yours to manage: decide which repositories and web sources are in scope, restrict MCP servers to reviewed ones, require the sandbox where it is supported, and keep auto-update enabled so that fixes reach developers. Review the Claude Code security documentation before approval, and record which permission mode each team uses.

Prompt injection safeguards by mode, surface and plan

This table compares each prompt injection safeguard Anthropic documents for Claude Code by whether it works out of the box, depends on Manual mode or configuration, needs an outside component, or is not available. Read each row against the session type your developers use. The main takeaway is that the -p session shows neither the workspace trust dialog nor the MCP approval prompt, so those protections do not apply there.

SafeguardBuilt inDepends on Manual mode or configurationNeeds an outside componentNot available
Workspace trust dialogShown in untrusted folders before Claude Code works in themNot applicableNot applicableNot shown in -p sessions
MCP server approval prompt for .mcp.jsonPrompts for approval of servers defined in a project's .mcp.jsonNot applicableNot applicableNot shown in -p sessions
WebFetch separate model callFor most fetches, a separate model call reads the page and Claude receives only its answer, not the raw pageNot applicableNot applicableNot applicable
Manual mode prompts for curl and wgetNot applicableNetwork commands such as curl and wget prompt by default in Manual modeNot applicableNot applicable
Sandbox network isolationNot applicableEnforces network limits independent of command text, once the sandbox is configuredNot applicableNot applicable
Anthropic Directory connector reviewAnthropic reviews connectors before listing them in the Anthropic DirectoryNot applicableNot applicableNo security audit or management of any MCP server
Virtual machine isolationNot applicableNot applicableRecommended by Anthropic for scripts and tool calls against external web services; you must provide the VMNot applicable
-p session behaviorNot applicableNot applicableNot applicableNeither the trust dialog nor the MCP approval prompt appears

How the safeguards work across repositories, web pages and MCP servers

Claude Code defends against prompt injection along three paths, and each one has a different safeguard that a reviewer should verify rather than assume. The first path is the repository. When a developer opens an untrusted folder, Claude Code shows a workspace trust dialog before it works in that folder. Servers declared in a project's .mcp.json file also need a separate approval prompt before they run. Both checks depend on a person being present to answer them, so the reviewer should confirm with engineering which folders developers clone and open, and whether any project policy pre-approves servers that were never reviewed.

The second path is web content. For most WebFetch calls, Claude Code does not hand the raw page to Claude. A separate model call reads the page, and Claude receives only that call's answer. This reduces the amount of attacker-written text that reaches the main agent, but it is a control on one tool, not a general filter. Reviewers should ask which tools in their rollout can fetch external content, including Bash commands that call curl or wget. In Manual mode those network commands prompt by default. Anthropic's security documentation points to sandbox network isolation for enforcement that does not depend on the command text, so a reviewer who needs that guarantee should confirm the sandbox is enabled and enforced on managed machines.

The third path is MCP servers. Anthropic reviews connectors before listing them in the Anthropic Directory, but it does not security-audit or manage any MCP server. Treat a directory listing as a review of the connector, not an endorsement of the server's code or its handling of data. Finally, the trust and MCP prompts are skipped in -p (print) sessions, so any unattended automation that runs with -p loses both checks. Anthropic also states that no system is completely immune to all attacks, and recommends virtual machines for tool calls that touch external web services. Plan for that residual risk by limiting what unattended jobs can reach.

Where prompt injection defenses fall short

Claude Code's protections against prompt injection reduce risk but do not remove it, and several depend on how the tool is run. The cards below cover the gaps a reviewer should close with permission rules, isolation and team-owned controls before approving use on repositories, web content or MCP servers.

Model-mediated WebFetch answers

For most WebFetch requests, a separate model call reads the page and Claude receives that call's answer instead of the raw page. This reduces exposure to hidden instructions in the page, but the answer is still produced from untrusted content, so injected text can shape what Claude does next. Restrict WebFetch to the domains your team needs, and run work that touches external web services inside a virtual machine rather than on a developer workstation.

Security docs

Manual mode prompts depend on users

In Manual mode, network commands such as curl and wget prompt by default. Those prompts only protect you if a developer reads the command and declines anything unexpected, and approval fatigue makes that unreliable over a long session. Enforce network controls at the operating system level through sandbox network isolation and an egress allowlist, so enforcement does not depend on the command text or on the user's judgment.

Automated sessions skip prompts

Claude Code shows a workspace trust dialog in untrusted folders and a separate approval prompt for servers in a project's .mcp.json, but a -p session shows neither prompt. Scripts, CI jobs and other automated runs that use -p therefore accept untrusted folders and project MCP servers without a human check. Before approving automation, confirm which folders and servers those jobs can reach, and restrict the permission rules for non-interactive runs.

Directory review is not an audit

Opening a folder and accepting the trust dialog tells Claude Code that you trust the folder, not that its contents are safe. A repository can contain instructions in comments, documentation or configuration files that steer the agent. Treat a trust decision as a developer convenience, and require your own review of unfamiliar repositories, configuration files and project settings before they run with agent permissions.

Pre-approved domains widen exfiltration

Advisory GHSA-fg94-h982-f3mm (CVE-2026-54316, moderate, CVSS 6.0) describes how a pre-approved huggingface.co WebFetch domain let injected content exfiltrate data in versions from 0.2.54 before 2.1.163. It was patched in 2.1.163. Any domain you pre-approve can carry data out if its content is attacker-controlled or can be written to, so keep the allowlist short, review it when you approve new domains, and confirm managed machines run 2.1.163 or later.

Read the advisory

No system is immune

Anthropic's security page states that no system is completely immune to all attacks. Permission rules, trust prompts and model-mediated fetching each reduce risk, but none is a guarantee, so the residual risk stays with the organization that runs the agent. Document which protections your deployment depends on, test them with your own prompt injection cases, and define how you will detect and respond when an injected instruction succeeds.

Security docs

What advisory GHSA-fg94-h982-f3mm shows about exfiltration

The advisory GHSA-fg94-h982-f3mm shows that a permission you approve in advance can become the path an attacker uses. Anthropic published it as CVE-2026-54316, rated moderate with a CVSS score of 6.0. It describes how a pre-approved huggingface.co WebFetch domain allowed injected content to exfiltrate data. The affected range runs from version 0.2.54 up to, but not including, 2.1.163, and the fix shipped in 2.1.163. Reviewers should read the advisory itself through the GitHub advisory for GHSA-fg94-h982-f3mm before deciding how to treat WebFetch allowances in their own policy.

The lesson for reviewers is that a pre-approved domain is a trust decision, and a page on that domain can carry instructions written by someone else. If a domain is allowed without a per-request check, injected text on a trusted page may steer the agent toward sending data out. Before approving any WebFetch domain, ask who can publish content on it, whether user-generated pages or shared documents are hosted there, and what the agent could send in a follow-up request. Keep the allowlist short, and record the reason for each entry so it can be reviewed when the threat picture changes.

Patch status is the second check, and it depends on how each machine gets Claude Code. The advisory's exposure ends at 2.1.163, so an inventory should confirm the installed version on every developer workstation and CI runner, whether it came from the npm package @anthropic-ai/claude-code or the native installer. Machines on standard auto-update receive fixes automatically, while manually updated or pinned installs stay exposed until someone upgrades them. Confirm the update channel with your endpoint team, set a minimum version in your management tooling, and treat any machine below 2.1.163 as in scope for the advisory until it is upgraded.

Injection paths and the checks that sit on each

The diagram starts with content entering Claude Code from three places: a repository file, a page fetched by WebFetch, and a server listed in a project's .mcp.json. Each path meets a different check. A repository opened in an untrusted folder hits the workspace trust dialog, a WebFetch page is read by a separate model call before Claude sees the answer, and an MCP server needs approval. Any tool action that is still left to run is then bounded by Manual mode prompts or the sandbox. The -p path skips the trust and MCP prompts, so reviewers should confirm how their teams invoke it.

Three injection paths, the check on each, and the print mode route that skips two of them.

How the risk changes by working mode and team

Interactive sessions on developer laptops are the mode the security page describes most fully, and it is where the approval prompts do the most work. In Manual mode, Claude Code asks before it runs actions, and the docs state that network commands such as curl and wget prompt by default. The workspace trust dialog also appears in folders the tool has not been told to trust, and a separate approval prompt applies to servers defined in a project's .mcp.json. The protections still depend on a person reading each prompt carefully.

  • Default prompts: Network commands prompt in Manual mode, but the prompt depends on the command text.
  • Trust dialog: Untrusted folders trigger a workspace trust dialog before the session proceeds.
  • MCP approval: Servers in .mcp.json need a separate approval before they are used.
  • Enforcement gap: The docs point to sandbox network isolation for enforcement that does not depend on command text, so prompts alone are not a hard control.
  • Shared machines: A developer who approves prompts quickly on a machine with broad credentials carries the most exposure.

Confirm with Anthropic which sandbox settings you can make mandatory on managed machines, and check whether your endpoint policy enforces them.

Steps to take before approving Claude Code for untrusted input

This sequence turns Claude Code's prompt injection safeguards into a documented approval decision. Each step confirms a control, fixes its scope and records the evidence a security reviewer needs before untrusted repositories, web pages or MCP servers reach the agent.

  1. Confirm installed version and update path

    Start by inventorying how Claude Code is installed on each developer machine, whether through the npm package @anthropic-ai/claude-code or the native installer. Anthropic's GitHub advisories state that users on standard auto-update receive fixes automatically, while manual updaters must upgrade themselves. Record which machines fall into each group and confirm the running version against the affected and patched versions listed in the advisories. The step is done when every machine has a known version and a named owner for upgrades on the manual path.

  2. Decide the permitted permission mode

    Decide which permission mode developers may use when Claude Code reads untrusted content. The security page notes that in Manual mode, network commands such as curl and wget prompt by default, and that sandbox network isolation is the enforcement point that does not depend on command text. Security and engineering leads should write down which modes are allowed for which repositories and confirm the setting with a test session on a managed machine. The step closes when the approved mode is documented and the exception path is named.

  3. Set WebFetch and MCP server boundaries

    Define where WebFetch and MCP servers may be used and which domains are approved. The security page explains that for most WebFetch fetches a separate model call reads the page and Claude receives only that call's answer. The advisory GHSA-fg94-h982-f3mm shows why a pre-approved domain matters: injected content on an approved domain exfiltrated data in affected versions. Confirm the domain list with the data owners, and confirm that Anthropic reviews connectors in the Anthropic Directory but does not security-audit or manage any MCP server. The step closes with a written allowlist and an owner for each MCP server.

  4. Restrict print mode and unattended runs

    Identify every workflow that runs Claude Code with the -p flag or without a person watching. The security page states that a -p session shows neither the workspace trust dialog nor the approval prompt for servers in a project's .mcp.json. Those checks therefore do not protect unattended runs, so decide whether such runs may touch untrusted input at all. Confirm with the pipeline owners that any permitted unattended job is limited to trusted repositories and known tools. The step is complete when the list of unattended jobs is approved or blocked.

  5. Isolate external web interactions in virtual machines

    Require that scripts and tool calls which interact with external web services run inside virtual machines, as the Claude Code security page recommends. Confirm that developers working with untrusted pages or third-party content do so in a VM that holds no production credentials and no access to internal networks. Ask the platform team to show the VM image, the network egress rules and the process for resetting it. The step closes when the isolation standard is written and a sample workflow has been checked against it.

  6. Test injected content in a controlled repository

    Before approving untrusted input, have the security team run Claude Code against a controlled repository that contains test instructions planted in files, web content and MCP responses. The goal is to observe whether the agent follows the injected text, what it asks the user to approve and whether any data leaves the test environment. Record each result with the version tested. The security page states that no system is completely immune to all attacks, so the test is evidence for a risk decision rather than proof of safety. The step closes with a signed test report.

  7. Monitor advisories and re-approve on change

    Subscribe the security team to the GitHub security advisories for the anthropics/claude-code repository and tie each advisory to the inventory from the first step. When an advisory affects a version in use, confirm the patched version is deployed, then review whether the approved modes, domains and MCP servers still hold. Re-run the controlled test after material changes. The step is in place when the advisory watch has a named owner and each change produces a dated record of the decision.

Evidence a security reviewer asks for on prompt injection

This table lists the evidence a security reviewer should request before approving Claude Code where prompt injection is a concern, with the source of each item and who produces it. Read it as a request list: each row names what to ask for, where it lives, and whether Anthropic or your own team must produce it. The main takeaway is that the published security page describes limits, so the residual risk is judged with your own records.

Evidence itemWhere it comes fromWho produces it
Published security page and stated limitsClaude Code security page, including its statement that no system is completely immune to all attacksAnthropic publishes it; your reviewer records which limits apply to your setup
GitHub advisory history and patched versionsanthropics/claude-code security advisories, including GHSA-fg94-h982-f3mm (CVE-2026-54316), patched in 2.1.163Anthropic publishes; your team maps each advisory to affected versions in use
Version inventory of managed machinesInstalled Claude Code version on each developer device, from MDM or package recordsYour IT team; confirm whether devices use auto-update or a manual upgrade path
Permission mode policySettings that define Manual mode, the mode in force for each group, and whether managed settings lock itYour security team sets the policy; the enforced state is verified on endpoints
WebFetch domain allowlist recordApproved domains and the review that added each one, including any pre-approved domain that can receive contentYour security team; ask Anthropic only for the documented behavior of WebFetch summarization
MCP server allowlist recordApproved server list, the approval status for each project's .mcp.json entries, and the owner of each serverYour team; Anthropic reviews Directory connectors but does not audit or manage MCP servers
Test results from an injection exerciseWritten results from a test where injected content is placed in repositories, web pages and MCP responsesYour testing team or an external tester, run against your own configuration and approved versions
SOC 2 Type 2 report and ISO 27001 certificateAnthropic Trust Center; confirm the audited scope covers Claude Code before relying on itReport and certificate issued by independent auditors and certification bodies, not Anthropic or DeployOpen

Questions buyers ask about Claude Code prompt injection risk

Can Claude Code be fully protected from prompt injection?

No. Anthropic's security guidance states that no system is completely immune to all attacks, so prompt injection cannot be treated as solved by any product setting. Your task is to reduce exposure: limit what the agent can read and run, control which external sources it touches, and decide where it runs. Plan on residual risk that you accept, document and monitor, and ask Anthropic and your security team to agree on the controls that apply to your deployment. Read the Claude Code security documentation before approving any rollout scope.

Which Claude Code plan do I need for prompt injection safeguards?

The safeguards described in the security documentation, such as workspace trust prompts, MCP server approval prompts and WebFetch isolation, are product behavior that applies to the Claude Code client. Central enforcement is an admin capability, and what an admin can lock down depends on the edition and the managed settings available to your organization. Confirm with Anthropic, for each plan and deployment route you are considering, which settings admins can enforce, whether approval prompts can be disabled by users, and how the -p print mode behaves, since that mode skips the workspace trust and MCP approval prompts.

What drives the cost and effort of a prompt injection test?

A prompt injection test costs what the scope makes it cost. The main drivers are the number of repositories, MCP servers and external sources the agent can reach, the permission modes in use, whether tests run in isolated virtual machines or on developer laptops, and how many attack scenarios must be replayed after each Claude Code update. Most DeployOpen engagements are fixed-scope, so the written scope, deliverables and timeline are agreed before work starts. Ask any provider for the list of in-scope attack paths, the test environment, the reporting format and the retest conditions, and treat a quote without those as incomplete.

Can our own team run the prompt injection review internally?

Often yes for the basic review, but the depth depends on skills and time. Your team can inventory which repositories, MCP servers and web sources developers use, check the permission mode and managed settings on sample machines, and confirm that high-risk tasks run in virtual machines, as Anthropic recommends for external web services. Adversarial testing of injected content, data exfiltration paths and MCP tool behavior needs security testing experience and a controlled environment. DeployOpen provides application, cloud and AI agent security testing, including red teaming, so an outside test can complement an internal review. Confirm whether the test will cover your specific Claude Code configuration.

How do we confirm that a developer machine is patched?

Start by checking the installed Claude Code version on each machine and comparing it with the fixed version in the relevant advisory. Claude Code is distributed as the npm package @anthropic-ai/claude-code and as a native installer, and GitHub advisories state that users on standard auto-update receive fixes automatically while manual updaters must upgrade themselves. That means your inventory must separate auto-updating installs from manually managed ones. Check the version reported by the installed client on every machine, including those on the npm route, and record the result as evidence. Do not assume auto-update has run on machines that are offline or pinned.

Does the published advisory affect our Claude Code version?

Check the version range in the advisory itself. GHSA-fg94-h982-f3mm (CVE-2026-54316, rated moderate with a CVSS score of 6.0) describes how a pre-approved huggingface.co WebFetch domain let injected content exfiltrate data in versions from 0.2.54 before 2.1.163, and it was patched in 2.1.163. Any installed version in that range is affected, and any version at or above 2.1.163 contains the fix. Confirm the installed version on each machine, and review the GitHub security advisories for Claude Code for later entries before you record a machine as current.

What should we ask Anthropic about our prompt injection exposure?

Ask which controls are product defaults and which are enforceable by an administrator, and whether those controls differ between Claude for Teams, Enterprise, the Console and third-party cloud routes. Ask how WebFetch summaries are produced, which domains can be pre-approved, and whether any setting lets a pre-approved domain send data out. Ask how MCP connectors are reviewed, since Anthropic reviews connectors before listing them in the Anthropic Directory but does not security-audit or manage any MCP server. Get the answers in writing and attach them to your risk acceptance record.

Which official pages to check each claim against

Before approving Claude Code for prompt injection risk, the reviewer should read the Claude Code security page at code.claude.com/docs/en/security and treat it as the source for what Anthropic says the product does and does not protect against. That page is where the stated limits are written down: the Manual mode behavior for network commands such as curl and wget, the separate model call that reads most WebFetch pages, the workspace trust dialog and the approval prompt for servers in .mcp.json, and the recommendation to run scripts and tool calls against external web services inside a virtual machine. It also states that no system is completely immune to all attacks, which should shape how the reviewer frames residual risk in the approval record.

Next, read the advisory for GHSA-fg94-h982-f3mm in the anthropics/claude-code security advisories list. It describes a pre-approved huggingface.co WebFetch domain that let injected content exfiltrate data, affected versions from 0.2.54 before 2.1.163, and a fix in 2.1.163. Check which Claude Code versions your managed machines run, confirm they are at or beyond the patched release, and confirm how your update channel works, because the advisory notes that users on standard auto-update receive fixes automatically while manual updaters must upgrade themselves. Also review the full advisories list, since later disclosures may matter more to your environment than this one.

Re-check the security page at every approval and at each major rollout change. The stated limits depend on the release in use, and a protection that applies in one version or permission mode may not apply in another. Record the date you read the page, the Claude Code version you approved, and the permission mode your policy requires, so the approval can be reconstructed later. Where the page is unclear on a point your data classification depends on, ask Anthropic directly before approving that use.

How DeployOpen tests and governs Claude Code prompt injection exposure

DeployOpen plans, implements and tests self-hosted open-source platforms inside the client's own infrastructure, and runs security testing that includes AI systems and agents. For Claude Code, that means mapping where injected content can reach the agent, testing those paths against the controls your organization actually configures, and documenting what remains the organization's responsibility.

How we scope

  • Engagements are fixed-scope, with the scope, deliverables and timelines agreed in writing before work starts.
  • The written scope names which permission mode, WebFetch use, MCP servers and repositories are in the Claude Code review.
  • Scope confirms which Claude Code versions and install methods on your machines are covered, including auto-update behavior.

How we build

  • Controls are configured in your own environment, such as managed settings, sandbox network isolation and MCP server approvals.
  • Security testing covers AI systems and agents, including attempts to inject instructions through repositories, web pages and MCP servers.
  • Test cases record which safeguards are active in each mode, so results reflect the configuration you will run in production.

How we hand over

  • Deliverables include a written record of tested configurations, findings, and the residual risks the organization must accept or mitigate.
  • Documentation maps each exposure to the Anthropic guidance and advisory it relates to, so reviewers can trace the evidence.
  • Handover states which responsibilities stay with your security team, such as vetting MCP servers and reviewing advisories on upgrade.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers, so new Claude Code releases can be retested.
  • Retainer work can re-run injection tests after a published advisory or a change to your permission or sandbox policy.
  • Quotes follow from the written scope. Ask for the scope, deliverables and retainer terms to be itemized before approving work.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.