Threat Models, Sandboxes and Least Privilege
Introduction
- What This Book Covers
- Who Should Read This Book
- How to Use This Book
- What This Book Does Not Do
- A Note on Sources
- On Style and Conventions
Chapter 1: What Are AI Agents?
- Defining AI Agents
- Agents Versus Chatbots Versus APIs
- Core Capabilities: Perception, Reasoning, Action
- Real-World Agent Use Cases
- Why Traditional Security Models Fail
Chapter 2: How Agents Work: Architectures and Mechanisms
- Large Language Models as Control Planes
- Function Calling and Tool Use
- Autonomous Execution Loops
- Memory: Short-Term, Long-Term and Working Memory
- Retrieval-Augmented Generation (RAG)
- Multi-Agent Systems and Coordination Patterns
- Agent Frameworks and Orchestration Platforms
Chapter 3: The Emerging Threat Landscape
- From Lab Research to Production Incidents
- Taxonomy of AI Agent Attacks
- High-Profile Cases and Lessons Learned
- The Scale of the Problem: Agents at Scale
- Regulatory and Compliance Pressure
Chapter 4: Trust, Boundaries and Assumptions
- Security Assumptions in AI Systems
- Defining Trust Boundaries for Agents
- Assets Worth Protecting
- Adversary Models and Motives
- What Breaks: The Unique Failure Modes of Agents
Chapter 5: Attack Trees, Abuse Cases and Risk Assessment
- Adapted STRIDE for AI Agents
- Building Attack Trees for Agents
- Abuse Case Diagrams
- Quantifying Risk: Likelihood and Impact
- Threat Modeling the Lifecycle: Design, Deploy, Operate
Chapter 6: Prompt Injection and Jailbreak Attacks
- Direct Prompt Injection: Mechanisms and Variants
- Indirect (Data) Injection: The Real Production Risk
- Jailbreaks: Bypassing Alignment
- Multi-Turn and Conversational Exploits
- Defense Strategies: Separation, Validation and Monitoring
- When Defense Is Impossible: Designing Around the Risk
Chapter 7: Tool Misuse and API Exploitation
- How Tools Become Attack Vectors
- Argument Injection and Malformed Inputs
- Off-Spec and Off-Path Tool Use
- Chained Tool Abuse: From Read to Root
- The Confused Deputy Problem in Agents
- Mitigating Tool-Based Attacks
Chapter 8: Data Exfiltration and Sensitive Information Leakage
- Paths Data Can Escape
- Exfiltration via Tool Outputs
- Leakage Through Model Providers
- Embeddings, RAG and Knowledge Store Risks
- Log Poisoning and Side-Channels
- Detection and Prevention
Chapter 9: Supply Chain, Model and Prompt Risks
- Model Supply Chain Risks
- Prompt Template Compromise
- Third-Party Tools and Plugins
- Framework and Library Vulnerabilities
- Pretrained Knowledge Poisoning
Chapter 10: Multi-Agent Attack Surfaces
- Trust and Trust Delegation in Multi-Agent Systems
- Cross-Agent Prompt Injection
- Shared Resource Contention and Abuse
- Coordination Failures as Security Incidents
- Poisoned Agent-to-Agent Communication
- Securing Agent Teams
Chapter 11: Operating System Security for Agents
- The Linux Security Model: Capabilities and Privileges
- Seccomp: Restricting System Calls
- User Namespaces and ID Mapping
- Control Groups: Resource Limits for Untrusted Workloads
- Read-Only Filesystems and Mount Namespaces
- Composing Primitives for Strong Isolation
Chapter 12: Containers, Namespaces and Ephemeral Execution
- Container Isolation: What It Is and What It Is Not
- Hardening Container Runtimes
- Network Policies and Pod Security
- Immutable and Ephemeral Agent Execution
- Breaking Out: Container Escape Scenarios
- When Containers Are Enough (and When They Are Not)
Chapter 13: Virtual Machines and MicroVMs
- Hardware Virtualization and Full VM Isolation
- MicroVMs: Firecracker and Alternatives
- gVisor: User-Space Kernel Isolation
- Kata Containers and Confidential Computing
- Performance, Latency and Cost Trade-offs
Chapter 14: WebAssembly and Fine-Grained Sandboxing
- WebAssembly as an Isolation Primitive
- Memory Safety and Capability-Based Access
- Wasmtime, Wasmer and Agent Runtimes
- Isolating Individual Tools in Wasm
- Limits of WebAssembly for Agents
- Hybrid Architectures: Wasm Plus Other Controls
Chapter 15: Network Segmentation, Browser Isolation and Peripheral Controls
- Network Segmentation for Agent Environments
- Egress Filtering and DNS Control
- Browser Sandboxing for Web Agents
- Controlling External Service Access
- Per-Request Network Policies
- Air-Gapped and Restricted Network Agents
Chapter 16: Capability-Based Security for Agents
- Capabilities Versus Traditional RBAC
- Designing Capabilities for Agent Tools
- Capability Scoping and Delegation
- Revocation and Expiration
- Building a Capability-Based Agent Runtime
Chapter 17: Identity, Credentials and Just-in-Time Access
- Identity for Agents: Who Are They?
- Short-Lived Credentials and Tokens
- Workload Identity: AWS, GCP, Azure, Kubernetes
- OAuth 2.0 and OIDC for Agent Access
- Just-in-Time Authorization Patterns
- Credential Rotation and Revocation
Chapter 18: Policy Enforcement and Authorization
- Declarative Policy for Agents
- OPA and Rego for Agent Authorization
- Tool-Level Access Policies
- Workflow and Multi-Step Policies
- Policy Testing and Validation
- Integrating Policy Engines into Agent Runtimes
Chapter 19: Secrets Management for Agents
- The Secret Management Problem for Agents
- HashiCorp Vault and Alternatives
- Per-Session and Per-Tool Secrets
- Secrets in Prompts: What Not to Do
- Ephemeral Credential Provisioning
- Auditing Secret Access
Chapter 20: Human Approval Gates and Secure Human-in-the-Loop
- When Humans Must Be in the Loop
- Designing Approval Flows for Agents
- Risk-Based Approval Gating
- Secure Notification and Authentication
- Avoiding Approval Fatigue and Automation Bias
- Auditing Human Decisions
Chapter 21: Building a Secure Agent Runtime
- The Security Model of an Agent Runtime
- Process Model: One Agent Per Process?
- Tool Execution Architecture
- Fail-Closed and Secure Defaults
- Input and Output Validation
- Reference Architectures for Secure Runtimes
Chapter 22: Policy Engines, Tool Gateways and Permission Brokers
- The Tool Gateway Pattern
- Permission Brokers and Dynamic Authorization
- Policy Enforcement Points
- Rate Limiting and Quota Enforcement
- Observability in Security Components
Chapter 23: Monitoring, Logging and Audit Trails
- What to Log: The Audit Trail for Agents
- Structured Logging and Schema Design
- Tamper-Resistant Audit Storage
- Real-Time Anomaly Detection
- Alerting on Suspicious Agent Behavior
Chapter 24: Secure Memory, RAG and Knowledge Stores
- Memory as an Attack Surface
- Securing Vector Databases
- Document Store Integrity
- Knowledge Base Poisoning and Defense
Chapter 25: Defense-in-Depth Architecture
- The Layered Defense Model for Agents
- Designing for Failure Modes
Chapter 26: Reference Implementation: A Secure AI Agent System
- System Overview and Design Goals
- Project Structure
- The Agent Core
- Security Middleware
- The Tool Gateway
- The Policy Engine
- The Sandbox Layer
- Running the Full System
- Adversarial Test Suite
Chapter 27: Multi-Tenant and Cloud Deployments
- Kubernetes Security for Agent Workloads
- Multi-Tenant Isolation
- Cloud Provider Patterns
Chapter 28: Security Testing and Red Teaming
- Security Testing Pyramid
- Automated Prompt Injection Testing
- Red Team Playbooks
Chapter 29: Incident Response for AI Agents
- Detection Patterns
- Containment Strategies
- Recovery
Chapter 30: Governance, Compliance and Audit Readiness
- Regulatory Landscape
- Control Mapping
- Building a Governance Program
Chapter 31: Production Readiness Checklist and Security Review
- Pre-Deployment Checklist
- Runtime Checklist
- Emergency Response Checklist
Chapter 32: The Future of AI Agent Security
- Emerging Attack Surfaces
- Next-Generation Isolation
- The Arms Race
- Final Recommendations