Papers › Universal and Transferable Adversarial Attacks on Aligned Language Models

Universal and Transferable Adversarial Attacks on Aligned Language Models

27 Jul 2023arXiv:2307.15043archive 2025-07-28

Andy Zou, Zifan Wang, Nicholas Carlini, Milad Nasr, J. Zico Kolter, Matt Fredrikson

Because "out-of-the-box" large language models are capable of generating a great deal of objectionable content, recent work has focused on aligning these models in an attempt to prevent undesirable generation. While there has been some success at circumventing these measures -- so-called "jailbreaks" against LLMs -- these attacks have required significant human ingenuity and are brittle in practice. In this paper, we propose a simple and effective attack method that causes aligned language models to generate objectionable behaviors. Specifically, our approach finds a suffix that, when attached to a wide range of queries for an LLM to produce objectionable content, aims to maximize the probability that the model produces an affirmative response (rather than refusing to answer). However, instead of relying on manual engineering, our approach automatically produces these adversarial suffixes by a combination of greedy and gradient-based search techniques, and also improves over past automatic prompt generation methods. Surprisingly, we find that the adversarial prompts generated by our approach are quite transferable, including to black-box, publicly released LLMs. Specifically, we train an adversarial attack suffix on multiple prompts (i.e., queries asking for many different types of objectionable content), as well as multiple models (in our case, Vicuna-7B and 13B). When doing so, the resulting attack suffix is able to induce objectionable content in the public interfaces to ChatGPT, Bard, and Claude, as well as open source LLMs such as LLaMA-2-Chat, Pythia, Falcon, and others. In total, this work significantly advances the state-of-the-art in adversarial attacks against aligned language models, raising important questions about how such systems can be prevented from producing objectionable information. Code is available at github.com/llm-attacks/llm-attacks.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2307.15043")

Code

Syntology Ran 33 of 61 code samples harvested from 9 repositories linked to this paper; 28 have no recorded run. Of those that ran: 4 ran · honoured contract; 1 ran · violated contract; 16 ran · our draft was wrong; 2 ran · fixture could not drive it; 10 ran with no contract checked.

By repository: community (archive-listed): 59 samples from 9 repositories, 31 ran; 2 identical to code first harvested elsewhere. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

25 repositories listed; official and paper-mentioned ones first.

llm-attacks/llm-attacks officialmentioned in papermentioned on GitHubpytorchMIT report
NJUNLP/ReNeLLM mentioned on GitHubpytorchMIT report
amanb2000/magic_words mentioned on GitHubpytorch report
aounon/certified-llm-safety mentioned on GitHubpytorch report
arobey1/smooth-llm mentioned on GitHubpytorch report
chawins/pal mentioned on GitHubjaxMIT report
dsn-2024/dsn mentioned on GitHubpytorchNOASSERTION report
ed-zh/parden mentioned on GitHubpytorch report
framartin/trap mentioned on GitHubpytorchMIT report
grayswanai/nanogcg mentioned on GitHubpytorch report
jailbreakbench/jailbreakbench mentioned on GitHubMIT report
mcgill-nlp/adversarialtriggers mentioned on GitHubpytorch report
osu-nlp-group/amplegcg mentioned on GitHubpytorchNOASSERTION report
parameterlab/trap mentioned on GitHubpytorchMIT report
pku-ml/pat mentioned on GitHubpytorch report
princeton-sysml/jailbreak_llm mentioned on GitHubpytorch report
rain152/PAT mentioned on GitHubpytorchMIT report
rotaryhammer/code-autodan mentioned on GitHubpytorchMIT report
shijiawenwen/judgedeceiver mentioned on GitHubpytorch report
sj21j/Regularized_Relaxation mentioned on GitHubpytorchMIT report
thompsonj/nanoGCG mentioned on GitHubpytorch report
thu-coai/safeunlearning mentioned on GitHubpytorch report
vinusankars/beast mentioned on GitHubpytorch report
zhaoyiran924/probe-sampling mentioned on GitHubpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

61 samples harvested; 33 ran; 4 honoured the contract we drafted; 28 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

4ran · honoured contract
1ran · violated contract
16ran · our draft was wrong
2ran · fixture could not drive it
10ran
28unverified

Licence: 4 of the 61 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 9 repositories linked to this paper, official or community; each sample names its own and says which. Some samples are identical code Syntology first harvested from another repository; for those, this paper's copy is not located and its licence is not recorded. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

