Adversarial machine learning

On this page 7

Adversarial machine learning is the field that studies how attackers deliberately manipulate machine learning systems and how those systems can be made robust against such manipulation. It forms the technical core of AI security, covering attacks at training time, at inference time and against the confidentiality of models and data.

The field rests on a simple observation: learned models generalize from statistical patterns, not from rules, so an adversary who understands those patterns can craft inputs or data that steer the model toward a chosen error. Classic examples include adversarial examples that fool image classifiers with imperceptible noise, while modern examples include prompt injection against large language models.

How adversarial attacks exploit learned models

Adversarial attacks exploit the fact that a model’s decision boundary is only approximately aligned with human concepts. In high-dimensional input spaces, a point that a human sees as clearly belonging to one class often lies very close to a boundary, so a small, targeted perturbation can move it across.

Attacks are usually formulated as an optimization problem: find the smallest change to an input, measured by a norm such as L-infinity or L2, that maximizes the model’s loss or forces a target label. Gradient-based methods such as the fast gradient sign method solve this in one step, while the projected gradient descent attack iterates and is considered a strong first-order baseline.

A practically important property is adversarial transferability: perturbations crafted against one model often fool other models trained on similar data. Transferability enables black-box attacks, in which the attacker trains a surrogate model, crafts examples against it and then uses them on a target system whose internals remain hidden.

Attacks are not limited to digital inputs. Physical adversarial attacks print perturbations as patches, stickers or textures that survive changes in lighting, distance and viewing angle. Methods such as expectation over transformation optimize a perturbation across many simulated conditions, which makes real-world attacks on cameras and sensors feasible, although usually less reliable than purely digital ones.

Taxonomy of attacks in adversarial machine learning

Adversarial machine learning classifies attacks by lifecycle stage, attacker goal and attacker knowledge. Taxonomies such as NIST AI 100-2 and MITRE ATLAS organize the field along these axes, and the table below summarizes the main attack classes.

Attack classLifecycle stageAttacker goalTypical example
Evasion attackInferenceCause misclassification of a crafted inputNoise that turns a stop sign into a speed limit sign
Data poisoningTrainingDegrade the model or plant a backdoorLabel flipping or clean-label poisoning
Model extractionInferenceCopy model functionality through queriesTraining a clone on API responses
Membership inferenceInferenceLearn whether a record was in training dataConfidence-based tests on medical records
Model inversionInferenceReconstruct sensitive training featuresRecovering face images from a classifier
Prompt injectionInferenceOverride instructions of an LLM applicationHidden instructions in a retrieved web page
Main attack classes and their targets

Attacker knowledge ranges from white-box access, with full knowledge of weights and gradients, to black-box access, with only query results or even only final labels. Security evaluations should state the threat model explicitly, because a defense that resists black-box attacks may fail immediately under white-box conditions.

Defenses and their trade-offs

Defenses in adversarial machine learning aim to raise the cost of attacks or to provide guarantees, and each one involves trade-offs in accuracy, compute or usability. No single defense covers every attack class, so practical systems combine several layers.

DefenseProtects againstMain cost or weakness
Adversarial trainingEvasion within a chosen perturbation boundHigher training cost, lower clean accuracy
Certified robustnessEvasion within a provable radiusSmall certified radii, expensive inference
Randomized smoothingL2-bounded evasion with guaranteesMany samples per prediction
Data provenance and filteringPoisoning and backdoorsCannot catch all clean-label attacks
Differential privacyMembership inference and inversionReduced utility at strong privacy levels
Rate limiting and query monitoringModel extractionSlows but rarely prevents extraction
Common defenses compared

A recurring lesson is the danger of gradient masking. Defenses that hide or distort gradients, including early proposals such as defensive distillation, often appear robust against gradient attacks but fail against adaptive attacks designed specifically to circumvent them.

Adversarial machine learning for language models

Large language models extend adversarial machine learning from numeric perturbations to natural language manipulation. The input space is discrete, but the core problem is unchanged: the model cannot reliably separate trusted instructions from untrusted data.

Classic attackLLM counterpartShared weakness
Evasion with pixel noiseJailbreak with crafted suffixesInputs steer outputs outside intended behavior
Data poisoningRAG poisoning or memory poisoningUntrusted data enters the model’s context or weights
Backdoor triggerSleeper behavior in fine-tuned modelsHidden trigger activates attacker behavior
Model extractionDistillation from API outputsOutputs reveal learned knowledge
Classic and LLM-era attack counterparts

Defenses for LLM systems emphasize architecture over model hardening: instruction hierarchy, input spotlighting, the dual LLM pattern and strict limits on tool permissions. Red-teaming tools such as garak and PyRIT automate the search for jailbreaks and injection paths before deployment.

Limitations and open problems

Adversarial machine learning remains an arms race with few final answers. Robustness in one threat model rarely transfers to another, and evaluations are only as strong as the attacks used to test them.

  • Robustness versus accuracy: robust models often lose several points of clean accuracy on standard benchmarks.
  • Unrealistic threat models: small Lp-norm bounds do not capture physical patches, semantic changes or natural language attacks.
  • Weak evaluations: many published defenses were later broken by adaptive attacks.
  • Scale of modern models: certified methods scale poorly to large networks and long text inputs.

For these reasons, practitioners treat adversarial robustness as one part of AI threat modeling and secure engineering, rather than as a property a model either has or lacks.

Explained without jargon

Adversarial machine learning is about people trying to trick AI on purpose, and about stopping them. An AI model learns from examples. It does not understand the world the way people do. So a clever attacker can find tiny changes that confuse it.

A few stickers on a road sign can make a car’s camera misread it. A hidden sentence on a web page can make a chatbot ignore its rules. Researchers in this field study such tricks. They then build models and systems that resist them better.

A typical use case

A company deploys an email security model that classifies incoming messages as phishing or legitimate. Before launch, its security team runs an adversarial evaluation. Using a surrogate model and character-level perturbations, testers find that inserting invisible Unicode characters and synonym swaps lets about one in five phishing samples evade detection.

The team responds with three measures. It normalizes text before classification, adds adversarially generated phishing samples to the training set, and limits how many verdict queries an external sender can trigger. A repeat evaluation shows the evasion rate dropping to a few percent, with a small loss in clean accuracy that the team accepts. The findings are recorded in the system’s threat model and retested every quarter.