Skip to main content
XenonStack

XAI

XenonStack Blog Adversarial Attacks in Computer Vision and Defences

| Published | Updated

Adversarial Attacks in Computer Vision and Defences
16:11

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.

AttackWhen it happensWhat the attacker doesTypical goal
EvasionAt inference, on live inputsAdds a small crafted perturbation to an imageCause a wrong label or a missed detection
Data poisoningDuring training or fine-tuningInserts altered or mislabelled images into the training dataPlant a hidden behaviour or degrade accuracy
Privacy and extractionAgainst a deployed modelQueries the model repeatedly to infer training data or copy its behaviourExpose 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.

Two-column diagram. Attacks: evasion, data poisoning, model extraction, privacy attacks. Defences: adversarial training, input checks, ensembles, monitoring.
DefenceWhat it doesWatch out for
Adversarial trainingTrains the model on adversarial examples so it learns to resist themExtra training cost, and protection is limited to the threat model you trained against
Input preprocessingCleans or transforms images before the model sees them, for example by resizing or denoisingAn attacker who knows the preprocessing can design around it
Data augmentationWidens the variety of training images, in line with data augmentation practiceImproves general robustness but is not a guarantee against targeted attacks
EnsemblesCombines several models so one fooled model is outvotedMore compute and more models to maintain
Robust architecturesTests newer designs such as Vision Transformers against your own attack suiteDo not assume a newer architecture is safer until you measure it
MonitoringTracks input distribution and confidence in productionNeeds 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?

  1. List the vision models in production and what a wrong prediction costs for each.
  2. Write a threat model for the highest-risk one: attacker access, goals and limits.
  3. Adopt shared terms from the NIST taxonomy so security and ML teams mean the same thing.
  4. Build a small attack test set and record accuracy under attack as a release metric.
  5. 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.

virtual-reality

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

virtual-reality

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.

Table of Contents

dr-jagreet-gill

Dr. Jagreet Kaur

Chief AI Officer, XenonStack

LinkedIn profile

Dr. Jagreet Kaur specializing in Generative AI for synthetic data, Conversational AI, and Intelligent Document Processing. With a focus on responsible AI frameworks, compliance, and data governance, she drives innovation and transparency in AI implementation

Get the latest articles in your inbox

Subscribe Now

Interested in solving your challenges with the XenonStack team?
Get Started

Tell us about you and your priorities so we can prepare the right conversation. It takes about 2 minutes.

Please Select your Industry
Banking
Fintech
Payment Providers
Wealth Management
Discrete Manufacturing
Semiconductor
Machinery Manufacturing / Automation
Appliances / Electrical / Electronics
Elevator Manufacturing
Defense & Space Manufacturing
Computers & Electronics / Industrial Machinery
Motor Vehicle Manufacturing
Food and Beverages
Distillery & Wines
Beverages
Shipping
Logistics
Mobility (EV / Public Transport)
Energy & Utilities
Hospitality
Digital Gaming Platforms
SportsTech with AI
Public Safety - Explosives
Public Safety - Firefighting
Public Safety - Surveillance
Public Safety - Others
Media Platforms
City Operations
Airlines & Aviation
Defense Warfare & Drones
Robotics Engineering
Drones Manufacturing
AI Labs for Colleges
AI MSP / Quantum / AGI Institutes
Retail Apparel and Fashion

Continue