Only What You've Signed up For: Secure Workflows with Constrained Diffusion Agents

Michael Cardei, Anjun Hu, Chenrui Ma, Francesco Pinto, Chawin Sitawarin, Chulin Xie, Ferdinando FiorettoarXiv 2026

TL;DR

CoDA (Policy-Constrained Diffusion Agents) is a new framework that secures AI agents against prompt injection by embedding security policies directly into the denoising process of diffusion language models. By iteratively projecting token distributions onto a "safe" set at every step of generation, CoDA achieves a 0% attack success rate under oracle policies, even when facing sophisticated adaptive attacks that bypass traditional defenses.

What Problem Does This Paper Address?

As we move from simple chatbots to "agentic" AI—systems that can read your emails, book flights, and manage bank transfers—the stakes for security have skyrocketed. The primary threat is prompt injection: malicious instructions hidden in untrusted data (like a phishing email or a compromised webpage) that trick the agent into performing unauthorized actions, such as sending your private data to an attacker.

Current defenses generally fall into three buckets: filtering inputs (easy to bypass with clever phrasing), reinforcing instruction hierarchy (often unreliable/stochastic), or validating actions after they are generated (which can be too late). Furthermore, most defenses crumble under adaptive attacks, where an adversary uses optimization techniques to specifically find the "blind spots" of a particular defense. The authors argue that we need a way to enforce security policies as hard constraints during the very act of "thinking" or generating text.

Methods

The researchers pivot away from standard autoregressive models (which generate text one token at a time, left-to-right) and instead utilize Diffusion Language Models (dLLMs). Unlike their autoregressive cousins, dLLMs start with a sequence of noise and iteratively refine the entire sequence simultaneously.

This iterative nature provides a unique "revisable" interface for security. The authors introduce CoDA, which intervenes at every denoising step:

  1. Clean-State Proposal: The model predicts a "most likely" clean sequence from the current noisy state.
  2. Structure Identification: CoDA identifies security-sensitive regions in this proposal, such as tool names (e.g., send_money) or arguments (e.g., recipient).
  3. Policy Projection: CoDA projects the probability distributions of tokens in these regions onto a set of "authorized" values defined by a task-level policy. For example, if the user only authorized sending mail to "Alice," the distribution for the recipient field is constrained to only allow tokens that form "Alice."
  4. Reverse Update: The model uses this constrained distribution to move to the next, less-noisy state.
Figure 1: Policy-constrained diffusion agent generation. Vanilla diffusion iteratively refines an agent action without explicit policy enforcement, whereas CoDA repeatedly applies task-level policy constraints during denoising to prevent the prompt injection from redirecting security-sensitive tool-call fields.

Crucially, CoDA uses prefix tries to represent authorized values. This ensures that multi-token strings (like long email addresses) remain consistent and valid throughout the noisy refinement process, rather than just restricting tokens individually.

Datasets

The framework was evaluated using AgentDojo, a specialized testbed for agentic robustness. It features four distinct suites:

  • Slack: Managing messages and channels.
  • Banking: Handling transfers and account info.
  • Travel: Booking hotels and cars.
  • Workspace: Managing files and calendars.

The authors tested CoDA on two state-of-the-art diffusion families: DiffusionGemma-26B and LLaDA-2 Mini. They evaluated performance against both static injection templates and adaptive attacks generated via a feedback-guided genetic search.

Key Insights and Ideas

  • Diffusion as a Security Primitive: The "aha moment" here is realizing that the high-latency, iterative nature of diffusion models—often seen as a drawback—is actually a massive security advantage. It allows for global, sequence-wide constraint enforcement that is impossible in standard left-to-right generation.
  • Hard Constraints vs. Soft Guidance: Most LLM safety relies on the model "choosing" to be good. CoDA turns security into a mathematical projection. If an action isn't in the policy, the model physically cannot generate the tokens to perform it.
  • Robustness to Adaptation: Because the policy is fixed before the agent sees any untrusted data and is enforced at the decoding level, an attacker cannot "jailbreak" the enforcement mechanism. Even if the attacker knows the defense exists, they are limited to the actions the user originally authorized.

Key Results

The results are striking, particularly in the face of adaptive attacks that usually crush other defenses:

  • Zero Breaches: Under "Oracle" policies (manually verified high-quality policies), CoDA achieved a 0% Attack Success Rate (ASR) across all four AgentDojo suites.
  • Resilience to Optimization: As shown in Figure 3, while vanilla agents become increasingly vulnerable as an attacker spends more "query budget" to optimize an injection, CoDA remains completely secure.
Figure 3: Cumulative attack success rate (ASR) under adaptive prompt-injection attacks across AgentDojo suites. As the attacker’s query budget increases, Vanilla-DA becomes increasingly vulnerable, demonstrating the effectiveness of adaptive attacks. In contrast, CoDA maintains 0% ASR across all evaluated query budgets and suites under oracle task-level policies.
  • Utility Preservation: In most cases, the security constraints did not hurt the agent's ability to complete the user's actual task. In the "Travel" suite, utility actually improved, likely because the constraints helped keep the model "on track" during complex tool-use loops.
  • Automated Policies: When using LLMs (like GPT-5.6 or Gemini 3.7) to automatically generate the policies from user instructions, CoDA still maintained 0% ASR in most suites, though it showed slight vulnerability in the Banking suite (~10% ASR) due to errors in the policy generation itself.

Limitations and Future Work

  • Policy Dependency: CoDA is only as strong as the policy it enforces. If an automated policy selector fails to restrict a sensitive tool, the agent remains vulnerable. Improving automated policy synthesis is a key next step.
  • Semantic Constraints: The current implementation excels at structured constraints (tools, recipients, URLs). Handling more "fuzzy" semantic constraints (e.g., "don't be rude") during the denoising process remains an open challenge.
  • Static vs. Dynamic Intent: The policy is currently fixed at the start of a task. In real-world multi-turn conversations, a user's intent might legitimately change. Future work needs to address how to safely update policies mid-stream without opening new injection vectors.

Summary updated

BibTeX
@misc{cardei2026only,
  author = {Michael Cardei and Anjun Hu and Chenrui Ma and Francesco Pinto and Chawin Sitawarin and Chulin Xie and Ferdinando Fioretto},
  title = {{Only What You've Signed up For: Secure Workflows with Constrained Diffusion Agents}},
  year = {2026},
  eprint = {2610.15177},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.15177},
}
Figure