PAL: Surrogate-Model-Guided Black-Box Attacks on Large Language ModelsPAL: Proxy-Guided Black-Box Attack on Large Language Models
The authors propose PAL, a surrogate-model-guided black-box jailbreak attack, achieving 84% ASRH on GPT-3.5-Turbo-0613 and 48% on Llama-2-7B (TAP: 4%).
black-box query-only setting: the attacker can only query the target LLM through an API (assumed to provide top-5 logprobs and logit bias), with no gradient access; the goal is to optimize an adversarial suffix so that the model outputs harmful content; the victim systems are a commercial LLM API (GPT-3.5-Turbo) and open-source models accessed via API (Llama-2-7B).
- Optimization-based jailbreak attacks such as GCG require gradient access and cannot be used against commercial LLMs that only expose an API; existing black-box attacks (e.g., TAP) have low success rates on more robustly aligned models. The authors aim to address the practical jailbreak problem in the black-box query-only setting.
- PAL uses the gradients of an open-source surrogate model (Vicuna-7B) to guide token-level search, then filters candidates with the surrogate loss, querying the target model for only a small number of candidates; it is accompanied by a logit bias technique that infers loss from top-5 logprobs, a heuristic that discards poor candidates early by prefix matching, and optional surrogate model fine-tuning. It also proposes a white-box improved version GCG++ and a pure random search baseline RAL.
- On 50 AdvBench behaviors: PAL achieves ASRH 84% on GPT-3.5-Turbo-0613 (TAP 80%) and 48% on Llama-2-7B (TAP 4%); GCG++ achieves ASRS 94% on Llama-2-7B at 1,000 steps (GCG 56%); RAL achieves ASRH 26% on Llama-2-7B.
- The authors point out that the attack cannot be used against APIs that do not provide logprobs and logit bias (such as Anthropic). The experiments covered 3 black-box target models, 50 harmful behaviors, and a 25k query budget; ASRH was manually annotated by two authors, and the paper does not report an annotation consistency value; no defenses were evaluated.
- Evaluated models
- Llama-2-7B (meta-llama/Llama-2-7b-chat-hf)GPT-3.5-Turbo-0613GPT-3.5-Turbo-1106Vicuna-7B (lmsys/vicuna-7b-v1.5-16k)OpenChat-3.5 (openchat/openchat-3.5-1210)Llama-2-13B
- Benchmarks
- AdvBench(harmful behavior 设置,随机选 50 个行为)
- Metrics
- ASRSASRH平均查询数每次成功越狱的估计成本(美元)
Researchers from UC Berkeley and other institutions propose PAL, which uses the gradients of an open-source surrogate model (Vicuna-7B) to guide optimization; the authors claim this is the first token-level black-box optimization jailbreak method that can actually attack real LLM APIs. The attack uses the surrogate model to screen candidate suffixes to reduce queries to the target model, and uses a logit bias technique to infer the logprob of the target token from an API that returns only top-5 logprobs. Under a budget of 25k queries per sample, PAL achieves a 74% harmful output success rate against GPT-3.5-Turbo-1106 (TAP: 58%), costs an average of 0.88 USD per successful jailbreak, achieves 84% against GPT-3.5-Turbo-0613, and achieves 48% against Llama-2-7B while TAP achieves only 4%.
Why it was selectedThe paper provides black-box jailbreak attack success rate and cost data for real LLM APIs, which teams conducting model safety evaluations can use to select stronger attack baselines.
Paper analysis
What problem does this paper attempt to solve?
Addresses the problem of practical optimization-based jailbreak attacks against commercial LLM APIs in the black-box query-only setting.
Core question: how to perform practical token-level optimization jailbreak attacks on safety-fine-tuned LLMs in a black-box setting without gradient access and with only API queries.
- Setting and motivation: white-box optimization attacks such as GCG can find suffixes that induce harmful outputs, but they require gradients and do not apply to proprietary models that only expose an API; the authors believe a method is needed to assess the safety risks of proprietary LLMs behind black-box APIs.
- Shortcomings of existing methods (per the paper): the authors say that methods using an LLM as optimizer, such as PAIR and TAP, have a search space limited by the output distribution of the attacker LLM, and have low ASR on more stably aligned models such as Llama-2-7B; evaluating safety with only weak attacks is risky.
- Two technical challenges: first, the attack budget — GCG requires up to 256k queries plus gradients, and queries alone on GPT-3.5-Turbo cost about $18; second, loss computation — most commercial APIs expose at most top-5 logprobs, making it impossible to directly compute a log-likelihood objective.
- Core observation: many open-source models share architecture and training data with proprietary models, or are simply distilled from proprietary models, so the loss of an open-source proxy model can approximate the target model's loss (Lϕ ≈ Lθ) and can be used to guide the search.
- The paper proposes: PAL (Proxy-Guided Attack on LLMs), a black-box attack; GCG++, a white-box improved version; RAL, a random search baseline; and accompanying API loss computation techniques.
- Threat model:
- Goal: find an adversarial suffix that makes the target model output actually harmful content (jailbreak, as distinct from prompt injection).
- Knowledge: black-box query-only; no gradients, no full logits; assumes the API provides top-5 logprobs and logit bias (per the OpenAI Chat API setting).
- Capability: iteratively query the target API, with a budget of 25k queries/sample; run locally and optionally fine-tune an open-source proxy model.
- Victim systems: commercial LLM APIs (GPT-3.5-Turbo) and open-source models accessed via API (Llama-2-7B).
What related research exists?
Related work falls into four categories: manual jailbreaks, optimization attacks, LLMs as optimizers, and proxy model query attacks; the baseline is TAP.
Manually discovered failure modes
- Measurement studies such as Shen et al. (2023), Wei et al. (2023), Yong et al. (2023), and Zeng et al. (2024) evaluated the effectiveness of manually crafted jailbreak techniques such as DAN, the "Grandma exploit", and non-English prompts.
Optimization attacks
- GCG (Zou et al., 2023) — a gradient-based discrete optimization method, and the direct object of improvement in this paper; the authors point out that its main limitation is requiring gradients, making it unusable for API models.
- AutoDAN (Liu et al., 2023) and Lapid et al. (2023) — black-box jailbreaks using genetic algorithms and transfer attacks, respectively; the paper points out that both were evaluated only on open-source models and did not propose a method for computing loss through commercial APIs, that Liu et al. also relies on manual mutation and manual jailbreak initialization, and that Lapid et al. did not release an implementation, making fair comparison difficult.
- Andriushchenko (2023) — parallel work using a simple hill-climbing algorithm for black-box jailbreaks; the paper points out that it requires manually constructed target strings.
LLMs as optimizers
- Perez et al. (2022) trained an LLM to automate red teaming; PAIR (Chao et al., 2023) uses an attacker LLM to generate semantic jailbreaks in the black-box setting; TAP (Mehrotra et al., 2023) uses tree-of-thought reasoning to iteratively refine adversarial prompts.
- The authors argue that the search space of such methods is limited by the output distribution of the attacker LLM, and cite Takemoto (2024) as saying their success rates are similar to simple paraphrase attacks, with low ASR on Llama-2-7B.
Proxy model query attacks
- In black-box visual classifier attacks, proxy model gradients have been used in place of target model gradients to reduce queries (Cheng et al., 2019; Yan et al., 2019; Cai et al., 2022; Lord et al., 2022, etc.); PAL borrows this idea to adapt GCG to the black-box setting, and the authors say this is the first practical application of such attacks in the LLM/NLP field.
Baseline and benchmark: the comparison baseline is TAP (Mehrotra et al., 2023), where the results for Llama-2-7B and GPT-3.5-Turbo-0613 are quoted directly from the original source (with slightly different ASR criteria), and those for GPT-3.5-Turbo-1106 were run by the authors themselves; the benchmark is the harmful behavior setting of AdvBench (50 randomly selected behaviors).
The authors position this paper as: introducing proxy-model-guided query attacks into LLM jailbreaking, and solving the problem of incomputable loss with a loss function designed for real APIs, distinct from the PAIR/TAP line that relies on the semantics of an attacker LLM.
How does the paper address this problem?
PAL uses the gradients of an open-source surrogate model to guide the search and filter candidates, and together with an API loss inference technique adapts GCG to the black box.
Overall idea: use the gradients of an open-source proxy model in place of the target model's gradients to guide token-level optimization, and query the target API only on a small number of filtered candidates, thereby moving GCG-style attacks into the black-box query-only setting.
Problem setting
- Given a prompt p and a target string y, search for an n-token adversarial suffix x that maximizes the probability of the target model outputting y: maxx ∈ Vn log pθ(y ∣ p | x), where V is the vocabulary.
- The attack combines elements of query attacks, transfer attacks, and model extraction; its effectiveness depends on how well the proxy loss approximates the target loss, so the proxy model can optionally be fine-tuned on target model outputs.
PAL main procedure (Algorithm 1)
- Initialization: use GCG++ to attack the proxy model and obtain an initial suffix.
- Gradients and sampling: compute gradients on the proxy model, select top-k replacements in the GCG manner, and randomly sample B candidates.
- Proxy filtering: filter the B candidates down to K by proxy loss to reduce target queries.
- Query the target model: query the target loss and responses for the K candidates (see the next section).
- Select the best: select the next-step candidate by target loss (same as GCG).
- Optional fine-tuning: fine-tune the proxy model on the target model's responses so that it is closer to the target model near the optimization region.
- Default parameters: k = 256, B = 128, K = 32; black-box budget 25k queries/sample.
Computing loss from the API (Section 3.3)
- Logit bias trick: the OpenAI Chat API only gives top-5 logprobs, and the target token is often not among them. The authors query twice (once normally, once with a logit bias b added to the target token, e.g., 30), and derive the target token's logprob from log py = log p′y − log p′1 + log p1 − b, thereby computing the cross-entropy or CW loss.
- Candidate ranking heuristic: a naive implementation requires 2L queries per sample (L is the target string length, about 18 tokens on average for AdvBench). Instead, generate token by token, and once a generated token does not match the target string, terminate that candidate and set its loss to infinity: L̃θ(z, y) computes partial loss only for the candidate with the longest common prefix match among all candidates, and ∞ for the rest. The authors say this resembles best-first/beam search, and the queries saved are more worthwhile than occasionally selecting the wrong candidate.
- Other APIs: APIs that return full logprobs can save about half the queries; echo mode can compute the loss for the whole string at once; when only top-1 logprob is available, binary search can be used, but the authors say their differencing trick is more efficient when k ≥ 2.
Other improvements (Section 3.4)
- CW loss: replace cross-entropy with a multi-class hinge loss to avoid softmax gradient vanishing; the authors say it works better empirically on attacking LLMs.
- Format-aware target string: Llama-2-7B tends to output a space at the start of its reply; allowing the target string to start with a space raises GCG's ASR on it from 56% to 80% (Section 4.3); the authors say the official GCG codebase ignored this detail.
GCG++ and RAL (Section 3.5)
- GCG++: the white-box version, combining CW loss, format-aware target strings, and the implementation improvements in PAL (candidate sampling/filtering, skipping visited suffixes).
- RAL: removes the proxy model and samples candidates fully uniformly at random, with the rest the same as PAL; deployment cost is 40% of PAL, serving as a simple black-box baseline and ablation.
Success determination
- ASRS: the proportion of cases where the model verbatim outputs a predefined affirmative string; ASRH: the proportion of cases where the output is actually harmful and can assist the attacker in achieving the goal, manually annotated by two authors with disagreements resolved by discussion; merely expressing willingness to answer does not count as success.
What experiments did the paper conduct?
Evaluated on 50 AdvBench behaviors: PAL achieves ASRH 84% on GPT-3.5-Turbo-0613 and 48% on Llama-2-7B; GCG++ white-box ASRS reaches up to 94%.
Experimental Setup
- Target models (black-box): Llama-2-7B (meta-llama/Llama-2-7b-chat-hf), GPT-3.5-Turbo-0613, GPT-3.5-Turbo-1106; all assumed to be accessed via the OpenAI Chat API (top-5 logprobs + logit bias).
- Target models (white-box): Llama-2-7B, Vicuna-7B, OpenChat-3.5 (openchat/openchat-3.5-1210).
- Surrogate/auxiliary models: PAL uses Vicuna-7B (lmsys/vicuna-7b-v1.5-16k) as the surrogate; the authors' own run of TAP uses Vicuna-13B as the attack LLM and GPT-4 as the judge LLM.
- Dataset: AdvBench harmful behavior setting, with 50 behaviors randomly selected following the setup of Mehrotra et al. (2023).
- Metrics: ASRS (verbatim match of the target string), ASRH (manually judged as actually harmful, annotated by two authors with disagreements resolved by discussion); cost estimated using API and cloud GPU prices as of January 30, 2024.
- Parameters: black-box budget 25k queries/sample; greedy decoding (temperature 0), default system prompt; white-box attacks run for 500 steps with the suffix initialized to 20 "!"; PAL defaults k=256, B=128, K=32.
Main Results
Black-box attack results (per Table 1; TAP results on Llama-2-7B and GPT-3.5-Turbo-0613 are cited from Mehrotra et al. (2023), with slightly different ASR criteria):
Swipe horizontally to read the table
Attack Llama-2-7B ASRS / ASRH / cost GPT-3.5-Turbo-0613 ASRS / ASRH / cost GPT-3.5-Turbo-1106 ASRS / ASRH / cost TAP 0 / 4 / $3.85 4 / 80 / $1.34 8 / 58 / $1.68 RAL 10 / 26 / $0.60 not reported not reported PAL (w/o FT) 38 / 48 / $1.54 28 / 78 / $0.24 16 / 70 / $0.53 PAL (w/ FT) 36 / 42 / $1.93 18 / 84 / $0.40 12 / 74 / $0.88 - The authors state that PAL's ASRS on GPT-3.5-Turbo-0613 and -1106 is 4 and 16 percentage points higher than TAP, respectively, at less than half of TAP's cost; they also observe that -1106 is harder to jailbreak than -0613.
- The authors state that RAL and PAL are the first black-box jailbreak attacks to achieve non-trivial ASR on Llama-2-7B; Llama-2-7B is harder to jailbreak than GPT-3.5-Turbo: it is easier to make it output the target string (ASRS 38% vs 18%), yet harder to make it output actually harmful content (ASRH 48% vs 84%).
- ASRH is consistently higher than ASRS: by 10–20 percentage points on Llama-2-7B and by up to 60 percentage points on GPT-3.5-Turbo; only 6 of 37 successful jailbreaks repeated the target string verbatim (Figure 3), on which basis the authors argue that target strings beginning with "Sure, here" are far from optimal.
White-box Attacks (GCG++)
- Main results (Table 2): at 500 steps with default parameters (batch 512, k=256), GCG++ achieves ASRS of 80% on Llama-2-7B (GCG 56%), 96% on Vicuna-7B (86%), and 80% on OpenChat-3.5 (70%).
- Convergence speed (Figure 5): the authors state that GCG++ reaches 50% ASRS in about 100 steps (GCG requires 400 steps); at 1,000 steps GCG++ reaches 94%, while GCG plateaus at 56% after 500 steps.
- Gradient-free ablation: GCG++ (RANDOM) removes gradients and samples candidates randomly, reaching 78% ASRS at 1,000 steps, still above GCG's 56% and slightly below GCG++'s 94%; the authors state this indicates that gradients play only a moderate role in GCG-style attacks.
Surrogate Fine-tuning and Loss Correlation Analysis (Appendix C.1)
- What was measured: with Llama-2-13B as the target and Vicuna-7B as the surrogate, the relationship between surrogate loss and target loss with and without fine-tuning was compared (Figure 6, Figure 7).
- Results: without fine-tuning the two are negatively correlated, whereas after fine-tuning both decrease together; the authors consider this the reason the fine-tuned version of PAL is usually better, and speculate that without fine-tuning there is an "overfitting" region to the surrogate model (target loss is lowest near surrogate loss 0.75).
Other Ablations and Analyses
- Format-aware target string (Table 8, Llama-2-7B): adding this technique alone raises ASRS from 56% to 76% (1,000 steps); the authors state it yields the largest improvement among the techniques.
- Loss function and spaces (Table 7): CW loss is no worse than CE in most settings; removing/adding spaces can change ASRS by −2 to −68 percentage points.
- Momentum and multi-coordinate (Table 8, Table 9): adding momentum (80→68), multi-coordinate (80→60), or removing the format-aware target string (80→64) on GCG++ all lower ASRS; adding multi-coordinate to GCG alone gives +12 percentage points (1,000 steps).
- Batch size (Figure 8): affects the ASR of RAL/PAL but the differences are not statistically significant, with no clear pattern observed.
- Number of queries (Table 5): PAL without fine-tuning uses fewer queries than with fine-tuning (lowest median 1.1k for GPT-3.5-Turbo); Llama-2-7B requires about 6–7 times the queries of GPT-3.5.
- Harmful categories (Figure 9): the authors state that misinformation behaviors are the easiest to elicit across all models, and that the success distributions of Llama-2-7B and GPT-3.5-Turbo differ markedly.
- Cost comparison (Table 4): running the full default budget, TAP is estimated at $5.34 (of which GPT-4 judging is $4.21) and PAL at $3.60 (including $2.15 in surrogate model GPU costs).
What are some points that can be further explored?
The authors note that the inability to attack APIs that do not expose logprobs/logit bias is a main limitation, and list multiple defense directions awaiting verification.
Limitations and Future Directions Noted by the Authors
- API capability constraints (Section 5): the main limitation is the inability to attack APIs that provide neither logprobs nor logit bias (e.g., Anthropic); this setting requires hard-label query attacks; a possible workaround is to score using output strings (LLM judging or sentence similarity).
- Target string selection (Section 4.2, Appendix B.3): target strings beginning with "Sure, here" are far from optimal; using prefixes actually generated by the model as targets may be more efficient, and how to choose the target set Y may lead to stronger jailbreak algorithms.
- The Llama-2-7B phenomenon (Section 4.2): it is easier to force it to output the target string yet harder to make it output actually harmful content, which the authors consider worthy of future study.
- Defense directions (Section 5): removing logit bias and logprobs from APIs would reduce API usability and would not stop TAP/PAIR; whether directions such as training against latent attacks, reducing the similarity between open-source and deployed models, and stateful attack detection are effective for LLMs remains unclear.
- Actual harm of harmful outputs (Appendix A): the authors state that the harmful responses generated by PAL are not specific enough to constitute an immediate threat, and are uncertain whether this is due to limited model capability or the model downplaying on its own, leaving it for future study.
- Automatic judging (Appendix A): manual annotation is currently used because of the lack of a reliable jailbreak detector; the authors believe that once a reliable detector is released it could be used to terminate attacks early and further reduce cost.
Scope of Experiments
- Black-box target models are Llama-2-7B, GPT-3.5-Turbo-0613, and GPT-3.5-Turbo-1106, 3 in total; white-box additionally tests Vicuna-7B and OpenChat-3.5 (Table 2).
- Evaluation data are 50 harmful behaviors randomly selected from AdvBench; black-box budget is 25k queries/sample, white-box 500–1,000 steps.
- The only comparison baseline is TAP; its numbers on Llama-2-7B and GPT-3.5-Turbo-0613 are cited from the original paper, with ASR criteria slightly different from this paper (Table 1 footnote).
- ASRH is manually annotated by two authors with disagreements resolved by discussion; the paper reports no annotation agreement values and does not use an automatic judge model to score PAL/RAL results.
- The paper does not evaluate the effect of any defense on PAL/GCG++, nor does it report the number of repeated runs per condition.
Summarize the main content of the paper
PAL uses proxy model guidance to achieve practical black-box jailbreaks: ASRH 84% on GPT-3.5-Turbo-0613 and 48% on Llama-2-7B (TAP 4%).
A paper on black-box jailbreak attacks, aiming to perform practical token-level optimization attacks on safety-fine-tuned LLMs in a setting without gradients and with only API queries.
- Problem: white-box optimization attacks such as GCG require gradients and cannot be used on commercial APIs; the authors say that LLM-optimizer methods such as PAIR/TAP have low success rates on more stably aligned models, and that evaluating safety with weak attacks is risky.
- Method: PAL uses the gradients of an open-source proxy model (Vicuna-7B) to guide candidate generation and filters by proxy loss, querying the target model only on a small number of candidates; it is paired with two API techniques — deriving the target token's logprob via two queries with logit bias, and discarding poor candidates early by prefix matching to save queries; the proxy can optionally be fine-tuned on target model outputs. It also proposes a white-box improved version GCG++ (CW loss + format-aware target string + implementation improvements) and a pure random search baseline RAL.
- Black-box results (Table 1, 50 AdvBench behaviors, 25k query budget): PAL achieves ASRH 84% on GPT-3.5-Turbo-0613 (TAP 80%), 74% on GPT-3.5-Turbo-1106 (TAP 58%), and 48% on Llama-2-7B (TAP 4%); the average cost per successful jailbreak is as low as $0.24 (GPT-3.5-Turbo-0613, without fine-tuning).
- White-box results (Table 2, Figure 5): GCG++ achieves ASRS 80% on Llama-2-7B at 500 steps (GCG 56%) and 94% at 1,000 steps; GCG++ (RANDOM) without gradients also reaches 78%, on which basis the authors say gradients play only a moderate role in GCG-style attacks.
- Other findings: RAL achieves ASRH 26% on Llama-2-7B; ASRH is consistently higher than ASRS, with only 6 of 37 successful jailbreaks verbatim matching the target string, and the authors believe commonly used target strings are far from optimal.
- Authors' conclusion: the authors believe PAL, GCG++, and RAL can serve as practical baselines for evaluating LLM safety in white-box and black-box settings, and point out that the inability to attack APIs that do not expose logprobs/logit bias is a major limitation, with practical defenses still unresolved.