Research map / Large language models / Instruction and fine-tuning
CodeAttack: Revealing Safety Generalization Challenges of Large Language Models via Code Completion
Qibing Ren, Chang Gao, Jing Shao, Junchi Yan, Xin Tan, Wai Lam, Lizhuang Ma
Shanghai Jiao Tong University · The Chinese University of Hong Kong · Shanghai AI Laboratory · East China Normal University
Read the paperPlace an idea next to itCheck your own paper ↗
AI-extracted. The measured effects below were read by AI from the paper's full text (no summary yet). Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.
Measured effects reported in the paper
| What was changed | Where | Measured | Effect |
|---|---|---|---|
| Use CodeAttack code-completion prompts instead of CipherChat | CipherChat (SelfCipher) · AdvBench, average over 8 LLMs | attack success rate: 9% -> 78% (stack) | Improved |
| Encode input with stack instead of string (ablation) | CodeAttack · AdvBench, average over 8 LLMs | attack success rate: 51% -> 68% (queue) -> 78% (stack) | Improved |
| Encode input as stack instead of queue for smaller models (ablation) | CodeAttack · AdvBench, Llama-2-7b | attack success rate: 88% -> 54% | Hurt |
| Use CodeLlama-70b (code-tuned) instead of Llama-2-70b | CodeAttack (string) · AdvBench | attack success rate: 40% -> 93% | Hurt |
| Add decode() function for task understanding instead of comments (ablation) | CodeAttack (string) · AdvBench 50-subset, Claude-1 | attack success rate: 60% -> 92% | Improved |
| Add decode() function for task understanding instead of comments (ablation) | CodeAttack (string) · AdvBench 50-subset, GPT-3.5 | attack success rate: 94% -> 90% | Hurt |
| Specify output by populating a list instead of comments (ablation) | CodeAttack (string) · AdvBench 50-subset, Claude-1 | attack success rate: 42% -> 92% | Improved |
| Use Go instead of Python (ablation) | CodeAttack (string) · AdvBench 50-subset, Claude-2 | attack success rate: 24% -> 74% | Improved |
| Use Go instead of Python (ablation) | CodeAttack (string) · AdvBench 50-subset, GPT-3.5 | attack success rate: 90% -> 92% | No clear effect |
| Prepend benign quick sort code to prompt (ablation) | CodeAttack (list) · AdvBench, Claude-2 | attack success rate: 36% -> 54% | Improved |
| Prepend benign quick sort code to plain-text query (ablation) | plain text prompt · AdvBench, GPT-4-1106 and Claude-2 | attack success rate: 0% -> 0% | No clear effect |
| Apply Rand-Insert defense (ablation) | CodeAttack (stack) · AdvBench, GPT-4-1106 | attack success rate: 86% -> 34% | Improved |
Open problems in safety alignment after fine-tuning
Do safety defenses against harmful fine-tuning hold on larger models and against adaptive attacks?
- Larger models were not tested, mostly for lack of compute. · 27 papers state it
- Defenses are tested against few attacks and not against adaptive ones. · 15 papers state it
- Safety is scored by one LLM judge or classifier that may be biased. · 15 papers state it
Closest papers by meaning
- Navigating the Safety Landscape: Measuring Risks in Finetuning Large Language Models (NeurIPS 2024 · similarity 0.93)
- CodeMimicry: Exploiting Safety Generalization Lag in Large Language Models via Structured Code Completion (NeurIPS 2026 · similarity 0.92)
- Fine-tuning Aligned Language Models Compromises Safety, Even When Users Do Not Intend To! (ICLR 2024 · similarity 0.91)
- Safety Depth in Large Language Models: A Markov Chain Perspective (NeurIPS 2025 · similarity 0.91)
- SG-Bench: Evaluating LLM Safety Generalization Across Diverse Tasks and Prompt Types (NeurIPS 2024 · similarity 0.91)
- Controllable Safety Alignment: Inference-Time Adaptation to Diverse Safety Requirements (ICLR 2025 · similarity 0.91)
Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.