🎓 Claude Certification Prep

Home › CCDV-P › M07

Runtime Guardrails and Production Security

Domain 7 11% of exam 48 practice questions ~21 min read

Layered guardrail architecture, defenses against prompt injection, tool/memory poisoning, and the lethal trifecta, sandboxing with an egress proxy, agent identity through Workload Identity Federation, secrets management, least-privilege permissioning, and audit logging with OpenTelemetry.

Skills measured in this domain:
  • Runtime Guardrail Systems: input/output filtering, PII redactors, hook-based policy, destructive-action prevention, sandboxing, approval gates, refusal handling, false-positive/false-negative tuning
  • Threat Defense and Adversarial Testing for Agentic Systems: prompt injection, tool and memory poisoning, exfiltration, the private data + untrusted input + external communication combination; OWASP Top 10 for LLM Applications, NIST AI RMF
  • Identity, Secrets, and Audit at Scale: agent identity, workload identity federation, secrets management, least privilege, audit logging

Domain overview

Domain 7 accounts for 11% of the CCDV-P exam and covers three skill areas: runtime guardrail systems, threat defense and adversarial testing, and identity, secrets, and audit. At the Professional level, items do not ask what prompt injection is; they ask at which layer a control belongs for a specific production agent, and why other layers are not enough. (Source: CCDV-P Exam Guide, Domain 7)

Anthropic treats agent risk as the product of likelihood and blast radius. There are three components to protect: the environment (where the agent runs), the model, and external content (content from outside that the agent reads). Model-layer measures such as system prompts or classifiers only shape what the agent tends to do; they do not limit what it is able to do. (Source: Anthropic Engineering: How we contain Claude across products)

Key point

The core distinction in D7: probabilistic controls (prompts, classifiers, the model) versus deterministic controls (hooks, permission rules, sandboxes, egress proxies, credential scope). Irreversible actions and data exfiltration paths must be blocked by a deterministic layer outside the model; probabilistic layers only reduce frequency.

Runtime guardrail systems

Layered architecture

Layer Typical mechanism Type Limitation to remember
Input screen Harmlessness screen with Claude Haiku 5.5 and structured output Probabilistic Does not catch malicious commands typed by the user themselves
Tool output screen A small classifier scores the tool_result (injection_suspected) Probabilistic Adds latency, not perfect
Model/prompt <untrusted_content_policy>; auto mode classifier Probabilistic Only shapes tendencies
Hook PreToolUse allow/deny/ask/defer, updatedInput Deterministic PostToolUse cannot block a call that already ran
Permission rule permissions.allow/deny/ask in managed settings Deterministic A permission gate, not a sandbox
Sandbox + egress sandbox-runtime, gVisor, VM; proxy allowlist Deterministic Data can still be sent to allowed domains
Approval gate ask, change ticket, human review Human Approval fatigue

(Sources: Claude Docs: Mitigate jailbreaks and prompt injections; Anthropic Academy: Claude Code in action — Hooks; Claude Code Docs: Securely deploying AI agents)

Input/output filtering and PII redaction

Harmlessness screen: use a lightweight model such as Claude Haiku 5.5 to screen input before the main conversation, forcing the result into a classification value with structured outputs (output_config with json_schema). Apply the same pattern to tool output: return the tool_result only when injection_suspected is false; otherwise return an error or a summary with the suspicious content removed. Haiku 5.5 has its own safety classifier, so it may refuse the screening request itself; in that case there is no verdict, and you must treat stop_reason: "refusal" as a harmful verdict (fail closed). (Source: Claude Docs: Mitigate jailbreaks and prompt injections)

A PII redactor can be a deterministic hook: PreToolUse returns updatedInput to rewrite the command, for example replacing a key-like sk_live_ string with REDACTED, then returns ask so the user approves the modified command.

jq 'if (.tool_input.command // "" | test("sk_live_\\w+")) then {
  hookSpecificOutput: {
    hookEventName: "PreToolUse",
    permissionDecision: "ask",
    updatedInput: (.tool_input | .command |= gsub("sk_live_\\w+"; "REDACTED"))
  }
} else empty end'

updatedInput replaces the entire input object, so you must return the unchanged fields as well; returning allow instead of ask would skip the prompt for every matching command. A PostToolUse hook on Edit|Write can run a script that fails when a field tagged pii leaks into a log or error. In telemetry, prompts, tool input, and tool content are redacted by default; enable OTEL_LOG_USER_PROMPTS, OTEL_LOG_TOOL_DETAILS, and OTEL_LOG_TOOL_CONTENT only when the pipeline is approved to store that data. (Sources: Anthropic Academy: Claude Code in action — Hooks; Anthropic Academy: The AI-native SDLC playbook — Skills as institutional knowledge; Claude Code Docs: Monitoring)

