Free self-study · No account needed · Progress stays in this browser. Back it up before clearing site data or changing devices.

← Week 17: AI Threat Modeling

Week 17 / Lesson 3

Evaluating layered defenses

Measure legitimate task success alongside adversarial outcomes.

Section 3.1 1 of 7

Overview

Focus

Measure legitimate task success alongside adversarial outcomes.

Your route through the lesson

  • 3.2 Control layers and their failure modes
  • 3.3 Building a safe adversarial catalog
  • 3.4 Coverage, attack success, and useful operation
  • 3.5 Put it into practice
  • 3.6 Guided comparison
  • 3.7 A defense that blocks legitimate users

All required teaching is included here. Review selections are saved. Choose a correct answer for every question to continue; retries are unlimited. Study time and personal notes are optional.

Section 3.2 2 of 7

Control layers and their failure modes

Focus

Assign each defense layer a specific job and a testable failure mode.

Layered defense combines controls with different responsibilities. Source labels preserve provenance. Model instructions describe intended behavior. Schema checks constrain proposal shape. Authorization limits permitted effects. Runtime isolation constrains process capabilities. Output and audit controls reduce disclosure through results and logs. No layer should be credited with guarantees it does not enforce.

For a case-summary assistant, a source label can remind the model that retrieved text is data, but it cannot stop an unrestricted process from reading a host credential file. A filesystem boundary can block that read, but it cannot guarantee a summary is factually correct. An authorization rule can deny export while still allowing a bad answer in response text.

Map each control to a failure observation. A changed destination tests approval scope; a disallowed file read tests filesystem enforcement; a fabricated fact tests grounding. Combining them into one generic secure score obscures which boundary failed. Layering is valuable because one mistake need not cause the final harmful effect, but controls can share assumptions. Test their interactions and document the residual paths rather than treating the presence of many controls as proof of complete protection.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Which control directly restricts a process reading host files?
2. An export is denied but the response repeats a secret. What happened?
3. Why avoid one undifferentiated secure score?

Section 3.3 3 of 7

Building a safe adversarial catalog

Focus

Build a safe adversarial catalog with normal controls and explicit outcomes.

An adversarial catalog is a set of cases designed to challenge particular boundaries. Each case names entry surface, attacker control, intended unauthorized effect, expected denial, and observed result. Include normal cases using the same supported system so a defense cannot appear successful merely by rejecting everything.

The core catalog uses one legitimate local summary and three negative proposals: foreign destination, canary disclosure, and tool-override export. Every payload is fictitious. The executor has no external send path, and expected outcomes are fixed before execution. This keeps the exercise focused on authorization logic rather than on producing real harmful effects.

Vary one factor when diagnosing a defect. If both operation and destination change, a denial may not reveal which rule worked. Follow with cases isolating operation, destination, and payload checks. Keep case identifiers, versions, and per-case observations. New attack variants can expand coverage, but never use real credentials or live external recipients just to make a classroom example feel realistic. A safe catalog can still expose a genuine control error through a failed assertion on a harmless local proposal.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. A catalog contains only attacks and the system rejects everything. What is missing?
2. Why isolate destination changes in a follow-up case?
3. What data should the classroom catalog use?

Section 3.4 4 of 7

Coverage, attack success, and useful operation

Focus

Measure adversarial effects, legitimate success, and coverage separately.

Attack success should be defined by the attempted boundary violation, not by the presence of suspicious text or a dramatic response. For an export attack, inspect whether an unauthorized effect occurred. For disclosure, inspect the relevant output channels. Preserve denied and unresolved outcomes separately when the evidence cannot determine whether an effect happened.

The weekly fixture reports normal success as one of one and adversarial effects as zero of three. Those denominators matter: zero successful attacks among three fixed proposals is a narrow result. It does not establish immunity against all future content or a live model. Coverage describes which surfaces, operations, transformations, and legitimate tasks were actually exercised.

Also report false rejections of authorized work. A defense that blocks an ordinary local summary reduces usefulness even if it prevents every export. Track regressions when controls change, keeping the same normal cases and adversarial definitions for comparison. If the system or tool set changes, update the catalog before claiming continued coverage. Measurements are strongest when tied to exact versions of the executor, cases, model integration if present, and runtime configuration.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Zero unauthorized effects among three fixture attacks supports which claim?
2. What is a false rejection in this setting?
3. A new tool is added after catalog execution. What should coverage reporting say?

