Join our Newsletter — 33% off our NHI Course
Home› Guides› Adversarial Robustness Toolbox Guide: Testing ML Model Defences
Guide AI Threats & Model Security

Adversarial Robustness Toolbox Guide: Testing ML Model Defences

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 8 November 2026 10 min read
On this page

Machine learning teams ship image, tabular, audio and detection models with accuracy figures but no evidence of how those models behave under deliberate manipulation, and that gap is where evasion, poisoning, extraction and inference attacks succeed. The Adversarial Robustness Toolbox (ART) is an open-source Python library, hosted by the LF AI & Data Foundation, that lets defenders run those attacks against their own models in a controlled way, apply defences and measure the result. This guide explains how ART is organised, the evaluation workflows it supports, how to run it safely and how to turn its outputs into hardening decisions and metrics. It is for ML engineers, AI red teams and model risk reviewers working on predictive models. The attack theory itself is covered in the Adversarial Examples and Evasion Attacks Guide; this page is about the tool.

This is an independent guide from NHI Mgmt Group, based on ART's public documentation as of November 2026. It is not sponsored or reviewed by the ART project or LF AI & Data. Features change, so confirm settings against ART's current documentation.

Key takeaways

  • Four threat families in one library. ART implements evasion, poisoning, extraction and inference attacks, so one harness can test a model against all four ATLAS technique areas.
  • Estimators make it framework-agnostic. You wrap a PyTorch, TensorFlow, Keras, scikit-learn, XGBoost, LightGBM, CatBoost or black-box model in an ART estimator, and every attack and defence works against that wrapper.
  • Defences come in five types. Preprocessors, postprocessors, trainers, transformers and detectors, from feature squeezing and spatial smoothing to adversarial training and Neural Cleanse.
  • Measure, do not just attack. Robustness metrics (CLEVER, empirical robustness, loss sensitivity), randomised smoothing certification and privacy metrics (PDTP, SHAPr) turn experiments into numbers you can track.
  • Mature open governance. IBM contributed ART to LF AI & Data in June 2020, it is now a graduated project (LF AI & Data announced the graduation in May 2022), and it is released under the MIT licence.

What the tool does

ART describes itself as a Python library for machine learning security that helps developers and researchers evaluate, defend, certify and verify models against adversarial threats, for both red and blue team work. It covers images, tables, audio and video, and tasks including classification, object detection, speech recognition and generation. It is installed from PyPI with pip install adversarial-robustness-toolbox; framework support is added with extras such as [pytorch], [tensorflow] or [all], because the core package does not pull in deep learning frameworks.

Library structure

ModulePurposeRepresentative contents (from the ART wiki and API docs)
art.estimatorsWrap models so attacks and defences can query predictions and gradientsPyTorchClassifier, KerasClassifier, BlackBoxClassifier; object detection (Faster R-CNN, YOLO), speech recognition, regression and certification estimators
art.attacks.evasionCraft inputs that cause misclassification at inferenceWhite box: Fast Gradient Method, PGD, Auto-PGD, Carlini and Wagner, DeepFool. Black box: Square Attack, HopSkipJump, SimBA, ZOO, Boundary Attack
art.attacks.poisoningCorrupt training data or plant backdoorsBackdoor, Clean-Label Backdoor, Hidden Trigger Backdoor, Sleeper Agent, poisoning attack on SVMs
art.attacks.extractionReplicate a model through its query interfaceCopycat CNN, KnockoffNets, Functionally Equivalent Extraction
art.attacks.inferenceInfer membership, attributes or training dataMembership Inference Black-Box, Label-Only Gap Attack, Attribute Inference, MIFace model inversion, Database Reconstruction
art.defencesReduce attack successPreprocessor, postprocessor, trainer, transformer and detector defences (see below)
art.metricsQuantify robustness and privacyempirical_robustness, clever_u, clever_t, loss_sensitivity, PDTP, SHAPr