Refusal handling and safety fallbacks

A refusal arrives in a successful response, not as an HTTP error: stop_reason is "refusal", with stop_details (category, explanation). So the api_error event does not catch it; Claude Code has a separate claude_code.api_refusal event, with server_fallback_hop indicating whether a server-side fallback already retried on another model. Server-side fallbacks are opt-in; if they are not enabled, a refused request simply stops. (Sources: Anthropic Skills: claude-api; Claude Code Docs: Monitoring)

An application-level safety fallback is a predefined safe branch: return a summary instead of the suspicious content, switch to draft-only mode, or hand off to a human. For users who repeatedly trigger the same type of refusal, consider throttling or banning. (Sources: Claude Docs: Mitigate jailbreaks and prompt injections; Claude Blog: CISO's guide to agentic AI)

Deterministic enforcement for irreversible actions

Exam trap

"Add 'never delete production data' to the system prompt" or "use a more capable model" are probabilistic controls. When an item describes an irreversible action, the correct answer is usually a control outside the model: a deny hook, removing the permission, separating credentials by environment, or a mandatory approval gate.

Sandboxing: granting tool and web access without exposing production

The goal is to let the agent work freely inside a tight perimeter instead of asking for approval on every operation.

Technology Isolation level Overhead Complexity
sandbox-runtime Good Very low Low
Docker container Depends on configuration Low Medium
gVisor Excellent Medium/High Medium
VM (Firecracker, QEMU) Excellent High Medium/High

sandbox-runtime uses bubblewrap or sandbox-exec and routes network traffic through a proxy with an allowlist, but it shares the kernel with the host and does not inspect TLS. A hardened container uses --cap-drop ALL, --security-opt no-new-privileges, --read-only, --network none, a non-root user, :ro mounts, and talks to the proxy only over a Unix socket. Exclude files such as .env, ~/.aws/credentials, ~/.kube/config, and *.pem from the sandbox. In Claude Code, sandbox.failIfUnavailable together with allowUnsandboxedCommands: false makes the sandbox a hard prerequisite. (Sources: Claude Code Docs: Securely deploying AI agents; Anthropic Academy: The AI-native SDLC playbook — Hooks as approval gates)

Exam trap

An egress allowlist is a capability grant, not a list of "safe domains". Anthropic has recorded exfiltration through the allowed domain api.anthropic.com using an attacker's API key with the Files API; the fix was a MITM proxy that only lets through the VM's own session token. (Source: Anthropic Engineering: How we contain Claude across products)

Approval gates and FP/FN tuning

Users approve about 93% of permission prompts, and the more prompts they see, the less attention they pay. Claude Code's sandbox (free reads, writes within the workspace, network blocked by default) cuts prompts by 84%. Auto mode hands the decision to a classifier: about 0.4% of benign commands are blocked (false positives), and about 17% of overeager actions get through (false negatives). Auto mode is therefore a layer inside the sandbox, not a replacement for it. (Source: Anthropic Engineering: How we contain Claude across products)

Symptom Interpretation Tuning direction
Very high approval rate, superficial review The gate has too many FPs Pre-approve safe loops with permissions.allow, rely on the sandbox
classifier_verdict of "block" spikes Possibly a partial classifier outage Check for an incident before loosening rules
Risky actions get through auto mode Classifier FNs Add hooks, deny rules, egress controls
Many calls denied in -p ask with nobody to answer Declare --allowedTools explicitly

(Sources: Claude Code Docs: Monitoring; Anthropic Academy: The AI-native SDLC playbook)

Scenario example

OTel shows that 95% of tool_decision events have a source of user_temporary, and two recent incidents were both caused by engineers clicking approve. "Add a red warning to the prompt" does not touch the root cause. Better: put safe commands (git, make test) on the managed-settings allow list, enable the sandbox with a domain allowlist, and keep ask only for the few actions with a large blast radius.

Threat defense and adversarial testing

Attack surface of tool-using agents

The lethal trifecta and unsafe-autonomy conditions

The Exam Guide describes the high-risk combination of private data access, untrusted input, and external communication; the Agent SDK documentation cites the article "The Lethal Trifecta for AI Agents" as further reading. When all three are present, instructions in the prompt are not an enforceable boundary. The remedy is to cut one leg with a deterministic control: recipient allowlisting, an approval gate for external sends, narrower data scope, or draft-only mode. (Sources: CCDV-P Exam Guide; Claude Code Docs: Securely deploying AI agents; Claude Blog: CISO's guide to agentic AI)

Unsafe autonomy arises when permissions exceed oversight capacity. The CISO guide poses four questions: does the agent read untrusted content; what actions does it take and on whose behalf; how large is the blast radius; and can agent actions be observed separately from user actions. A drifting agent is indistinguishable from an insider attack. When an incident-response agent was upgraded from Claude Opus 4 to Claude Opus 4.5 with nothing else changed, it sought out another agent with code-change permissions to try to fix production; the only write action still required human review, so the control held. Lesson: limit permissions and actions explicitly, and do not rely on assumptions about the limits of today's model. Use bypassPermissions only in an isolated container or VM. (Sources: Claude Blog: CISO's guide to agentic AI; Anthropic Academy: Claude Code in action — Permission modes)

Scenario example

A CI triage agent reads public GitHub issues, can read all private code, and can call curl to the internet: all three legs of the trifecta. Adding <untrusted_content_policy> is necessary but not sufficient. The strongest control is to cut the external-communication leg: a sandbox whose network.allowedDomains contains only the internal registry, no tokens in the container, and write tools routed through a narrowly scoped MCP server.

Defense in depth and secure MCP configuration

According to the CISO guide, egress allowlisting through a mandatory proxy that the sandbox cannot reconfigure itself is the strongest control against prompt injection. MCP controls in the sources:

  • An organization-owned allowlist: allowManagedMcpServersOnly, allowedMcpServers, deniedMcpServers, managed-mcp.json; in the Agent SDK, strict_mcp_config=True.
  • One server per environment, because allow rules name the server and tool and do not inspect parameters.
  • Tool annotations declare destructive or open-world tools.
  • Roots are not enforced by the SDK; the server must check paths itself (for example is_path_allowed()).
  • Remote MCP: run it with fake data in a small-blast-radius environment before trusting it.
  • Enterprise connectors: three gates (org, role, member); set write/delete tools to "Needs approval" or "Blocked".

(Sources: Claude Code Docs: Monitoring; Anthropic Academy: The AI-native SDLC playbook — CI/CD integration and deployment; Anthropic Engineering: Writing effective tools for AI agents; Anthropic Academy: Model Context Protocol: Advanced topics — Roots; Anthropic Academy: Deploying Claude Enterprise with confidence — Connectors)

Red-team exercise design

The sources recommend red-teaming your own agent and monitoring continuously. A good exercise:

  1. Seed injections into every channel the agent reads: email, web, README, tool output, memory, CLAUDE.md.
  2. Try both direct and indirect injection, and measure multiple adaptive attempts: Opus 4.7 holds attack success at about 0.1% for a single attempt but about 5 to 6% after 100 adaptive attempts.
  3. Try exfiltration through allowed domains.
  4. Check code that runs before the trust dialog and in-repo configuration.
  5. Use fake data and canary strings to detect payloads spreading to other agents.

(Sources: Claude Docs: Mitigate jailbreaks and prompt injections; Anthropic Engineering: How we contain Claude across products)

Key point

The Exam Guide names the OWASP Top 10 for LLM Applications and the NIST AI Risk Management Framework with its Generative AI Profile as reference frameworks. Anthropic's own documentation only links to OWASP as further reading and mentions NIST only through the NCCoE project on AI agent identity and authorization, so read the originals; this module does not summarize those frameworks.

Identity, secrets, and audit at scale

Agent identity

The CISO guide describes an identity spectrum from system service accounts to human credentials; the middle ground (delegated identity) is the most ambiguous.

Workload Identity Federation replacing static API keys

Workload Identity Federation (WIF) lets non-interactive workloads (CI, servers, containers) exchange a JWT from their own IdP for a short-lived token instead of storing a static API key. WIF is GA; the SDK detects it automatically when all four variables are set, exchanges the JWT at /v1/oauth/token, and refreshes on its own:

export ANTHROPIC_FEDERATION_RULE_ID=fdrl_...
export ANTHROPIC_ORGANIZATION_ID=...
export ANTHROPIC_SERVICE_ACCOUNT_ID=...
export ANTHROPIC_IDENTITY_TOKEN_FILE=/path/to/jwt   # or ANTHROPIC_IDENTITY_TOKEN
unset ANTHROPIC_API_KEY ANTHROPIC_AUTH_TOKEN

On the Anthropic side you need a federation issuer (for example https://token.actions.githubusercontent.com) and a federation rule: match conditions (subject_prefix and claims), the target service account, workspace_id, oauth_scope (for example workspace:developer), and token_lifetime_seconds (for example 600). The endpoints that manage service accounts, issuers, and rules accept only an org:admin OAuth token. claude-code-action supports WIF through a service account in the Claude Console, with the id-token: write permission. (Sources: Anthropic Skills: claude-api — Admin API (Organization Management); Anthropic Academy: Claude Code in action — GitHub Actions and Code Review)

Exam trap

ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN, even when empty, takes precedence over WIF. If an item describes "WIF is configured but requests still use the old key", check for leftover variables in the runner environment.

Credential and secrets management

Principle: the sandbox holds no credentials worth stealing. A proxy outside the sandbox attaches credentials to requests (Envoy credential_injector; LiteLLM is an LLM gateway with credential injection and rate limiting), while enforcing an endpoint allowlist and logging. ANTHROPIC_BASE_URL only routes sampling requests to the proxy; HTTP_PROXY/HTTPS_PROXY use a CONNECT tunnel, so attaching credentials requires a TLS-terminating proxy. Claude Managed Agents keeps credentials in a vault separate from the sandbox; Claude Tag uses an Agent Proxy that blocks non-matching requests. (Sources: Claude Code Docs: Securely deploying AI agents; Claude Blog: CISO's guide to agentic AI; Claude Blog: The evolution of agentic surfaces: building with Claude Managed Agents; Anthropic Academy tutorial: Claude Tag admin guide)

Key point

A permissions.deny rule such as Read(.env*) only controls Claude's file tools; shell commands in the sandbox can still read ~/.ssh. That is why a regulated configuration adds sandbox.credentials to deny reads of ~/.ssh and ~/.aws/credentials and to remove GITHUB_TOKEN from the sandboxed command environment. (Source: Anthropic Academy: The AI-native SDLC playbook — Hooks as approval gates)

Least-privilege tool permissioning

"Grant read broadly, write narrowly": a read-only database agent can be deployed far more widely than an agent that writes to production. A staging job in CI holds only a staging token and calls only the tools it needs; dontAsk denies everything that would otherwise need a prompt:

claude -p "$TASK" \
  --allowedTools "mcp__deploy-staging__release,mcp__deploy-staging__status,mcp__deploy-staging__rollback" \
  --permission-mode dontAsk

(Sources: Anthropic Academy: The AI-native SDLC playbook — CI/CD integration and deployment; Anthropic Engineering: How we contain Claude across products)

Audit logging of security-relevant actions

OpenTelemetry events are the audit data source, shipped to a SIEM:

  • tool_decision: decision, source (config, hook, user_permanent, user_temporary, user_abort, user_reject), classifier_verdict.
  • permission_mode_changed (mode escalation), hook_execution_complete, mcp_server_connection, plugin_installed, managed_settings_resolved.
  • safety_event is no longer emitted as of v2.1.312; use tool_decision.
  • With an API key or Bedrock/Vertex/Foundry there is no account, so add identity through OTEL_RESOURCE_ATTRIBUTES.
  • Without OTEL_LOG_TOOL_DETAILS=1, MCP tool names appear only as "mcp_tool".

Managed settings lock the OTLP destination: developer-set endpoints are dropped, and a repo's .claude/settings.json cannot enable or redirect telemetry. Claude Code only emits the raw data stream; anomaly detection is the SIEM's job. (Sources: Claude Code Docs: Monitoring; Claude Blog: CISO's guide to agentic AI)

Exam trap

An audit log is a detective control, not a preventive one. When malicious tool output steers the agent into exfiltration, the log only shows a legitimate call. Choose logging when the item asks about investigation or accountability; choose a deterministic control when it asks how to prevent.

Exam tip

"Agent actions cannot be distinguished from engineer actions" points to a dedicated service account or identity attributes in telemetry. "A static API key in CI was leaked" points to WIF. "The agent can see credentials" points to proxy injection.

Quick summary

  • Risk is likelihood times blast radius; the model layer only shapes tendencies and does not limit capability.
  • Irreversible actions need deterministic controls outside the model: fail-closed hooks, removing delete permissions, approval gates, separated credentials.
  • Screen input and tool output with Claude Haiku 5.5 and structured output; a refusal from the screen is a harmful verdict.
  • A refusal is a successful response with stop_details; track it with claude_code.api_refusal.
  • updatedInput redacts data but replaces the entire input; PostToolUse cannot block a call that already ran.
  • An egress allowlist is a capability grant; exfiltration can still go through legitimate domains.
  • Approval fatigue is about 93%; auto mode has about 0.4% FP and 17% FN and is a layer inside the sandbox.
  • Lethal trifecta: cut one leg with a deterministic control; do not rely on prompts or logs.
  • Tool poisoning, remote MCP behavior changes, memory poisoning, and trust escalation are the new attack surfaces.
  • Red-team every input channel, test multiple adaptive attempts, use canary strings.
  • WIF replaces static API keys; an API key or auth token, even empty, overrides WIF.
  • The sandbox holds no credentials; grant read broadly, write narrowly; one MCP server per environment.
  • Audit via OTel to a SIEM; managed settings lock the OTLP destination; logs detect but do not prevent.