Security Architecture for Generative AI: Threat Models and Defenses
Nov, 6 2026
You built a killer Generative AI application. It summarizes emails, writes code, or chats with customers. But here is the uncomfortable truth: your model is now a new attack surface. Traditional firewalls don't care if someone tricks your LLM into leaking database credentials via a cleverly worded prompt. As we move deeper into 2026, securing these systems isn't just an IT checkbox; it's the difference between a scalable product and a data breach headline.
Most teams treat AI security like traditional app security. They slap an API key on it and call it a day. That approach fails because Generative AI introduces non-deterministic behavior and unique vulnerabilities like prompt injection. This guide breaks down exactly how to build a security architecture that actually holds up against modern threats. We will look at what attackers want, where they strike, and the specific defenses you need to deploy right now.
Why Traditional Security Fails GenAI
Standard cybersecurity assumes inputs are data and logic is fixed. In Large Language Models (LLMs), input is natural language, and logic is probabilistic. An attacker doesn't need to exploit a buffer overflow; they just need to convince the model to ignore its instructions. This shift requires a fundamental change in how we view trust boundaries.
Consider the shared responsibility model. If you use a provider like AWS Bedrock or Azure OpenAI, they secure the infrastructure and the base model weights. You are responsible for the prompts, the retrieved context, the output handling, and the user access controls. Many organizations miss this split. They assume the cloud provider handles everything, leaving their custom applications exposed to training data poisoning or model theft.
| Layer | Provider Responsibility | Your Responsibility |
|---|---|---|
| Infrastructure | Hardware, Network, Hypervisor | VPC Configuration, Access Logs |
| Model Core | Base Model Weights, Training Pipeline | Fine-tuning Data Hygiene |
| Application | API Availability | Prompt Engineering, Input Validation, Output Filtering |
| Data | Storage Encryption at Rest | Ingress/Egress Rules, PII Masking |
The Top Threats Targeting Your AI Stack
According to the OWASP AI Security Solutions Landscape, four categories dominate the risk profile for production GenAI systems. Understanding these helps you prioritize your budget and engineering time.
- Prompt Injection: The most common vector. Attackers craft inputs that override system instructions. A classic example involves hiding malicious commands inside seemingly harmless text, causing the model to execute unintended actions or reveal hidden context.
- Training Data Poisoning: If you fine-tune models or use RAG (Retrieval-Augmented Generation), bad data gets in. An adversary injects misleading facts during training or retrieval, subtly biasing the model’s output over time. This is hard to detect because the model still sounds confident.
- Model Denial of Service (DoS): Unlike traditional DoS, this targets computational resources. Attackers send complex, long-context prompts that force the GPU to work harder, spiking costs and latency. Since LLM inference is expensive, a few thousand targeted requests can drain your budget in hours.
- Model Extraction: Also known as model theft. By querying the model repeatedly and analyzing outputs, attackers can reconstruct a surrogate model. For proprietary algorithms, this means losing intellectual property without ever seeing the source code.
Agentic AI adds another layer. When agents reason, remember, and act autonomously, they introduce temporal persistence threats. A compromised agent might store a poisoned memory that affects decisions days later, making the root cause difficult to trace back to the initial attack.
Building a Defense-in-Depth Architecture
You cannot rely on a single gatekeeper. Effective defense-in-depth for AI requires layers that catch different types of failures. Start from the outside in.
1. Input Validation and Sanitization
This is your first line of defense. Before a prompt hits the LLM, it must pass through a validation layer. Simple regex filters aren't enough anymore. You need multi-layered checks:
- Rule-Based Filters: Block obvious patterns like SQL keywords or HTML tags if they aren't expected.
- AI-Driven Anomaly Detection: Use a smaller, faster classifier model to score incoming prompts for toxicity or injection likelihood. Tools like ProtectAI or CalypsoAI specialize in this runtime analysis.
- Context Isolation: Ensure user inputs are clearly delimited from system instructions. Use XML tags or special tokens to separate untrusted data from trusted instructions.
2. Runtime Controls and Sandboxing
Once the model processes the input, control what happens next. If your AI generates code or executes tools, sandbox those executions. Never let an LLM-generated script run with full server privileges. Use isolated containers or WebAssembly modules to limit blast radius.
Implement strict rate limiting per user and per IP. This mitigates cost-based DoS attacks. Additionally, enforce token limits. If a user sends a 100k-token prompt, reject it or summarize it before processing to prevent resource exhaustion.
3. Output Filtering and PII Protection
The model’s output is just as dangerous as the input. It might hallucinate sensitive data or leak internal knowledge. Deploy an output filter that scans responses for Personally Identifiable Information (PII) or secrets before returning them to the user. If the model tries to print an API key found in its context window, block it. This step is critical for compliance with regulations like GDPR or HIPAA.
Zero Trust Patterns for AI Systems
The concept of Zero Trust fits naturally with GenAI security. The core principle is "never trust, always verify." In an AI context, this means verifying every interaction, not just the initial login.
Apply least privilege to every component. Does your chatbot really need read-write access to the customer database? Probably not. Restrict it to read-only on specific tables. Segment your network so that the AI inference service cannot directly talk to your primary production database unless explicitly allowed through a gateway.
For agentic systems, implement governance circumvention defenses. Agents often have tool-use capabilities. Ensure that each tool call is authenticated and authorized independently. Just because an agent is "logged in" doesn't mean it has permission to delete records. Contextual access control ensures that permissions are checked at the action level, not just the session level.
Data Protection and Provenance
Your model is only as good as its data, and only as secure as its provenance. If you are using Retrieval-Augmented Generation, your vector database is a high-value target. Encrypt data in transit using TLS 1.3 and at rest using AES-256. Consider confidential computing options, such as NVIDIA Confidential GPUs, which allow computation on encrypted data without decrypting it in memory. This prevents even cloud admins from peeking at your sensitive genomic or financial data.
Maintain a Software Bill of Materials (SBOM) for your AI pipeline. Track every dependency, dataset version, and model checkpoint. If a vulnerability is discovered in a specific library used for embedding generation, you need to know immediately which models are affected. Cryptographic signing, using tools like Sigstore, can attest to the integrity of your model files, ensuring no one tampered with the weights after training.
Monitoring and Incident Response
Traditional logs won't tell you if your model is being jailbroken. You need model-aware telemetry. Monitor metrics like:
- Token Usage Spikes: Sudden increases often indicate DoS attempts or runaway loops.
- Latency Deviations: Unusual delays might suggest the model is struggling with obfuscated inputs.
- Output Sentiment Shifts: A sudden drop in response quality or sentiment could signal poisoning or drift.
Integrate these signals into your SIEM (Security Information and Event Management) system. Create playbooks specifically for AI incidents. For example, if a prompt injection is detected, automatically quarantine the user session and trigger a manual review queue. Don't wait for a user complaint to find out your bot started swearing at customers.
Testing Your Security Posture
You wouldn't launch software without penetration testing. Do the same for your AI. Conduct red team exercises focused on generative vulnerabilities. Try to poison your RAG index with conflicting documents. Attempt to extract the system prompt by asking the model to repeat its instructions. Simulate adversarial examples where slight changes to input words completely flip the model's classification.
Regular chaos engineering experiments help too. Randomly fail components of your AI stack-like the vector DB or the embedding service-to see how gracefully the system degrades. Does it return a helpful error message, or does it crash with a stack trace that reveals internal paths?
Key Takeaways
- Shift Left: Incorporate security checks into the prompt design phase, not just deployment.
- Validate Everything: Treat all inputs and outputs as hostile until proven otherwise.
- Monitor Behavior: Watch for anomalies in token usage and output quality, not just HTTP status codes.
- Least Privilege: Restrict AI agents' access to tools and data strictly to what is necessary for the task.
- Provenance Matters: Keep track of data sources and model versions to quickly identify contamination.
What is the biggest security risk for Generative AI?
Prompt injection is currently the most prevalent and impactful threat. It allows attackers to manipulate the model's behavior by crafting specific inputs that override system instructions, potentially leading to data leakage or unauthorized actions.
Does cloud providers handle all AI security?
No. Cloud providers secure the infrastructure and base models, but you are responsible for securing your prompts, fine-tuning data, application logic, and user access controls. This is known as the shared responsibility model.
How do I prevent model denial of service?
Implement strict rate limiting, set maximum token limits for inputs and outputs, and monitor for unusual spikes in computational usage. Using a caching layer for frequent queries can also reduce load on the inference engine.
Is Zero Trust applicable to AI systems?
Yes, Zero Trust is highly effective for AI. It involves verifying every request regardless of origin, applying least privilege to tool access, and segmenting networks to limit lateral movement if an agent or model component is compromised.
What is training data poisoning?
Training data poisoning occurs when malicious actors insert flawed or biased data into the training set. This causes the model to learn incorrect associations or behaviors, which can be subtle and hard to detect without rigorous validation.