AI Infra
0%
Part VIII · Chapter 58

Adversarial Robustness and Red-Teaming

AuthorChangkun Ou
Reading time~12 min

Alignment is a trained disposition, not a guarantee. A model that refuses a harmful request in the average case still holds, somewhere in its weights, the capability the refusal is meant to suppress, and an adversary with access to the input can search for the phrasing that recovers it. That search, and the effort to defeat it, now has a stable shape. Four families of jailbreak attacks, prompts designed to bypass refusal, each exploit a different surface. red-teaming has become a measurement discipline rather than a one-time audit. And because every known defense is partial, adversarial robustness turns out to be a property of the system, not of the model alone.

2026-06-21T21:26:43.954623 image/svg+xml Matplotlib v3.11.0, https://matplotlib.org/
Figure 58.1. Schematic of attack success as adversarial pressure rises. Hardening bends the curve down, but stronger attacks still find surface area unless defenses keep adapting. Idealized curves, not measured data.

The boundary with the two neighboring chapters matters. Chapter 57 adds a filter around the model that inspects inputs and outputs; Chapter 56 bounds what a compromised agent can reach by scoping its authority. The problem sits between them, on the manipulation itself: how an attacker turns a refusal into compliance, how a defender measures the rate at which that succeeds, and whether the rate can be driven to zero at all.

The problem: a refusal is a soft boundary

Post-training installs refusal by example (Chapter 19): the model is shown harmful requests paired with declines and learns to reproduce the pattern. The result is a decision boundary in a space the operator cannot enumerate. Refusal holds densely over the prompts seen in training and thins out in the corners no one wrote down. An attack is a procedure for finding those corners, and the unsettling discovery of the period is that the corners are not rare accidents but a reliably reachable surface, often by automated search.

Four families of attack have stabilized, and they differ in what part of the model they exploit.

M aligned model refusal boundary H harmful completion M->H O optimization adversarial suffix (GCG) O->M MS many-shot fake dialogue in context MS->M MT multi-turn persona, crescendo MT->M I indirect injection untrusted tool content I->M
Figure 58.2. Four jailbreak families, grouped by what each exploits. Optimization attacks search token space directly; many-shot attacks exploit the long-context window; multi-turn attacks exploit conversational state; indirect injection exploits the open input channel of a tool-using agent. Defenses below address different families, and none covers all four.

The first family is optimization-based. The Greedy Coordinate Gradient (GCG) attack treats jailbreaking as a search problem: append a suffix of tokens to a harmful request and optimize the suffix by gradient, the signal that says which token change pushes the model toward the target answer, over a white-box model whose weights are fully visible, to maximize the probability that the model begins its answer with an affirmative phrase (Zou et al. 2023). The suffixes look like noise, they are found by machine rather than by a person, and the central result is that they transfer: a suffix tuned against open weights often jailbreaks closed models it never saw. Optimization turned jailbreaking from craft into a reproducible pipeline.

The second family exploits scale in the context window rather than the token search. Many-shot jailbreaking fills the prompt with a long fabricated dialogue in which an assistant answers a sequence of escalating harmful questions, then asks the real one (Anil et al. 2024). The model, completing a pattern, extends the fabricated assistant's compliance to the final question. The attack's effectiveness grows with the number of shots in a roughly power-law fashion, so the same long-context capability that makes a model useful (Chapter 35) widens the surface this attack runs on.

Figure 58.3. Many-shot jailbreaking: as the fabricated dialogue fills the context with more compliant answers, attack success climbs roughly as a power law in the number of shots. The same long context that makes a model useful widens this surface. Illustrative.

The third family is conversational. Rather than break the boundary in one shot, a multi-turn attack walks the model across it. A persona attack asks the model to role-play a character not bound by the policy; a crescendo attack opens with a benign request and escalates over several turns, each step a small increment from an answer the model already gave, so no single turn looks like a violation (Russinovich et al. 2024). These attacks exploit that the model conditions on its own prior outputs, and that a request is judged against the visible turn rather than the trajectory.

The fourth family does not come through the user at all. Indirect prompt injection plants instructions in content the agent will read as data: a web page, a document, a tool's output (Greshake et al. 2023). When the agent ingests that content, it cannot reliably tell the planted instruction from the operator's. This is the family that breaks agents specifically, because an agent's reason for existing is to read untrusted external content and act on it. It is the hinge between adversarial robustness and Chapter 56, and the constraint arrow below names why no model-level fix closes it.

Red-teaming as measurement, not audit

