Learn
AI security & red-teaming

What is Jailbreaking & Red-Teaming in Open-Weight Models?

The short answer

Jailbreaking is getting a model to abandon its own safety policy; prompt injection is getting it to abandon yours. With open weights there is no provider-side moderation to fall back on: anyone who downloads the file can inspect it, fine-tune it, abliterate it or serve it without guardrails. Red-teaming is the discipline of measuring those failures systematically before someone else does.

On this page

Two failures that get confused

Jailbreaking is an attack on the model's own policy. The user wants output the model was trained to refuse, and the attack is any technique that moves the model off that policy: a persona, a fictional frame, an encoded request, a long context that normalises compliance. The operator of the model is not the target. The model's alignment is.

Prompt injection is an attack on the application's policy. Untrusted text arrives through a document or tool result and redirects the assistant away from the operator's instructions. The two overlap in practice, because a jailbreak delivered inside a retrieved document is both things at once, but they have different owners and different fixes. A jailbreak is mitigated by better alignment, moderation and monitoring. An injection is mitigated by privilege separation and action authorisation. Conflating them produces security programmes that buy a content classifier and call the problem solved.

The distinction matters more with open weights, because the deployer inherits both problems at once. A hosted API gives you a vendor who filters inputs and outputs and can suspend an account. A downloaded checkpoint gives you a file and a licence.

Why open weights move the safety boundary

When weights are public, the alignment layer is no longer enforceable by the party that trained it. The checkpoint can be inspected to find the exact system prompt format and refusal behaviour, fine-tuned on a few hundred examples to erode refusals, edited to remove a refusal direction, quantised into a smaller file, merged with another model, or served by an inference stack that simply does not implement the vendor's filters. None of that requires breaking a law or a terms of service in most jurisdictions, and the derivative can be redistributed under a new name.

This is not an argument against open weights. It is an argument about where the control plane sits. With a closed API, safety is partly a service the vendor operates. With open weights, safety is a property of your deployment: your system prompt, your input and output filters, your tool scoping, your logging, your account controls. The training-time alignment is still useful, because it raises the cost of casual misuse and makes the model a better base for your own guardrails, but it is a starting condition rather than a guarantee.

The practical consequence is that a security review of an open-weight deployment has to ask questions that do not appear in a vendor questionnaire: which checkpoint and which hash, which quantisation, which chat template, which inference server and version, whether prefill or raw continuation is exposed, what filtering runs outside the model, and who can fine-tune and redeploy it.

How safety training actually works, briefly

Refusal behaviour is produced by post-training, not by the pretraining objective. A base model that has only read the internet will happily continue almost any text. Supervised fine-tuning teaches the shape of a helpful assistant, including refusals on a curated set of harmful requests. Preference optimisation, whether RLHF, RLAIF or a direct method such as DPO, then shifts the policy toward answers annotators prefer, which usually means more careful handling of sensitive topics and fewer refusals of benign ones. Constitutional or rule-based approaches replace some human labels with a written policy and a model that critiques against it.

What this produces is a statistical disposition, not an access control list. The policy lives in the weights as a preference over continuations, distributed across layers and tokens. It generalises well to the requests in and near the training distribution, and it generalises less well to requests that are structurally unusual: encoded, fictionalised, spread over many turns, or written in a language with little safety data. That gap between the training distribution and the space of possible requests is the entire jailbreak surface.

Jailbreak families a defender should recognise

  • Persona and role-play: the request is reframed as fiction, a character, a hypothetical or a developer mode, so refusal would contradict an accepted premise.
  • Competing objectives: the prompt constructs a conflict between helpfulness, honesty and safety, and argues that refusing is the less helpful or less honest choice.
  • Encoding and obfuscation: base64, leetspeak, homoglyphs, reversed text, translation into a low-resource language or unusual formatting that the safety data rarely covers.
  • Many-shot conditioning: hundreds of fabricated question-answer pairs establish a norm of compliance inside one long context, exploiting in-context learning rather than argument.
  • Adversarial suffixes: optimised token sequences, found by gradient search, that shift the model toward compliance and often transfer between models and across quantisation.
  • Multi-turn escalation: a harmless opening, a gradual reframe, and a final request that is only slightly beyond the previous one, so no single turn looks like the attack.
  • Prefill and decoding manipulation: forcing the assistant turn to begin with compliant text, or changing temperature, top-p and repetition penalties to sample past a refusal.
  • Weight-level modification: fine-tuning on a small harmful set, refusal-direction ablation, or merging with an uncensored derivative so the deployed model is no longer the one that was evaluated.

