AI Security Framework Stack: A Layered Defense Guide (2026)
Introduction: Seeing AI Security as a Stack Shows Where Each Control Belongs
AI security cannot be solved by a single product or a single risk list, because an AI system is built from six or seven layers of components, each with its own trust boundaries and attack methods. Asking only “is the model safe?” checks just the one layer of the stack that looks most like a black box.
Incidents over the past year show that the center of gravity has moved from “the model says something wrong” to “the system does something wrong.” EchoLeak (CVE-2025-32711) let a single crafted email exfiltrate internal file contents from Microsoft 365 Copilot with zero clicks. The serialization injection flaw in LangChain Core (CVE-2025-68664, CVSS 9.3) escalated prompt injection all the way to secret leakage. What the two have in common is that the failure was not in the model itself, but in the data flows, frameworks and permissions around it.
This article makes three arguments to CISOs and AI architects:
- Put controls at the boundaries between layers, not only inside the model. A model can be persuaded; a boundary cannot.
- Make permissions and blast radius the core of the design. An agent's exposure equals every credential, tool and API it can reach.
- Treat industry frameworks as reference coordinates, not blueprints. OWASP, NIST and MITRE ATLAS each describe a different slice of the stack, and each must be mapped onto your own architecture.
We first present the full stack, then take apart the threats and controls layer by layer, and finally distill them into an actionable roadmap and checklist.
The AI Framework Stack at a Glance
An AI system can be split into six layers. Governance, cross-cutting capabilities and the AI Gateway are not separate layers; they are control mechanisms laid over the six. This article uses the layering to locate each control.
AI framework stack overview · 6 layers, governance, cross-cutting capabilities
The codes on the right of the figure map to the OWASP LLM and Agentic lists. The orange AI Gateway sits between the orchestration framework layer and the model layer as the single entry point for model calls and tool / MCP traffic; it is a control point, not a separate layer. The higher the layer, the more directly model output
becomes action, and the higher the priority of boundary controls.
Layer by Layer (Part 1): Infrastructure, Data and Model
The principle for the lower layers is to treat data and weights as “executable inputs that change system behavior,” and to verify their provenance before they enter production.
Infrastructure and Data Layer
This layer holds GPU / inference clusters, training and fine-tuning data, RAG knowledge bases and vector databases. Once data is poisoned or retrieved without authorization, every layer above accepts it as is.
Key threats
- Data and model poisoning (OWASP LLM04): malicious content planted in training, fine-tuning or knowledge-base documents changes model output.
- Sensitive information disclosure (LLM02): the model or retrieval results surface data the user should not see.
- Vector and embedding weaknesses (LLM08, new in the 2025 edition): vector store permission bypass, cross-tenant mixing, and embeddings that can be inverted to recover the original text.
Controls
- Data classification and lineage: every record entering training or the knowledge base has an owner, a classification and a provenance record.
- Apply document-level access control at retrieval time, rather than filtering after the fact in the application layer.
- Isolate vector stores by tenant or data classification, and encrypt data at rest and in transit.
- Segment the inference cluster's network, keep management interfaces off the public network, and route every model endpoint through a gateway.
Model Layer (Including the Model Supply Chain)
The core judgment for this layer: model weights of unknown origin are equivalent to executables of unknown origin.
Key threats
- Supply chain vulnerabilities (LLM03): weights, adapters (such as LoRA) or quantized builds from public model hubs carry backdoors, or smuggle in malicious code through executable serialization formats (such as pickle).
- Prompt injection and jailbreaks (LLM01): the model cannot reliably tell instructions from data. This is a structural weakness of the model itself and cannot be eliminated with a single filter.
- System prompt leakage (LLM07, new in the 2025 edition): putting secrets or access rules in the system prompt assumes it will never leak.
- Model theft and unauthorized access: causes intellectual property loss and lets attackers study offline how to break your model.
Controls
- Accept only non-executable weight formats (for example safetensors), and forbid production from downloading directly from public model hubs.
- Maintain an internal model registry that retains signatures, versions, evaluation results and an AIBOM (AI bill of materials).
- Put a security evaluation gate before model launch, including prompt injection, jailbreak, data leakage and backdoor detection tests.
- Keep secrets and authorization logic out of system prompts; make every authorization decision in deterministic code, not in the model.
- Run due diligence on third-party model providers: data retention, whether data is used for training, data residency and incident notification deadlines.
Layer by Layer (Part 2): Orchestration Framework, Agent / Tool / MCP and Application
Risk in the upper layers concentrates on “how model output becomes action,” so controls belong at the boundary of every such conversion.
Orchestration Framework Layer
This layer is the glue code, such as LangChain and LlamaIndex, that strings together prompts, retrieval, tools and memory. It is ordinary software that also handles model output directly, so it carries both traditional vulnerabilities and AI-specific risks.
Key threats
- Traditional vulnerabilities in the framework itself: the serialization injection in langchain-core (CVE-2025-68664) stemmed from internal markers not being escaped properly, so user-controlled data was restored as framework objects. In 2026 a further deserialization issue appeared (CVE-2026-44843), caused by an overly broad load() allowlist.
- Improper output handling (LLM05): model output fed straight into a shell, SQL, a template or a deserialization flow.
- Dependencies and secrets: frameworks often read secrets from environment variables, which can leak once an object is manipulated.
Controls
- Bring AI frameworks into software composition analysis (SCA) and the SBOM, pin versions, and set shorter emergency patch deadlines for these packages.
- Always treat model output as untrusted input: validate structured output against a schema, and escape or parameterize it before it enters downstream systems.
- Forbid deserializing prompts or runnable objects from untrusted sources (shared prompt stores, external hub objects).
- Move secrets to a secrets manager with short-lived credentials, rather than leaving them long-term in environment variables the framework can read.
Agent, Tool and MCP Layer
This is the layer where risk concentrates most, because here the model moves from “answering questions” to “taking action with credentials.” In December 2025 OWASP published the Top 10 for Agentic Applications (ASI01–ASI10), which describes these risks specifically, covering goal hijacking, tool misuse, identity and privilege abuse, memory poisoning and rogue agents.
Key threats
- Excessive agency (LLM06): an agent is granted more tools, permissions or autonomy than the task needs.
- Tool poisoning and “swap-in updates”: malicious instructions hidden in an MCP tool's name, description or parameter schema, so the user sees a simplified interface while the model reads the full content. A tool rewritten after it passes review is called a rug pull.
- Shadow MCP servers: unregistered, unmonitored servers create blind spots and data exfiltration paths; the CoSAI white paper lists them as a governance risk.
- Supply chain and remote code execution: for example CVE-2025-6514 in mcp-remote (CVSS 10.0), and poisoning of agent tools and skill packages.
Controls
- Give each tool a single, limited purpose, and never hand security decisions to the LLM.
- Maintain an approved list of MCP servers and tools: register the source, pin versions, and hash tool descriptions so rewrites can be detected.
- Issue each agent its own identity and short-lived, narrowly scoped tokens (the June 2025 MCP specification already requires binding a token to a single server through resource indicators).
- Require human approval for high-risk actions (transfers, deletion, external sending, permission changes), and avoid wearing users down with so many prompts that they simply click approve.
- Run code execution in a sandbox with outbound connections denied by default; validate memory writes and keep context short-lived.
- Prepare a kill switch that can disable an agent immediately, plus automatic detection of abnormal behavior.
Application and User Layer
This layer is the interface employees and customers actually touch: chat windows, Copilots, embedded assistants and automated workflows.
Key threats
- Indirect prompt injection: the attacker does not talk to the AI directly, but hides instructions in an email, web page or document and waits for the AI to read it. EchoLeak is of this kind.
- Over-trust (ASI09): users treat AI output and suggestions as authoritative, creating a new entry point for social engineering.
- Unbounded consumption (LLM10) and misinformation (LLM09): cost-based attacks, and decision and compliance risk from wrong answers.
- Shadow AI: employees use unapproved AI tools and plugins, and data leaves the organization without anyone knowing.
Controls
- Input and output guardrails are one layer of defense in depth, not the only layer; do not use them to replace permission design.
- Restrict automatic rendering of external images and links, cutting off a common channel for “exfiltrate immediately after reading.”
- Set quotas, rate limits and token budgets, and alert on abnormal usage.
- Show data sources and uncertainty in the interface, so users can question the answer.
- Keep inventorying shadow AI, and offer approved alternatives with data protection.
AI Gateway: Turning Entry Control into an Enforceable Boundary
The AI Gateway is the best place in the stack to put “controls at the boundary” into practice: when all model calls, tool calls and MCP traffic pass through one entry point, policy can be enforced and audited centrally and consistently.
It differs from a traditional API gateway in that the traffic is natural language and the caller is often an agent. Beyond authentication and rate limiting, it has to inspect the semantic content of prompts, responses and tool calls.
The Three Traffic Flows It Should Govern
- Application to model: Bring internal and external model providers behind one entry point, so teams do not connect directly with their own keys.
- Agent to tools and MCP servers: Act as an MCP gateway that governs every tool call.
- Users and external content entering AI applications: Inspect content before it reaches the model.
Six Entry-Control Capabilities
- Identity and authorization. Every caller (user, service, agent) is identified by an identity, with short-lived, narrowly scoped tokens; provider keys are held centrally rather than scattered across applications and frameworks.
- Approved lists. Allow only registered models, versions, MCP servers and tools, and deny anything unregistered by default, which removes shadow AI and shadow MCP servers.
- Input and output inspection. Detect direct and indirect prompt injection, and leakage of sensitive data and secrets; validate structure before output enters downstream systems, and restrict automatic rendering of external images and links.
- Tool-call control. Check tools and parameters against the agent's identity and task, route high-risk actions to human approval, and hash MCP tool descriptions to detect rewrites.
- Quotas and cost. Rate limits, token budgets and abnormal-usage alerts, addressing unbounded consumption (LLM10).
- Unified logging and emergency shutoff. Prompts, response summaries, tool calls, approvers and guardrail triggers are collected here and sent to the SIEM; a kill switch can disable a specific model, tool or agent in one step. The logs themselves contain sensitive data, so mask it first and set a retention period.
These six capabilities map broadly to LLM01, LLM02, LLM06 and LLM10 on the OWASP LLM list, and to ASI02 and ASI03 on the Agentic list.
Gateway Limits, and How to Fill the Gaps
- It governs only the traffic that passes through it. Direct connections that bypass it, local agents and AI features inside the browser must be covered by egress blocking and endpoint controls.
- Semantic inspection produces false positives and false negatives. It is one layer of defense in depth and cannot replace least privilege and human approval.
- It becomes a concentrated target. The gateway holds the keys and all the traffic, so it must be highly available, deployed with least privilege, and monitored to the same standard as core systems.
In practice, start with “bring model egress behind one entry point and keep logs,” then extend to MCP traffic and tool control; manage gateway policy as code, under version control and change review.
Four Cross-Cutting Capabilities
Controls in a single layer can stop a single-point attack but not a cascading failure across layers, so four cross-cutting capabilities are needed to tie the layers into one line of defense.
1. Identity and least privilege: treat agents as identities that need governance. An agent's risk equals every credential, tool and API it can reach. Every agent and every workflow should have an identity that is identifiable, revocable and time-limited, with permissions narrowed dynamically by task rather than inheriting everything the builder or user has. NIST already treats “agent identity and authorization” as a key near-term gap, and in February 2026 CAISI launched an AI Agent Standards Initiative.
2. Observability and audit: be able to reconstruct “why the model did this.” Traditional SAST and SCA cannot see prompts, tool calls, memory or agent-to-agent traffic, so separate logging is needed. At a minimum, retain the following and feed it into your existing SIEM:
- The full prompt and context, with the source of each part marked (user input, retrieved documents, tool returns)
- The parameters, returns, approver and identity used for every tool call
- Model and prompt versions, and guardrail trigger records
3. Red teaming and continuous validation: make attack tests regression tests that run on every release. Design test scenarios from MITRE ATLAS and the OWASP lists, covering direct and indirect prompt injection, tool poisoning, data exfiltration and unauthorized calls. Re-run them whenever the model, prompt or tools change; behavior drifts after a model upgrade, so the previous version's passing result cannot be carried over.
4. Incident response: rehearse the “AI-specific” actions first. Actions that general response playbooks do not cover include disabling a specific tool or MCP server, revoking agent credentials, rolling back a prompt or model version, purging poisoned memory and vector stores, and notifying affected data owners. Write these into a runbook in advance and validate them with tabletop exercises, rather than discussing them on the day of the incident.
How Industry Frameworks Map to the Stack
OWASP explains “what can go wrong,” MITRE ATLAS explains “how attackers do it,” and NIST and ISO explain “how the organization governs it.” Each covers a different slice of the stack, and they should be used together rather than choosing one.
Framework | What it describes | Best-fit layer | Practical use |
OWASP Top 10 for LLM Applications 2025 (November 2024) | Ten classes of application risk, LLM01–LLM10; the 2025 edition adds system prompt leakage and vector and embedding weaknesses | Data, model and application layers | Threat modeling, red-team scoping, procurement questionnaires |
OWASP Top 10 for Agentic Applications 2026 (December 9, 2025) | Ten classes of agent risk, ASI01–ASI10 | Agent / Tool / MCP layer | Layered on top of the LLM list to threat-model autonomous agents |
CoSAI MCP security white paper (January 2026) | MCP-specific threats such as tool poisoning and shadow MCP servers | Agent / Tool / MCP layer | Approval and design guidelines for MCP servers |
AI attack tactics and techniques organized in the ATT&CK matrix format, with 16 tactics; new agent techniques added from 2026 | Full stack | Detection engineering, red-team playbooks, incident mapping | |
NIST AI RMF 1.0 and AI 600-1 (January 2023, July 2024) | Four functions (Govern, Map, Measure, Manage); AI 600-1 lists 12 generative AI risks | Governance layer | Policy, risk assessment process and audit mapping |
NIST Cyber AI Profile (IR 8596) (preliminary draft, December 2025) | Extends CSF 2.0 to the security of AI systems and to AI-assisted cybersecurity | Governance layer, cross-cutting capabilities | Organizations already on CSF can extend it directly instead of starting over |
ISO/IEC 42001 (published 2023) | An AI management system standard that a third party can verify | Governance layer | Give customers and regulators auditable management evidence |
Two points deserve attention. First, NIST AI RMF still stands at version 1.0; the official position is that a revision is under way and no new version has been released, and AI 600-1 itself is not agent-specific, so the agent side should also draw on the OWASP Agentic list and NIST's developing SP 800-53 control overlays (COSAiS).
Second, ATLAS describes only the attacker's side and does not provide defensive control specifications, so its output should feed back into your detection rules and red-team playbooks rather than serve as a compliance checklist.
Implementation Roadmap and Common Mistakes
We recommend three phases: in the first 90 days, gain visibility and stop the bleeding; from 90 days to one year, build repeatable controls; after one year, move to steady-state operation.
Implementation roadmap · 3 phases, 2 gates
The two gates are the conditions for entering the next phase: if they are not met, do not expand agent autonomy or the range of data an agent can reach.
The three most common mistakes when pushing this forward:
- Buying guardrail products without changing permission design. Guardrails get bypassed; permission boundaries do not.
- Governing only the model, not MCP servers and framework dependencies. Most of the incidents in this article occurred in components around the model.
- Running red-team tests only once. When the model, prompt or tools change, the previous round's results no longer hold.
Checklist and Closing
The key to strengthening AI security is to accept the premise that “a model can be persuaded” and to build the defenses outside the model: identity, permissions, boundaries and traceability. Use the list below to review where you stand; every unchecked item is a priority for the next quarter.
- ☐ All AI assets are inventoried: models, frameworks, MCP servers, agents and data sources, including shadow AI
- ☐ All model, tool and MCP traffic passes through the AI Gateway, and direct connections that bypass it are blocked
- ☐ Every agent has its own identity, least privilege and expiring credentials
- ☐ High-risk actions require human approval, and a kill switch can be activated immediately
- ☐ Models and frameworks have an AIBOM / SBOM, signatures and version pinning, and only non-executable weight formats are accepted
- ☐ Model output is always treated as untrusted input and validated or escaped before entering downstream systems
- ☐ RAG enforces document-level access control at retrieval time, and vector stores are isolated by tenant or classification
- ☐ MCP servers and tools have an approved list, and description hashes detect rewrites
- ☐ Prompt, tool-call, approval and guardrail-trigger logs are fed into the SIEM
- ☐ Any change to the model, prompt or tools triggers red-team regression tests
- ☐ The incident response runbook includes AI-specific actions and has been through a tabletop exercise
- ☐ OWASP, ATLAS and NIST are mapped to internal controls, with an owner assigned to each
References
The links below come from pages retrieved at the time of writing; check the official pages for versions and dates. The description of ISO/IEC 42001 is the author's background knowledge and was not separately verified.
- OWASP: 2025 LLM Top 10 announcement
- OWASP: Top 10 for Agentic Applications
- OWASP: Agentic Top 10 release notes
- Cycode: OWASP Agentic Top 10, item by item
- Coralogix: LLM Top 10 and EchoLeak (CVE-2025-32711)
- Microsoft: LangChain serialization injection case study (CVE-2025-68664)
- GitHub Advisory: LangChain deserialization (CVE-2026-44843)
- Cequence: MCP security risks
- Adversa: Key takeaways from the CoSAI MCP security white paper
- Identra: MCP security and token binding
- DEV Community: 11 classes of MCP risk (including CVE-2025-6514)
- MITRE CTID: ATLAS Secure AI update
- Vectra: MITRE ATLAS explained
- NIST AI 600-1 Generative AI Profile
- AI-ERA: NIST AI RMF status (Cyber AI Profile, COSAiS)
- Anaconda: AI 600-1 guide (AI Agent Standards Initiative)