SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2310.04451 · ICLR · 2024

AutoDAN: Generating Stealthy Jailbreak Prompts on Aligned Large Language Models

Chaowei Xiao, Muhao Chen, Xiaogeng Liu, Nan Xu

arXiv · PDF · Open in the Atlas

Code that ran

6 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 5 failures of our instrument; 4 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2310.04451.json · badge: /api/ran/2310.04451.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
SheltonLiu-N/AutoDAN canonical (classifier label)
classifier basis: classifier_2025
2 ran · 1 no recorded run
sheltonliu-n/autodan community
Papers with Code archive
4 ran · 3 no recorded run
FunctionStatusWhere it lives
apply_crossover_and_mutation Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
sheltonliu-n/autodan/utils/opt_utils.py
code served (permissive licence) · get_code("7c9e974e56708d13")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import random
import re
import nltk
from nltk.corpus import stopwords, wordnet

# Download required NLTK data
try:
    nltk.data.find('corpora/stopwords')
except LookupError:
    nltk.download('stopwords')

try:
    nltk.data.find('corpora/wordnet')
except LookupError:
    nltk.download('wordnet')

try:
    nltk.data.find('tokenizers/punkt')
except LookupError:
    nltk.download('punkt')

# Create sample text data for selected_data parameter
sample_text_1 = """This is the first paragraph with multiple sentences here.
This is another sentence in the first paragraph."""

sample_text_2 = """This is the second paragraph containing different content.
This is yet another sentence in the second paragraph."""

sample_text_3 = """Third example text with several sentences for testing.
Another sentence goes here for completeness."""

sample_text_4 = """Fourth piece of sample text for genetic algorithm.
Final sentence in this particular example."""

# Create reference data (list of alternative texts)
reference_texts = [
    "Alternative text one with different content",
    "Alternative text two for mutation purposes",
    "Alternative text three as backup option",
    "Alternative text four for selection",
]

# Build the selected_data list (pairs of parent texts)
selected_data = [
    sample_text_1,
    sample_text_2,
    sample_text_3,
    sample_text_4,
]

