All lessons Leer en español

Security in depth · Unit 27 · Lesson 4 of 11

Designing layered AI defenses

Give an AI feature a useful job, a limited identity, and checks that remain effective when its answer is wrong.

7 minready

MITRE ATLAS

Helpful before thisPrompt injection and instruction boundariesDefenses and detection

After this lesson you can

  • Assign separate controls to data access, proposed actions, and generated output.
  • Explain what a meaningful approval must show and bind to.
  • Design monitoring and recovery for a bounded AI feature.

A useful AI assistant needs a clear job. “Help with appointments” is vague; “draft a reply using this selected request” gives designers a task they can match to data, permissions, and an interface.

Layered defense assumes a model can produce an incorrect or manipulated proposal. The application should still limit what information it can expose and what actions it can perform.

Designing layered AI defensesModel guidance informs a proposal. Independent permissions, validation, and any required approval determine whether the application may execute it.Defined user taskIndependent checksLimited action
Model guidance informs a proposal. Independent permissions, validation, and any required approval determine whether the application may execute it.

Start with the smallest useful capability

Least privilege applies to the application’s identity, not just the wording of its prompt. A drafting feature may need one conversation and a place to save a draft. It does not automatically need mailbox administration, broad customer exports, or permission to send.

Sometimes the tool uses a delegated user identity; sometimes it uses a service identity with explicitly constrained access. Neither pattern is automatically safe. Verify the effective permissions, which user request they represent, and the resource scope checked for each operation.

Limit network destinations and tool parameters according to the actual feature. A permitted tool name is insufficient if its arguments still allow unrelated resources or unlimited effects.

Separate data, suggestions, and execution

Retrieve only records within the user’s permitted scope. Treat retrieved instructions as source content. Screen suspicious input where useful, preserve provenance, and apply safe output handling at the destination.

A model can suggest an operation, but application code should validate its structure, meaning, target, limits, and authorization. Model-based guardrails can provide another signal; they do not replace these independent checks.

If a required security decision is unavailable, fail closed for that protected operation. The interface can explain that a draft is available while sending remains paused. The whole application need not fail simply because one sensitive action cannot proceed.

Make approval specific

An action approval should show the actual operation, destination, relevant data, and consequence. Bind it to the same operation that is eventually executed. If the destination or scope changes, the earlier approval may no longer apply.

Use human review where the product’s risk policy requires it. Reversible, tightly bounded automation can be appropriate for some tasks; high-impact actions may need stronger review. A blanket “always trust this assistant” toggle should be treated as continuing delegation, with explicit limits and revocation.

Approval also needs an informed reviewer. A reassuring summary is not enough when the real operation affects a different account or a larger set of records.

Test the surrounding controls

Use fictional fixtures to check that unauthorized records are not retrieved, invalid actions are rejected, important limits are enforced, and a timeout cannot skip a required decision. Test benign requests too: a control that blocks ordinary work may encourage unsafe workarounds.

Version model settings, prompts, tools, and relevant data sources so changes can be compared. Model behavior may vary between runs; deterministic permission and validation rules should still enforce their contract.

Monitor outcomes and prepare recovery

Record the identity, source references, requested action, policy decision, approval reference when needed, and execution result. Minimize sensitive content and protect diagnostic access. Logs should help distinguish a suggestion from a completed side effect.

A recovery plan identifies who can pause a tool, review affected actions, correct data, and restore service. Revoke or replace credentials when the evidence and response plan require it; do not assume every incident has the same cleanup.

NIST’s AI RMF organizes risk work through Govern, Map, Measure, and Manage. Such frameworks help structure responsibility and evaluation. They complement, rather than substitute for, evidence that this particular feature respects its limits.

Terms you met

least privilegeaction approvalfail closed

Check yourself

No timer. No penalties. Read the explanation and try again whenever you like.

  1. An assistant only needs to draft replies. Which design best follows least privilege?

    Show the answer

    Correct answer: Provide access to the selected conversation and a draft operation. The capabilities should match the task; sending and broad mailbox access need separate justification.

  2. What makes an approval meaningful?

    Show the answer

    Correct answer: It shows the actual target, action, data, and limits, and applies to that same operation. An approval for one operation should not silently authorize a changed destination or larger scope.

  3. A required permission service times out. What should happen to the protected action?

    Show the answer

    Correct answer: Pause or deny it until the required authorization can be established. Failing closed prevents an unavailable security check from becoming permission.

  4. What belongs in useful AI-action monitoring?

    Show the answer

    Correct answer: The relevant identity, source references, action, decision, and result with sensitive data minimized. This supports investigation while reducing unnecessary copies of private content.

Try it

  • WriteDesign a fictional assistant that drafts replies to appointment requests. Choose the minimum records and tools it needs, what a user would approve before sending, what a useful redacted audit record contains, and how the team could pause sending if a defect appears.
References