CodeMimicry jailbreaks LLMs via code completion blind spots
Start here
Researchers propose a fully automated black-box jailbreak framework, CodeMimicry, which embeds malicious intent into syntactically valid object-oriented code and uses code completion tasks to induce models to output harmful content. On 8 commercial large language models, the method achieves a 96.25% attack success rate on AdvBench with an average of 1.51 queries, and 96.07% with 1.46 queries on HarmBench, outperforming template-based and optimization-based baselines. The authors attribute the phenomenon to lagging safety generalization: alignment trained mainly on natural language struggles to transfer to the code domain, creating a code completion blind spot.
Generated by AI from reports · Updated 2026-10-19
Related research
This event's paper
- CodeMimicry: Exploiting Safety Generalization Lag in Large Language Models via Structured Code Completion
NeurIPS 2026 · 2026-09-30 · Deep reading
Progress timeline
- arXiv: Jailbreaks, Prompt Injection, Poisoning & DefensesSelectedCodeMimicry: Exploiting code-domain safety generalization lag for structured code completion jailbreaks.
Researchers propose CodeMimicry, a fully automated black-box jailbreak framework that embeds malicious intent into syntactically valid object-oriented code, leveraging code completion tasks to induce models to output harmful content. On 8 commercial large language models, the method achieves a 96.25% attack success rate on AdvBench with an average of only 1.51 queries, and 96.07% with 1.46 queries on HarmBench, significantly outperforming template-based and optimization-based baselines. The authors attribute this phenomenon to safety generalization lag, where alignment primarily trained on natural language fails to transfer to the code domain, creating a blind spot in code completion. Latent space analysis shows that successful jailbreak samples are representationally close to benign code and systematically avoid refusal directions; activation steering experiments further support this explanation. The authors also note that the method relies on the target model's code generation capability and depends on string side channels such as comments and docstrings; after regex filtering of comments, the attack success rate drops to 20% to 26%.