Estimator constructors take parameters that shape every test: clip_values sets the valid input range, preprocessing captures normalisation, and preprocessing_defences and postprocessing_defences attach defences so attacks are evaluated against the defended model.

Defender use cases

Mapping ART to threats and controls

Threat (MITRE ATLAS)ART attack modules to test withART defences and metrics to evaluateRelated guide
AML.T0015 Evade AI Model; AML.T0043 Craft Adversarial DataEvasion: PGD, Auto-PGD, Square Attack, HopSkipJumpAdversarial training (Madry's protocol), spatial smoothing, feature squeezing; empirical robustness, CLEVER, randomised smoothingAdversarial Examples and Evasion Attacks Guide
AML.T0020 Training Data PoisoningPoisoning: backdoor and clean-label backdoor attacksActivation clustering detection, spectral signatures, data provenance, Neural Cleanse, STRIPAI Data Poisoning and Backdoors Guide
AML.T0024.002 Extract AI ModelExtraction: Copycat CNN, KnockoffNetsPostprocessors: Reverse Sigmoid, Rounding, Class Labels, High Confidence, Random NoiseModel Extraction and Distillation Defence Guide
AML.T0024.000 Infer Training Data MembershipInference: Membership Inference Black-Box, Label-Only Gap AttackPDTP and SHAPr privacy metrics; DP-InstaHide trainingMembership Inference Attacks
AML.T0024.001 Invert AI ModelInference: MIFace, attribute inferenceOutput obfuscation postprocessorsAdversarial ML Taxonomy Guide
  • Pre-release robustness testing: attack a candidate model at several perturbation budgets and record accuracy under attack beside clean accuracy. This is evidence for ATLAS AML.M0008 Validate AI Model.
  • Defence selection: run the same attack against the undefended and defended estimator to measure what a preprocessor or adversarial training actually buys, at what cost to clean accuracy.
  • Training data assurance: run poisoning detectors over a dataset from an external or crowd-sourced source before training, supporting AML.M0007 Sanitize Training Data.
  • Privacy review: score per-record membership risk with SHAPr or PDTP before a model trained on personal data is exposed through an API.
  • API exposure decisions: test how much an extraction attack recovers when the API returns full probabilities versus labels only, then choose the output format.

Deployment and safe use

ART runs locally against models you own. It is a testing library, and the safe use rules are about authorisation, data handling and reproducibility.

  1. Get authorisation and scope. Test only models your organisation owns or has written permission to test. Black-box attacks against a third-party API can violate its terms of service and generate large query volumes.
  2. Isolate the environment. Install ART and its framework extras in a dedicated virtual environment or the project's Docker build, with pinned versions. Confirm the current release on the GitHub repository before pinning.
  3. Use copies, not production artefacts. Load a copy of the model weights and a test split. Poisoning experiments create backdoored datasets and models: label them clearly, keep them out of model registries and delete them after the test.
  4. Protect training data. Inference attacks are designed to reveal training records. Run them only where the tester is already allowed to see that data, and treat outputs as sensitive.
  5. Start with the example scripts. The repository's examples/ folder has a minimal example per framework and notebooks/ has detailed tutorials. Reproduce one on your framework before adapting it.
  6. Wrap the model correctly. Set clip_values and preprocessing to match production input handling; a mismatch produces misleading robustness figures.
  7. Fix seeds and record parameters. Log attack name, norm, perturbation budget, iterations and library version with every result so the test can be rerun after a change.
  8. Roll back safely. If a defence lowers clean accuracy beyond the agreed tolerance, revert to the previous model version and record why. Our recommendation at NHI Mgmt Group: agree that tolerance with the model owner before testing.

Pipelines that pull ART, framework packages and pretrained weights are part of your software supply chain. Pin dependencies and verify sources as described in the OWASP LLM Top 10 LLM03 Supply Chain Guide.

Detection and hardening value

Choosing a defence type

ART defence typeWhen it fitsTrade-off to measure
Preprocessor (feature squeezing, spatial smoothing, JPEG compression)Quick protection for an existing model without retrainingOur view at NHI Mgmt Group: adaptive attacks that account for the preprocessor may still succeed, so retest with them
Trainer (adversarial training, Madry's protocol, certified adversarial training)Models in high-risk decisions where retraining is acceptableTraining cost and possible clean accuracy loss
Postprocessor (Reverse Sigmoid, Rounding, Class Labels)Models exposed through an API where extraction or inference is the concernLess information for legitimate consumers of scores
Transformer (Neural Cleanse, STRIP, defensive distillation)Suspected backdoors in a trained modelCompute cost; confirm with poisoning detectors
Detector (activation analysis, spectral signatures, input detectors)Screening datasets or flagging suspicious inputs at runtimeFalse positive rate on normal traffic

Report results as curves, not single numbers: robust accuracy plotted against perturbation budget shows where a defence stops helping, and a defence that only works at one budget is fragile. Our recommendation at NHI Mgmt Group is to include at least one black-box attack, such as Square Attack or HopSkipJump, in every suite, because white-box gradient attacks alone can overstate robustness when a defence masks gradients.

Small teams should start with evasion testing and one preprocessor or postprocessor on their highest-impact model. Larger programmes can build an ART harness into model CI that runs a fixed attack suite on every retrain and blocks release when robustness drops.

Metrics to track

  • Robust accuracy: accuracy under a fixed attack and perturbation budget, per model version.
  • Empirical robustness: average minimal perturbation needed for misclassification; higher is better.
  • Clean accuracy cost: change in clean accuracy after each defence is applied.
  • Membership leakage: share of training records with a SHAPr score above zero.
  • Extraction fidelity: agreement between a stolen surrogate model and the original at a fixed query budget.
  • Coverage: share of production models with a current ART test report.

Framework mapping

FrameworkReferenceHow ART testing supports it
MITRE ATLAS mitigationsAML.M0003 Predictive AI Model Hardening; AML.M0002 Predictive AI Output Obfuscation; AML.M0015 Predictive AI Adversarial Input DetectionTrainers, postprocessors and detectors implement these mitigations; attacks verify them
NIST SP 800-53 Rev. 5SA-11 Developer Testing and Evaluation; RA-3 Risk AssessmentTest reports evidence model testing and inform AI risk assessments
NIST CSF 2.0ID.RA-01Weaknesses found by attacks are identified, validated and recorded

The threat taxonomy behind these categories is set out in NIST AI 100-2; see the Adversarial ML Taxonomy Guide.

Alternatives

ART focuses on predictive models and classical adversarial ML. Related needs are served by other approaches:

  • LLM and agent evaluation frameworks: for prompt injection, jailbreak and agent safety testing of generative models, use an evaluation framework with sandboxed tool execution. See the Inspect AI Guide.
  • Framework-specific robustness libraries: some deep learning ecosystems offer their own adversarial example and certification utilities, useful when a team works in one framework only.
  • Formal verification tools: for small, safety-critical networks where provable bounds matter more than empirical attack results.
  • Managed AI red teaming services: for organisations without in-house ML security expertise. The AI Red Teaming and Testing Tools Buyer's Guide sets out evaluation criteria.

Practitioner checklist

  • Confirm written authorisation and scope before testing any model.
  • Install ART with pinned versions in an isolated environment, with only the framework extras you need.
  • Wrap models with clip_values and preprocessing that match production.
  • Test each relevant family: evasion, poisoning, extraction and inference.
  • Evaluate defences against adaptive attacks, not only the attack they were tuned for.
  • Record robust accuracy, empirical robustness and clean accuracy cost per model version.
  • Score membership risk with SHAPr or PDTP for models trained on personal data.
  • Keep poisoned datasets and backdoored models out of registries and delete them after tests.
  • Add a fixed ART attack suite to model CI for high-impact models.

Standards and references

Related NHI Mgmt Group resources: Adversarial Examples and Evasion Attacks Guide · AI Data Poisoning and Backdoors Guide · Model Extraction and Distillation Defence Guide · Inspect AI Guide

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 8 November 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org