Getting Started
- Unsure How to Get Started? Try our Book Workshop!
- How to Write on Leanpub
- Previewing and publishing
- Basic formatting
- Markdown and Markua
- Generate a preview version of your book
- Either read a tutorial, or just go for it!
- Thanks for being a Leanpub author!
Writing in Markua
- Section One
- Including a Chapter in the Sample Book
- Links
- Images
- Lists
- Page Breaks
- Code Samples
- Tables
- Math
- Headings
- Block quotes, Asides and Blurbs
- Good luck, have fun!
- author: Caio Incau date: “2026-05-25T13:41:16Z” identifier: “urn:uuid:9224380c-44fa-4fba-a29b-526741c89a23” language: en title: AI Security for Developers
Preface
- Who this book is for
- How this book is organized
- What you need
Chapter 1 —- The New Attack Surface
- The pre-AI security model
- What AI changes
- The new threat categories
- Why traditional AppSec is not enough
- A defense-in-depth model for AI
- Common mistakes
- Exercises
- Summary
Chapter 2 —- How AI-Generated Code Introduces Vulnerabilities
- Why AI writes insecure code
- The vulnerability taxonomy
- Measuring your exposure
- The trust calibration problem
- Common mistakes
- Exercises
- Summary
Chapter 3 —- Prompt Injection: The SQL Injection of AI
- How prompt injection works
- The attack taxonomy
- Why there is no parameterized query equivalent
- Building layered defenses
- Common mistakes
- Exercises
- Summary
Chapter 4 —- Data Leakage and Model Extraction
- Training data memorization
- Context window exposure
- Model extraction attacks
- Practical data loss prevention for AI
- Common mistakes
- Exercises
- Summary
Chapter 5 —- Securing AI-Generated Code
- Static analysis for AI-generated code
- Building the CI/CD security gate
- GitHub Actions integration
- Automated fix suggestions
- Common mistakes
- Exercises
- Summary
Chapter 6 —- Secure Coding with AI Assistants
- Security-aware prompting
- The security review checklist for AI code
- Configuring AI assistants for security
- The review workflow
- Common mistakes
- Exercises
- Summary
Chapter 7 —- Input Validation for AI Systems
- Input validation architecture
- Pre-model input filters
- Runtime guardrails
- Output sanitization
- Putting it all together
- Common mistakes
- Exercises
- Summary
Chapter 8 —- Authentication and Authorization with AI
- The agent authentication problem
- OAuth 2.0 for AI agents
- API key management for AI services
- The principle of least privilege for AI agents
- Middleware for AI endpoint protection
- Common mistakes
- Exercises
- Summary
Chapter 9 —- Securing MCP Servers
- The MCP security model
- Server hardening
- Transport security
- Production deployment patterns
- Common mistakes
- Exercises
- Summary
Chapter 10 —- Securing AI Agents in Production
- The agent threat model
- Sandboxing agent execution
- Network isolation
- Resource limits and quotas
- Comprehensive audit trails
- Putting it all together: the secure agent runtime
- Common mistakes
- Exercises
- Summary
Chapter 11 —- Supply Chain Security for AI
- Model provenance
- Dependency risk management
- Third-party model evaluation
- AI Software Bill of Materials (AI-SBOM)
- Common mistakes
- Exercises
- Summary
Chapter 12 —- Monitoring and Incident Response
- What to monitor
- Building the monitoring pipeline
- Detection rules
- Incident response playbooks
- Forensic analysis
- Common mistakes
- Exercises
- Summary
Chapter 13 —- Compliance and Regulatory Requirements
- OWASP Top 10 for LLM Applications
- EU AI Act security requirements
- SOC 2 implications for AI
- Automated compliance evidence collection
- Common mistakes
- Exercises
- Summary
Chapter 14 —- Building a Security-First AI Practice
- The DevSecAI workflow
- Threat modeling for AI systems
- Security training program
- The security champion model
- Security metrics and reporting
- Common mistakes
- Exercises
- Summary