Adversarial Machine Learning
Understanding Attacks, Defenses, and the Future of AI Security
Build secure and resilient AI systems by mastering the landscape of adversarial machine learning.
207 pages9 chaptersAug 5, 2026Machine Learning
About this book
This comprehensive guide takes you from foundational concepts to advanced defense strategies, equipping you with the knowledge to protect your models against sophisticated attacks. You'll explore how adversarial examples expose vulnerabilities in neural networks, understand the mechanics of evasion and poisoning attacks, and discover proven defense mechanisms that work in practice. Through clear explanations, practical examples, and real-world case studies, you'll learn to think like an attacker to defend like an expert. Whether you're developing autonomous systems, deploying facial recognition, or building medical AI, this book provides the essential framework for understanding and mitigating adversarial risks. Gain the skills to evaluate your model's robustness, implement effective defenses, and make informed security decisions in your AI projects.
Table of contents
- IntroductionWhy Adversarial Machine Learning Matters, What This Book Covers, How to Use This BookRead below
- Chapter 1: Foundations of Adversarial Machine LearningWhat Are Adversarial Examples?, Understanding Threat Models and Assumptions, The Adversarial Landscape in AI
- Chapter 2: Evasion Attacks: Fooling Models at Test TimeEvasion Attack Fundamentals, Gradient-Based Attack Methods, Black-Box and Query-Based Attacks, Adversarial Examples in the Physical World
- Chapter 3: Poisoning Attacks: Corrupting Training DataPoisoning Attack Overview, Targeted and Untargeted Poisoning, Backdoor Attacks and Trojan Models
- Chapter 4: Model Extraction and Privacy AttacksModel Extraction and Stealing, Membership Inference Attacks, Privacy Risks in Machine Learning
- Chapter 5: Adversarial Training and Robust ModelsAdversarial Training Techniques, The Robustness-Accuracy Tradeoff, Advanced Training Strategies for Robustness
- Chapter 6: Certified Defenses and Formal VerificationCertified Robustness Guarantees, Randomized Smoothing and Verification, Formal Verification of Neural Networks
- Chapter 7: Detection and Mitigation StrategiesDetecting Adversarial Examples, Input Preprocessing and Sanitization, Ensemble Methods and Defensive Diversity
- Chapter 8: Real-World Applications and Case StudiesAdversarial Threats in Autonomous Systems, Attacks on Facial Recognition and Biometrics, Adversarial Risks in Medical AI, Adversarial Attacks on NLP Systems
- Chapter 9: Evaluating and Testing RobustnessMetrics for Measuring Robustness, Testing and Evaluation Frameworks, Benchmarking Against Standard Attacks
- ConclusionKey Takeaways and Best Practices, The Future of Adversarial Machine Learning
- Glossary
- Further Reading and Resources
Introduction
A self-driving car misreads a stop sign because someone placed a few carefully positioned stickers on it. A spam filter lets a malicious email through because an attacker added invisible whitespace characters to the subject line. A medical imaging model confidently misclassifies a cancerous lesion because a tiny, imperceptible pattern was embedded in the scan. None of these failures look like bugs in the traditional sense. The models are working exactly as trained. The problem is that someone figured out how to work against them.
These are not hypothetical scenarios. Researchers have demonstrated each of them in controlled settings, and the underlying techniques are well-documented in the academic literature. What makes them unsettling is not their complexity but their simplicity. In many cases, a small, deliberate change to an input, one that a human observer would never notice, is enough to completely derail a state-of-the-art machine learning model. The gap between human perception and model behavior turns out to be a surprisingly exploitable surface.
Adversarial machine learning is the field that studies this gap. It asks two fundamental questions: how can machine learning systems be attacked, and how can they be defended? Those questions sound straightforward, but the answers are layered, technically rich, and still actively contested. The field has grown rapidly since the early 2010s, driven by the widespread deployment of deep learning in security-critical applications and by a research community that has developed increasingly sophisticated tools for both offense and defense.
This book is a guide through that landscape. It is written for software engineers, AI practitioners, and computer science professionals who already have a working understanding of machine learning and want to understand where it breaks, why it breaks, and what can be done about it. The goal is not to survey every paper ever published on the topic. The goal is to give you a clear, practical, and honest picture of the field so that you can make better decisions when building and deploying ML systems in the real world.
Why Adversarial Machine Learning Matters
Machine learning models are no longer confined to research labs. They make decisions in credit scoring, medical diagnosis, content moderation, fraud detection, and autonomous navigation. As these systems take on more consequential roles, the question of whether they can be deliberately manipulated becomes a practical engineering concern, not just an academic curiosity. A model that performs well on a benchmark but fails under adversarial conditions is not actually reliable in the environments where reliability matters most.
The core problem is that standard machine learning training optimizes for average-case performance. A model trained on millions of images learns to classify them correctly most of the time. But that training process does not guarantee robustness against inputs that are specifically designed to cause failures. An attacker who understands how a model works, or even one who can only observe its outputs, can often find inputs that exploit the model's blind spots. This is a fundamentally different threat than random noise or distribution shift.
Consider what happened when researchers demonstrated that a neural network trained to classify road signs could be fooled by physical stickers placed on a stop sign.[1] The stickers were designed to look like graffiti to a human observer, but they caused the model to classify the sign as a speed limit sign with high confidence. This is an example of a Physical Adversarial Example, and it illustrates why the stakes are real. A self-driving vehicle relying on that model would behave incorrectly at an intersection.
The threat is not limited to vision systems. Natural language processing models can be manipulated by inserting specific words or characters into text. Audio recognition systems can be fooled by imperceptible perturbations in sound files. Malware classifiers can be evaded by attackers who understand which features the model relies on. In each domain, the same underlying principle applies: a model that has learned a statistical mapping from inputs to outputs can be exploited by anyone who understands that mapping well enough to craft inputs that produce a desired, incorrect output.
What makes this especially challenging is the asymmetry between attacker and defender. An attacker needs to find only one effective perturbation. A defender needs to anticipate and block all of them. This asymmetry is not unique to machine learning, but it is particularly sharp here because the attack surface is high-dimensional and the model's decision boundaries are complex and often poorly understood even by the people who built the model.
There is also a competitive dynamic at work. As new defenses are proposed, researchers develop Adaptive Attack strategies that are specifically designed to defeat those defenses. Many defenses that appeared promising in initial evaluations were later shown to be ineffective against adaptive attackers. This back-and-forth has shaped the field significantly and is one reason why rigorous evaluation methodology matters as much as the defenses themselves.
Understanding adversarial machine learning is not just about protecting against malicious actors. It also reveals something fundamental about how neural networks represent and process information. The existence of Adversarial Examples tells us that models can achieve high accuracy on standard benchmarks while relying on features that are brittle, non-intuitive, and easily manipulated. That insight has implications for model interpretability, generalization, and trustworthiness that extend well beyond security applications.
A model that achieves 99% accuracy on a clean test set but drops to 10% accuracy under a simple adversarial attack is not a 99% accurate model in any meaningful sense for a security-critical deployment. Accuracy on clean data and robustness under attack are different properties, and both need to be measured.
The practical implication is clear. If you are building or deploying machine learning systems in any context where an adversary might interact with them, or where the cost of a wrong prediction is high, you need to understand adversarial threats. That includes not just obvious security applications like intrusion detection or fraud prevention, but also medical AI, content moderation, and any system where users might have an incentive to game the model's outputs.
What This Book Covers
The field of adversarial machine learning spans a wide range of attack types, defense strategies, theoretical frameworks, and application domains. This book organizes that material into a coherent progression, starting from foundational concepts and building toward advanced techniques and real-world applications. Each topic is treated with enough depth to be genuinely useful, without assuming prior familiarity with the adversarial ML literature.
The book begins by establishing the conceptual vocabulary that everything else depends on. The chapter on foundations introduces Adversarial Examples, explains what a Threat Model is and why it matters, and maps out the major categories of attacks and defenses. Getting this vocabulary right early is important because the field uses precise terminology that carries specific technical meaning. A White-Box Attack is not the same as a Black-Box Attack, and a Perturbation Budget is not just a vague notion of "small change." These distinctions shape how attacks are designed and how defenses are evaluated.
From there, the book covers the three major attack categories in dedicated chapters:
- Evasion Attacks are attacks that happen at inference time. The attacker crafts inputs that cause a trained model to make incorrect predictions. This includes gradient-based methods like the Fast Gradient Sign Method (FGSM), the Projected Gradient Descent Attack (PGD), and the Carlini-Wagner Attack (C&W), as well as Black-Box Attack strategies and Physical Adversarial Examples.
- Poisoning Attacks and Backdoor Attacks target the training process. An attacker who can influence the training data can degrade a model's overall performance or embed a hidden Trigger Pattern that causes specific misbehavior when activated at inference time.
- Model Extraction, Membership Inference Attacks, and Model Inversion are privacy and confidentiality attacks. They allow adversaries to steal a model's functionality, determine whether specific data was used in training, or reconstruct sensitive training data from model outputs.
The defense side of the book is equally detailed. Adversarial Training is the most widely studied empirical defense, and the book covers both its mechanics and its limitations, including the Robustness-Accuracy Tradeoff that makes it difficult to achieve high performance on both clean and adversarial inputs simultaneously. The TRADES Loss formulation is covered as a principled approach to managing that tradeoff.
Certified defenses receive their own dedicated treatment. Certified Robustness provides mathematical guarantees that a model's output cannot be changed by any perturbation within a defined Certification Radius. Techniques like Randomized Smoothing and Interval Bound Propagation (IBP) make these guarantees computationally tractable for real models. The book explains how these methods work, what they guarantee, and where their limits lie.
Detection and mitigation strategies are covered separately from training-based defenses. Adversarial Detection methods attempt to identify adversarial inputs before they reach the model. Feature Squeezing and other preprocessing techniques reduce the attack surface by removing the high-frequency perturbations that many attacks rely on. Ensemble Defense strategies use diversity across multiple models to make attacks harder to transfer. Each of these approaches has known failure modes, and the book is honest about them.
The real-world applications chapter grounds all of this in concrete domains. Autonomous vehicles, biometric systems, medical imaging, and natural language processing each present distinct adversarial threat profiles. The challenges of deploying defenses in production systems, where latency, cost, and accuracy constraints are real, are different from the challenges of demonstrating a defense in a research paper. This chapter bridges that gap.
The book closes with a chapter on evaluation methodology. Robust Accuracy, AutoAttack, RobustBench, and Adaptive Evaluation are the tools the field uses to measure whether defenses actually work. This is not a minor technical detail. A significant portion of the adversarial ML literature has been invalidated by later work showing that the evaluation methodology was flawed. Understanding how to evaluate robustness correctly is as important as understanding how to achieve it.
Throughout the book, the focus is on building genuine understanding rather than cataloging techniques. Every major concept is explained from first principles, connected to the broader picture, and illustrated with concrete examples. Where the field has open questions or genuine disagreements, those are acknowledged rather than papered over. The goal is to give you a foundation that will remain useful as the field continues to evolve, not just a snapshot of the current state of the art.
How to Use This Book
This book is designed to be read sequentially, but it is also structured so that individual chapters can stand on their own once you have the foundational vocabulary from the first chapter. The progression from foundations to attacks to defenses to evaluation follows the natural logic of the field, and reading in order will give you the clearest picture of how everything connects. That said, if you are already familiar with the basics and want to go directly to a specific topic, each chapter is self-contained enough to be useful on its own.
The assumed background is a working knowledge of machine learning. You should be comfortable with concepts like neural networks, gradient descent, loss functions, and classification. You do not need to be an expert in deep learning theory or have prior exposure to security research. The book introduces adversarial ML concepts from the ground up, building on ML fundamentals rather than assuming you already know the adversarial literature.
Here is a practical guide to navigating the content based on your goals:
- If you want a broad overview of the field: Read the foundations chapter first, then skim the attack chapters before moving to the defense chapters. The real-world applications chapter will help you connect the theory to practice.
- If you are building a system and need to assess its risk: Start with the foundations chapter to understand Threat Models, then read the attack chapter most relevant to your deployment context (evasion for inference-time threats, poisoning for training pipeline threats, extraction for API-exposed models).
- If you are implementing defenses: The chapters on adversarial training, certified defenses, and detection strategies are your primary references. Read the evaluation chapter alongside them so you can assess whether your defenses are actually working.
- If you are evaluating an existing system: Go directly to the evaluation chapter, then work backward to the attack chapters to understand what you are testing against.
The book uses a consistent set of canonical terms throughout. When a term like Perturbation Budget or Transferability is introduced, it is defined precisely and then used consistently in that sense for the rest of the book. This is intentional. The adversarial ML literature sometimes uses the same concept under different names, or uses the same name for slightly different concepts. Sticking to a consistent vocabulary makes it easier to reason clearly about the material and to connect what you read here to the broader literature.
Code and mathematical notation are used where they add clarity, not as decoration. When an attack algorithm is described, the key steps are explained in plain language first, and any formal notation is introduced to make the description more precise, not to replace the intuition. You do not need to be fluent in mathematical notation to follow the core arguments, but familiarity with basic linear algebra and probability will help you get the most out of the more technical sections.
Each chapter ends at a natural stopping point rather than with a summary of what was covered. The goal is to leave you thinking about the implications and open questions, not reviewing a list of bullet points. The field of adversarial machine learning is genuinely unsettled in many areas, and that intellectual tension is part of what makes it interesting. Where there are open problems or active debates, the book names them rather than pretending the field has reached consensus.
A few practical notes on how to engage with the material actively:
- When you encounter a new attack technique, ask yourself: what does the attacker need to know, and what can they observe? That question maps directly to the Threat Model, which determines whether the attack is realistic in your context.
- When you encounter a defense, ask: what does this defense assume about the attacker? Has it been evaluated against an Adaptive Attack that is specifically designed to defeat it? Many defenses that look strong in initial evaluations turn out to be brittle against adaptive adversaries.
- When you see a robustness claim, ask: what metric was used, what attack was used to evaluate it, and what was the Perturbation Budget? Robust Accuracy numbers are only meaningful in the context of a specific evaluation setup.
The glossary at the end of the book provides concise definitions of all canonical terms. If you encounter a term mid-chapter and want a quick reference, the glossary is the place to look. The further reading section points to key papers and resources for each major topic, organized by chapter, so you can go deeper on any area that is particularly relevant to your work.
One honest caveat: this field moves fast. New attack methods and defense techniques are published regularly, and the state of the art shifts. The foundational concepts, the threat modeling framework, the core attack categories, and the evaluation principles covered in this book are stable enough to remain relevant as the field evolves. But specific benchmark numbers and claims about which defense is currently best should always be checked against recent literature. The goal of this book is to give you the conceptual tools to understand and evaluate new developments as they emerge, not to give you a static snapshot that will be outdated in two years.
What you will find, as you work through the material, is that adversarial machine learning is not just a collection of attack tricks and defense patches. It is a lens for thinking about what machine learning models actually learn, where their representations are fragile, and what it means for a model to be trustworthy in a world where not everyone interacting with it has benign intentions. That perspective is useful far beyond the specific techniques covered here, and it is the deeper takeaway that this book is trying to convey.
Notes
Introduction
- 1. Kevin Eykholt and others, "Robust Physical-World Attacks on Deep Learning Visual Classification," IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2018
This is the end of the free sample. The full book has 9 chapters.
Want this book written for you?
Tell us your goals and background, and get your own version of this book, tailored by AI to you.
Benefits of AI-tailored books
- Read one book, not ten:
- all the Machine Learning knowledge you need, gathered into a single book.
- Save days of learning:
- tell us your goals, choose your topics, and the whole book is built around them.
- Learn effortlessly:
- Machine Learning book written for your specific background and expertise.
- Understand at a glance:
- includes charts, tables, timelines, checklists, decision trees, and more.
- Stay current:
- written the day you order it, not years ago.
- Trust what you read:
- every book is checked for accuracy, with real research when your subject needs it.
Create your unique book in 3 steps
- 1. Select your focus
Select the focus of your Machine Learning book and share your background
- 2. Personalize your book
Specify your goals and choose sub-topics to include
- 3. Get your tailored book
Your book is ready in 10 minutes. Read it online, download as EPUB or PDF, or send to Kindle.
Frequently asked questions
- What is TailoredRead?
TailoredRead creates complete, full-length nonfiction ebooks, written specifically for you. Tell us what you want to learn and why, and TailoredRead writes you a complete ebook on it, with charts, tables, and diagrams throughout. Read it online, on Kindle, or on any e-reader, or download it as a PDF or EPUB. Every book is written fresh the day you order it.
- How is the book tailored to me?
Before anything is written, you answer a few short questions about your goals, your background, and the topics you care about. Your book is then planned around your answers: written at your level, focused on your goals, and covering the topics you chose, instead of the one-size-fits-all book a store sells everyone.
- Will it read like generic AI content?
No. Your book isn't a chat transcript: it's planned chapter by chapter before a single word is written, told in a clear book voice, and explains ideas visually with charts, tables, and diagrams. After writing, every book goes through an editorial pass that polishes chapters so the book reads consistent from start to finish. Judge for yourself: browse thousands of sample books on our Explore Books page.
- How accurate is the content?
Our AI first checks whether your subject needs live research. Niche and fast-moving subjects are researched before writing, and the book plan and chapters are grounded in what it finds. After writing, every book goes through a quality pass that checks its facts and consistency, and researched books list their sources in a Notes section at the back.
- How long is the book?
You choose the length: Comprehensive (250-300 pages), Detailed (150-200 pages), Essential (70-100 pages), or Short (30-50 pages).
- Does the book include visuals?
Yes. Every book includes charts, tables, and diagrams: timelines, checklists, step-by-step guides, decision trees, comparison tables, matrices, and bar charts. A typical book includes dozens of these visual elements.
- Can I read it on Kindle? What formats can I download?
Yes. Every book can be read in our online reader or downloaded as a PDF or EPUB. The EPUB can be opened with Kindle, Apple Books, Kobo, and any e-reader. The Commercial and Author licenses also include an editable Word (DOCX) and Markdown download.
- How much does it cost?
About the price of a regular ebook. The exact price depends on your book's length and complexity, from $2 for the shortest books to $35 for the most comprehensive, and it's shown when you review your book, before you commit to anything. Each book is a one-time purchase, yours to keep, no subscription. Licenses that let you share, teach, or publish your book range from $35.99 to $49.99.
- Can I preview the book before purchasing?
Before you pay, you'll see what your book will cover: the title, a detailed description, the estimated length, and the complete chapter-by-chapter table of contents, so you know what you're getting before you decide. The full text itself is written after you purchase.
- How long does it take to create a book?
About 10 minutes. You can start reading the opening chapters while the rest is still being written.


