# The long context window you shipped as a feature is a jailbreak with a scaling law.

A vendor ships a model with a million-token context window and puts the number on the launch slide, because a longer context is unambiguously a better product. The model can now read a whole codebase, a quarter of contracts, a book, before it answers. The safety team signed off: the model refuses the harmful requests it was trained to refuse, and a longer prompt does not change what it refuses. Then someone pads the prompt with a few hundred fabricated dialogues in which a compliant assistant happily answers exactly the kind of question the real model refuses — and at the bottom, the real question. The real model answers it. Nothing in the prompt was a clever exploit. It was the headline capability, used as designed, against the alignment.

You will be tempted to file this as a jailbreak — one more prompt trick on a long list, the kind a patch or a sterner refusal will close. It is not a trick on a list. It is a property of the thing you sold, and the company that treats it as a trick will close this instance and ship the next one. This post is about a jailbreak that has no fix because it has a scaling law: its success climbs with the number of fabricated examples as a power law, and the curve gets _worse_ on exactly the two axes a model vendor competes on — context length and model size. The published mitigations move the curve. They do not retire it.

## The attack is the feature, used as designed

Many-shot jailbreaking is the cleanest demonstration that a capability and a vulnerability can be the same axis. The attack is to fill the context window with many faux dialogues of a model behaving badly, then ask the real question — and let the model's own in-context learning do the rest. The anchor result is [Many-shot Jailbreaking](https://proceedings.neurips.cc/paper_files/paper/2024/hash/ea456e232efb72d261715e33ce25f208-Abstract-Conference.html) (Anil, Durmus, Panickssery, Sharma, Benton, et al.; NeurIPS 2024), and it is blunt about why the attack exists now and did not before: "This attack is newly feasible with the larger context windows recently deployed by language model providers like Google DeepMind, OpenAI and Anthropic," and "very long contexts present a rich new attack surface for LLMs."

Read that as an engineer, not a headline. The attack did not get invented; the room it needed got built. A two-thousand-token window has no space for hundreds of demonstrations; a two-hundred-thousand-token window does, and a million-token window has room to spare. Every extension of the context window — shipped as a feature, benchmarked as a capability, sold as the reason to switch — is also an extension of this attack surface, by construction. Anthropic's own write-up names the shape: "The ever-lengthening context window of LLMs is a double-edged sword," one that "also makes feasible a new class of jailbreaking vulnerabilities" ([Many-shot jailbreaking](https://www.anthropic.com/research/many-shot-jailbreaking)). The capability and the vulnerability are not correlated; they are the same thing measured by a defender and a marketer.

