Skip to content
mentoor

Topic 3 of 5 · 5 min read

Threat modeling agent workflows step by step

Goal: Assume the model is attacker-controlled and list what each tool in an agent workflow would let an attacker do.

For an agent, assume the model is controlled by an attacker, then list what each tool, memory store and handoff would let that attacker do. This turns a fuzzy worry about "prompt injection" into a concrete list of worst cases.

Check yourself · 1 of 3

What does 'assume the model is attacker-controlled' mean when modeling an agent?

Choose one answer

Why it matters

You cannot prove that a model will never follow hostile text. You can bound the damage. If the worst case of each step is acceptable, a successful injection is an incident you survive, not a breach. This is the "assume breach" habit from normal security, applied to the model.

How to do it

  1. Write the workflow as steps. For example: read ticket, search knowledge base, draft reply, update CRM, send email.
  2. For each step, list the capabilities. Tool name, arguments, the credentials it runs with, the data it can read and the systems it can change.
  3. Ask the attacker question. "If the model were fully attacker-controlled at this step, what is the worst thing this tool allows?" Write the answer in one line.
  4. Follow the data. What does the step read that an outsider wrote? What does it write that a later step or another agent will read? Memory and handoffs carry poison forward.
  5. Reduce. Remove the tool, narrow its scope, split it into read and write, run with the user's own permissions, add a confirmation, cap rate and spend.
  6. Look for combinations. Private data plus untrusted input plus a way to send data out is the combination that makes theft possible.

Before and after

Weak: "The agent is told not to leak data." Fixed:

Step 4  update_crm(record_id, fields)
  Worst case: attacker rewrites any customer's email field.
  Fix: scope to the ticket's own customer; allow-list fields; log diffs.
Step 5  send_email(to, body)
  Worst case: sends customer data to any address.
  Fix: recipient must equal the ticket requester; human confirms otherwise.

What goes wrong

  • Reviewing the prompt, not the tools. The prompt is words. The tool is the capability.
  • Shared credentials. One service account for every tool turns any single hijack into full access.
  • Trusting other agents. A sub-agent's output is untrusted input to the next agent.
  • Memory poisoning. A note saved today from a hostile page steers behavior next week.

Examples

Worst case per tool

A coding agent has run_shell, read_file and open_pr. For run_shell the worst case is arbitrary code on the build host. The fix is a sandbox with no network and no secrets, not a longer instruction.

Memory handoff

An agent saves 'user prefers replies sent to backup@example.net' after reading a forwarded email. Next week it follows that note. The threat model lists memory writes as a boundary and requires user confirmation for stored preferences.

Key points

  • Assume the model is attacker-controlled at each step and write the worst case each tool allows.
  • Bound the damage with narrow scopes, split read and write tools, and use the user's own permissions.
  • Follow what each step reads and writes: memory and handoffs carry attacker text to later steps.
  • Output from another agent is untrusted input to the next one.
  • Private data, untrusted input and an outbound channel together make exfiltration possible.

Common mistakes

  • Putting the control in the prompt instead of removing or narrowing the tool.
  • Giving all tools one broad service account.
  • Treating other agents' output as trusted.
  • Skipping memory and scheduled tasks because they are not part of 'this run'.

Check yourself · 2 of 3

Which change best reduces the worst case of a send_email tool?

Choose one answer

Check yourself · 3 of 3

Why is agent memory part of the threat model?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic