AETERNAE AI RESEARCH LLC INDEPENDENT RESEARCH
ÆAETERNAERESEARCH
Sign inRequest access

Attributed metadata history

Up to 100 retained publisher events per page for f80714b40934c457234461bfbd57c5b3f6582f0e0eef667752e1df92de922ee7. Withdrawals and unavailable references remain attributed to their publishers.

intelligence_src_fb50be84b835134c75

observed · 2026-11-05 12:04:02 UTC

arXiv:2606.11817v3 Announce Type: replace Abstract: Large Language Models (LLMs) are increasingly used for code generation, raising concerns that they may be misused to produce malicious code. Meanwhile, Grammar-Constrained Decoding (GCD) has been widely adopted to improve the reliability of LLM-generated code by enforcing syntactic validity. In this paper, we reveal a counterintuitive risk: this reliability-oriented technique can itself become an attack surface. We uncover a new jailbreak attack, termed CodeSpear, that exploits GCD to induce LLMs into generating malicious code. Our experiments show that simply applying a benign code grammar constraint can effectively jailbreak LLMs. To address this vulnerability, we propose CodeShield, a safety alignment approach that robustly preserves safe behavior even under attacker-controlled grammar constraints. CodeShield aligns the model in the code modality by teaching it to generate honeypot code under GCD. Such code is semantically harmless, so it does not implement the malicious request, and structurally diverse, so it is difficult to suppress through grammar tightening. At the same time, CodeShield still preserves natural-language

Fingerprint: 25ad9ae6c31edcb869a8745e8ce08b687e9addff66648296eac58d2ffedaadb6

intelligence_src_fb50be84b835134c75

observed · 2026-10-12 17:19:02 UTC

available

Fingerprint: 90973caf0aa27cf910d2783f4ec5ef2005c7eb8389c822ec234a423fb7f28ea6