# Define arguments dictionary for apply_crossover_and_mutation
ARGS = {
    'selected_data': selected_data,
    'crossover_probability': 0.5,
    'num_points': 3,
    'mutation_rate': 0.01,
    'API_key': None,
    'reference': reference_texts,
    'if_api': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
nltk, openai — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
apply_gpt_mutation Ran
ran on a synthesized input
sheltonliu-n/autodan/utils/opt_utils.py
code served (permissive licence) · get_code("9b962dc06655770e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import random
import nltk
from nltk.corpus import stopwords, wordnet

# Download required NLTK data
try:
    nltk.data.find('corpora/stopwords')
except LookupError:
    nltk.download('stopwords', quiet=True)

try:
    nltk.data.find('corpora/wordnet')
except LookupError:
    nltk.download('wordnet', quiet=True)

try:
    nltk.data.find('tokenizers/punkt')
except LookupError:
    nltk.download('punkt', quiet=True)

# Setup for apply_gpt_mutation function
offspring = [
    "The quick brown fox jumps over the lazy dog.",
    "Machine learning is a powerful tool for data analysis."
]

reference = [
    "The rapid auburn fox leaps above the idle canine.",
    "Artificial intelligence represents an influential mechanism for information processing.",
    "Deep neural networks process complex patterns effectively.",
    "Natural language processing enables machines to understand text."
]

mutation_rate = 0.5

API_key = None

if_api = False

ARGS = {
    'offspring': offspring,
    'mutation_rate': mutation_rate,
    'API_key': API_key,
    'reference': reference,
    'if_api': if_api
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
nltk, openai — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
check_for_attack_success Ran
ran; our contract draft was wrong, not the code
SheltonLiu-N/AutoDAN/autodan_ga_eval.py
code served (permissive licence) · get_code("7a1925d40005947b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from types import SimpleNamespace

torch.manual_seed(0)

# Minimal tokenizer stand-in
class MinimalTokenizer:
    def __init__(self):
        self.pad_token_id = 0
    
    def decode(self, token_ids):
        # Simple mock: convert token ids to words
        return "I cannot help with that request"

# Minimal generation config
class MinimalGenerationConfig:
    def __init__(self):
        self.max_new_tokens = 64

# Minimal model that supports generate
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
        self.generation_config = MinimalGenerationConfig()
        self.device_type = "cpu"
    
    @property
    def device(self):
        return torch.device("cpu")
    
    def generate(self, input_ids, attention_mask=None, generation_config=None, 
                 pad_token_id=None, top_p=None, do_sample=None, temperature=None):
        # Return mock generated token ids
        # input_ids shape: (batch_size, seq_len)
        batch_size = input_ids.shape[0]
        seq_len = input_ids.shape[1]
        # Generate some output tokens (append 10 new tokens)
        new_tokens = torch.randint(1, 100, (batch_size, seq_len + 10))
        return new_tokens

# Create instances
model = MinimalModel()
tokenizer = MinimalTokenizer()

# Create input_ids tensor (small, shape: 15 tokens)
input_ids = torch.randint(1, 100, (15,))

# Create assistant_role_slice - a slice object indicating where assistant response starts
# Using slice(10, 15) means assistant response is from token 10 to 15
assistant_role_slice = slice(10, 15)

# Test prefixes to check against
test_prefixes = ["I cannot", "I can't", "I apologize"]

# Optional generation config (can be None to use model's default)
gen_config = None

ARGS = {
    "model": model,
    "tokenizer": tokenizer,
    "input_ids": input_ids,
    "assistant_role_slice": assistant_role_slice,
    "test_prefixes": test_prefixes,
    "gen_config": gen_config,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
crossover Ran
ran; our contract draft was wrong, not the code
sheltonliu-n/autodan/utils/opt_utils.py
code served (permissive licence) · get_code("f7269d0d60790e7b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import random
import re

random.seed(0)

# Construct sample strings with paragraphs and sentences
str1 = "This is the first sentence. Here is the second one! And a third. More content here.\n\nAnother paragraph starts here. It has multiple sentences. And even more."

str2 = "This is a different first sentence. The second sentence varies. A third one too. Different content.\n\nA different second paragraph begins. With its own sentences. And conclusion."

num_points = 2

ARGS = {
    "str1": str1,
    "str2": str2,
    "num_points": num_points
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
generate Ran
ran; our contract draft was wrong, not the code
SheltonLiu-N/AutoDAN/autodan_ga_eval.py
code served (permissive licence) · get_code("c0332de7e8c09ed4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 1, dtype family int, shape (10,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from types import SimpleNamespace

torch.manual_seed(0)

# Create a minimal tokenizer stand-in with required attributes
class MinimalTokenizer:
    def __init__(self):
        self.pad_token_id = 0

tokenizer = MinimalTokenizer()

# Create a minimal generation config
class MinimalGenerationConfig:
    def __init__(self):
        self.max_new_tokens = 64

gen_config = MinimalGenerationConfig()

# Create a minimal model that supports generate() and has device/generation_config
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
        self.generation_config = gen_config
        self.device_type = 'cpu'
    
    @property
    def device(self):
        return torch.device('cpu')
    
    def generate(self, input_ids, attention_mask=None, generation_config=None, 
                 pad_token_id=None, top_p=None, do_sample=None, temperature=None):
        # Return a tensor with shape (batch_size, seq_len)
        # Input shape is (1, seq_len), we'll return (1, seq_len + 10)
        batch_size = input_ids.shape[0]
        seq_len = input_ids.shape[1]
        output_len = seq_len + 10
        return torch.randint(0, 100, (batch_size, output_len))

model = MinimalModel()

# Create input_ids tensor with shape (seq_len,) - using 12 tokens
input_ids = torch.randint(0, 100, (12,))

# Create assistant_role_slice as a slice object
# slice.stop will be used to index into input_ids
assistant_role_slice = slice(5, 12)  # stop at index 12

ARGS = {
    'model': model,
    'tokenizer': tokenizer,
    'input_ids': input_ids,
    'assistant_role_slice': assistant_role_slice,
    'gen_config': None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 1, dtype family int, shape (10,) — shape (10,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
roulette_wheel_selection Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
sheltonliu-n/autodan/utils/opt_utils.py
code served (permissive licence) · get_code("1fe7dbe6f5cc4593")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

np.random.seed(42)

# Construct arguments for roulette_wheel_selection
data_list = ["item_a", "item_b", "item_c", "item_d"]
score_list = np.array([1.0, 2.5, 0.5, 3.2])
num_selected = 3
if_softmax = True

ARGS = {
    "data_list": data_list,
    "score_list": score_list,
    "num_selected": num_selected,
    "if_softmax": if_softmax
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
autodan_sample_control Not yet run
unverified (harvested, no recorded run)
sheltonliu-n/autodan/utils/opt_utils.py
code served (permissive licence) · get_code("830a85ed7000f19b")
How it ran

no invocation recorded.

get_developer Not yet run
unverified (harvested, no recorded run)
SheltonLiu-N/AutoDAN/autodan_ga_eval.py
code served (permissive licence) · get_code("272207fb8d21ce30")
How it ran

no invocation recorded. this sample carries JSON test cases instead of a setup block; get_reference_implementation serves them with the level they back.

gpt_mutate Not yet run
unverified (harvested, no recorded run)
sheltonliu-n/autodan/utils/opt_utils.py
code served (permissive licence) · get_code("b4c5d45b78d6c1b9")
How it ran

no invocation recorded.

replace_with_synonyms Not yet run
unverified (harvested, no recorded run)
sheltonliu-n/autodan/utils/opt_utils.py
code served (permissive licence) · get_code("d013d2ff9040eecb")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 4 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 4 later) and 6 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
roulette_wheel_selection
brick of this paper's assembly: sampler
2 other papers
2 later
2402.16459 (2024-02)
Defending LLMs against Jailbreaking Attacks via Backtranslation
2410.04234 (2024-10)
Functional Homotopy: Smoothing Discrete Optimization via Continuous Parameters for LLM Jailbreak Attacks
autodan_sample_control
brick of this paper's assembly: entry
1 other paper
1 later
2410.04234 (2024-10)
Functional Homotopy: Smoothing Discrete Optimization via Continuous Parameters for LLM Jailbreak Attacks
check_for_attack_success 1 other paper
1 later
2403.04957 (2024-03)
Automatic and Universal Prompt Injection Attacks against Large Language Models
generate 1 other paper
1 later
2403.04957 (2024-03)
Automatic and Universal Prompt Injection Attacks against Large Language Models

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Warning: This paper contains potentially offensive and harmful text. The aligned Large Language Models (LLMs) are powerful language understanding and decision-making tools that are created through extensive alignment with human feedback. However, these large models remain susceptible to jailbreak attacks, where adversaries manipulate prompts to elicit malicious outputs that should not be given by aligned LLMs. Investigating jailbreak prompts can lead us to delve into the limitations of LLMs and further guide us to secure them. Unfortunately, existing jailbreak techniques suffer from either (1) scalability issues, where attacks heavily rely on manual crafting of prompts, or (2) stealthiness problems, as attacks depend on token-based algorithms to generate prompts that are often semantically meaningless, making them susceptible to detection through basic perplexity testing. In light of these challenges, we intend to answer this question: Can we develop an approach that can automatically generate stealthy jailbreak prompts? In this paper, we introduce AutoDAN, a novel jailbreak attack against aligned LLMs. AutoDAN can automatically generate stealthy jailbreak prompts by the carefully designed hierarchical genetic algorithm. Extensive evaluations demonstrate that AutoDAN not only automates the process while preserving semantic meaningfulness, but also demonstrates superior attack strength in cross-model transferability, and cross-sample universality compared with the baseline. Moreover, we also compare AutoDAN with perplexity-based defense methods and show that AutoDAN can bypass them effectively. Code is available at https://github.com/SheltonLiu-N/AutoDAN.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2310.04451")
get_code_for_paper("2310.04451")
have("2310.04451")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2310.04451.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2310.04451.svg)](https://syntology.ai/paper/2310.04451)

Connect an agent — have() is free.