Attack arobey1/smooth-llm/lib/attacks.py community (archive-listed) ran MIT (permissive) · c8b60c98283b0f93 · report
AttackBuffer grayswanai/nanogcg/nanogcg/gcg.py community (archive-listed) ran MIT (permissive) · cb8e994854e018bd · report
AttackBuffer thompsonj/nanoGCG/nanogcg/gcg.py community (archive-listed) ran · metamorphic tier: deterministic MIT (permissive) · b9d6e9f0f2ef1785 · report
GCG arobey1/smooth-llm/lib/attacks.py community (archive-listed) ran MIT (permissive) · 8f2bb9303de66805 · report
GCGConfig grayswanai/nanogcg/nanogcg/gcg.py community (archive-listed) ran MIT (permissive) · a9682b120ee13622 · report
GCGHistory thompsonj/nanoGCG/nanogcg/gcg.py community (archive-listed) ran MIT (permissive) · 88a3e18b9506e939 · report
GCGResult grayswanai/nanogcg/nanogcg/gcg.py community (archive-listed) ran MIT (permissive) · 5c73323812cc0eb2 · report
Logger fra31/rlhf-trojan-competition-submission/method/attacks.py community (archive-listed) ran Apache-2.0 (permissive) · a445b00c2e83ec24 · report
Prompt arobey1/smooth-llm/lib/attacks.py community (archive-listed) ran MIT (permissive) · 6b3191d8fc67d0d2 · report
_get_eval_loss mcgill-nlp/adversarialtriggers/adversarial_triggers/trainer/trigger_trainer.py community (archive-listed) ran · honoured contract MIT (permissive) · d84d37af47c6fe79 · report
_get_token_grad mcgill-nlp/adversarialtriggers/adversarial_triggers/trainer/trigger_trainer.py community (archive-listed) ran · our draft was wrong MIT (permissive) · 737b13f7178dd472 · report
add_reply fra31/rlhf-trojan-competition-submission/method/attacks.py community (archive-listed) ran · our draft was wrong Apache-2.0 (permissive) · 4ab92d112af903d0 · report
check_tokenization fra31/rlhf-trojan-competition-submission/method/attacks.py community (archive-listed) ran · our draft was wrong Apache-2.0 (permissive) · 72493c9a581afc21 · report
configure_pad_token grayswanai/nanogcg/nanogcg/gcg.py community (archive-listed) ran · our draft was wrong MIT (permissive) · 32c910ba47ebc6b3 · report
create_token_mask mcgill-nlp/adversarialtriggers/adversarial_triggers/trainer/trigger_trainer.py community (archive-listed) ran · our draft was wrong fingerprinted MIT (permissive) · eaa3fb63f5fe88fe · report
find_executable_batch_size grayswanai/nanogcg/nanogcg/gcg.py community (archive-listed) ran · our draft was wrong MIT (permissive) · 1422bdde04346c68 · report
find_executable_batch_size thompsonj/nanoGCG/nanogcg/gcg.py community (archive-listed) ran · our draft was wrong MIT (permissive) · 4a4125358e03ea60 · report
forward fra31/rlhf-trojan-competition-submission/method/attacks.py community (archive-listed) ran · our draft was wrong Apache-2.0 (permissive) · 855a5a17a02b08d8 · report
gcg_suffix aounon/certified-llm-safety/gcg.py community (archive-listed) ran · fixture could not drive it MIT (permissive) · 8bbdca63196e835b · report
generate_mini_batch ed-zh/parden/utils.py community (archive-listed) ran · our draft was wrong no licence file found · pointer only · e88ba59fcb846ef1 · report
get_alt_prompt_ids amanb2000/magic_words/magic_words/easy_gcg.py community (archive-listed) ran · our draft was wrong MIT (permissive) · c4c28b82836a4d42 · report
get_embedding_weights amanb2000/magic_words/magic_words/easy_gcg.py community (archive-listed) ran · our draft was wrong MIT (permissive) · f7b4f2c24a3317d7 · report
get_future_mask amanb2000/magic_words/magic_words/easy_gcg.py community (archive-listed) ran · honoured contract MIT (permissive) · d849de4df6ec1de0 · report
get_invalid_token_ids mcgill-nlp/adversarialtriggers/adversarial_triggers/trainer/trigger_trainer.py community (archive-listed) ran · honoured contract MIT (permissive) · ac107ad22088a015 · report
get_logits fra31/rlhf-trojan-competition-submission/method/attacks.py community (archive-listed) ran · our draft was wrong Apache-2.0 (permissive) · 9a336610f22b79b2 · report
get_nonascii_toks grayswanai/nanogcg/nanogcg/gcg.py community (archive-listed) ran · honoured contract MIT (permissive) · 726e8111ce3c1903 · report
get_nospace_tokens fra31/rlhf-trojan-competition-submission/method/attacks.py community (archive-listed) ran · our draft was wrong Apache-2.0 (permissive) · aa73ffad17ad20cf · report
insert_trigger fra31/rlhf-trojan-competition-submission/method/attacks.py community (archive-listed) ran · fixture could not drive it Apache-2.0 (permissive) · be197b73817c3f69 · report
instantiate_prompt amanb2000/magic_words/magic_words/easy_gcg.py community (archive-listed) ran · our draft was wrong MIT (permissive) · ee4a998eb4a5b23d · report
sample_ids_from_grad thompsonj/nanoGCG/nanogcg/gcg.py community (archive-listed) ran MIT (permissive) · 3d96d44d2ce14f72 · report
should_reduce_batch_size grayswanai/nanogcg/nanogcg/gcg.py community (archive-listed) ran · violated contract MIT (permissive) · 2ae3afb9e485c484 · report
GCG grayswanai/nanogcg/nanogcg/gcg.py community (archive-listed) unverified MIT (permissive) · 56ecfab9afa7f5d4 · report
GCG thompsonj/nanoGCG/nanogcg/gcg.py community (archive-listed) unverified MIT (permissive) · 19335ae7cecba250 · report
GCGConfig thompsonj/nanoGCG/nanogcg/gcg.py community (archive-listed) unverified MIT (permissive) · 12ad826809223d64 · report
GCGResult thompsonj/nanoGCG/nanogcg/gcg.py community (archive-listed) unverified MIT (permissive) · 83a5e2270cf28813 · report
Metric mcgill-nlp/adversarialtriggers/adversarial_triggers/trainer/trigger_trainer.py community (archive-listed) unverified MIT (permissive) · ea93b766b4220f03 · report
ModelWorker mcgill-nlp/adversarialtriggers/adversarial_triggers/trainer/trigger_trainer.py community (archive-listed) unverified MIT (permissive) · 7a57a282eb260bdb · report
ProbeSamplingConfig grayswanai/nanogcg/nanogcg/gcg.py community (archive-listed) unverified MIT (permissive) · 06c48f95ad71eeb3 · report
TriggerDataset mcgill-nlp/adversarialtriggers/adversarial_triggers/trainer/trigger_trainer.py community (archive-listed) unverified MIT (permissive) · 2ca4e25741ed5c74 · report
TriggerTrainer mcgill-nlp/adversarialtriggers/adversarial_triggers/trainer/trigger_trainer.py community (archive-listed) unverified MIT (permissive) · 8a7d360fcc062ddc · report
adjust_learning_rate sj21j/Regularized_Relaxation/rr.py community (archive-listed) unverified MIT (permissive) · e0fcb1c976d55bf4 · report
batch_compute_score amanb2000/magic_words/magic_words/easy_gcg.py community (archive-listed) unverified MIT (permissive) · 00c5d6ebb885337e · report
calc_loss sj21j/Regularized_Relaxation/pgd.py community (archive-listed) unverified MIT (permissive) · bbec7a51e90453b0 · report
calc_loss sj21j/Regularized_Relaxation/softprompt.py community (archive-listed) unverified MIT (permissive) · e496788013a04ab0 · report
compute_score amanb2000/magic_words/magic_words/easy_gcg.py community (archive-listed) unverified MIT (permissive) · 13866ab049e2380b · report
create_example mcgill-nlp/adversarialtriggers/adversarial_triggers/trainer/trigger_trainer.py community (archive-listed) unverified MIT (permissive) · 7c2fecd166e014b6 · report
easy_gcg_qa_ids amanb2000/magic_words/magic_words/easy_gcg.py community (archive-listed) unverified MIT (permissive) · 5c805aa7bede7abd · report
estimate_grad fra31/rlhf-trojan-competition-submission/method/attacks.py community (archive-listed) unverified Apache-2.0 (permissive) · ba6f3154083bbf4f · report
filter_ids grayswanai/nanogcg/nanogcg/gcg.py community (archive-listed) unverified MIT (permissive) · d6bcee2f6eaa08f3 · report
filter_ids thompsonj/nanoGCG/nanogcg/gcg.py community (archive-listed) unverified MIT (permissive) · d8b335ad38108209 · report
filter_triggers mcgill-nlp/adversarialtriggers/adversarial_triggers/trainer/trigger_trainer.py community (archive-listed) unverified MIT (permissive) · a090e5ff02ef9ba4 · report
flush_memory ed-zh/parden/utils.py community (archive-listed) unverified no licence file found · pointer only · 7d27a4d4ed0c2348 · report
get_embedding_matrix sj21j/Regularized_Relaxation/helper.py community (archive-listed) unverified MIT (permissive) · 8e6c241c57e9b7d0 · report
get_prompt_grads amanb2000/magic_words/magic_words/easy_gcg.py community (archive-listed) unverified MIT (permissive) · 00acd6d7ab2a8438 · report
init_trigger fra31/rlhf-trojan-competition-submission/method/attacks.py community (archive-listed) unverified Apache-2.0 (permissive) · cb1b3fcdda5461cd · report
project_rows_to_simplex sj21j/Regularized_Relaxation/pgd.py community (archive-listed) unverified MIT (permissive) · ccf45483abe6b7a6 · report
rs_on_tokens fra31/rlhf-trojan-competition-submission/method/attacks.py community (archive-listed) unverified Apache-2.0 (permissive) · 2e3657f835661222 · report
sample_new_trigger_token_ids mcgill-nlp/adversarialtriggers/adversarial_triggers/trainer/trigger_trainer.py community (archive-listed) unverified MIT (permissive) · 110432e6c193e23e · report
simplex_projection sj21j/Regularized_Relaxation/pgd.py community (archive-listed) unverified MIT (permissive) · 88162fb08fbc4e3a · report
mellowmax identical code first harvested elsewhere ran · our draft was wrong fingerprinted licence of this copy not recorded · 932da9d6ec274164 · report
sample_ids_from_grad identical code first harvested elsewhere ran · our draft was wrong licence of this copy not recorded · 56640da5aa960a42 · report

Tasks

Adversarial AttackIngenuity

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Pythia

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections