Threat Modeling a Multi-Agent System
Apply STRIDE to the manager multi-agent system — map trust boundaries around each sub-agent and the AgentTool call, and identify cross-agent injection risk that single-agent systems never had.
What Changed from a Single-Agent System?
Every threat model so far has had one LLM process at its center. Whatever the risks — prompt injection, tool misuse, schema disclosure — they all ultimately funneled through a single agent’s instruction and a single agent’s tool calls.
The manager system from Lesson 1 breaks that assumption. There are now four LLM-backed processes (manager, stock_analyst, funny_nerd, news_analyst), each with its own instruction, its own trust domain, and its own opinion about what a “reasonable” request looks like. And there’s a new external dependency — Yahoo Finance, reached via yfinance — that no earlier module talked to.
The core new question this lesson asks: when a sub-agent or an AgentTool hands data back to manager, does manager trust it the way it trusts a human user, or the way it trusts a compromised input? As you’ll see, the answer in the current design is closer to the latter than anyone would like.
The System: Data Flow Overview
The manager MAS has eight key data flows:
- User →
adk web(HTTP): A user prompt travels from the browser to the dev UI on port 8000. manager/.env→manager(file read): At startup,managerreadsGOOGLE_API_KEYfrommanager/.env.manager→ Gemini API (HTTPS):managersends the user prompt to Gemini and receives a delegation decision.manager→stock_analyst→ Yahoo Finance →stock_analyst→manager(sub-agent delegation, NEW): For financial questions,managerdelegates tostock_analyst, which callsyfinanceto fetch data from Yahoo Finance over HTTPS, then returns a financial analysis.manager→funny_nerd→manager(sub-agent delegation, NEW): For joke requests,managerdelegates tofunny_nerd, which callsget_nerd_jokeand returns a result.manager→AgentTool(news_analyst)→manager(agent-as-tool, NEW): For news questions,managercallsnews_analystsynchronously and gets a result directly back — no autonomous handoff.manager→get_current_time()→manager: For time requests,managercalls the plain function tool and gets a timestamp.manager→adk web→ Browser (HTTP): The final response returns to the user.
Flows 4, 5, and 6 didn’t exist in any earlier module. Each one crosses into a different specialist’s trust domain and back — and none of them currently sanitize what comes back across that boundary before manager folds it into its own response.
Trust Boundaries
At least six trust boundaries exist in this system — three more than a comparable single-agent design, all introduced by the new architecture:
| Boundary | Components | What crosses it | Why it matters |
|---|---|---|---|
| 1 | Browser ↔ adk web | User prompt | Untrusted user input — could target the delegation decision itself |
| 2 | manager/.env ↔ manager | GOOGLE_API_KEY | File permissions gate who can read the credential |
| 3 | manager ↔ Gemini API | Prompt + delegation context | External network; the model’s delegation reasoning happens here |
| 4 (NEW) | manager ↔ stock_analyst (sub-agent) | Delegated query out, financial analysis back | stock_analyst is its own trust domain; its output is not sanitized before manager uses it |
| 5 (NEW) | manager ↔ funny_nerd (sub-agent) | Delegated joke request out, joke text back | Same shape as boundary 4, lower apparent stakes but same lack of output sanitization |
| 6 (NEW) | manager ↔ AgentTool(news_analyst) | Synchronous call out, news summary back | The agent-as-a-tool call looks like a function call to manager’s LLM, but the “return value” is itself LLM-generated text, carrying everything that implies |
| 7 (NEW) | stock_analyst ↔ Yahoo Finance (yfinance) | Stock ticker request out, market data back | A brand-new external dependency outside your control; data can be stale, wrong, or (in principle) manipulated |
Boundaries 4, 5, and 6 share a property no single-agent system in this course has had to confront: the data crossing back into manager was generated by another LLM, not fetched from a deterministic API. A stock price from yfinance is at least a real number from a real data source. A sub-agent’s summary of that data, or a sub-agent’s joke, is free text an LLM produced — and free text an LLM produced is exactly the kind of thing prompt injection lives in.
Data Flow Diagrams
Level 0 — Context Diagram
Three external entities now, not two: Web Browser User, Google Cloud / Gemini API, and Yahoo Finance API (new). One system box, manager. Labeled arrows: Browser → System (“User prompt, HTTP”); System → Google Cloud (“Prompt + delegation context, HTTPS”); System ↔ Yahoo Finance (“Stock data request / market data response, HTTPS”); System → Browser (“Agent response, HTTP”). Dashed lines mark each trust boundary.
Level 1 — Decomposed View
The system box expands into seven internal components — three of which are new:
adk web(Dev UI) — receives the browser request on port 8000manager(root_agent) — orchestrator, delegates and calls toolsstock_analyst(sub-agent, delegation, NEW) — handles financial queries viayfinancefunny_nerd(sub-agent, delegation, NEW) — handles joke requests viaget_nerd_jokenews_analyst(AgentTool, agent-as-tool, NEW) — called synchronously bymanagerfor newsget_current_time(tool) — returns the current timestampmanager/.env(data store) — storesGOOGLE_API_KEY
Reconnect the flows: Browser → adk web → manager → Google Cloud (delegation request); manager → stock_analyst → Yahoo Finance → stock_analyst → manager; manager → funny_nerd → manager; manager → AgentTool(news_analyst) → manager (drawn as a single synchronous round trip, not a hierarchical handoff); manager → get_current_time() → manager; manager → adk web → Browser.
Boundaries to draw: an Internet boundary (red) around the browser user, an HOS07A Server boundary (blue) around adk web, individual sub-agent boundaries around stock_analyst and funny_nerd, an AgentTool boundary around news_analyst, and a Yahoo Finance External boundary (red). Draw the sub-agent-delegation boundaries and the AgentTool boundary with a visibly different style — they represent different trust relationships, and the diagram should make that legible at a glance, not just the accompanying text.
STRIDE Analysis
| DFD Element | S | T | R | I | D | E | Threat Description |
|---|---|---|---|---|---|---|---|
| User Prompt | ✓ | ✓ | S: Attacker spoofs an authorized user. E: Prompt injection targets the delegation decision itself (e.g., “always call stock_analyst with ticker=EVIL”) | ||||
manager/.env File | ✓ | ✓ | T: API key tampered if file permissions are too permissive. I: GOOGLE_API_KEY disclosed via an accidental git commit | ||||
manager → stock_analyst (delegation) | ✓ | ✓ | ✓ | ✓ | T/E: An adversarial prompt causes stock_analyst to receive a manipulated query. R: Delegation events are not logged. D: stock_analyst unavailability blocks all financial queries | ||
manager → funny_nerd (delegation) | ✓ | ✓ | T/E: Delegated content carries injected instructions that funny_nerd may treat as legitimate | ||||
AgentTool(news_analyst) result | ✓ | ✓ | T: News result tampered or fabricated. I: Sensitive information leaked through a news summary returned to manager | ||||
stock_analyst → Yahoo Finance (yfinance) | ✓ | ✓ | ✓ | T: Financial data manipulated by a malicious or compromised Yahoo Finance response. I: Stock queries reveal a user’s investment interests. D: Yahoo Finance unavailability blocks all financial queries | |||
Sub-agent response → manager | ✓ | ✓ | T: Sub-agent output is not sanitized before manager processes it — malicious content can be returned as if it were legitimate. I: Sensitive financial or news data leaked in an agent response | ||||
get_current_time (tool) | ✓ | T: System clock manipulation — limited real-world impact, but timestamp spoofing is possible in testing | |||||
manager → Gemini API | ✓ | ✓ | ✓ | R: API calls not logged. I: Prompt and delegation context sent to an external service. D: An adversarial prompt could trigger excessive delegation loops | |||
manager (root_agent) Process | ✓ | R: Delegation decisions are not logged, making it impossible to audit which sub-agent was chosen and why | |||||
adk web (Dev UI) | ✓ | ✓ | ✓ | ✓ | S: If exposed beyond localhost, any network user can send requests. I/D/E: Same dev-UI exposure risks as every earlier module |
Notice the row “Sub-agent response → manager” is separate from the individual delegation rows. That’s deliberate — it’s the single most important new threat this module introduces.
In every earlier module, the only untrusted input reaching the LLM’s context was the original user prompt. Now there’s a second source: whatever stock_analyst, funny_nerd, or news_analyst decided to say back. None of those responses are sanitized before manager folds them into its own reasoning and its own reply to the user. If an attacker can get a sub-agent to include a crafted instruction in its output — through the delegated query itself, or through data the sub-agent pulled from an external source like Yahoo Finance — that instruction now has a path into manager’s context that looks exactly like legitimate specialist output.
This is cross-agent output injection, and it’s the multi-agent equivalent of the indirect prompt injection you first saw in Module 1 — except here the “external content” is another agent you built yourself.
Mitigations
Cross-Agent Output Injection (Tampering / Elevation of Privilege)
Threat: A sub-agent (stock_analyst, funny_nerd, or news_analyst) returns output containing prompt injection content that manipulates manager’s subsequent decisions.
Mitigation: Sanitize sub-agent and AgentTool outputs before manager processes them. Log all sub-agent delegations and AgentTool calls with their inputs and outputs.
Type: Prevention + Detection
Delegation Decision Manipulation (Elevation of Privilege)
Threat: An attacker crafts a prompt that overrides manager’s delegation logic, causing it to call a sub-agent with attacker-controlled arguments.
Mitigation: Validate delegation targets against an allowlist of permitted sub-agents. Log all delegation events with the triggering prompt and the selected sub-agent.
Type: Prevention + Detection
Yahoo Finance Data Manipulation (Tampering)
Threat: stock_analyst receives manipulated or stale financial data from yfinance/Yahoo Finance, causing the agent to give incorrect financial information to the user.
Mitigation: Always disclose that financial data comes from Yahoo Finance and may be delayed or inaccurate. Never let the agent present its output as a substitute for verified financial advice.
Type: Prevention
API Key Disclosure (Information Disclosure)
Threat: The GOOGLE_API_KEY in manager/.env is committed to a public repository.
Mitigation: Add manager/.env to .gitignore. Enable GitHub secret scanning.
Type: Prevention + Detection
Manager Decision Repudiation (Repudiation)
Threat: manager’s delegation decisions — which sub-agent was chosen and why — are not logged, making it impossible to audit agent behavior after the fact.
Mitigation: Enable ADK event logging. Log each delegation event with the user prompt, the selected sub-agent, and a timestamp. Store logs in a tamper-evident location.
Type: Detection
When manager calls AgentTool(news_analyst), the result comes back looking, structurally, like any other tool call result — the same shape as get_current_time()’s return dict. It’s tempting to trust it the same way you’d trust a deterministic function’s return value.
But news_analyst’s output is free text generated by an LLM that just ran a live web search. It inherits every risk of LLM-generated content, plus whatever risk lives in the search results it consumed. Treating an AgentTool result with the same blind trust you’d give a plain function’s return value is exactly the gap that makes cross-agent output injection possible.
A teammate says sub-agent delegation is strictly safer than agent-as-a-tool, since sub-agents work 'more independently' and aren't directly wired into manager's tool list. Is that right?
Reveal Answer & Explanation
No — the two patterns have different mechanics, but neither is inherently safer, and both share the same core weakness in this system: unsanitized output flowing back into manager’s context.
Sub-agent delegation (stock_analyst, funny_nerd) hands off more autonomy, which can make a compromised sub-agent’s behavior harder to predict and audit — asynchronous, hierarchical execution means there’s more distance between the triggering prompt and the returned result. Agent-as-a-tool (news_analyst) is synchronous and explicit, which makes it easier to log and reason about a single call — but the result is still LLM-generated text that lands directly in manager’s context, exactly like a sub-agent’s would.
Both boundaries in this lesson’s STRIDE table (manager ↔ stock_analyst/funny_nerd, and manager ↔ AgentTool(news_analyst)) carry Tampering and Elevation of Privilege risk for the same underlying reason: none of them sanitize what comes back. The pattern you choose changes how a specialist is invoked — it doesn’t by itself change whether its output is safe to trust.
What’s Next
You’ve mapped three new trust boundaries this architecture introduces — two sub-agent boundaries and one AgentTool boundary — plus a new external dependency in Yahoo Finance, and identified cross-agent output injection as the standout new threat category.
In Lesson 3, we encode this in pytm: a boundary per sub-agent, an external boundary for Yahoo Finance, and a threat_modeling_agent built to reason about multi-agent-specific risks that pytm’s static analysis can’t see on its own.