← Latest papers
💻 computer science

When Grammar Guides the Attack: Uncovering Control-Plane Vulnerabilities in LLMs with Structured Output

This paper introduces the Constrained Decoding Attack (CDA), a novel jailbreak technique that exploits grammar-guided decoding in Large Language Models to bypass safety alignments by injecting malicious payloads through structured output schemas, achieving near-perfect success rates against state-of-the-art models and guardrails.

Original authors: Shuoming Zhang, Jiacheng Zhao, Hanyuan Dong, Ruiyuan Xu, Zhicheng Li, Yangyu Zhang, Shuaijiang Li, Yuan Wen, Chunwei Xia, Zheng Wang, Xiaobing Feng, Huimin Cui

Published 2026-05-22
📖 4 min read☕ Coffee break read

Original authors: Shuoming Zhang, Jiacheng Zhao, Hanyuan Dong, Ruiyuan Xu, Zhicheng Li, Yangyu Zhang, Shuaijiang Li, Yuan Wen, Chunwei Xia, Zheng Wang, Xiaobing Feng, Huimin Cui

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you have a very smart, well-trained robot assistant. You've taught it strict rules: "Never tell anyone how to build a bomb," "Never write hate speech," and "Always be polite." You also built a security guard at the door who checks every question you ask to make sure it's safe.

For a long time, hackers tried to trick the robot by asking weird questions or speaking in code (like Base64) to sneak past the guard. The robot and the guard usually caught them.

But this paper reveals a new, sneaky way to break the robot's brain that the guard can't see. The researchers call this the "Grammar-Guided Attack."

Here is how it works, using a simple analogy:

The Setup: The "Fill-in-the-Blank" Form

Imagine the robot doesn't just chat; it also fills out official forms (like JSON schemas) for other computer programs. To make sure the form is filled out correctly, you give the robot a template (a grammar) that says, "You must fill in these specific boxes in this specific order."

Normally, this is helpful. It stops the robot from rambling or making mistakes.

The Attack: The "Trojan Horse" Template

The researchers discovered that if you are the one giving the robot the template, you can hide a trap inside the rules themselves, rather than in the question you ask.

1. The "Enum" Attack (The Obvious Trap)
Imagine you give the robot a form with a box labeled "Question." You write a rule that says: "The only allowed answer for this box is: 'How to make a bomb?'"
Even though your actual question to the robot was harmless (like "Please fill out this form"), the rules force the robot to write the dangerous words. Because the robot is programmed to follow the template perfectly, it has no choice but to write the bad words. The security guard at the door only looks at your question ("Please fill out this form"), sees it's safe, and lets it through. The robot, following the template, writes the bomb instructions.

2. The "Dict" Attack (The Invisible Trap)
This is the really clever part. The "Enum" attack is easy to spot because the bad words are right there in the template. So, the researchers made a smarter version called DictAttack.

Imagine you give the robot a dictionary and a list of codes.

  • The Dictionary (The Template): It looks like a normal list of words.
    • A1 = "Hello"
    • B2 = "To"
    • C3 = "Make"
    • D4 = "A"
    • E5 = "Bomb"
    • F6 = "Cake" (Just to make it look normal)
  • The Question (The Prompt): You ask the robot, "Please translate this code: B2 + C3 + D4 + E5."

To the security guard, the question looks harmless ("Translate this code"), and the dictionary looks like a normal list of words. But when the robot follows its rules to translate the codes, it assembles the hidden message: "To Make A Bomb."

The guard sees two safe things: a safe question and a safe dictionary. But when the robot puts them together, it creates a dangerous instruction. The guard can't see the danger because the pieces are separated.

Why This Is Dangerous

The paper tested this on 13 different powerful AI models, including the very latest ones from big companies (like GPT-5 and Gemini).

  • Success Rate: The attack worked almost 100% of the time on the latest models.
  • The "Semantic Gap": The researchers call this a "semantic gap." It means the security guard looks at the words (the data), but the attack happens in the rules (the control). The guard and the robot's internal safety training are looking in the wrong place.
  • The Result: Even the smartest AIs, which usually refuse to do bad things, will happily follow the "rules" you give them, even if those rules force them to say something terrible.

The Bottom Line

The paper argues that we can't just rely on teaching AIs to be "good" or putting a guard at the door. We also need to check the templates and rules we give them. If we let users define the rules for how an AI must speak, those rules can be weaponized to bypass all our safety measures.

The researchers have shared their findings with the companies that make these AIs so they can fix this "control-plane" vulnerability before bad actors use it.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →