Key takeaway
- Adversarial attacks change images to fool vision models. See evasion, poisoning and extraction attacks, the main defences, and how to test robustness.
An adversarial attack on a computer vision model is a deliberately crafted change to an input, often too small for a person to notice, that makes the model produce a wrong result. Defences exist, such as training on adversarial examples, checking inputs and monitoring in production, but none of them removes the risk completely.
This guide is for ML engineers, security teams and product owners who run computer vision in settings where a wrong prediction is costly, such as medical imaging, document checks in finance, driver assistance and face recognition and detection. It covers the main attack types, the defences and how to test them, how AI agents help operate them, and what to do first.
What are adversarial attacks in computer vision?
Adversarial examples are inputs that are, in the words of the Madry and colleagues paper, "almost indistinguishable from natural data" yet get misclassified by a neural network. A photograph with a few altered pixels, a sticker on a sign or a patterned frame can be enough to flip a prediction while looking normal to a person.
The field has a shared vocabulary. NIST AI 100-2 E2025, published by the US National Institute of Standards and Technology in March 2025, provides a taxonomy of concepts and terminology for adversarial machine learning, organised around attacker goals, objectives, capabilities and knowledge. Use it to agree on terms before you write a threat model.
What types of attack should you plan for?
Attacks differ by when they happen and what the attacker wants. The NIST page lists evasion, data poisoning, abuse and privacy breach among its keywords; the table below describes the three that matter most for vision models.
| Attack | When it happens | What the attacker does | Typical goal |
|---|---|---|---|
| Evasion | At inference, on live inputs | Adds a small crafted perturbation to an image | Cause a wrong label or a missed detection |
| Data poisoning | During training or fine-tuning | Inserts altered or mislabelled images into the training data | Plant a hidden behaviour or degrade accuracy |
| Privacy and extraction | Against a deployed model | Queries the model repeatedly to infer training data or copy its behaviour | Expose private data or steal the model |
Your exposure depends on access. A public API invites repeated probing, while a closed on-device model is harder to query but can still be reached through the physical world, for example through printed patterns in front of a camera.
How do you defend a vision model against adversarial inputs?
No single defence is enough, so teams layer them. The Madry and colleagues paper frames robustness as a robust optimisation problem and reports training methods that give networks significantly improved resistance to a wide range of attacks. That is the basis of adversarial training: you train on perturbed examples as well as clean ones.
| Defence | What it does | Watch out for |
|---|---|---|
| Adversarial training | Trains the model on adversarial examples so it learns to resist them | Extra training cost, and protection is limited to the threat model you trained against |
| Input preprocessing | Cleans or transforms images before the model sees them, for example by resizing or denoising | An attacker who knows the preprocessing can design around it |
| Data augmentation | Widens the variety of training images, in line with data augmentation practice | Improves general robustness but is not a guarantee against targeted attacks |
| Ensembles | Combines several models so one fooled model is outvoted | More compute and more models to maintain |
| Robust architectures | Tests newer designs such as Vision Transformers against your own attack suite | Do not assume a newer architecture is safer until you measure it |
| Monitoring | Tracks input distribution and confidence in production | Needs agreed alert thresholds and a person to respond |
Be careful with defences that hide a model's gradients or distil its outputs. The Madry paper argues for evaluating robustness against clearly defined classes of adversary rather than only against attacks you already know, because a defence tested against a narrow set can give false confidence.
How do you test whether a model is robust?
Start with a written threat model: who the attacker is, what they can see and change, and what a failure costs. Then evaluate against that adversary, report accuracy under attack beside clean accuracy, and keep a held-out set of attacks that were never used for training or tuning. Repeat the test after every retrain, because robustness can regress when data or architecture changes.
Expect trade-offs. Robust training usually costs compute and can lower accuracy on clean images, so set the acceptable balance with the business owner of the use case, not only with the data science team. Related fields such as augmented and virtual reality face the same issue wherever a camera feeds a model, and the broader topic sits within explainable AI and machine learning practice.
How do AI agents change adversarial defence?
Defence is ongoing work, which suits agents. An agent can run your attack suite on every new model version, compare accuracy under attack with the last release, watch live input statistics for drift, and route low-confidence predictions to a human reviewer. The decision to block a model release or retrain should stay with people and follow a recorded policy. NexaStack is XenonStack's inference infrastructure, the layer where vision models are served and where such checks are applied.
What should you do first?
- List the vision models in production and what a wrong prediction costs for each.
- Write a threat model for the highest-risk one: attacker access, goals and limits.
- Adopt shared terms from the NIST taxonomy so security and ML teams mean the same thing.
- Build a small attack test set and record accuracy under attack as a release metric.
- Add input and confidence monitoring with a named owner and an escalation path.
To map one decision your agents make, and the data and policy it depends on, book a Context Workshop. See what happens in the workshop.
Adversarial attacks pose significant risks to critical fields such as healthcare, finance, and autonomous driving, making it crucial to develop protective measures against these attacks to prevent AI system compromises
Defensive methods like adversarial training, defensive distillation, data augmentation, regularizations are essential for enhancing robustness of machine learning models and effectively countering adversarial threats
See agentic video intelligence on your own cameras. XenonStack Vision AI agents search, summarise and investigate video, then act within the decision boundaries you set. Explore xenonstack.ai
Frequently asked questions
What is an adversarial example?
It is an input changed in a way a person would barely notice that causes a model to give a wrong answer. Madry and colleagues describe such inputs as almost indistinguishable from natural data.
What is the difference between evasion and poisoning attacks?
Evasion attacks alter inputs at inference time to fool a trained model, while poisoning attacks corrupt the training data so the model learns the wrong behaviour.
Does adversarial training make a model fully secure?
No. It improves resistance against the attacks used in training, and robustness should be judged against a clearly defined adversary rather than a narrow set of known attacks.
Where can I find standard terminology for these attacks?
NIST AI 100-2 E2025 provides a taxonomy and terminology of attacks and mitigations in adversarial machine learning, organised around attacker goals, objectives, capabilities and knowledge.
Can AI agents help defend vision models?
They can automate repeated checks such as running attack tests on each release and monitoring live inputs, while people keep decisions on blocking or retraining.
Follow XenonStack on LinkedIn: XenonStack on LinkedIn for new guides on agentic AI, data and platform engineering.
Ready to put AI agents to work? Explore ElixirClaw, the agentic OS platform to build, orchestrate and govern AI agents.
Explore the XenonStack platform family: ElixirData · ElixirClaw · ElixirHub · NexaStack · MetaSecure · Neural AI · AgentGRC · AgentSRE · AgentAnalyst · AgentInstruct · AgentRAI · AgentScrum · AgentSearch · AgentForce · AI Aviator · SAIF Aviator · CohortIQ · XenonStack AI · XenonStack UAE