Refusal training is shallower than it looks

The most important result for anyone deploying fine-tuned open weights is that safety alignment is fragile under further training. Published work has shown that a handful of adversarial examples, on the order of ten, is enough to remove safety behaviour from an aligned model while leaving general capability intact, and that even benign fine-tuning on unrelated data erodes refusals as a side effect. The mechanism is unsurprising once you accept that refusal is a behaviour in the weights: gradient descent on any objective will move it if the objective does not protect it.

A second line of work shows that refusal is mediated by a relatively low-dimensional direction in activation space. Estimate that direction, ablate it, and the model loses much of its refusal behaviour without retraining. This is why abliterated checkpoints appear within days of a release, and why a model card's safety evaluation describes the checkpoint as shipped, not the checkpoint as re-uploaded by a third party.

Quantisation adds a smaller and less well understood effect. Several evaluations report that aggressive 4-bit quantisation can degrade safety behaviour more than capability benchmarks suggest, because refusal decisions sit near decision boundaries that rounding perturbs. The effect is not uniform across models or formats, which is exactly why safety evaluation has to be repeated on the artefact you actually serve rather than inherited from the vendor's BF16 numbers.

What red-teaming is for

Red-teaming is structured adversarial testing with a decision at the end. It is not a leaderboard, and a single attack success rate presented without a threat model is close to meaningless. The output of a good programme is a set of failure modes with reproduction steps, a severity judgement, a proposed mitigation, and a measurement that lets you tell whether the mitigation worked without breaking legitimate use.

Three kinds of evaluation get mixed together. Capability evaluation asks what the model can do. Safety evaluation asks how it behaves on a harm taxonomy under ordinary use. Adversarial robustness asks how it behaves against someone actively trying to make it fail. Only the third is red-teaming in the strict sense, and only it requires an adversary model: who the attacker is, what they can send, how many attempts they get, and whether they can modify the weights.

Scoping the engagement

  • Adversary model: scripted opportunist, motivated insider, automated attacker at scale, or someone with weight access, since each implies a different budget and technique set.
  • Harm taxonomy: adopt a published one such as MLCommons AILuminate or your regulator's list, then add domain categories for your deployment, such as clinical advice or financial promotion.
  • Scope boundary: model only, model plus system prompt, or the full deployment including tools, retrieval and the front end, which is where most real harm occurs.
  • Rules of engagement: what may be generated, where outputs are stored, who can read them, and how synthetic harmful content is destroyed afterwards.
  • Stop conditions: a written threshold for pausing the test, such as a reproducible pathway to actionable instructions in a high-severity category.
  • Disclosure path: who receives a finding, in what timeframe, and whether the model vendor or upstream maintainer is notified.

Building a test set that reflects your deployment

Start from your own traffic and your own refusal logs. Sample real requests, redact them, and cluster them into intents. Real users produce phrasings no synthetic generator thinks of, and the clusters tell you where the model is already struggling. Then add adversarial variants: the same intent encoded, fictionalised, split across turns, translated, and embedded in a document. Keep a benign counterpart for every harmful prompt, matched on topic and surface form, because that is the only way to detect the over-refusal that a heavy-handed mitigation will cause.

Version the set. Every prompt gets an identifier, a category, a severity expectation and a source. When a model or a filter changes, the same identifiers run again and the diff is the result. Teams that regenerate prompts each cycle cannot distinguish a real regression from a change in the test.

For open-weight work, test the artefact you serve: the quantised file, the chat template you actually use, the inference server version, and any system prompt you prepend. A test run against the vendor's reference implementation tells you about a model you are not deploying.

Automated red-teaming and its limits

Tooling has matured enough that no serious programme is fully manual. Garak runs a broad library of probes against an endpoint and reports hits by category. PyRIT orchestrates multi-turn attack strategies and scorer pipelines. Inspect provides an evaluation framework with reproducible logs. HarmBench and JailbreakBench supply standardised harmful-behaviour sets so results are comparable to published numbers. Attack-generation methods such as PAIR and tree-of-attacks-with-pruning use an attacker model to iteratively rewrite prompts against a target, which finds paraphrases a static list never would.

