TL;DR
This paper introduces PAL (Proxy-Guided Attack on LLMs), the first practical token-level optimization attack designed for black-box, query-only LLM APIs. By leveraging gradients from an open-source surrogate model alongside a clever API-tailored loss function, PAL achieves an 84% jailbreak success rate on GPT-3.5-Turbo and 48% on Llama-2-7B at a fraction of the cost of current state-of-the-art methods.
What Problem Does This Paper Address?
Jailbreaking Large Language Models (LLMs)—manipulating prompts to bypass safety alignment and generate harmful content—remains a persistent security challenge. While white-box optimization attacks like Greedy Coordinate Gradient (GCG) are highly effective, they require direct access to model gradients and token probabilities. This makes them inapplicable to proprietary, commercial models (like GPT-3.5 or GPT-4) hidden behind black-box APIs.
Existing black-box alternatives either rely on other LLMs as optimizers (which struggle against robustly aligned models like Llama-2) or require an impractical number of queries, making them prohibitively expensive. This paper bridges the gap by introducing a practical, token-level optimization attack optimized for real-world commercial APIs.
Methods
The authors propose PAL, an attack framework that combines query-based optimization, transfer attacks, and model extraction. The pipeline operates as follows:
- Proxy Guidance: Instead of querying the target API for gradients, PAL uses an open-source surrogate model (such as Vicuna-7B) to compute gradients and propose candidate token replacements for an adversarial suffix.
- Proxy Filtering: Candidates are filtered down to a small batch ($K$) based on the proxy model's loss.
- Logit Bias Trick: Commercial APIs typically only expose the top-5 log-probabilities, hiding the target tokens needed to compute cross-entropy loss. PAL bypasses this by querying the API twice: once normally, and once with a high logit bias applied to the target token to force it into the top-5, allowing its exact log-probability to be mathematically inferred.
- Candidate-Ranking Heuristic: To save query budget, PAL uses an early-termination strategy. If a candidate prompt fails to generate the first token of the target prefix (e.g., "Sure"), the evaluation is immediately aborted and its loss is set to infinity.
- Proxy Fine-Tuning (Optional): The proxy model can be iteratively fine-tuned on the target model's responses to better mimic its local behavior.
The authors also introduce GCG++ (an enhanced white-box attack using Carlini-Wagner loss and format-aware target strings) and RAL (a simplified black-box baseline using purely random search instead of proxy gradients).
Datasets
The attacks were evaluated using a randomly selected subset of 50 harmful behaviors from AdvBench, a standard benchmark for evaluating LLM safety alignment against malicious prompts (covering categories like hacking, terrorism, misinformation, theft, and dangerous activities).
Key Insights and Ideas
- Open-Source Proxies Transfer Surprisingly Well: Even though proprietary models are black boxes, they share architectural similarities and training data sources (e.g., CommonCrawl derivatives) with open-source models, making proxy-guided gradients highly effective.
- The Importance of Whitespace Formatting: A major breakthrough for white-box attacks on Llama-2-7B came from a tiny formatting detail: prepending a space token (" Sure") to match the model's specific chat template prior. This single change boosted GCG's success rate dramatically.
- API Constraints Can Be Hacked Mathematically: The logit bias trick demonstrates that restricted API outputs (like top-5 logprobs) do not fully protect a model from gradient-based optimization if the API allows logit manipulation.
- Early Pruning Saves Dollars: The candidate-ranking heuristic shows that jailbreak optimization behaves like a shortest-path search; dropping bad candidates early drastically cuts down API costs without sacrificing attack success.
Key Results
- High Success Rates on Commercial Models: PAL achieved an 84% Attack Success Rate (Harmful content, $\text{ASR}_\text{H}$) on GPT-3.5-Turbo-0613 and 74% on GPT-3.5-Turbo-1106, outperforming the state-of-the-art black-box attack (TAP).
- Cracking Llama-2-7B: On Llama-2-7B (notoriously difficult to jailbreak), PAL achieved 48% $\text{ASR}_\text{H}$, whereas TAP only achieved 4%.
- Remarkable Cost Efficiency: PAL found successful jailbreaks on GPT-3.5-Turbo-1106 for an average financial cost of just $0.88, making it highly practical for real-world red-teaming.
- GCG++ White-Box Superiority: GCG++ achieved 80% $\text{ASR}_\text{S}$ (verbatim target string matching) on Llama-2-7B within 500 steps (and 94% at 1,000 steps), compared to only 56% for the original GCG algorithm.
Limitations and Future Work
- API Feature Dependency: PAL relies heavily on the availability of logprobs or logit bias features in the target API. If a provider completely hides these features (offering only hard labels/text outputs), PAL cannot compute its loss function.
- Defenses: The authors note that while removing logit bias and logprobs from APIs would mitigate this specific attack, it severely degrades API utility for legitimate developers. Future work includes exploring stateful attack detection and reducing the transferability between open-source and proprietary models.
Summary updated