AI threat modeling
Map assets, actors and boundaries
AI threat modeling is the process of identifying what must be protected, how it could be harmed and which controls reduce the risk. Start with a fictional internal handbook assistant: a user authenticates to a host, the host retrieves authorized documents, the model proposes a response or a tool action, and a separate service validates the proposal. Assets include document contents, embeddings, model weights, credentials, account budgets, tool permissions, logs and service availability. Actors include authorized employees, unauthorized callers, maintainers, suppliers and compromised components. A trust boundary is a transition between components with different authority, for example from retrieved document text to model context or from a model proposal to a tool executor. Draw arrows for data and separate arrows for authority: a document supplies evidence, not permission. Rank scenarios by impact and plausible exposure, record assumptions and assign a control owner. Do not treat an arbitrary risk score as a measured probability. The example returns only eligible document IDs, using server-supplied metadata and identity. Its internal policy admits active same-tenant internal records only. The example prints a for north and b for south; inactive c is excluded.
def allowed_ids(records, tenant): # Metadata and tenant are supplied by the trusted service, not the model. return sorted(r["id"] for r in records if r["tenant"] == tenant and r["active"] is True and r["classification"] == "internal")
records = [{"id":"a", "tenant":"north", "active":True, "classification":"internal"}, {"id":"b", "tenant":"south", "active":True, "classification":"internal"}, {"id":"c", "tenant":"north", "active":False, "classification":"internal"}]print(allowed_ids(records, "north"))print(allowed_ids(records, "south"))Distinguish threats by affected component
Prompt injection occurs when untrusted inputs influence model behavior contrary to the application intent; direct user input and indirect retrieved content are both relevant. Data poisoning compromises the integrity of data used for learning or retrieval; model poisoning compromises model artifacts or learned behavior. These are different from an inference-time instruction conflict. Retrieval leakage exposes information beyond the caller’s permissions, including via embeddings, caches, logs or citations. Improper output handling occurs when untrusted generated output is treated as executable or trusted downstream content. Excessive agency means a system can take actions beyond the necessary scope, whether from overly broad permissions or uncontrolled autonomy. Unbounded consumption risks service disruption and unexpected spend (sometimes called denial of wallet). A dependency, dataset or checkpoint can introduce supply-chain risk. The OWASP 2026 risk list is a useful starting checklist, not an exhaustive threat model; NIST AI 100-2e2025 provides adversarial ML terminology. Record attack surfaces and consequences without constructing operational attack payloads.
Place controls outside model authority
The host authenticates callers, scopes retrieval before fetching content, checks access again when returning data, and derives tool authorization from trusted policy. The local tool routing example returns deny for an unknown action, missing permission or unavailable sandbox; a permitted write preview without verified approval returns review. A permitted read with isolation ready can produce a preview, and a permitted approved write preview still produces only a preview, never a write. In a real application bind approval to actor, exact action, target, arguments, expiry and policy version; revalidate immediately before a real action and consume the approval appropriately. The Boolean flags here stand for already-verified decisions, not values accepted from a model or client. Validate structured output types and permitted values, encode for the actual rendering context and use parameterized data access. Avoid executing generated code or commands. Use least privilege for tool identities and segregate credentials. A prompt that tells the model to obey permissions is not an enforcement mechanism.
def tool_route(action, permitted, approved, sandbox_ready): # All flags are independently verified host decisions in this fixture. if action not in ("read", "write_preview") or permitted is not True: return "deny" if sandbox_ready is not True: return "deny" if action == "write_preview" and approved is not True: return "review" return "preview"
print(tool_route("read", True, False, True))print(tool_route("write_preview", True, False, True))print(tool_route("write_preview", True, True, False))print(tool_route("write_preview", True, True, True))Build a control matrix and monitor residual risks
For each asset, write a scenario, boundary, preventive control, detection signal, response and responsible owner. Example: handbook leakage crosses the retrieval boundary; use server-side access checks, record denied case counts without storing protected text, and investigate unexpected disclosures. Model output that conflicts with policy crosses the action boundary; use an independent authorization gate and require a scoped approval for consequential operations. Review data lineage and ingestion permissions to limit integrity risks. An output filter may flag suspicious content but cannot reliably prevent all injection or substitute for authorization. A sandbox constrains effects but cannot determine legitimate intent. Human review is valuable for ambiguous or consequential actions but does not grant rights that the reviewer lacks. Combine layers, test legitimate tasks and expected denials, and document residual risks. Record only minimal, allowlisted diagnostics; route confirmed incidents to the security owner, restrict access and follow an authorized recovery plan.
Practice a threat review
Draw the fictional handbook data flow and identify at least five assets, three boundaries and six risk scenarios. Run the project’s read-only and preview checks; add a retired document and a disallowed tool action. Explain why changing content cannot change trusted metadata, why a denied request must not fetch protected content, and why a preview is not execution. Link the threat scenarios to Chapter 48 regression cases. Reference: ref-ai-ai-threat-modeling. Next: security controls and supply chain.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
AI threat modeling quiz
Assess threat modeling, independent controls, artifact integrity and resource protection.
What is a trust boundary?
What should determine retrieval access?
Which threat concerns compromised training data or model artifacts?
An authorized write preview lacks approval. What does the fixture return?
Can a prompt filter replace independent authorization?