The weak point is the judge. Most pipelines score outputs with another language model, and that judge has its own biases: it is lenient on fluent refusals that still leak information, harsh on terse ones, and sensitive to ordering and verbosity. It can also be manipulated by the text it is judging, since the output under evaluation is untrusted input to the judge. Calibrate against a human-labelled sample of a few hundred items, report agreement, pin the judge model and prompt version, and re-calibrate whenever either changes.

Automation also narrows the search. Generators optimise for the categories and phrasings in their seed set, so they find variations of known attacks and rarely a new failure mode. Human red-teaming remains necessary for failures that need domain knowledge, patience across many turns, or a reframe no mutation operator would produce.

Metrics that do not mislead

Report attack success rate with a confidence interval, because a rate from two hundred samples has a wide one. The Wilson interval is the right default for proportions near zero, where the normal approximation fails. Report per category rather than only in aggregate: a model that is robust everywhere except one high-severity category is not 95 percent safe, it is unsafe in the way that matters.

Weight by severity, and separate partial compliance from full compliance. An output that begins to comply and then stops is a different finding from one that provides the complete requested artefact, and collapsing them hides the difference that drives remediation priority. Pair every adversarial number with an over-refusal number on the benign set, and refuse to compare results obtained with different judges, prompt sets or sampling parameters.

Finally, report the number of attempts. A jailbreak that works after four hundred automated variations is a different risk from one that works first try, especially if your deployment rate-limits and logs. Attack success without an attempt budget is a research result, not a risk statement.

Defending an open-weight deployment

Assume the model can be talked into anything and build the layers that do not depend on its cooperation. A safety-oriented system prompt is cheap and worth having. Input classification and output moderation catch known categories and give you telemetry. A separate moderation model or a hosted moderation endpoint adds a second opinion that the attacker has to defeat independently. Tool scoping and action authorisation, as described for prompt injection, bound what a successful jailbreak can actually accomplish.

Operationally, pin the checkpoint by hash and record it in your deployment manifest. Verify that the file you loaded is the file you evaluated, prefer safetensors over pickle-based formats, and treat any community fine-tune as an unaudited model requiring its own evaluation. Gate who can pull the weights from your registry, log inference with retention you can defend, and keep per-tenant rate limits so a scripted campaign is visible as a pattern rather than absorbed silently.

Publish a model card that states the evaluated checkpoint, the harm taxonomy, the measured rates and the known gaps. Provide a channel for users to report harmful output, and rehearse what happens when a report arrives: triage, reproduce, mitigate, and decide whether the finding requires notifying upstream.

When you fine-tune, you own the alignment

The moment you run a fine-tune, the vendor's safety evaluation stops describing your model. Include refusal and safety examples in the training mix, keep a held-out adversarial set that is never trained on, and evaluate both capability and safety before and after. Watch for the benign-fine-tuning effect specifically: a model tuned only on domain data often becomes more compliant across the board, including on requests it used to decline.

If you cannot afford a full re-evaluation, restrict the fine-tune's scope, keep the guardrail stack outside the model so it survives retraining, and document the residual risk. The alignment you did not measure is the alignment you do not have.

Key points

  • Jailbreaking targets the model's policy; prompt injection targets the application's. They need different controls and different owners.
  • Open weights make alignment a deployer responsibility, because the checkpoint can be inspected, fine-tuned, abliterated or re-served without the vendor's filters.
  • Refusal behaviour is a learned disposition and is fragile under further training, including benign fine-tuning and aggressive quantisation.
  • Red-team against the artefact you actually serve, with a written adversary model, harm taxonomy and attempt budget.
  • Report severity-weighted rates with confidence intervals, alongside over-refusal on a matched benign set, and pin the judge.
  • Every fine-tune resets the safety baseline; keep guardrails outside the model so retraining cannot remove them.
Page feedback

Was this helpful?

A quick signal helps improve these notes.

Report a mistake Straight to the lab inbox

Put it to work

See the models, datasets and gateway this lab runs.