If attacks are a reliably reachable surface, then a one-time security review is the wrong instrument. What a deployer needs is a continuous estimate of how often an adversary succeeds, recomputed as both the model and the attacks change. Red-teaming is that estimate, and treating it as a measurement discipline, with a metric, a dataset, and a reproducible harness, is what separates it from anecdote.

The metric is attack success rate: over a fixed set of harmful behaviors and a fixed attack method, the fraction of attempts that elicit a genuinely harmful completion. Whether the number can be trusted lives in the judge that decides what counts as harmful, which is itself a model or a rubric and carries the same construct-validity worries as any judge (Chapter 50). A standardized harness fixes the behaviors, the attacks, and the judge so that two models or two defenses can be compared on the same footing; HarmBench is one such framework, pairing a behavior set with a battery of attacks and an automated classifier (Mazeika et al. 2024). The harmful-behaviors dataset that the GCG work introduced, often called AdvBench, became a common substrate underneath many of these evaluations (Zou et al. 2023).

Generating the attacks is itself automatable, and this is where red-teaming scales past a human team. A language model can be pointed at a target and asked to generate prompts that make it misbehave, then trained on which of its prompts succeeded, turning attack discovery into its own optimization loop (Perez et al. 2022). Automated red-teaming widens coverage far beyond what a human team can hand-write, at the cost that it finds the attacks its generator is shaped to find and can miss whole families the generator never models. Human red teams remain the source of genuinely novel attack classes; the automation amortizes them across every model release.

Constraint arrow

The harness in Chapter 41 reads untrusted content by construction: an agent that cannot ingest a web page or a tool result cannot do its job. That open input channel dictates that indirect injection cannot be closed at the prompt layer, because the model has no reliable channel-level signal separating the operator's instruction from one planted in the data it was asked to read. The defense therefore cannot live in the model. It moves down to authority scoping (Chapter 56), which bounds what a manipulated agent can reach, and out to runtime filtering (Chapter 57), which inspects the crossing. Robustness is a property of the system that wraps the model, not of the weights. A more aligned model raises the cost of the first family and barely touches the fourth.

Defenses, and why each is partial

Defenses divide by where they intervene, and reading them as a defense-in-depth stack rather than a search for the one fix is the realistic posture.

defenses atk attack adv training-time adversarial training, refusal tuning atk->adv cls inference-time input/output classifiers adv->cls safe contained adv->safe leaks optimized suffixes rep representation-level circuit breakers cls->rep cls->safe leaks novel phrasings aut authority scoping bound the blast radius rep->aut rep->safe can be re-broken aut->safe
Figure 58.4. Defense in depth against jailbreaks and injection. Each layer catches a different family and leaks others: training-time hardening generalizes poorly to optimized suffixes, classifiers add latency and miss novel phrasings, representation defenses can be re-broken, and only authority scoping bounds the damage when the upstream layers fail.
A crafted prompt aims to pull a harmful completion past the model's guardrails. It meets not one defense but a stack of them, each catching some attacks and missing others.
Adversarial training and refusal tuning raise the floor against known attack styles, but leak the optimized suffixes found after the weights froze.
Input and output classifiers catch known phrasings, but leak the novel ones they were never trained on.
Interventions on the internal representation cut a harmful continuation short, but can be re-broken by a fresh attack.
Whatever slips through still meets a bounded blast radius: scope the model's authority so a successful jailbreak reaches little. No layer is whole, so the stack is the defense.
Figure 58.5. The same defense-in-depth stack as the diagram above, fired through one attack at a time. Each layer is partial and leaks something, which is why the realistic posture reads them as a stack rather than a search for the one fix.

Training-time hardening adds adversarial examples to the post-training mix so the refusal boundary covers more corners. It raises the floor against known attack styles and generalizes poorly to optimized suffixes found after the model froze, because the attacker optimizes against the deployed boundary while the defender trained against last quarter's.

Inference-time classifiers, the subject of Chapter 57, place a separate model on the input and the output to catch attacks the target itself missed. They are independent of the target's alignment, which is their strength, and they add a latency and cost tax on every call while missing phrasings their own training never covered.

Representation-level defenses intervene inside the model rather than around it. Circuit breakers reach into the residual stream, the running vector of activations that carries information through the model's layers, and reroute the internal representations that precede a harmful completion, so that when an attack steers the model toward producing harm, the rerouted representation derails the generation into incoherence rather than compliance (Zou et al. 2024). The appeal is that the defense attaches to the harmful internal state rather than to surface phrasing, which is what optimized and many-shot attacks vary. Whether it generalizes durably or is re-broken by attacks that find new internal routes is exactly the open question the next box names, and it ties this work to the interpretability program in Chapter 54, which supplies the picture of internal features the defense acts on.

