{"slug": "threat-modeling-an-ai-agent-maestro-in-practice-with-usecvislib", "title": "Threat Modeling an AI Agent: MAESTRO in Practice with USecVisLib", "summary": "Security researcher Simon Roses published a hands-on threat model of an MCP-connected coding agent using MAESTRO, the Cloud Security Alliance's seven-layer framework for agentic AI published in February 2025, built and validated with his open-source tool USecVisLib 0.6.1 and rendered with Graphviz. The model walks three cross-layer attack chains and cross-maps them to STRIDE and a MITRE ATLAS kill chain, with config files and RENDER.md commands released so others can reproduce the figures. Roses argues classical data flow diagrams fail for agents because tool calls are decided at runtime, instructions and data share one channel, and the trust boundary sits inside the model itself.", "body_md": "**Read Time:** 20 minutes\n\n## TL;DR\n\nClassical threat modeling assumes a system with fixed data flows. An AI agent does not have those: it decides what to do at runtime, calls tools you did not hard-code, carries instructions in the same channel as its data, and in October 2026 we watched exactly that turn into real breaches. MAESTRO, the Cloud Security Alliance’s seven-layer framework for agentic AI, is built for this, and in this post I use it for real. I model an MCP-connected coding agent (the kind of system LiteLLM and the SP-API MCP rug pull actually hit) in my own tool, [USecVisLib](https://github.com/vulnex/usecvislib), walk its three cross-layer attack chains, and cross-map the whole thing to STRIDE and a MITRE ATLAS kill chain. Every config and command here is real and runs; I give you the files so you can render them yourself. I also pair it with Jim Manico’s new Grim Prompter so you can see the two halves of the job: an agent that discovers the threats, and a framework that structures and draws them. The point is not a diagram. The point is being able to reason about an attack that starts as a prompt and ends as a poisoned release.\n\n**A note on the lab.** Everything below was built and validated with USecVisLib 0.6.1 and rendered with Graphviz. The MAESTRO model, the STRIDE and attack-graph exports, and the ATLAS kill chain are all real artifacts from one source model. I ship the config files alongside this post ([https://simonroses.com/wp-content/uploads/2026/11/maestro-threat-model-configs.zip](https://simonroses.com/wp-content/uploads/2026/11/maestro-threat-model-configs.zip)): the model, the three cross-framework exports, and `RENDER.md` with the exact commands); the commands produce the figures you see. I render the images; you can reproduce them.\n\n## Why agents break classical threat modeling\n\nI have drawn a lot of data flow diagrams. For a normal application they work: you enumerate the processes, the data stores, the external entities and the flows between them, you draw the trust boundaries, and you run STRIDE over each element. The model holds because the system is, in the end, deterministic. The same input takes the same path.\n\nAn agent breaks every one of those assumptions, and it is worth being precise about how, because the precision is what tells you which tool to reach for.\n\nThe data flow is decided at runtime. You do not know in advance which tool the agent will call, in what order, or how many times. The “diagram” is generated fresh on every task by a model reasoning about a goal. You cannot draw a fixed flow for something whose flow is an output.\n\nThe instructions and the data share a channel. In a classical system, code is code and input is input, and the boundary between them is the thing you defend. An agent reads everything, a file, a web page, a tool result, as potential instruction. The prompt is the attack surface, and it arrives wearing the clothes of ordinary data.\n\nThe trust boundary moved inside the model. The interesting privilege transition is no longer “untrusted user crosses into trusted server.” It is “untrusted content crosses into the agent’s context and changes what the agent decides to do with the tools it already holds.” STRIDE has no element for that.\n\nAnd the system is rarely one agent. It is an agent plus a model backend plus a vector store plus a handful of tools reached over the Model Context Protocol plus, increasingly, other agents. The attack that matters crosses all of those, and a per-element checklist that looks at each in isolation misses exactly the chain that gets you breached.\n\nNone of this means STRIDE is dead. It means STRIDE answers a different question. For the agent you need a model whose primitives are autonomy, tools, memory, the model itself, and the ways those compose. That is what MAESTRO is.\n\n## Meet MAESTRO\n\nMAESTRO, published by the Cloud Security Alliance in February 2025, stands for Multi-Agent Environment, Security, Threat, Risk and Outcome. It is a seven-layer reference model for agentic AI, and it exists specifically to cover what STRIDE, PASTA and LINDDUN do not: adversarial machine learning, model extraction, agent autonomy and, above all, attacks that chain across the stack.\n\nThe seven layers, from the foundation up:\n\n- **L1 Foundation Models** : the LLMs and base models. Adversarial examples, model extraction, training-data poisoning, backdoors, sleeper agents.\n- **L2 Data Operations** : RAG, vector stores, training corpora. Exfiltration, pipeline compromise, data tampering.\n- **L3 Agent Frameworks** : the orchestration layer: LangChain, AutoGen, custom runners, the MCP client. Code injection, framework evasion, supply-chain compromise.\n- **L4 Deployment and Infrastructure** : containers, Kubernetes, IaC. Poisoned images, lateral movement, resource hijacking.\n- **L5 Evaluation and Observability** : eval, monitoring, logs. Log leakage, detection evasion, observability poisoning.\n- **L6 Security and Compliance** : a cross-cutting layer, not a stage: it is AI used as a security control, with its own attack surface.\n- **L7 Agent Ecosystem** : the marketplace, agent-to-agent interaction, tool use, users. Impersonation, tool misuse, goal manipulation, rogue agents.\n\nThe seven layers are useful on their own, but the part that earns MAESTRO its place is the insistence on **cross-layer threats**: the scenarios where a weakness at one layer becomes the entry to an attack at another. A prompt injection at L3 that drives a tool call into your infrastructure at L4. A stolen key at L6 used to exfiltrate from a vector store at L2 through an agent at L7. Those chains are the realistic, high-impact cases, and they are exactly what a single-layer checklist cannot see. Hold that thought, because it is where the whole exercise pays off.\n\n## The system we will model\n\nI picked the system deliberately: an **MCP-connected coding agent**. Think Claude Code or Cursor, wired through the Model Context Protocol to a set of tools: a filesystem server, a git server, a package registry, a CI/CD runner, and a connector pulled from an MCP marketplace. It reads the repository for context, calls an LLM backend, acts through those tools, and a developer approves the high-risk actions.\n\nI chose it for two reasons. First, it is the system a lot of us are now running, often without having modelled it at all. Second, it is the system October’s incidents actually hit. The [LiteLLM compromise](https://simonroses.com/2026/10/the-month-ai-switched-sides-october-2026-in-security/) started with an AI coding tool embedding a token in its output, which landed in logs. The SP-API MCP “rug pull” was a trusted connector, repackaged to ship a seller’s secrets to an undisclosed address. If you have read this blog this autumn, you have watched this exact shape of attack happen. Now we are going to draw it.\n\n## Modelling it in USecVisLib\n\nUSecVisLib implements MAESTRO as CLI mode 12. You describe the system in a small TOML file, and the tool auto-populates the relevant threats from a catalog of 55, applies the mitigations you declare, draws the cross-layer chains you specify, and renders the result. Here is the heart of the model; the full file ships with this post.\n\n```\n[meta]\nname = \"MCP-Connected Coding Agent\"\nowner = \"VULNEX\"\n\n[architecture]\npatterns = [\"single-agent\", \"task-oriented\", \"human-in-the-loop\",\n            \"distributed\", \"unconstrained-conversational\"]\n\n[[agents]]\nid = \"coding_agent\"\nname = \"Coding Agent\"\ntype = \"task-oriented\"\nautonomy = \"deliberative\"\ntools = [\"mcp-filesystem\", \"mcp-git\", \"mcp-package-registry\",\n         \"mcp-ci-runner\", \"mcp-marketplace-connector\"]\nlayers = [\"agent-ecosystem\", \"agent-frameworks\", \"foundation-models\",\n          \"data-operations\", \"infrastructure\", \"observability\"]\n```\n\nTwo authoring choices matter. The `patterns` list is not decoration: declaring `unconstrained-conversational` attaches prompt-injection threats, `distributed` attaches marketplace and registry threats, `human-in-the-loop` attaches feedback-manipulation threats. And listing the agent across six layers gives the model a continuous spine, which both produces a clean diagram and, more importantly, reflects the truth that this one agent really does touch the model, the data, the framework, the infrastructure and the ecosystem at once.\n\nI declared the assets the agent owns (the source repository, the model and CI/CD keys, the connected MCP servers, the execution logs), then overrode the catalog threats that this specific deployment should worry about, mapping each to its real-world twin:\n\n```\n# The coding tool embeds an OAuth token in its output, which lands in logs (LiteLLM).\n[[threats]]\nid = \"T-L5-005\"          # Log / Dashboard Leakage\ntarget = \"coding_agent\"\nseverity = \"critical\"\nmitigations = [\"M-secret-redaction-logs\", \"M-egress-monitoring\"]\n\n# A repackaged / rogue MCP server in the ecosystem (the SP-API rug pull).\n[[threats]]\nid = \"T-L7-001\"          # Compromised Agent in Ecosystem\ntarget = \"coding_agent\"\nseverity = \"critical\"\n```\n\nThen I ran it:\n\n```\nusecvis -m 12 -i mcp-coding-agent.toml -o mcp_layered -v layered -s ma_dark\n```\n\nBefore rendering anything, the model is worth interrogating as data. USecVisLib’s Python API gives you the stats and a validation pass:\n\n```\nThreats: 47 (13 critical, 20 high, 14 medium)\nCross-layer chains: 4\nThreats by layer: L7=14, L1=8, L5=8, L3=6, L4=6, L2=5\nValidation: [] (clean)   Warnings: []\n```\n\nForty-seven threats from a dozen lines of description. That number is not the deliverable, it is the starting point: the catalog’s job is to make sure you do not forget the model-extraction threat at L1 while you are busy worrying about the tool misuse at L7. The deliverable is what you do with them.\n\n## Reading the model\n\n*Figure 1: The layered MAESTRO view. The agent appears in each layer it touches, with a badge counting its open critical threats there; assets sit in their owning layer; L6 Security renders as the cross-cutting note; the dashed red edges are the cross-layer chains. Rendered with [USecVisLib](https://github.com/vulnex/usecvislib).*\n\nThe **layered view** (Figure 1) is the one I use for a security review. Seven bands, L7 at the top down to L1, the agent repeated in each layer it declared with a badge showing its open critical count there, the assets sitting in the layer that owns them, and L6 Security floating as a note because it is cross-cutting rather than a stage. The fourteen open criticals at L7 are the loudest thing on the page, which is correct: for an MCP-connected agent, the ecosystem, the tools and the connectors are where the surface concentrates.\n\n*Figure 2: The severity heatmap, agent by layer. Every layer the agent touches is critical-red; L6 is grey because this agent is not itself a security control.*\n\nThe **heatmap** (Figure 2) is the one I put in front of a manager. One row per agent, one column per layer, each cell coloured by its worst unmitigated threat and labelled with a count. Our row is red across the board except L6, which stays grey because this coding agent is not itself a security AI. It answers “where is this thing on fire” in one glance, and the honest answer for an unmitigated agent is: everywhere it touches.\n\nThere is a third view, the **agent graph** (`-v graph`), which clusters agents as nodes and draws the chains as edges between them. For a single-agent system like this one it is sparse, the chains loop back on the one node, and it comes into its own when you model a multi-agent system and want to show how a compromise propagates from one agent to the next. I show it here (Figure 3) precisely because that sparseness is the point.\n\n*Figure 3: The agent-graph view (`-v graph`). For a single agent it is deliberately sparse: one node, the cross-layer chains looping back on it. The view earns its keep on a multi-agent model, where those same edges stretch into a map of how a compromise hops from one agent to the next. Rendered with [USecVisLib](https://github.com/vulnex/usecvislib).*\n\n## The part that matters: the cross-layer chains\n\nA list of 47 threats is a checklist. The reason to use MAESTRO rather than a spreadsheet is the chains, and I declared three, each one a real October incident expressed in the model’s own vocabulary.\n\n**CL-token-to-release, the LiteLLM cascade.** The agent emits an OAuth token into its output, which lands in logs (T-L5-005, Observability). The token is read from the logs and used to reach further secrets (T-L2-002, Data Operations). Those credentials disable branch protection and hijack the release pipeline, and a poisoned build ships (T-L3-004, Agent Frameworks). Three layers, one sentence of description in the config, and it is drawn as a dashed edge threading L5 to L2 to L3. This is not hypothetical; it is the LiteLLM post-mortem with the layer labels added.\n\n```\n[[cross_layer_threats]]\nid = \"CL-token-to-release\"\nname = \"Leaked token in logs cascades to a poisoned release\"\nlayers = [\"observability\", \"data-operations\", \"agent-frameworks\"]\nattack_chain = [\"T-L5-005\", \"T-L2-002\", \"T-L3-004\"]\nseverity = \"critical\"\n```\n\n**CL-rogue-mcp-exfil, the SP-API rug pull.** A trusted-looking MCP server from the marketplace is repackaged to redirect its endpoint (T-L7-001). The agent calls it exactly as before (T-L7-004, tool misuse). The server ships the repository secrets and keys to an undisclosed address (T-L2-002). The attack needs no exploit and no malware on your side; it needs you to trust a connector that earned the trust and then changed hands.\n\n**CL-injection-to-infra, the pivot.** A poisoned file or tool result injects instructions (T-L3-003, code injection) that the agent executes with the CI/CD token it already holds, pivoting into the build infrastructure (T-L4-006, lateral movement). This is the chain that keeps me up: the agent did nothing it was not allowed to do. It used its own legitimate tools, on behalf of an instruction it should never have trusted.\n\nReading these three chains together is the whole point of the exercise. Each threat, on its own, has a tidy mitigation. The chains show you that mitigating the first link (redact the token, pin the connector, sanitise the tool result) is worth ten times mitigating the last, because the last link, the poisoned release, the exfiltration, the infra pivot, is the one you cannot walk back. MAESTRO makes the chain a first-class object. That is what a spreadsheet cannot do.\n\n## Do not throw STRIDE and ATLAS away\n\nMAESTRO is not a replacement for the frameworks you already know; it is the layer that organises them for agents. USecVisLib leans into this: the same model exports into other lenses.\n\nExport it to STRIDE and you get a classical data flow diagram with the agent as a process, the keys and repo as data stores, the MCP servers as external entities, and the threats mapped onto STRIDE categories:\n\n```\n# from the MAESTRO model, emit a STRIDE DFD and render it\nusecvis -m 1 -i mcp-coding-agent.stride.json -o mcp_stride\n```\n\nThat is the right artifact for the parts of the system that are still classical, the CI pipeline, the key store, the network boundary, where STRIDE’s tampering-repudiation-disclosure vocabulary is exactly what an auditor wants to see.\n\nAnd for the adversary’s-eye view, map the headline chain to MITRE ATLAS as a kill chain:\n\n*Figure 4: The same cross-layer chain as a MITRE ATLAS kill chain. Ten techniques from Reconnaissance to Impact; the coverage heat shows that only one step, the human-approval gate on write tools, is currently mitigated.*\n\n```\nusecvis -m 9 -i mcp-agent-atlas-killchain.tml -o mcp_atlas_killchain -f png -s sv_dark --render-engine svg\n```\n\nThe ATLAS view (Figure 4) walks the rogue-MCP chain across ten techniques, from Search Open Technical Databases through Indirect Prompt Injection and AI Agent Tool Invocation to External Harms, with the detection and mitigation coverage drawn as heat. The coverage line is the uncomfortable part: one step mitigated out of ten, the human-approval gate on write tools. Everything else is open. The same facts that MAESTRO shows as layers, ATLAS shows as adversary tactics, and an auditor or a red team will each want their own. One model, three lenses, no re-keying.\n\nOne more framework belongs in this conversation, even though it is a ranked list rather than a drawable lens: [OWASP’s Top 10 for Agentic Applications](https://genai.owasp.org/2025/12/09/owasp-genai-security-project-releases-top-10-risks-and-mitigations-for-agentic-ai-security/), the ASI01 to ASI10 risk ranking that has become the common benchmark for agentic security since its late-2025 release. MAESTRO and OWASP answer complementary questions. MAESTRO tells you *where* a threat lives, by layer; the OWASP list tells you *what* the most common and impactful agentic risks are, ranked. The move that pays off is to tag each threat in your model with its ASI risk, so CL-rogue-mcp-exfil reads as ASI04 (agentic supply chain), and CL-injection-to-infra as ASI01 (goal hijack) feeding ASI02 (tool misuse). Do that and your MAESTRO model becomes legible to anyone who has adopted the benchmark, which by 2026 is most of the industry: you can hand a reviewer the ranked list and the layered picture at once, and they map onto each other instead of competing.\n\nThis piece shows three of USecVisLib’s modes; it ships a dozen. If you want to see the rest before you reach for it, the [USecVisLib gallery](https://github.com/vulnex/usecvislib-gallery) collects worked examples across every mode the library draws: attack trees, kill chains, component and dependency diagrams, privilege-gradient graphs, incident timelines and the MAESTRO views used here. It is the fastest way to tell whether the tool fits a diagram you need to draw, and to start from a config close to your case rather than a blank file.\n\n## The pipeline: who finds the threats, and who draws them\n\nThere is a gap in everything above, and it is worth naming. USecVisLib structures and draws a model, but it does not read your codebase and tell you what is in it. Someone, or something, has to discover the threats first. In 2026 that “something” is increasingly an agent, and the piece that caught my eye is Jim Manico’s [Grim Prompter](https://github.com/jmanico/grim-prompter).\n\nGrim Prompter is a threat-modeling skill you install into a coding agent. You point Claude Code or Codex at a repository and it produces an evidence-traced threat model, with file-and-line citations, applying a library of methods, MAESTRO and MITRE ATLAS among them, under a strict read-only runbook where the repository’s own text is treated as evidence and never as instruction. The output is prose and JSON findings.\n\nPut the two tools next to each other and you have the two halves of the job:\n\n- **Grim Prompter discovers.** An agent reads the actual code, cites where each concern lives, and applies the method prompts to surface threats you would otherwise enumerate by hand.\n- **USecVisLib structures and visualises.** You take those findings, express the system as a MAESTRO model, and get the layered view, the cross-layer chains, the severity heatmap, and the STRIDE and ATLAS crosswalks.\n\nDiscover, then structure, then draw, then cross-map. That is a real workflow, and both ends of it are open source and available today.\n\nThere is a recursion here that is almost too neat, and it is the honest reason I chose a coding agent as the worked example. Grim Prompter *is* a skill that runs inside a coding agent to threat-model a repository. The system I modelled *is* an MCP-connected coding agent. So you can point a coding agent at a repository to threat-model it, and then threat-model the coding agent that did the work. The tool that finds the threats is built from exactly the parts whose threats we just drew. That is not a gimmick; it is the whole reason this subject matters now. We are shipping these agents into production faster than we are modelling them, and the agents are now reviewing each other’s code.\n\nTwo honest caveats, because I would want them if I were reading this. Grim Prompter is new and its author says plainly that its prompts are drafts and its output needs human review; treat it as a strong assistant, not an oracle. And a visualization, mine included, is a model, not a guarantee. Which brings me to the part nobody likes.\n\n## A model is not security\n\nI spent an entire recent post arguing that AI has collapsed the cost of producing security work and left the cost of trusting it untouched, and threat modeling is the cleanest example I know. USecVisLib will cheerfully auto-populate 47 threats in a second. Grim Prompter will cheerfully generate a full report from your repo in a few minutes. Neither of those is a threat model. They are the raw material for one.\n\nThe judgment is still yours, and it is still the expensive part. Deciding that CL-token-to-release is the chain that matters and the model-extraction threat at L1 is an accepted risk for your deployment; confirming that the human-approval gate actually fires on the tool calls that matter and not just the obvious ones; knowing that your “mitigated” egress monitoring has a blind spot on the one domain the rogue connector uses, none of that comes out of the tool. The catalog is a checklist so you do not forget; the chains are a structure so you can reason; the diagram is a way to make the reasoning legible to someone who was not in the room. The security is the reasoning, and the reasoning is a person.\n\nSo use the machines for what they are good at. Let an agent read the repo and surface the candidates. Let the framework organise them into layers and chains. Let the tool draw the picture and export the crosswalks. And then do the actual work, which is looking at the three chains, deciding which one would end your week, and fixing the cheap first link before the expensive last one fires.\n\n## Where to start\n\nIf you run an agentic system in production and have never modelled it, here is the short version.\n\nModel the system you actually run, not the one in the vendor diagram. List the layers your agent genuinely touches, the tools it can really call, and the credentials it actually holds. The MCP coding agent in this post touches six of the seven layers; yours may touch all seven. The honesty of the layer list is the honesty of the model.\n\nWrite the cross-layer chains before you write anything else. Do not start from the 55-threat catalog; start from the two or three ways a bad input becomes a bad outcome in your system, and trace each across the layers. If you cannot write three chains, you do not yet understand your agent’s blast radius.\n\nFix the first link. For almost every agentic chain, the cheap, decisive mitigation is early: redact secrets from agent output and logs, pin and allowlist your MCP servers, sanitise tool results before they reach context, scope tokens to least privilege, and gate write-capable tool calls behind human approval. The last link, the poisoned release, the exfiltration, is the one you cannot undo.\n\nAnd keep the model alive. An agent’s tools, connectors and permissions change weekly. A threat model rendered once and filed is a diagram; a threat model you re-run when you add an MCP server is a control. The configs ship with this post precisely so that updating the model is editing a few lines of TOML, not redrawing a picture. CSA’s own 2026 follow-up shows the logical end of this, [wiring a MAESTRO-layered model into CI/CD](https://cloudsecurityalliance.org/blog/2026/02/11/applying-maestro-to-real-world-agentic-ai-threat-models-from-framework-to-ci-cd-pipeline) so the threats are re-classified and diffed on every pull request. A model that runs in the pipeline cannot go stale the way a diagram in a wiki does.\n\n## So what\n\nWe spent 2026 watching AI move to every side of the security fight, and the agents we are building are now both the thing we defend and the thing doing the defending. You cannot secure what you have not modelled, and the models we inherited were built for software that does what it is told. MAESTRO is built for software that decides, and USecVisLib lets you draw what it decides to put at risk. The frameworks are converging, the tools are open, and the only part that does not come in a box is the judgment. Model your agents. Trace the chains. Fix the first link. And trust the output a little less than it asks you to.\n\n- X (Twitter): [@SimonRoses](https://x.com/SimonRoses)\n\n**Further Reading:**\n\n**Questions or feedback?** Reach out via:\n\n- **Website:**[vulnex.com](https://vulnex.com)\n- **AI Security Strategy:**[vulnex.ai](https://vulnex.ai)\n- **Twitter/X:**[@SimonRoses](https://x.com/SimonRoses)\n- **LinkedIn:**[linkedin.com/in/simonroses](https://linkedin.com/in/simonroses)\n- **GitHub:**[github.com/vulnex](https://github.com/vulnex)\n\nContact: [info@vulnex.com](mailto:info@vulnex.com)", "url": "https://wpnews.pro/news/threat-modeling-an-ai-agent-maestro-in-practice-with-usecvislib", "canonical_source": "https://simonroses.com/2026/11/threat-modeling-an-ai-agent-maestro-in-practice-with-usecvislib/", "published_at": "2026-11-26 09:59:22+00:00", "updated_at": "2026-11-26 10:18:46.594547+00:00", "lang": "en", "topics": ["ai-safety", "ai-agents", "agent-protocols", "ai-tools"], "entities": ["Simon Roses", "MAESTRO", "Cloud Security Alliance", "USecVisLib", "Graphviz", "STRIDE", "MITRE ATLAS", "Jim Manico"], "also_reported_by": [], "takeaway": "Model agentic systems with MAESTRO's seven layers rather than fixed data flow diagrams, then export the same source model to STRIDE and a MITRE ATLAS kill chain to trace attacks that cross layers, such as a prompt that ends in a poisoned release.", "recommendation": {"advice": "Threat-model MCP-connected agents with MAESTRO's seven layers and export to STRIDE and ATLAS kill chains, because runtime tool selection and shared instruction/data channels break fixed data flow diagrams.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/threat-modeling-an-ai-agent-maestro-in-practice-with-usecvislib", "markdown": "https://wpnews.pro/news/threat-modeling-an-ai-agent-maestro-in-practice-with-usecvislib.md", "text": "https://wpnews.pro/news/threat-modeling-an-ai-agent-maestro-in-practice-with-usecvislib.txt", "jsonld": "https://wpnews.pro/news/threat-modeling-an-ai-agent-maestro-in-practice-with-usecvislib.jsonld"}}