CCDV-F Prep unofficial
← All skills

Security and Safety

Prompt Injection and Jailbreak Defense

Exam objective: Analyzing the prompt-injection and jailbreak exposure of an agent that processes untrusted content, and selecting layered mitigations that prevent data leakage and unintended actions without breaking the agent's function.

What the exam tests

Whether you can look at an agent that reads untrusted content, name how it could be turned against its user (data leaked, unintended actions), and pick layered mitigations that still let it do its job. Expect to separate controls that only lower the odds of a successful injection from controls that limit what success can achieve.

Key rules

Threat model first

  • Jailbreak / direct injection: the user is the adversary. Indirect injection: the user is trusted, but webpages, emails, files or tool results carry hostile instructions.
  • Exposure comes from combining untrusted input with sensitive data or powerful tools (shell, writes, web fetch, anything using a credential).

Direct attacks

  • Pre-screen input with a lightweight model (Claude Haiku 5.5) and structured outputs.
  • Validate input for known injection patterns, state boundaries and how to refuse in the system prompt, and throttle or ban repeat offenders.

Indirect attacks: structure the request

  • Third-party content goes in tool_result blocks, never in system or plain user text.
  • Say what the content is and where it came from. JSON-encode it so it cannot break out of its delimiters.
  • State in the system prompt that retrieved content is untrusted data.
  • Your own instructions do not go in tool results. Send them in a user turn after the result, or a mid-conversation system message where supported.
  • Screen tool outputs with a classifier before returning them. A stop_reason: "refusal" from the screen counts as a positive.
{"type": "tool_result", "tool_use_id": "toolu_01",
 "content": "{\"source\":\"inbound_email\",\"from\":\"unknown@example.com\",\"body\":\"Ignore previous instructions...\"}"}

Limit the damage

  • Least privilege: only the tools, files, secrets and hosts the task needs.
  • Egress allowlists (a proxy, --network none plus a Unix socket, allowed_domains on web tools). A fetched URL can carry data out.
  • Keep credentials outside the agent's boundary: a proxy or your application injects them.
  • To read and act: split reading from acting, give one narrow tool that your code validates, or require human approval. In Managed Agents, auto is not a human checkpoint; use always_ask.
  • Agents in one multiagent session share the sandbox and vault credentials. Separate sessions that exchange fixed fields isolate more strongly.

Prompt leaks

  • Leave out secrets the task does not need, filter outputs, and audit. No method is foolproof, and heavy leak-proofing can degrade performance.

Verify

  • Red-team with poisoned documents and tool outputs before deploying; monitor afterwards.

Traps

  • "Tell the model to ignore injections" as the only defense. It is one layer, not enforcement.
  • Putting retrieved text in a system message: it gains operator authority.
  • Relying on blocked_domains; mirrors and unlisted hosts get through.
  • Assuming HTTP_PROXY captures all traffic. Some programs ignore it.
  • Read-only mounts that include .env or key files: reading is enough to leak.
  • A screen that fails open when it returns no verdict.
  • Removing a capability the agent needs, when a narrower version of it would do.

Decide quickly

SituationChoiceWhy
Users try to jailbreak a public botLightweight input screenCheap, parseable verdict before the main model
Agent reads email or web pagestool_result, JSON-encoded, labeled sourceLower trust, no delimiter breakout
Agent needs an authenticated APIProxy or app-side tool holds the keyThe model cannot leak what it never sees
Scripts might exfiltrate dataNetwork isolation plus allowlistEnforced regardless of model behavior
Per-customer data from ticket textNarrow tool with ownership checkAuthorization lives in code
Irreversible or money-moving actionHuman approvalCatches what other layers miss
Proprietary text in the promptRemove what is unneeded, filter outputLess to leak, little quality cost

Sources