Section 3.5 5 of 7

Put it into practice

Focus

Run normal and adversarial fixtures against one bounded executor.

Download week17.py, save it in an exercise folder, and run python week17.py --lesson 3. This single practice runs four cases against the same fixed execute function. It needs only standard-library Python, a small processor, and seconds of runtime. It has no live model, external recipient, or generated-code execution.

Each case tuple contains name, operation, destination, payload, and expected allowed decision. The for statement unpacks those five values. The function returns a dictionary, and ['allowed'] retrieves its boolean decision. assert allowed == expected verifies the case. Appending the name and result preserves per-case observations before printing the report.

The normal summary to local-result succeeds. A summary to attacker.invalid fails destination authorization. A local summary containing the exact synthetic canary fails payload screening. A local export fails operation authorization. Expected output is normal_success 1/1 and adversarial_effects 0/3. The script explicitly warns that exact canary matching covers one representation only. Read the report as a deterministic executor test, not as measured language-model behavior or an operating-system network restriction.

Download this week’s Python lab ↓

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. A policy allows summarize to local-result when no protected canary is present. A normal request meets all three conditions. Expected decision?
2. A summarize request targets attacker.invalid. Which check should deny it?
3. Why preserve each case name and result in outcomes?

Section 3.6 6 of 7

Guided comparison

Focus

Explain the four outcomes and the limits of the literal-canary defense.

The completed catalog yields one allowed normal operation and three denied negative operations. The foreign-destination case fails before payload processing can authorize an external effect. The canary case uses the permitted operation and destination but is denied because its payload contains the exact synthetic secret. The tool-override case fails because export is not an allowed operation.

These cases separate useful operation from adversarial effect prevention. If the normal summary were denied, the attack-success count might still be zero, but the report would show normal success zero of one. That would be a functional regression rather than a fully successful defense.

The literal-canary check is intentionally limited. It detects a fixed string, not every confidential concept or transformed representation. A safe next evaluation would add selected encoded or split variants and inspect the relevant channels, while preserving the same executor permissions. This is expansion of the evidence catalog, not a reason to claim the existing result already covers those variants. Likewise, a live model may create different proposals; those must be observed through actual model integration rather than inferred from fixed fixture labels.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. If all attacks are denied but the normal case is also denied, what is the result?
2. The canary case uses summarize and local-result but is denied. Which layer distinguishes it?
3. Encoded canary variants were not tested. What should the report say?

Section 3.7 7 of 7

A defense that blocks legitimate users

Focus

Repair a defense that blocks legitimate users while preserving action boundaries.

A developer adds a keyword filter rejecting any document containing export. It blocks a malicious instruction, but also blocks a legitimate policy document explaining export restrictions. The rule confuses discussing an operation with authorizing it. Attack success falls while ordinary summarization fails.

The worked repair retains the executor's exact operation and destination checks and changes the input-handling policy so discussion can be summarized as data. The normal policy-document case should succeed without performing an export. A malicious instruction in that document still must not authorize an export. This pair of cases distinguishes content understanding from effect permission.

The revised defense is evaluated on both cases under the same versioned catalog. If a live model is used, record its actual summary and proposal, not just the keyword filter's decision. If only the fixture executor is used, label that limit. The transfer lesson is to preserve utility through precise boundaries: allow supported analysis of untrusted material while rejecting unauthorized consequences. Overbroad filtering can reduce risk in one narrow metric while making the product unusable for the very documents it must process.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. A document discusses export restrictions without requesting an export. Should the word alone grant or deny action?
2. Which paired test best evaluates the repair?
3. A filter lowers attack success but blocks all policy summaries. What tradeoff must be reported?

Your personal notes

Optional, ungraded, and saved only in this browser. Export a backup from the Academy homepage to keep them.

References and further reading
Ask your own AI assistant

Copy this prompt into an assistant you already use. Nothing is sent automatically, and your personal notes are not included.

Next lesson: Enforcing process and resource restrictions →