The mechanism is not exotic, which is what makes it durable. The defense paper [_Mitigating Many-Shot Jailbreaking_](https://arxiv.org/abs/2504.09604) (arXiv 2504.09604) states it plainly: "With enough examples, the model's in-context learning abilities override its safety training, and it responds as if it were the 'fake' assistant." The model was trained to be an excellent in-context learner — that is the whole product — and separately trained to refuse certain requests. The attack pits the first against the second, in a medium where the model resolves the conflict by what it was just shown, not by what it was aligned to do. This is the same structural fact behind [why prompt-injection defenses go stale against an adaptive attacker](/blog/prompt-injection-defenses-stale-by-adaptive/): the model reads one undifferentiated stream and cannot tell your authority from an attacker's demonstrations.

## The success rate is a power law, not a threshold

This is a scaling-law post and not a jailbreak-of-the-week post because the attack's success is not a coin flip you repeat — it is a measured curve. The anchor finding is that "in diverse, realistic circumstances, the effectiveness of this attack follows a power law, up to hundreds of shots." A handful of demonstrations leaves the safety training intact; the research tested up to 256 faux dialogues, and "simply including a very large number of faux dialogues preceding the final question ... produces a very different response." There is no clean threshold where the defense holds and past which it breaks — there is a curve, and you slide down it by adding shots.

The detail that should bother a defender most is what the benign curve looks like. Anthropic's write-up notes that "benign examples of in-context learning follow similar power laws as the scale increases." The jailbreak is not riding a separate, pathological curve you could detect by its shape — it is riding the _same_ power law that makes few-shot prompting work at all. You cannot flag the malicious learning curve as anomalous, because it is the normal learning curve with hostile content in the slots.

And the power-law framing is not a one-paper artifact. The independent black-box result in [_Best-of-N Jailbreaking_](https://arxiv.org/abs/2412.03556) (arXiv 2412.03556) finds the same functional form on a different attack axis: "Across all modalities, ASR, as a function of the number of samples (N), empirically follows power-law-like behavior for many orders of magnitude." Best-of-N spends the attacker's budget on repeated augmented samples rather than shots in one prompt, and it "reliably improves when we sample more augmented prompts" — reaching 89% attack success on GPT-4o and 78% on Claude 3.5 Sonnet when sampling 10,000 augmented prompts. Two budgets, one verdict: success scales smoothly with attacker spend, no plateau.

## It gets worse on the bigger model, which is the part that should scare you

Most things in safety get better with scale: capability improves, refusals get more precise, the model gets harder to confuse. This attack inverts that, and the inversion is the load-bearing claim of the whole post. Anthropic's write-up does not hedge it: "Many-shot jailbreaking is often more effective ... for larger models. The larger an LLM, the better it tends to be at in-context learning." The reason is mechanical: the attack's potency comes from in-context learning, the capability that improves as you scale the model up. So the better your model is at the thing you are selling it for, the better it is at being jailbroken this way — and the write-up draws the conclusion you would rather not read: "Given that larger models are those that are potentially the most harmful, the fact that this jailbreak works so well on them is particularly concerning."

Together the two scaling claims are the thesis. Attack success scales up with the number of shots, and it scales up with model size — both of them headline capabilities. A vendor's roadmap of longer context and bigger models is, read from the attacker's chair, a roadmap of increasing attack success, because the capability and the attack draw on the same underlying skill.

## You do not even need the harmful examples

The early reading of many-shot jailbreaking was that it depends on assembling many genuinely harmful demonstrations — bad, but at least the attacker has to author convincing harmful content. The follow-up work removes that comfort.

[_What Really Matters in Many-Shot Attacks?_](https://arxiv.org/abs/2505.19773) (arXiv 2505.19773) runs the attack across instruction styles, shot density, topic, and format at context lengths up to 128K tokens, and isolates the cause: "context length is the primary factor determining attack effectiveness." Not the cleverness of the shots — the length. And it lands the result that should change how you think about the attack surface: "successful attacks do not require carefully crafted harmful content. Even repetitive shots or random dummy text can circumvent model safety measures." Concretely, "Fake-512 and Fake-Text demonstrate comparable or even higher ASR than Harmful-512; Safe-512 demonstrates comparable or superior ASR levels to Harmful-512." Random filler — and even ostensibly _safe_ filler — in enough volume jailbreaks about as well as hand-crafted harmful demonstrations. The degradation is a slope, not a cliff: "the safety behavior of well-aligned models becomes increasingly inconsistent with longer contexts," with attack success climbing sharply as the context approaches roughly 2^17 (about 128K) tokens.

If the harmful content is not even necessary, the attack needs no author of harmful examples — only length, which is free to anyone with a long context window. [_Jailbreaking in the Haystack_](https://arxiv.org/abs/2511.04707) (arXiv 2511.04707) pushes this to its end with NINJA, "a method that jailbreaks aligned LMs by appending benign, model-generated content to harmful user goals." Benign, model-generated filler — the kind of text the model produces all day — appended in volume with careful goal positioning drives attack success up on HarmBench across families: LLaMA-3.1-8B-Instruct from 23.7% to 58.8% (+35.1 points), Qwen2.5-7B-Instruct from 23.7% to 42.5% (+18.8 points), Gemini Flash from 23% to 29% (+6 points). The conclusion to internalize: "even benign long contexts — when crafted with careful goal positioning — introduce fundamental vulnerabilities in modern LMs." A content filter looking for harmful demonstrations has nothing to catch.

NINJA also ties the two scaling axes together with a result a budget-conscious attacker will not ignore: it "is compute-optimal — under a fixed compute budget, increasing context length can outperform increasing the number of trials in best-of-N jailbreak." The best-of-N power law and the many-shot power law are two ways to spend an attacker's budget, and length is the more efficient spend — so the vendor who ships the longest context window has handed the attacker the most compute-efficient axis.

## The mitigations bend the curve; they do not break it

The defenses are real and they help, by a lot. Anthropic reports that prompt-based methods "substantially reduced the effectiveness ... dropping the attack success rate from 61% to 2%," while fine-tuning, on its own, "merely delayed the jailbreak." Sixty-one percent to two percent is a large, deployable reduction, and any team shipping a long-context model should apply the strongest such mitigation available. If you take one build instruction from this post, it is that these mitigations are worth deploying; the number they produce is genuinely better than the undefended one.

But read what the mitigation buys, in the defenders' own framing. The same paper is precise about its best result: fine-tuning on MSJ attacks with appropriate refusals "substantially flattens the relationship between the number of shots and jailbreak success, impacting the exponent of the power law," and "the combination of the two is most effective, both flattening the slope and raising the absolute NLL values." It changes the _exponent_ of the power law; it does not remove the power law. A flatter curve is still a curve that goes the wrong way — it still climbs with shots, just more slowly, so the attacker still wins by adding context, only needs more of it.

The same paper does the arithmetic out loud, and it is the most important number here. After the defense, they "would expect it to hit that value at ~2^8 shots, which would require ~32K tokens, or ~4 times as long a context window as the model has." Translate that: the mitigation pushes the shots the attacker needs out by a constant factor — to a context about four times longer than the model supports. That is a real win _today_, with an expiry date on it, because the thing the vendor is racing to ship is a longer context window. A defense whose safety margin is "the attacker would need a 4× longer context than we offer" is one the next context-length announcement partially un-ships. The authors are scrupulous about it: they "find incremental mitigation effectiveness for each," and pitch the result as something that "could meaningfully ameliorate this vulnerability if incorporated into model safety post-training." Ameliorate, not eliminate — a launch review should read the word the way they meant it.

This is the same structure that [defeats prompt-injection defenses benchmarked against a static attacker](/blog/prompt-injection-defenses-stale-by-adaptive/): a published number that looks like "handled" is conditional on the attacker not spending more, and the attacker's spend on this attack is denominated in context tokens — the one resource your product roadmap keeps increasing.

## What the claim does not cover

Three qualifications, because the version of this argument that overstates loses the reader who knows the field.

First, "the mitigations only bend the curve" is not "the mitigations are useless." Sixty-one percent to two percent is a real reduction, and a four-times-longer-context margin is real headroom for a model whose context is not about to quadruple this quarter. The claim is sharper than "defenses do not work": they shift a power law along its own axis rather than removing it, so the margin they buy is measured in context tokens and erodes as context length grows. Deploy them. Do not file the vulnerability as closed because you did.

Second, the per-number specifics are setup-dependent, not constants of nature. Every figure above is real on the systems its paper tested — frontier closed models in some cases, open 7-to-8-billion-parameter models in others — and the mechanisms generalize, but the exact percentages do not transfer unchanged to a model nobody measured. What transfers is the functional form: a power law in shots, monotone degradation with context length, and worse behavior on the larger, better in-context learner.

Third, this attack is about the model talking — producing harmful text — not yet about an agent acting on it. The full danger lands when the jailbroken model is wired to tools, money, or data. Many-shot jailbreaking is the upstream half: how an attacker gets a capable model to abandon its refusals. What that abandonment is worth depends on what the model is permitted to _do_ — and a model behind real privilege separation, jailbroken or not, reaches nothing irreversible.

## Building as if the curve is permanent

The instruction set falls out of the scaling law, not any single defense.

**Treat the context window as attacker-controlled capacity, not just user capacity.** Every token of context you ship is room for this attack, and the longer the window, the more this is true. Size the threat to the window you advertise, not the prompts you expect.

**Deploy the strongest published mitigation — and record what it actually bought.** Prompt-based defenses and refusal fine-tuning measurably reduce attack success and flatten the curve's exponent. Apply them, then write down that what you bought is a constant-factor shift along a power law — a margin in context tokens, not a fix — so the next reviewer does not read the reduced number as "solved."

**Re-measure on every context-length increase, not only on model swaps.** A longer window can raise this attack's success without anyone touching the safety code, because the attack scales with context length directly. Context length is a security-relevant parameter; extending it re-opens the evaluation.

**Do not rely on filtering for harmful demonstrations.** Random filler, repeated text, and benign model-generated content jailbreak about as well as crafted harmful shots. A detector tuned to harmful examples has nothing to match against a long context of innocuous filler.

**Make the refusal non-load-bearing.** The scaling law says you cannot guarantee the model refuses at sufficient context, so the system must be safe when it does not. Privilege separation under the model — the model proposes, deterministic code disposes — turns a successful jailbreak into a failed suggestion, the same move the [indirect-injection numbers](/blog/indirect-injection-numbers/) force for agents that can act.

## Reading list

- [Many-shot Jailbreaking](https://proceedings.neurips.cc/paper_files/paper/2024/hash/ea456e232efb72d261715e33ce25f208-Abstract-Conference.html) (NeurIPS 2024) — the anchor: hundreds of bad demonstrations defeat safety training with an effectiveness that follows a power law, newly feasible because of the long context windows providers ship.
- [Many-shot jailbreaking](https://www.anthropic.com/research/many-shot-jailbreaking) (Anthropic research) — names the context window a "double-edged sword," shows the attack is more effective on larger models, and reports prompt-based defenses cutting attack success from 61% to 2%.
- [_What Really Matters in Many-Shot Attacks?_](https://arxiv.org/abs/2505.19773) (arXiv 2505.19773) — isolates context length, not content cleverness, as the primary driver, and shows random or even safe filler jailbreaks about as well as crafted harmful shots, with success climbing near 128K tokens.
- [_Jailbreaking in the Haystack_](https://arxiv.org/abs/2511.04707) (arXiv 2511.04707) — NINJA jailbreaks aligned models with purely benign appended filler, and shows context length is compute-optimal: spending budget on length beats spending it on more attempts.
- [_Mitigating Many-Shot Jailbreaking_](https://arxiv.org/abs/2504.09604) (arXiv 2504.09604) — the defense paper, and the honest one: its best mitigation flattens the power law's exponent and pushes the attack out by a constant factor (~4× the model's context), an amelioration, not an elimination.
- [_Best-of-N Jailbreaking_](https://arxiv.org/abs/2412.03556) (arXiv 2412.03556) — corroborates the power-law form on a different budget axis, reaching 89% on GPT-4o and 78% on Claude 3.5 Sonnet at 10,000 samples, with no plateau.

You did not ship a jailbreak by accident; you shipped a context window, and the jailbreak is what that window is for, turned against the alignment instead of toward the user. Its success is a power law in the shots an attacker pads in, it sharpens on the larger model and the longer context you are racing to release, and the best published defense bends that curve by a constant factor measured in the exact tokens your roadmap keeps adding. Deploy the mitigation, stop calling the reduced number a fix, and make the refusal something the system does not depend on.