About 7 of the 60 scored questions come from this domain. It has 3 skills:
Lessons
Skill
Runtime Guardrail Systems
Layered guardrails: what the model decides and what code decides
A guardrail architecture is a set of layers, each of which stops a different failure. The exam asks you to match layers to an agent's risk profile. Start with one question: what is the worst thing this agent can do, and can it be undone? Reversible actions inside a disposable sandbox can be checked automatically. Irreversible actions need a control that does not depend on the model choosing well.
Deterministic enforcement
A system-prompt rule is a request. A hook, a deny rule, or an operating-system sandbox is enforcement. Know how the layers order themselves in Claude Code and the Agent SDK:
- Hooks run first. A hook can deny a call outright.
- Deny rules, then ask rules. A deny rule holds even in bypass mode and even when a hook returned allow.
- The permission mode, then allow rules.
- The approval callback runs only if nothing earlier decided the call.
Two consequences follow. A check placed in the approval callback never runs for a tool that an allow rule or mode already approved; put that check in a pre-execution hook. And a hook that throws lets the call go ahead by default; set the hook to block on failure when the action matters more than availability.
A shell deny rule matches the command text. Bash(rm *) stops rm -rf build/ but not /bin/rm -rf build/ or bash -c 'rm ...'. The documentation says such a rule "isn't a security boundary around the program". When a restriction must hold however a command is spelled, use sandboxing, which the operating system enforces.
Sandboxing without exposing production
Give the agent tools and web access inside a boundary, and keep credentials and production systems outside it. The options trade isolation for cost:
| Technology | Kernel | Cost |
|---|
| Sandbox runtime | Shared with host | Very low |
| Container | Shared with host | Low |
| gVisor | System calls intercepted in user space | Heavy on file I/O |
| Virtual machine | Own kernel | High |
Network allowlists work by host, not by operation: an allowed host accepts uploads as well as downloads. Check whether a sandbox has an escape hatch. In Claude Code a failed command can be retried outside the sandbox unless strict mode turns that off.
Approval gates
Managed Agents has three permission policies: run every call, pause every call for a person, or let the server evaluate each call. Server evaluation exists because "A person cannot approve every call in a long run". It is not a human checkpoint. Use the pause policy where a change cannot be undone outside the sandbox, and for anything that moves money. Watch for two failures: reviewers who approve thousands of low-risk calls stop reading them, and a client that approves every paused call without showing it to anyone is the same as no gate. Permission policies do not cover custom tools; your application must gate those itself. A paused session waits indefinitely, so an unattended agent needs something that answers or interrupts.
Filters, redaction and tuning
- Input screens: a small model classifies the input with a structured verdict. If the screen itself is refused, there is no verdict; treat that as harmful.
- PII redaction: redact where data enters the system (the tool result), not only where it leaves. Redacting the final answer leaves raw data in conversation history, traces and logs.
- Thresholds: a false positive costs a blocked user; a false negative costs whatever the agent can do. Set the threshold per agent by blast radius, not once for the fleet.
Refusals
A refusal is a successful HTTP 200 response with a refusal stop reason, so error-rate dashboards never see it. Count refusals as their own signal. Discard any partial output, do not parse the explanation text, and retry on a different model, because the same model usually refuses again. In a multi-turn conversation, remove or rephrase the refused turn before continuing.
Sources
Configure permissions (Agent SDK)
Intercept and control agent behavior with hooks
Hooks reference
Configure permissions (Claude Code)
Configure the sandboxed Bash tool
Securely deploying AI agents
Permission policies
Secure your Managed Agents deployment
Refusals and fallback
Handle streaming refusals
Mitigate jailbreaks and prompt injections
Skill
Threat Defense and Adversarial Testing for Agentic Systems
Attack surface of a tool-using agent, and how to test it
There are two threat models, and they call for different defences. In direct injection the user is the adversary and types the attack. In indirect injection the user is trusted, but the agent reads third-party content that carries instructions: an email, a webpage, a ticket, a repository file, a tool result. For agents, the second is the one that matters most, because the attacker needs no account.
Find the dangerous combination
List three things for each agent: what private data it can read, what untrusted content it reads, and how it can send data out. An agent with all three can be told by a document to send your data to an attacker. Outbound paths are easy to miss:
- A URL the agent fetches can carry data in its path or query string.
- A search query is sent to the search provider. A domain list on a search tool "limits which sites results come from, not what the query contains".
- An allowed host accepts any request, including
git push and package publishing. Shared hosting domains, where anyone can publish, are exfiltration paths. - The agent's own reply and tool outputs can contain anything it was allowed to read.
Remove one leg of the combination. The Managed Agents guidance gives three designs: split reading from acting, give the agent one narrow custom tool that your application runs and checks, or require a person's approval. For a strong split, use two sessions with separate environments and pass only fixed fields between them.
Handle untrusted content correctly
- Deliver third-party content only in tool results, never in the system prompt or a plain user text block.
- Label what it is and where it came from, and JSON-encode it so it cannot break out of its delimiters.
- State in the system prompt that tool content is data, not commands.
- Put your own instructions in a user turn after the tool result. Instructions you place inside a tool result may be ignored or flagged.
- Optionally screen tool output with a small model before the main model sees it.
A clean red-team result is not a reason to drop the other layers. The documentation says Claude is resilient to injection, "but model behavior is not a security control". Size the tools, credentials and network for the day an attempt succeeds.
Poisoning and MCP configuration
- Memory: text an agent saves from untrusted input is read by later sessions as trusted memory. Attach memory stores read-only unless the agent must write.
- Tools: an MCP toolset enables every tool the server exposes by default, so a server update can add a tool. Disable by default and enable tools by name, and keep the toolset default on approval so new tools wait for a person.
- Repositories: instruction files and skills in a mounted repository can load as agent instructions. Mount only repositories you trust.
- Tokens: an MCP server must accept only tokens issued for it and must use its own separate token upstream. Passing a client token through breaks audience checks and the audit trail.
- Scopes: start minimal and elevate when needed; avoid wildcard scopes.
Standards
The OWASP Top 10 for LLM Applications entry on excessive agency names three root causes: excessive functionality, excessive permissions and excessive autonomy. Fix those first. OWASP states that logging and rate limiting will not prevent excessive agency; they limit damage. Its prompt-injection entry says no fool-proof prevention is known, which is why least privilege and human approval sit beside filtering. The NIST Generative AI Profile (AI 600-1) organises actions under Govern, Map, Measure and Manage, lists prompt injection under information security, and calls for red-teaming to assess resilience to it.
Design the red-team exercise
Test the channels an attacker can actually reach. Seed documents, emails and tool outputs with injection attempts. Score outcomes, not refusals: did a tool get called, did data leave, did memory change? Check that screening and approval steps catch what the model misses. Repeat after every tool, prompt or model change, and keep monitoring production output for signs of success.
Sources
Mitigate jailbreaks and prompt injections
Secure your Managed Agents deployment
Security risks and sandbox boundaries
MCP Security Best Practices
MCP Authorization specification
OWASP LLM01: Prompt Injection
OWASP LLM06: Excessive Agency
NIST AI 600-1, Generative AI Profile
Skill
Identity, Secrets, and Audit at Scale
Identity, secrets and audit for agents in production
Three questions run through this skill. Who is this workload? What can its credential do? Can you prove afterwards what it did? Static shared keys answer all three badly: they never expire, they are copied into many places, and one key hides many callers.
Workload identity federation
With federation, a workload presents a short-lived signed token from an identity provider you already run (a cloud provider, Kubernetes, a CI system). The platform checks it against a rule and returns a short-lived access token bound to a service account. There is no static secret to store, rotate or leak. Three resources express the trust: the issuer (whose tokens count), the rule (which claims must match), and the service account (which identity the token acts as).
- All of a rule's matchers must pass. A rule that matches only a broad subject prefix lets every workload under that prefix act as the service account. Match the exact subject or claims.
- Register an issuer per environment, so production and staging trust are separate.
- Federation is only as strong as the identity provider that signs the token.
Migrating from a static key
- Configure federation alongside the existing key.
- Check which credential the workload actually uses.
- Remove the key from every place it is injected, and check again.
- Delete the key.
In the SDK's credential order the API-key environment variable sits above federation, so "a leftover key in the environment silently overrides federation". A migration can look complete while every request still uses the old key. Deleting the key first, while it is still injected, causes an outage instead of a migration.
Identity tokens with a token identifier are single-use. A retry loop that reuses a cached token fails as a replay. Fix the workload so it gets a fresh token for each exchange. Turning off the replay check is a last resort, and it removes the protection for every rule on that issuer.
Keeping secrets away from the agent
Anything inside the agent's sandbox can be read by code the agent runs, including code it was tricked into running. Keep credentials outside the boundary:
- Proxy pattern: a proxy outside the boundary adds the credential to outgoing requests, enforces a host allowlist and logs traffic. The agent never sees the credential.
- Vaults (Managed Agents): code sees a placeholder; the real secret is swapped in at egress, only for the hosts the credential allows. Limit it to exact hosts and to request headers.
- Custom tools: your application holds the key and exposes one narrow operation.
None of these limits what the key can do on a host you allowed. "Limit a key's permissions at the service that issued it": if the task is read and update, the key should not be able to delete. This is least privilege applied at the only place that can enforce it. Also check what sits in mounted directories; read-only access to a repository can still expose .env files and cloud credentials.
Least-privilege tool permissioning
Give each agent the smallest tool set, each tool the narrowest scope, and each credential the narrowest role. Run actions in the context of the user they are for, not with a shared administrator identity. For MCP, a server must accept only tokens issued for it and must use a separate token upstream; forwarding the client's token makes downstream logs show the wrong identity.
Audit logging
| Need | Do this |
|---|
| Attribute model-API traffic | One service account per workload, not a shared workspace key |
| Record what an agent did | Log each tool call at the layer that executes it (proxy, gateway, tool server), with identity, input, permission outcome and result |
| Trust the record | Store it where the agent cannot write; do not rely on the agent's own summary |
| Organisation activity | Enable the Compliance API Activity Feed early: recording starts at enablement and is not backfilled |
Managed Agents tool-use events carry the permission outcome and, under server evaluation, a reason code meant to be kept in audit records. When an incident starts, the order is: interrupt the agent, pause its schedule, rotate any exposed key at the issuer, then read the record.
Sources
Workload Identity Federation
Admin API
Query the Activity Feed
Authenticate with vaults
Secure your Managed Agents deployment
Security risks and sandbox boundaries
Permission policies
Securely deploying AI agents
MCP Authorization specification