System-prompt hardening, instructing the model to distrust embedded instructions and to treat tool content as data, is the cheapest layer and the weakest in isolation: it is itself just text in the context window, subject to the same override the attacks demonstrate.

What's contested
  • Is jailbreak robustness achievable, or perpetual whack-a-mole? One camp holds that robustness is a reachable engineering target, with circuit breakers and adversarial training driving attack success rate down release over release. The other holds that an unbounded input space against a fixed model guarantees a residual attack surface, so the realistic goal is raising attacker cost and bounding blast radius, not closing the boundary. The transfer result of optimized suffixes (Zou et al. 2023) is read by the first camp as a bug to patch and by the second as evidence the surface is intrinsic.
  • Do representation-level defenses generalize? Circuit breakers (Zou et al. 2024) act on internal state rather than surface form, which should generalize across phrasings. Skeptics expect adaptive attacks that find new internal routes to re-break them, the same pattern that defeated earlier defenses, and note that published breaks tend to follow published defenses.
  • Is automated red-teaming a safety signal or an arms race? Automated attack generation (Perez et al. 2022) widens coverage cheaply, but it measures robustness against the attacks its generator models, so a falling attack success rate may mean a safer model or only a generator that stopped finding what a human still can.

What robustness costs

Every defense here changes more than one operating axis. The capability cost is over-refusal: a model hardened against attacks declines benign requests that resemble them, and the same boundary that blocks a jailbreak blocks a security researcher's legitimate question, so robustness and helpfulness are tuned against each other rather than independently maximized. The efficiency cost is the classifier tax of Chapter 57 and the training cost of adversarial and representation-level methods, paid on every request or every release. Trust is the point of the whole exercise, and the credible form of it is a published attack success rate against a named harness rather than a claim of safety: robustness that cannot be measured the way HarmBench measures it (Mazeika et al. 2024) is an assertion, not a property. The discipline's contribution to Chapter 55 is precisely this, a number that says how far the deployed boundary can be pushed and by whom, recomputed every time the model or the attack changes.

Further reading

  • Zou et al., “Universal and Transferable Adversarial Attacks on Aligned Language Models” (GCG and the AdvBench harmful-behaviors set), 2023. arXiv:2307.15043
    GCG introduces an automated greedy coordinate gradient method to find adversarial suffixes that jailbreak aligned LLMs, transferring to black-box models including ChatGPT, Bard, and Claude.
  • Greshake et al., “Not What You've Signed Up For: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection,” 2023. arXiv:2302.12173
    This paper introduces indirect prompt injection, an attack where adversaries plant malicious instructions in data retrieved by LLM-integrated applications to remotely hijack the LLM without direct user access.
  • Anil et al., “Many-shot Jailbreaking” (long-context attack scaling), 2024. anthropic.com
    Many-shot jailbreaking exploits large context windows by packing hundreds of faux harmful-dialogue demonstrations into a single prompt, overriding LLM safety training via in-context learning.
  • Russinovich et al., “Great, Now Write an Article About That: The Crescendo Multi-Turn LLM Jailbreak Attack,” 2024. arXiv:2404.01833
    Crescendo is a multi-turn LLM jailbreak that escalates from benign prompts using the model's own prior outputs, bypassing safety alignment on GPT-4, Gemini-Pro, and other models with high attack success rates.
  • Perez et al., “Red Teaming Language Models with Language Models” (automated attack generation), 2022. arXiv:2202.03286
    This paper introduces LM-based red-teaming, using one language model to automatically generate test cases that elicit harmful outputs from a target LM, uncovering tens of thousands of failures in a 280B-parameter chatbot.
  • Mazeika et al., “HarmBench: A Standardized Evaluation Framework for Automated Red Teaming and Robust Refusal,” 2024. arXiv:2402.04249
    HarmBench is a standardized benchmark with 510 harmful behaviors and an evaluation pipeline that compares 18 automated red-teaming methods across 33 LLMs to enable rigorous, reproducible attack-defense co-development.
  • Zou et al., “Improving Alignment and Robustness with Circuit Breakers” (representation-level defense), 2024. arXiv:2406.04313
    Circuit breakers use representation rerouting to redirect internal model representations away from harmful outputs, achieving adversarial robustness across unseen attacks without sacrificing capability in LLMs, multimodal models, and agents.

Comments

Log in to comment