OWASP Top 10 for LLMs & AI Agents: Complete Technical Series
Step-by-step technical series on the OWASP Top 10 for LLMs and agentic systems: from tokenization and prompt injection to RAG security and FinOps DoW.
9 Engineering Articles • 9 Executable Hands-on Labs (.ipynb) • Author: Samir El Azem Crovetto
Architectural Overview & Threat Landscape
This 9-part engineering series is structured as a progressive curriculum to understand, audit, and harden Large Language Model (LLM) applications and autonomous agents. Rather than treating vulnerabilities as isolated theoretical checklists, the roadmap starts at the internal mechanics of the model (BPE tokenization and attention matrices) and advances layer by layer through the application stack.
Every technical installment is paired 1-to-1 with an executable Jupyter Notebook / Google Colab hands-on lab (Lab 01 through Lab 09), enabling engineers to reproduce real exploit vectors and empirically verify deterministic Python defenses.
Core Engineering Pillars & Reference Patterns
Phase 1 (Parts 1–2): Model Mechanics & The Flat Attention Window
Dissecting BPE subword tokenization, multilingual cost asymmetry, ChatML framing, and the flat memory illusion that conflates instructions with untrusted data.
Phase 2 (Parts 3–4): Semantic Injection & Secret Exfiltration
Exploiting and defending against Direct/Indirect Prompt Injection (LLM01), Unicode Smuggling, System Prompt Leakage (LLM07), Canary Tokens, and Output Redactors.
Phase 3 (Parts 5–6): Vector RAG Pipelines & AI Framework Stack
ConfusedPilot and vector data poisoning (LLM08), multi-tenant RBAC pre-filtering, and remediating RCE/SSRF vulnerabilities in AI orchestration frameworks (LLM03/LLM05).
Phase 4 (Part 7): Excessive Agency & Financial Attacks (FinOps)
Governing autonomous tool calling (LLM06), preventing Denial of Wallet (LLM10) via token budget circuit breakers, and HMAC-signed Human-in-the-Loop approvals.
Phase 5 (Parts 8–9): Supply Chain Poisoning & Systemic Misinformation
Auditing pre-training and fine-tuning backdoors (LLM04), secure model deserialization with safetensors over pickle RCE, mitigating Slopsquatting in coding agents (LLM09), and verified citation RAG.
Sequential Reading Roadmap (Step-by-Step)
Article 1: From Language to the Matrix: How Prompts and Tokens Truly Work on the Inside
Open the LLM engine room: learn how text becomes vectors (embeddings), Byte-Pair Encoding (BPE) tokenization mechanics, and ChatML format security implications.
Article 2: The Illusion of Flat Memory: Why LLMs Cannot Distinguish Instructions from Data
Deep-dive into Von Neumann architecture vs. Transformer context windows: why instructions and untrusted data share the same flat memory space, and how to prevent attention hijacking.
Article 3: Public Enemy #1: Direct and Indirect Prompt Injection (OWASP LLM01)
Definitive technical guide to direct and indirect prompt injection: multimodal attack surfaces, steganographic payloads, and layered defenses (Context Framing, Guardrails, and strict validation).
⚡ Lab 03: Public Enemy #1 — Direct and Indirect Prompt Injection (OWASP LLM01)
Article 4: Data Leakage and System Prompt Leakage: The Myth of the Secure Prompt and 4 Exfiltration Surfaces
Debunking the myth of secure System Prompts: reverse-engineering methods, format bypasses, Markdown/Side-channel exfiltration, and defenses using Canary Tokens and output filters.
⚡ Lab 04: Data Leakage and System Prompt Leakage (OWASP LLM02 & LLM07)
Article 5: RAG Under Attack: Vector Vulnerabilities and Data Poisoning (OWASP LLM08)
RAG architectures under attack: cross-tenant data leaks from weak isolation, vector document poisoning (Data Poisoning), and mitigation via strict metadata filtering and cryptographic signing.
⚡ Lab 05: RAG Under Attack — Vector Weaknesses and Data Poisoning (OWASP LLM08)
Article 6: Stack Vulnerabilities: Exploiting AI Frameworks (OWASP LLM03 & LLM05)
Security audit of the AI supply chain: vulnerabilities in popular open-source frameworks, Remote Code Execution (RCE) via unsafe evaluation, and Server-Side Request Forgery (SSRF) mitigations.
⚡ Lab 06: Vulnerabilities in the Stack — Exploiting AI Frameworks (OWASP LLM03 & LLM05)
Article 7: Rogue Agents: Excessive Agency and Financial Attacks (OWASP LLM06 & LLM10)
Agentic security and controlled autonomy: unsupervised tool-calling risks, infinite token consumption loops, financial attack surfaces, and resilient Human-in-the-Loop (HITL) architectural design.
⚡ Lab 07: Uncontrolled Agents — Excessive Agency and Financial Attacks (OWASP LLM06 & LLM10)
Part 8: Data and Model Poisoning: Backdoors, Sleeper Agents and Trojanized Artifacts (OWASP LLM04)
Engineering guide to OWASP LLM04: training data poisoning, sleeper agent backdoors, unsafe pickle serialization exploits, and safetensors defenses.
⚡ Lab 08: Data and Model Poisoning — Backdoors and Deserialization RCE (OWASP LLM04)
Part 9: Misinformation, Hallucinations and Slopsquatting: AI Supply Chain Attacks (OWASP LLM09)
Engineering guide to OWASP LLM09: package hallucinations, slopsquatting in software dependencies, citation verification, and grounded RAG pipelines.
Associated Hands-On Security Labs (Jupyter Notebooks / Google Colab)
Lab 01: From Language to Matrix — Prompts, Tokens and Generation Parameters
Interactive inspection of BPE subwords with tiktoken, multilingual cost asymmetry, ChatML delimiters, and stochastic temperature variability.
Lab 02: The Flat Memory Illusion — Why LLMs Fail to Separate Instructions from Data
Attention hijacking simulation (QK^T), context saturation, and evaluating XML delimiter guardrails versus traditional x86 NX-bit architectures.
Lab 03: Public Enemy #1 — Direct and Indirect Prompt Injection
Evasion attacks via Typoglycemia, Unicode Smuggling, indirect injection in documents, and remediation with semantic validators and CI/CD tests.
Lab 04: Data Leakage and System Prompt Leakage
Secret directive exfiltration techniques (meta-prompt, format bypass), synthetic Canary Token deployment, and Output Redactor pipeline.
Lab 05: RAG Under Attack — Vector Weaknesses and Data Poisoning
ConfusedPilot attack exploitation, ChromaDB/FAISS vector poisoning, cross-tenant data leakage, and hardened pipeline with pre-filtering and SHA-256.
Lab 06: Vulnerabilities in the Stack — Exploiting AI Frameworks
Auditing RCE by design (exec in PALChain), SSRF against cloud metadata, and remediation with restrictive AST evaluators and strict DNS validation.
Lab 07: Uncontrolled Agents — Excessive Agency and Financial Attacks
Unconstrained tool calling, financial order tampering, Denial of Wallet attacks via token exhaustion, and Human-in-the-Loop (HITL) architecture with HMAC.
Lab 08: Data and Model Poisoning — Backdoors and Deserialization RCE
Subliminal trigger backdoor simulation, measuring ASR vs clean accuracy, sleeper agent persistence, spectral anomaly detection, and pickle STACK_GLOBAL exploitation/remediation vs safetensors.
Lab 09: Misinformation, Grounding and Slopsquatting — Hallucinated Packages and Verified RAG
Empirical package hallucination simulation (USENIX 2025), Slopsquatting exploit chain in coding agents, Dependency Vetting Gate, RAG pipeline with cryptographic citation verifier, and Self-Consistency with selective abstention.
Architectural Frequently Asked Questions (FAQ)
What is the recommended reading order for the OWASP Top 10 for LLMs series?
Follow the sequential order from Part 1 to Part 9. The first two chapters establish the mathematical and architectural foundations (tokenization and flat self-attention) required to understand why the exploits in Parts 3 through 9 succeed and how to mitigate them.
What are the prerequisites to run the 9 hands-on labs paired with this series?
All 9 labs are self-contained Jupyter Notebooks (.ipynb) compatible with Python 3.10+ and can be executed in the cloud via Google Colab or locally inside isolated Docker containers.
Does this series cover chatbots, tool-calling agents, and model supply chain security?
Yes. Parts 1 through 4 cover core inference and prompt boundaries, Part 5 dives into enterprise RAG vector stores, Part 6 audits orchestration frameworks, Part 7 addresses autonomous agents and FinOps protection, Part 8 covers model poisoning and pickle deserialization RCE, and Part 9 examines misinformation, grounding, and package slopsquatting.