What you will be able to do
- Trace a described misuse path from where the attacker's input enters to the action that causes harm
- Explain why an instruction in a system prompt does not count as a security control, and where deterministic checks belong instead
- Choose the control that closes a misuse path while keeping a stated legitimate use case working
- Reject controls that sit at the wrong point on the path, or that close it by also blocking the legitimate use
Key concept
Guardrail placement — Guardrail placement means putting each control at the point on a misuse path where the harmful action becomes possible, and enforcing it in code or configuration rather than in model instructions. The right control blocks only the harmful version of the action and leaves the legitimate version alone.
1.A misuse path has an entry point, a carrier and a harmful action
Every misuse path runs from an entry point, through the model, to an action that causes harm. Finding the right guardrail starts with tracing that path. The attacker's text gets in somewhere: a chat message, a wiki page, a code comment, a tool result. The model carries it. Then a tool call does the damage, such as sending an email, running a shell command or returning another person's data. You can put a control at any point along the path, but they don't all work equally well.
The entry point decides which screens can see the attack at all. Direct injection and jailbreaks come from the user typing into your application. Indirect injection comes from content the model reads while working for a trusted user. In the indirect case, the attacker never types into your input box. The instructions arrive inside webpages, emails, documents or tool results. A screen that only checks what the user typed can't catch an attack that arrives through retrieval. The prompt injection surface lesson maps these entry points in detail. For placement, the point is that a screen only protects the channel it sits on.
The harmful action is where enforcement holds most reliably. Claude resists injected instructions well, but resistance is a property of the model, not a control you can configure, test and audit. Hardened system prompts, delimiters and untrusted-content policies all lower the odds that the model follows an attack. None of them guarantees it won't. A guardrail that has to hold every time has to stand outside the model: in the tool's code, a permission rule, a hook or the runtime environment.
Checkpoint 1 of 9· Check yourself
An internal research assistant summarizes wiki pages for employees and has a tool that sends email. An attacker edits a wiki page to add hidden instructions telling the assistant to email confidential notes to an outside address. The team had already put a lightweight classifier on every chat message employees type, but it never flagged the attack. What is the most likely reason?
This is indirect injection. The user is trusted, and the attacker's text arrives in third-party content the model reads. A screen only protects the channel it sits on, so a classifier on typed input never sees instructions planted in a retrieved page.
“Indirect prompt injection, where the user is trusted but Claude processes third-party content (webpages, emails, documents, tool results) that contains adversarial instructions.”Source: platform.claude.com
Checkpoint 2 of 9· Check yourself
For the same assistant, sending email to colleagues inside the company is a legitimate use that must keep working. Which change closes the path from a planted wiki instruction to emailing data outside the company?
Prompt policies, delimiters and refusal examples lower the odds that the model follows the injection, but they rely on model behaviour. A limit enforced in the tool's code holds whatever the model decides, and internal email still works.
“Claude is inherently resilient to it, but model behavior is not a security control.”Source: platform.claude.com
Checkpoint 3 of 9· Exam question
An internal assistant uses retrieval over the company wiki and has a send_email tool. A contractor edits a wiki page to include hidden text instructing the assistant to email the quarterly forecast to an outside address. Employees legitimately ask the assistant to email summaries to colleagues. Which placement of a control closes the path while keeping that use?
Correct answer: C — Validate recipients in the send_email tool code against a company-domain allowlist once the model proposes a call, and reject addresses outside it.
- A. The hidden instruction comes from the retrieved wiki page, while the employee's question is an ordinary request, so a classifier on the question has nothing to flag. The poisoned page still reaches the model and the email tool still accepts outside recipients.
- B. Delimiters and a prompt rule depend on the model choosing to obey them, and injected text can still persuade it. Nothing in the tool limits where mail can go, so a successful injection could still send the forecast to an outside address.
- C. The check runs in code at the point where the harmful action would happen, so it holds whatever the retrieved text convinces the model to attempt. Summaries to colleagues pass the allowlist and keep sending normally.
- D. Removing the tool does close the exfiltration path, but the assistant can then no longer email summaries to colleagues, which employees legitimately need. A control scoped to recipients closes the path without losing that function.
2.Where each layer sits, and what it can and cannot see
The available controls sit at different points on the path, and each one sees a different slice of it. Input screening runs a small classifier over user input before the main conversation, using a lightweight model such as Claude Haiku 5.5 with structured output and a single verdict field. Tool-output screening runs the same kind of classifier over what tools return, before the model acts on it. Prompt hardening tells the model what untrusted content is and how to treat it. Action-layer checks, meaning validation in tool code, permission rules and hooks, inspect the concrete call the model proposes. Environment limits, meaning sandboxing, egress restrictions and credential placement, limit what any action can reach.
| Layer | Where it runs | Catches | Misses |
|---|---|---|---|
| Harmlessness screen on user input | Before the main conversation | Direct injection and jailbreaks typed by the user | Instructions hidden in retrieved documents or tool results |
| Injection screen on tool output | Between the tool and the tool_result block | Indirect injection in fetched or retrieved content | A harmful action the model takes without any injection |
| System prompt policy, JSON-encoded tool results | Inside the model's context | Makes injected text clearly data, which lowers the odds it is followed | Any case where the model follows the text anyway |
| Least privilege on data and actions | Tool set, secrets, sandbox | Limits the damage from any successful injection | Misuse that only uses actions the job legitimately needs |
Screening tool output catches more than screening the question, but a classifier's verdict is still a probability. When the attack ends in a tool with real reach, such as email, the check that reliably closes the path sits inside the tool itself. In a managed deployment, custom tools run in your application and are limited only by your code. Platform settings don't secure them. A send_email tool that checks each recipient against a company-domain allowlist after the model proposes the call rejects the outside address no matter how persuasive the injected text was. Employees can still email summaries to colleagues.
Two other fixes go wrong in opposite directions. Removing the email tool closes the path, but it also removes the use case the assistant exists for. Wrapping retrieved passages in delimiters and adding a system prompt rule is good practice, since Claude treats tool-result content with skepticism. Still, it leaves the decision with the model. Use it as a layer, never as the closing control.
Checkpoint 4 of 9· Match them up
Each guardrail layer leaves a different gap on the misuse path. Match each layer to what it misses.
Tap a term, then the definition that fits it.
Each layer sees only one part of the path. A screen on user input never sees content that arrives later through retrieval. A screen on tool output only finds injected text, so it misses harmful actions that have no injection behind them. Prompt policies and JSON encoding make the harmful choice less likely but still leave it to the model. Least privilege limits how far a successful attack can reach, but it can't stop misuse of actions the job really needs.
“Indirect prompt injection, where the user is trusted but Claude processes third-party content (webpages, emails, documents, tool results) that contains adversarial instructions.”Source: platform.claude.com
3.Closing the path without removing the capability
When a capability is both what the legitimate job needs and what the attacker wants, restrict the dangerous forms of it instead of removing it. Take a Claude Code CLI job that reviews pull requests from external contributors. It has to read every source file and run unit tests, so it needs Bash. An injected code comment asks it to curl the deploy token to an outside host. That path needs three things: a network-capable command, a credential within reach and a route out. Take away any one of them and the path is closed.
Permission rules handle the first one. Allow rules let a tool run without approval, ask rules prompt for approval, and deny rules block it. A configuration can allow the exact test-runner commands the job needs and deny network-capable commands. Rule syntax needs care. A * matches whatever text is in its place, so Bash(git * main) also matches git -c core.fsmonitor=<script> diff main, which makes git run a program you name. Write allow rules narrowly enough that a wildcard can't become an escape.
{
"permissions": {
"allow": [
"Bash(npm run *)",
"Bash(git commit *)"
],
"deny": [
"Bash(git push *)"
]
}
}The environment handles the other two. Claude Code's sandbox restricts writes by default, but it can still read most of the machine, including files such as ~/.ssh and ~/.aws/credentials. Environment variables, secrets included, are inherited. A runner that never holds the deploy token leaves nothing to steal, whatever the agent is talked into. Restricting outbound traffic to an allowlist, for example only the package registry, means a stolen secret has nowhere to go. In larger deployments, a proxy outside the agent's container can inject credentials, so the agent never sees the real credentials at all. That kind of least-privilege configuration limits the damage from attacks nobody predicted.
The tempting alternatives each fail one side of the trade-off:
- Disabling Bash closes the path, but the job can no longer run its tests.
- A CLAUDE.md rule about untrusted comments is prompt-only, so it's model behaviour, not a control.
- A keyword filter for
curlover changed files fails any legitimate pull request that mentions the word. It also inspects text, not the command the agent actually runs.
Not necessarily. The egress allowlist controls where traffic can go, not what a credential can do once it gets there. If the credential lets the agent write data or trigger further requests through the allowed domain, data can still leave. Limit the credential's permissions at the service that issued it.
Checkpoint 5 of 9· Fill the gap
This settings file has to let the agent run npm scripts and make commits without approval. It also has to stop the agent from pushing, even if an injected instruction tells it to push. Which key completes the configuration?
{
"permissions": {
"allow": [
"Bash(npm run *)",
"Bash(git commit *)"
],
" ? ": [
"Bash(git push *)"
]
}
}A deny rule blocks the tool call outright, so the push fails no matter what the model was persuaded to do. An ask rule only prompts for approval. excludedCommands is a sandbox setting that runs matching commands outside the sandbox, so it makes the push less restricted, not more.
Source: code.claude.comCheckpoint 6 of 9· Exam question
A team runs the Claude Code CLI in a CI job to review pull requests from external contributors. A red-team pull request contains a code comment telling the agent to run curl with the repository's deploy token against an outside host. The job must still run the project's unit tests and read every source file. Choose two.(Select 2)
Correct answers: A, D — Add permission rules that deny curl, wget and other network-capable Bash commands, and allow only the test-runner commands the job needs.; Run the agent on a runner that holds no deploy credentials, and restrict its outbound traffic to an allowlisted set of hosts such as the package registry.
- A. Permission rules are enforced by the harness, not by the model's judgment, so a denied network command is refused even if the injected comment persuades the model. Allowing the test-runner commands keeps the unit tests running.
- B. Without the Bash tool the agent cannot execute the unit tests, which the job must still run. Targeted permission rules close the exfiltration path while keeping test execution available.
- C. CLAUDE.md is context the model weighs, not an enforced boundary, so a crafted comment can still outweigh it and trigger the command. It is a reasonable supplement but does not close the exfiltration path.
- D. With no deploy credentials on the runner and egress limited to an allowlist, a successful injection has nothing valuable to send and nowhere untrusted to send it. Reading source files and running tests still work.
- E. A string filter is not a security boundary. The command can be obfuscated, encoded or replaced by another network-capable tool, and legitimate pull requests that mention
curlorwgetwould fail the job.
4.Parameters the model supplies are untrusted input
Any argument the model writes into a tool call can be steered by whoever wrote the conversation, so never let a model-supplied argument decide whose data is accessed. Take a bank chatbot whose get_account_summary tool accepts a customer identifier from the model. A user types another customer's name and gets that customer's balance. Nothing went wrong in the model's reasoning. The tool simply trusted a parameter that an untrusted user effectively chose. Overeager agents can produce the same failure with no attacker involved, by inferring a target the user never specified.
The control that closes this path takes the identity from a source the model can't influence. The server reads the customer ID from the signed-in user's session, passes that to the tool and ignores whatever identifier the model wrote. Authenticated customers still see their own full balances and transactions, because nothing about their own data is hidden. In Claude Code and the Agent SDK, a PreToolUse hook offers the same kind of mechanism. It can deny a call, or rewrite the tool's input parameters before execution through updatedInput. Deny and ask rules are still evaluated regardless of what the hook returns. Deriving identity this way is part of the authorization posture of the system.
Output-side fixes fail the legitimate use. A regex that masks balances, or a second model call that redacts personal data from tool results, hides the very figures authenticated customers are entitled to see. A system prompt instruction with refusal examples leaves the boundary in the model's hands. When the stated legitimate use is "full details for your own account", any control that weakens the output is the wrong one. The fix belongs at the input to the tool.
Checkpoint 7 of 9· Check yourself
No attacker is involved in this case. A subscription-support agent has a cancel_subscription tool that takes an account ID. A signed-in customer types "cancel my plan". The agent looks up accounts, picks the closest name match, and cancels another customer's plan. Customers must still be able to view their full plan details and cancel their own plan. Which control closes this path?
The model chose the target. That happens even without injection when an overeager agent infers a target, so an input classifier has nothing to catch. A prompt rule leaves the decision to the model, and redaction hides details customers are entitled to see. Taking identity from the session, which the model can't influence, closes the path and leaves the legitimate use intact.
“This is blocked since the specific target may not have been what the user intended, and could have been owned by someone else.”Source: www.anthropic.com
Checkpoint 8 of 9· Exam question
A bank's public chatbot calls a get_account_summary tool. In testing, a user typed another customer's name and received that customer's balance and recent transactions. Authenticated customers legitimately ask for their own full balances and transaction details. Which control best closes this path?
Correct answer: A — Have the server take the customer ID from the signed-in user's session and pass it to the tool, discarding the customer identifier the model puts in the call.
- A. The server fixes the customer ID from the session, so no user phrasing or model output can point the tool at another customer's records. Customers still receive full detail on their own accounts.
- B. Masking balances and account numbers also hides the figures customers legitimately ask for about their own accounts. The tool still retrieves another customer's data, so the access path stays open.
- C. A prompt instruction is guidance the model can misapply or be talked out of, and it enforces nothing at the data layer. The tool would still return another customer's data whenever the model makes the call.
- D. A redaction pass cannot tell whose data is whose, so it strips the customer's own balances and transactions along with anyone else's. It is also a probabilistic filter, not an authorization check on the lookup.
5.Layers complement each other; they do not replace each other
Each layer covers a gap the others leave, so a strong control at one point doesn't make the rest unnecessary. Limiting an environment's network hosts doesn't stop the agent from using a credential on a host you allowed. The sandbox proxy checks the hostname the client supplies and doesn't inspect encrypted traffic by default, so code inside could use domain fronting to reach other hosts. In Claude Code, the sandbox doesn't cover the built-in file and web tools. A denyRead entry doesn't stop the Read tool, and allowedDomains doesn't limit WebFetch. Those tools follow permission rules instead.
The working design has a closing control at the harmful action, backed by screening and prompt hardening that lower how often the closing control is even tested. Then it gets verified. Before deploying, red-team the workflow with documents, emails and tool outputs that contain injection attempts. Confirm that the model ignores them and that the screening and confirmation steps catch what's left. Where an action is risky enough that no automated check should decide alone, a human approval checkpoint is the next layer.
Checkpoint 9 of 9· Check yourself
After enabling Claude Code's sandbox, a team adds ~/.aws/credentials to filesystem.denyRead and sets network.allowedDomains to the package registry only. They conclude that the agent can neither read the credentials file nor send its contents to an outside host. What did they miss?
The sandbox limits only Bash commands. Built-in file and web tools follow permission rules, so a denyRead entry doesn't stop Read and allowedDomains doesn't limit WebFetch. Both layers are needed because neither one replaces the other.
“A denyRead entry doesn’t stop the Read tool, and allowedDomains doesn’t limit WebFetch”Source: code.claude.com
Sources
(7)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Claude is inherently resilient to it, but model behavior is not a security control.”
↩︎ A misuse path has an entry point, a carrier and a harmful action“The settings do not secure your custom tools, your MCP servers, or your self-hosted infrastructure.”
↩︎ Where each layer sits, and what it can and cannot see“Smallest tool set, untrusted input kept away from powerful tools, approvals for risky actions”
↩︎ Parameters the model supplies are untrusted input“These limits do not replace each other.”
↩︎ Layers complement each other; they do not replace each other“Claude is inherently resilient to it, but model behavior is not a security control.”
↩︎ Key concept“model behavior is not a security control”
↩︎ Exam trap 2“These limits do not replace each other.”
↩︎ Exam trap 3 - 2.https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guardrails/mitigate-jailbreaksOfficial docs
“where the user is trusted but Claude processes third-party content (webpages, emails, documents, tool results) that contains adversarial instructions”
↩︎ A misuse path has an entry point, a carrier and a harmful action“Use a lightweight model such as Claude Haiku 5.5 to pre-screen user input before it reaches your main conversation.”
↩︎ Where each layer sits, and what it can and cannot see“Apply the principle of least privilege so that a successful injection can do minimal damage”
↩︎ Where each layer sits, and what it can and cannot see“Claude is trained to treat instructions that appear inside tool results with appropriate skepticism.”
↩︎ Where each layer sits, and what it can and cannot see“Before deploying, test your workflow with documents, emails, and tool outputs that deliberately contain injection attempts”
↩︎ Layers complement each other; they do not replace each other“where the user is trusted but Claude processes third-party content (webpages, emails, documents, tool results) that contains adversarial instructions”
↩︎ Exam trap 1“Indirect prompt injection, where the user is trusted but Claude processes third-party content (webpages, emails, documents, tool results) that contains adversarial instructions.”
↩︎ Checkpoint“Apply the same lightweight-model screening pattern you use for user input to the content your tools return.”
↩︎ Prediction“Indirect prompt injection, where the user is trusted but Claude processes third-party content (webpages, emails, documents, tool results) that contains adversarial instructions.”
↩︎ Checkpoint - 3.https://code.claude.com/docs/en/permissionsOfficial docs
“Deny rules prevent Claude Code from using the specified tool.”
↩︎ Closing the path without removing the capability“That includes -c, which makes git run a program you name.”
↩︎ Closing the path without removing the capability - 4.https://code.claude.com/docs/en/sandboxingOfficial docs
“Most of the machine, including credential files such as ~/.ssh and ~/.aws/credentials”
↩︎ Closing the path without removing the capability“A denyRead entry doesn’t stop the Read tool, and allowedDomains doesn’t limit WebFetch”
↩︎ Layers complement each other; they do not replace each other - 5.
“The agent never sees the actual credentials”
↩︎ Closing the path without removing the capability“ensure it cannot use that domain to trigger other network requests or to exfiltrate data”
↩︎ Closing the path without removing the capability“Code running inside the sandbox can potentially use domain fronting or similar techniques to reach hosts outside the allowlist.”
↩︎ Layers complement each other; they do not replace each other - 6.https://www.anthropic.com/engineering/claude-code-auto-modeSecondary source
“picked the closest match by name similarity, and tried to delete it”
↩︎ Parameters the model supplies are untrusted input“picked the closest match by name similarity, and tried to delete it”
↩︎ Exam trap 4“This is blocked since the specific target may not have been what the user intended, and could have been owned by someone else.”
↩︎ Checkpoint - 7.https://code.claude.com/docs/en/hooksOfficial docs
“input parameters before execution. Replaces the entire input object, so include unchanged fields alongside modified ones.”
↩︎ Parameters the model supplies are untrusted input“Deny and ask rules are still evaluated regardless of what the hook returns”
↩︎ Parameters the model supplies are untrusted input