AI threat modeling and adversarial testing

Find and block the action an attacker is trying to cause.

Visual lessons: 1 · 1:42 total Read estimate: 5 min Practice estimate: 14 hr Updated: 2026-10-03
In this lesson · P5 of 12All lessons in this track →

Progress for this track is saved in this browser only. No completion badge is issued. View your learning.

Start with the idea

Find and block the action an attacker is trying to cause.

Map what needs protection and where trust changes. Test attacks in the supplied sandbox. Verify that forbidden execution stays blocked even if the model’s words change.

Trust boundary: A point where information or an action crosses between different levels of permission or trust.

See the example and check your understanding

A made-up teaching example

The vulnerable seed follows instructions inside retrieved text and exposes export. The fix treats source text as untrusted, removes export by default and checks permission in application code.

Ask yourself

Is testing refusal wording enough to prove export never ran?

Show the explanation

No. Assert that forbidden actions produce no execution. Add the failed attack as a repeatable regression case.

Start with these checks

  • Check actual effects.
  • Enforce permission outside model output.
  • Use only the supplied sandbox targets.

Use the different practice case below and check every requirement in its full instructions.

Go to the practice task ↓

The video explains the main idea. Use the sources, instructions and checks below to complete the practice.

Visual lesson1:42

Captions appear here during playback.

AI threat modeling and adversarial testing

Find and block the action an attacker is trying to cause.

Download transcriptOpen video file

Source-based teaching example · Fictional data · Reviewed 2026-10-03. Microsoft Mark · locally synthesized. On a small screen, use fullscreen for diagram details or read the transcript.

Read the descriptive transcript

0:00 · What you will learn

Find and block the action an attacker is trying to cause.

What appears on screen

Find and block the action an attacker is trying to cause.

0:06 · The idea

Map what needs protection and where trust changes. Test attacks in the supplied sandbox. Verify that forbidden execution stays blocked even if the model’s words change.

What appears on screen

Map what needs protection and where trust changes. Test attacks in the supplied sandbox. Verify that forbidden execution stays blocked even if the model’s words change.

0:20 · One useful term

Trust boundary. A point where information or an action crosses between different levels of permission or trust.

What appears on screen

A point where information or an action crosses between different levels of permission or trust.

0:30 · A worked example

The vulnerable seed follows instructions inside retrieved text and exposes export. The fix treats source text as untrusted, removes export by default and checks permission in application code.

What appears on screen

The vulnerable seed follows instructions inside retrieved text and exposes export. The fix treats source text as untrusted, removes export by default and checks permission in application code.

0:46 · Your turn to think

Is testing refusal wording enough to prove export never ran? Pause and decide before continuing.

What appears on screen

Is testing refusal wording enough to prove export never ran? Pause the video if you need more time.

1:03 · Why this answer works

No. Assert that forbidden actions produce no execution. Add the failed attack as a repeatable regression case.

What appears on screen

No. Assert that forbidden actions produce no execution. Add the failed attack as a repeatable regression case.

1:14 · Check 1

Check actual effects.

What appears on screen

Check actual effects.

1:18 · Check 2

Enforce permission outside model output.

What appears on screen

Enforce permission outside model output.

1:24 · Check 3

Use only the supplied sandbox targets.

What appears on screen

Use only the supplied sandbox targets.

1:30 · Now try a different case

Open the lesson and try its different practice case. Use every check in the full task. Watching alone does not mark the lesson complete.

What appears on screen

Open the lesson Try the new case Check and revise The full task and its requirements are in the linked lesson.

Watching explains the example. Complete the lesson practice to check what you can do. Explore all visual lessons →

What you will be able to do

  1. Map assets, actors, trust boundaries, and abuse paths.
  2. Test injection, disclosure, poisoning, denial, and excessive agency.
  3. Verify mitigations with regression evidence.

Prerequisites: Builder-level interface validation, Python, testing, metadata logging and state-transition tracing. Hardware benchmarks and model accounts are not required.

This curriculum runs self-study on VetsLearn. Where the text calls for an instructor, peer or formal review, use the stated acceptance criteria for self-review. Reflection questions support reflection; they do not replace independent assessment. A peer review is optional unless your actual organization requires it.

Part 1 Technical instruction

AI threat modeling covers the whole system: users, identities, prompts, retrieved content, model, tools, data stores, telemetry, dependencies, operators, and supply chain. Begin with assets and unacceptable outcomes, then draw trust boundaries and entry points. A prompt injection is one attack path, not the threat model. Record preconditions, exploit path, affected asset, impact, existing controls, evidence, and residual risk. Test only in the authorized course sandbox. A mitigation is not complete until a regression test demonstrates containment.

Mechanism and implementation

Injection converts untrusted content into instructions or authority. Treat retrieved text and observations as data; authorize effects in an authenticated application boundary. Test multiple placements, including caches/logs/exports. A model refusal alone does not demonstrate containment.

Constructed offline example

Save as topic_example.py and run python topic_example.py with an installed Python 3.11+ interpreter. This standard-library construction uses synthetic values; its checks are not provider measurements.

allowed = {"read_public"}
def dispatch(action, source):
    return "allowed" if action in allowed else "denied"
assert dispatch("export_private", "trusted-looking-document") == "denied"
assert dispatch("read_public", "user") == "allowed"
assert dispatch("grant_admin", "tool_observation") == "denied"
print("authority escalation blocked")

Engineering decisions

  • Prioritize by plausible path and consequence.
  • Distinguish prevention, detection, containment, and recovery controls.
  • Stop testing at the authorized boundary.

Worked example

The vulnerable seed application trusts retrieved instructions and exposes an export tool. The red team demonstrates an indirect injection; the fix treats retrieval as untrusted, removes the tool by default, validates policy server-side, and adds a regression case.

Diagnose the failure

Forbidden dispatch stays denied regardless of source. Add zero-execution assertions if only refusal wording was tested. Use only the supplied synthetic sandbox.

Part 2 Guided practice

Draw a document-to-model-to-tool attack crossing. Seed a synthetic instruction and test the executor even when the mock model follows it. Independently test an egress target outside the allowlist.

Answer criteria and feedback: Forbidden dispatch stays denied regardless of source. Add zero-execution assertions if only refusal wording was tested. Use only the supplied synthetic sandbox.

Continue with the downloadable pack below. If the pack or interpreter is unavailable, trace this self-contained example by hand in an input/expected-status/controlling-rule table and label execution unverified. Do not invent passing output. No account, credential, paid call, purchase or actual deployment is required.

Part 3 Remediation

Reproduce one path in the local simulator. If a scenario would touch a real system, stop and translate it into a synthetic equivalent. After repair, reassess with the alternate scenario in scenario_alt.json. A critical authorization, data-handling, evidence-integrity, or prohibited-action failure cannot be averaged into successful practice; it requires targeted remediation.

Part 4 Sources and currency

Use the workflow decision reference for model/deployment/harness distinctions and controlled comparisons. Source currency must be checked before each cohort. Provider/product behavior is illustrative where mocked; resolve current interfaces only from official documentation in an authorized environment.

Lesson status:PRACTICE REVIEW REQUIRED

Review your practice