- Rating
- 4
- Clarity
- 3
- Confidence
- 4
- Originality
- 3
- Quality
- 3
- Significance
- 3
Read review
Summary
This work investigates a safety vulnerability in large language models called "safety generalization lag," which occurs because safety alignment is primarily trained on natural language data and fails to generalize effectively to structured, syntactically rigid spaces like source code. To demonstrate this vulnerability, the authors present CodeMimicry, an automated black-box jailbreak framework that transforms natural language toxic queries into incomplete object-oriented code templates. Disguised as standard engineering code-completion tasks, these prompts exploit the model's completion objective to bypass safety dialog guardrails. The effectiveness of this framework is demonstrated across eight state-of-the-art commercial models, achieving a high attack success rate (an average of 96.25% on AdvBench) with a very low query budget (around 1.5 queries). Furthermore, the authors perform latent space representation analysis, showing that successful jailbreak code samples cluster near benign code rather than aligning with refusal representation vectors.
Strengths and weaknesses
Strengths
- Conceptual Formulation of Generalization Discrepancy: The authors formalize the concept of "safety generalization lag" within code spaces, highlighting a major discrepancy between an LLM's advanced coding capabilities and its safety alignment data distribution mismatch.
- High Empirical Performance and Query Efficiency: Evaluating CodeMimicry against eight popular, closed-source models shows highly effective attack success rates (exceeding 96% with ~1.5 queries), demonstrating that contemporary safety guardrails have widespread blind spots in code domains.
- Mechanistic Internal State Exploration: Beyond empirical red-teaming, the paper stands out by analyzing internal representation engineering, projection onto refusal manifolds, and activation steering metrics, providing valuable theoretical reasoning for the success of code-completion-based bypasses.
Weaknesses
- Conceptual Subsumption Under General Distributional Shift Frameworks: The core concept of "safety generalization lag" represents the failure of safety alignment to generalize from conversational dialogues to structured code-completion spaces. However, this phenomenon can be fundamentally viewed as a specific instance of a broader, well-established class of vulnerabilities: namely, systemic ethical drift and safety failures under distributional shifts/coverage gaps (as studied in recent literature, such as Lian et al., Nature Communications 2026, "Revealing the intrinsic ethical vulnerability of aligned large language models"). Under this unified perspective, the post-hoc alignment (such as SFT, RLHF, DPO) only establishes a localized "safety region" within conversational supports, while pretrained harmful connections remain topologically accessible globally. By wrapping malicious intents into structured object-oriented code completion, the authors are essentially utilizing a manually designed distributional shift to bypass safety dialog manifolds rather than discovering a completely independent code-specific behavior. The paper would be significantly strengthened if the authors could theoretically or conceptually connect their "safety generalization lag" to general distributional shift frameworks and differentiate what specific characteristics code completion exhibits beyond typical manual formatting shifts.
- Robustness and Sensitivity of the Completion Trigger: The framework uses a static completion trigger to shift the model's attention. Testing of prompt perturbations is absent; a sensitivity analysis exploring how variations in this completion wrapper template affect safety defenses is needed to confirm the attack's structural robustness.
- Practicality of Proposed Defenses: Some of the most promising defenses evaluated (e.g., Circuit Breakers and Representation-Bending) require hidden layer interventions and direct activation steering. These metrics are impractical for commercial closed-source APIs, and the paper would benefit from suggesting and exploring realistic outer boundary or prompt-level protective guidelines.
- High Infrastructure and Attacker Model Dependency: Although CodeMimicry is black-box to the target model, the multi-turn optimization and critique loop rely on high-resource reasoning models (e.g., DeepSeek-R1) to automatically construct and repair the object-oriented wrapper. This dependency increases the optimization cost, which is not fully addressed or quantified in terms of hardware/API overhead.
Questions
Please refer to weaknesses
Limitations
yes
Paper formatting concerns
No formatting concerns
Final justification
The authors further clarified the novelty of CodeMimicry and strengthened the evaluation, resolving earlier concerns on rigor. While minor questions on broader applicability remain, the work presents a solid and timely contribution, and I maintain my positive recommendation.
We thank the reviewer for the thoughtful comments.
1.Relation to general distributional-shift / ethical-drift frameworks.
We agree that safety generalization lag can be viewed as a concrete instance of a broader failure mode: safety alignment may only cover a local region of the aligned conversational distribution, while harmful knowledge remains accessible under distributional shift. Our contribution is not to claim that code completion is completely independent from general distributional-shift vulnerabilities. Rather, we identify a specific and practically important instantiation of this broader phenomenon in the structured code-completion subspace. Code completion differs from ordinary formatting shifts in several ways: (i) it has rigid syntax and strong structural priors, (ii) models are heavily pretrained and optimized for completing partial programs, (iii) comments/docstrings, function names, class names, and parameter names provide multiple semantic channels, and (iv) completion objectives can shift the model from safety-oriented dialogue behavior toward implementation-oriented continuation. These properties make code not merely a superficial prompt format, but a semantically rich and capability-dense subspace where safety alignment may transfer poorly. We will revise the paper to connect safety generalization lag to the broader distributional-shift perspective.
2.Robustness and sensitivity of the completion trigger.
We agree that the static completion wrapper should be stress-tested. To address this, we added a sensitivity analysis on wrapper variants using AdvBench with GPT-4o as the target model. The full CodeMimicry wrapper is compared with semantic paraphrasing, removal of refusal-ban wording, a minimal trigger, and bare code without an explicit wrapper.
Here, Full-Wrapper is the original CodeMimicry setting. Paraphrased-Wrapper rewrites the wrapper semantically while preserving its intent. No-Refusal-Ban removes the explicit refusal-prohibition wording. Minimal-Trigger uses only a short instruction such as
"Complete this python code:"followed by the generated code. Bare-Code sends only the code context.These results show that the attack is sensitive to the wrapper, but not exclusively dependent on one exact fixed string. The paraphrased wrapper still achieves 72% ASR, indicating robustness to surface-level rewording. At the same time, the drop for No-Refusal-Ban, Minimal-Trigger, and Bare-Code shows that the wrapper contributes meaningfully by establishing a code-completion mode and suppressing refusal-style responses. We will add this ablation to the revised paper and clarify which parts of the prompt contribute to attack success.
3.Practicality of defenses.
We agree that hidden-layer defenses such as Circuit Breakers and Representation Bending are not directly applicable to closed-source commercial APIs. However, these are not the only defenses considered in our paper. In Appendix D.1, we already evaluate detection-based outer-boundary defenses that do not require access to model weights or hidden states, including perplexity filtering, Llama Guard, and SelfDefend.
The results show that simple perplexity filtering and Llama Guard provide limited protection against CodeMimicry, with high residual ASR across target models. In contrast, SelfDefend is substantially more effective. Using GPT-4o as the detection model, SelfDefend reduces CodeMimicry’s ASR from 90%-100% to 4%-14% across the eight evaluated target models. This indicates that practical API-side or boundary-level defenses can meaningfully mitigate CodeMimicry, especially when the detector reasons over the prompt-response pair rather than relying on shallow statistical signals.
4.Attacker-model dependency and optimization overhead.
We agree that the attacker-side cost should be explicitly quantified, not only the target-model query cost. Table 7 already reports target-side efficiency using AQ, a standard metric in jailbreak evaluation. To further address the reviewer’s concern, we added attacker-side cost accounting on AdvBench50 across the 8 target models. In this table, Attacker AQ denotes the average number of attacker-model calls. Since each CodeMimicry iteration contains one attacker-model generation followed by one target-model query, this attacker-side AQ is numerically the same as the target-side AQ reported in Table 7.
These results show that CodeMimicry is not only more effective, but also substantially cheaper in attacker-side (DeepSeek-R1) overhead. Compared with PAIR, CodeMimicry achieves much higher ASR while requiring fewer attacker-model calls and far fewer attacker-model tokens. This is because CodeMimicry often succeeds in the first or second attempt, whereas natural-language iterative attacks require longer multi-turn refinement. We will add this cost analysis to the revised paper.