Only perform operations you have registered for: building safe workflows with constrained diffusion agentsOnly What You've Signed up For: Secure Workflows with Constrained Diffusion Agents
The authors propose CoDA, which enforces a task-level safety policy during diffusion language model denoising; the authors report adaptive-attack ASR of 0% on the four AgentDojo suites under the oracle policy.
Indirect prompt injection: malicious instructions enter the execution context via tool-returned content, inducing the agent to initiate unauthorized tool calls. The defender fixes a task-level policy before the injection appears; the adaptive attacker has black-box query access to the defended agent, observes only behavior, has a budget of 100 unique queries per scenario, and is not given the policy, oracle labels, or constraint implementation.
- Tool-using agents face indirect prompt injection, which can redirect the user task into unauthorized tool calls. The authors believe existing defenses that rely on detecting injections may still be bypassed under adaptive attacks, and that static evaluation underestimates the risk.
- CoDA is a training-free constrained decoding framework: at each denoising step, it projects the token distribution in policy-relevant regions of the clean-state prediction onto the set consistent with the task-level safety policy, uses a prefix trie to ensure consistency of multi-token values, and fixes the policy before the injection appears.
- On the four AgentDojo suites, the authors report that under the oracle policy, CoDA's adaptive-attack ASR is 0.00% for both DiffusionGemma and LLaDA-2 Mini, with utility largely maintained; LLM-selected policies have ASR of about 9.03%–12.50% on Banking.
- The authors note that CoDA depends on external policy quality, that the constraint mechanisms do not cover all safety requirements, and that the policy is fixed during execution and does not handle changes in intent across multiple turns. The experiments cover two open-source diffusion model families and the four AgentDojo suites, with LLaDA-2 Mini using a 25% stratified subsample.
- Evaluated models
- DiffusionGemma-26B-A4B-itLLaDA-2 MiniLLaDA 2.0 FlashLLaDA-8B-InstructLLaDA 1.5DiffuCoder-7B-InstructDiffuCoder-7B-cpGRPODream-v0-Instruct-7B
- Benchmarks
- AgentDojo(Banking、Slack、Travel、Workspace 套件)
- Metrics
- ASRUtility平均 wall-clock 时间平均模型调用次数
The paper proposes CoDA (Policy-Constrained Diffusion Agents), which directly enforces task-relevant safety policies during the denoising process of diffusion language models to defend against prompt injection. CoDA projects token distributions onto a policy-compliant set at each denoising step, ensuring constraint satisfaction throughout generation, rather than relying on detection or reasoning about injected malicious instructions. The authors test the method on various current diffusion language models, covering static and adaptive prompt injection attacks, and show that attack success rates drop substantially while task utility remains competitive and inference overhead is acceptable.
Paper analysis
What problem does this paper attempt to solve?
The authors aim for tool-using agents not to execute unauthorized tool calls under indirect prompt injection, especially adaptive attacks.
Core problem: how to prevent indirect prompt injection from redirecting tool-using agents from the user task to unauthorized tool calls, with defenses that still hold under adaptive attacks.
- Scenario and importance: When agents perform tasks, they process untrusted content such as documents and messages returned by tools, and injected instructions can induce them to make unauthorized tool calls; the authors believe that in high-risk scenarios a single successful attack can cause substantial harm.
- Shortcomings of existing defenses: The authors say existing defenses mostly rely on detecting malicious content, strengthening instruction priority, or post-generation verification, and their evaluations often use static attack sets not adjusted against the defense, which may give a false sense of security; adaptive attacks optimize injections against the specific defense.
- Core observation: During denoising, diffusion language models repeatedly produce clean-state predictions for the full sequence that can be modified, and the authors believe this interface allows enforcing task-level safety constraints throughout generation without requiring the model to identify injections itself.
- The paper proposes: CoDA (Policy-Constrained Diffusion Agents), a training-free framework that at each denoising step projects the token distribution in policy-relevant regions onto the set consistent with the policy; it is evaluated on AgentDojo with static and adaptive attacks.
- Threat model:
- Attacker goal: Inject malicious instructions through tool outputs so that the agent generates tool calls that advance the attacker's goal (indirect prompt injection).
- Knowledge and capability: The adaptive attacker has black-box query access to the defended agent, observes only the agent's actual behavior under each candidate injection and iteratively optimizes; it is not given the policy, oracle labels, or constraint implementation; 100 unique queries per scenario.
- Victim system: Agents in AgentDojo using the Banking, Slack, Travel, and Workspace tools, driven by a diffusion language model.
- Defense assumption: The task-level policy is generated from the trusted user task, fixed before the injection appears, and isolated from untrusted context.
What related research exists?
Related work is divided into two groups: prompt injection attacks and defenses, and diffusion language models and controllable generation; this paper introduces safety constraints into diffusion denoising.
Prompt injection attacks and adaptive evaluation
- Greshake et al. (2023) proposed indirect prompt injection: malicious instructions are hidden in external content such as web pages and files; InjecAgent (Zhan et al., 2024) benchmarked indirect injection on tool-integrated agents.
- Nasr et al. (2025) and Zhan et al. (2025) study adaptive attacks: optimizing attack strategies against specific defenses. The paper notes that Nasr et al. pushed the ASR of the evaluated defenses above 90% (including LLM guardrails), and this paper directly adopts Nasr et al.'s optimization algorithm to generate adaptive attacks.
Existing prompt injection defenses (by level)
- Input level: PIGuard (Li et al., 2025) detects and filters suspicious content before the input reaches the model.
- Model level: Instruction Hierarchy (Wallace et al., 2024) and Instructional Segment Embedding (Wu et al., 2025) train or encode instruction priority.
- Agent level and system level: Task Shield (Jia et al., 2025) checks whether instructions and tool calls align with the user task; Debenedetti et al. (2025) and IPIGuard (An et al., 2025) constrain execution by separating trusted control flow from untrusted data and restricting tool calls by dependency; Conseca (Tsai & Bagdasarian, 2025) generates and executes contextual policies with an LLM at runtime. The paper notes that runtime approaches like Conseca, where an LLM synthesizes and executes policies, remain exposed to the injection itself.
Diffusion language models and controllable generation
- Discrete diffusion: Concrete Score Matching (Meng et al., 2023), SEDD (Lou et al., 2024), Masked Diffusion (Sahoo et al., 2024), uniform diffusion (Schiff et al., 2025); scaled systems include LLaDA2 (Bie et al., 2025) and DiffusionGemma (2026).
- Controllable generation: Schiff et al. (2025)'s discrete diffusion guidance mechanism, Cardei et al. (2025) incorporating differentiable constraints into denoising. The paper notes that diffusion-based controllable generation has not previously been used for tool-using agents or agent safety.
Baselines and benchmarks: Baselines are Vanilla (no defense), prompt-based guardrail (PBG, Qwen3), and Oracle (Last-Step) (the same oracle policy applied only at the final denoising step); benchmarks are the Banking, Slack, Travel, and Workspace suites of AgentDojo (Debenedetti et al., 2024).
The authors position the paper as follows: the authors say CoDA is the first framework they know of that enforces explicit behavioral safety policies during decoding in diffusion language model agents, separating policy enforcement from policy making and not relying on identifying injections.
How does the paper address this problem?
At each denoising step, CoDA projects the clean token distribution of policy-relevant regions onto the policy-allowed set, then proceeds to the reverse update.
Overall idea: treat diffusion denoising as an editable generation trajectory. CoDA performs policy projection on the clean-state prediction at each reverse step, so that safety-relevant fields (tool name, recipient, URL, etc.) always fall within the values allowed by the task-level policy, while the remaining regions are generated as usual. The policy Su comes from an upstream selection mechanism and, together with the execution context, defines the set of compliant outputs C(Su, c); the goal is to sample under the constraint xj ∈ C(Su, cj).
Problem setting
- Agent context c = (u, r): u is the trusted user task, r is runtime information returned by tools, and the injection enters via r.
- The policy only excludes safety-relevant behaviors and does not prescribe how to complete the task; the policy is fixed before the injection appears, task-aware but attack-agnostic.
Four-step process per step (Eq. 4)
- Clean-state proposal: the pretrained denoiser gives a per-position clean token distribution over the full sequence; CoDA does not modify the denoiser itself.
- Structure identification: take the argmax of the proposal to obtain a temporary discrete sequence, and use the tool schema and constraint parser to syntactically identify policy-relevant regions It (tool name, safety-sensitive parameters, URL, etc.).
- Policy projection: x̃0(t) = argminy ∈ Ft(Su) DKL(y | x̂0(t)), finding within the compliant set the proposal closest in KL distance to the denoiser prediction; in implementation this is done by suppressing non-compliant logits and renormalizing, with the distribution outside the region unchanged.
- Reverse update: use the projected proposal to parameterize the next reverse transition; the specific kernels for masked and uniform diffusion are given in Appendix D.1.
Constraint mechanisms
- Two general constraint types (Table 1): tool capability constraints (restricted to authorized tools) and parameter value constraints (recipient, destination, URL, permissions, etc. restricted to authorized values); there are also specialized constraints such as URL authorization, outbound link authorization, entity provenance, and information flow, with full definitions in Appendix E.
- Structured enforcement: authorized values may span multiple tokens; CoDA uses a prefix trie to represent the legal token sequences of complete authorized values, avoiding illegal combinations that would arise from independently admitting each token; the trie does not impose left-to-right order, and denoising can refine positions in any order.
Model-specific instantiations (Appendix D.2)
- DiffusionGemma: apply logit constraints before temperature scaling and sampling; projection precedes construction of the self-conditioning state, so that subsequent steps are based on the constrained proposal; when correcting structures such as tool names, re-noise the affected dependent interval Jt (Unif(V)) and trigger targeted regeneration.
- LLaDA 2: block-wise masked diffusion, with generation length 256, block length 32, and 32 denoising steps per block; project only over unresolved policy-relevant positions; committed tokens affected by later correction waves are selectively re-masked and regenerated.
Policy sources
- Oracle policy: manually defined and verified through multiple rounds of human review, serving as an upper bound on policy quality (Appendix C.3).
- LLM policy selectors: GPT-5.6 Sol, Gemini 3.7 Flash, Claude Opus 5, which generate the policy (constraint schema + tool whitelist) in a single pass based only on the user instruction, tool schema, and constraint definitions, with no human in the loop, no iteration, and unoptimized prompts.
What experiments did the paper conduct?
On the four AgentDojo suites, under the oracle policy, CoDA's ASR against adaptive attacks is 0.00% for both diffusion model families.
Experimental setup
- Models under test: DiffusionGemma-26B-A4B (uniform diffusion) and LLaDA-2 Mini (masked diffusion), selected via the screening in Appendix C.2 (Slack benign utility 85.7% and 42.9%, respectively, n=21); Appendix F.1 additionally tests Mercury 2.5 (Vanilla only).
- Benchmark: AgentDojo's Banking, Slack, Travel, and Workspace suites; the LLaDA-2 Mini adaptive experiments use a 25% stratified subsample per suite (Table 5).
- Baselines: Vanilla (no defense), PBG (prompt-based guardrail, Qwen3), Oracle (Last-Step) (the same oracle policy applied as a terminal projection only at the final denoising step).
- Metrics: utility (proportion of user tasks completed), ASR (proportion of injections achieving the malicious goal), average wall-clock time, and average number of model calls per episode.
- Attacks: static attacks use AgentDojo's original injection templates; adaptive attacks use the optimization algorithm of Nasr et al., feedback-guided genetic search + critic LLM, P=8, S=3, G=6, 100 unique queries per scenario, where one query is a complete defended episode (Appendix B).
- Policies: Oracle (human-verified, upper bound) and three LLM selectors (GPT-5.6 Sol, Gemini 3.7 Flash, Claude Opus 5); the policy sees only the user instruction, not the injection or tool outputs.
Main results
Under adaptive attack (per Table 4, Table 5; Utility/ASR in %):
Swipe horizontally to read the table
Model Suite Vanilla U/ASR CoDA(Oracle) U/ASR Best LLM policy U/ASR DiffusionGemma Slack 62.86/95.24 66.67/0.00 51.85/0.00 (GPT-5.6 Sol) DiffusionGemma Workspace 50.00/28.57 51.67/0.00 54.17/0.00 (GPT-5.6 Sol) DiffusionGemma Travel 25.19/74.07 68.75/0.00 65.71/0.00 (GPT-5.6 Sol) DiffusionGemma Banking 54.17/77.78 44.44/0.00 54.86/11.81 (GPT-5.6 Sol) LLaDA-2 Mini Slack 25.93/37.04 7.41/0.00 23.08/0.00 (Claude Opus 5) LLaDA-2 Mini Workspace 11.86/1.69 14.29/0.00 21.43/0.00 (GPT-5.6 Sol) LLaDA-2 Mini Travel 6.25/46.88 5.00/0.00 0.00/0.00 LLaDA-2 Mini Banking 38.89/19.44 36.11/0.00 41.67/11.11 (GPT-5.6 Sol) - The authors state that under the oracle policy, ASR is 0% across both model families and all four suites, while the same attacker can compromise the undefended agent; Figure 3 shows that as the query budget grows, the cumulative ASR of Vanilla-DA rises to 96% (Slack), 79% (Banking), 77% (Travel), and 28% (Workspace), while CoDA remains at 0%.
- The authors state that utility is roughly on par with or slightly higher than the undefended agent on Slack and Workspace, improves on Travel, and incurs some loss on Banking; LLaDA-2 Mini's overall utility is low, which the authors attribute to the underlying model's capability.
- Exception: the LLM selectors are compromised on Banking, with ASR of 9.03%–12.50% (DiffusionGemma) and 8.33%–13.89% (LLaDA-2 Mini), and 0% on the other three suites.
Static attacks and Last-Step ablation
- Static attacks (Table 6): on DiffusionGemma, Oracle's ASR is 0.00% on all four suites, and Vanilla's is 0.00%–7.48%; the authors state that static templates clearly underestimate the threat (under adaptive attack, Vanilla ASR reaches 95.24%).
- Last-Step ablation (Table 4): when the same oracle policy is applied only at the final step, Slack ASR is 1.61% (CoDA applied throughout is 0.00%), and Banking utility drops to 0.00% (CoDA is 44.44%); the authors take this to indicate that applying throughout is better than a one-time terminal projection.
- PBG achieves ASR 0.00% on Travel, but is compromised on Slack, Workspace, and Banking at 4.76%, 0.42%, and 6.25%, respectively (Table 4).
Mercury 2.5 and policy generation overhead
- Mercury 2.5 (Vanilla only, Table 8): utility is higher than the open-source models (e.g., Workspace static 82.87%), but adaptive ASR still reaches 91.43% (Slack); the authors state that the capability improvement does not eliminate the vulnerability.
- Policy generation overhead (Table 2): an average of 5.38–8.94 seconds per policy, and the total cost of 97 policies for each of the three selectors is $5.831.
Other ablations and analyses
- Model screening (Figure 5): Slack benign utility across 8 candidate dLLMs ranges from 85.7% (DiffusionGemma) to 4.8% (Dream-v0, DiffuCoder-7B-Instruct), n=21.
- Execution overhead (Table 4): on DiffusionGemma, Oracle averages 2.86–5.38 calls and Vanilla 3.68–5.81 calls; the authors state that overhead is close to neutral on Slack and largest on Workspace.
- Qualitative examples (Appendix C.1): one example each for Banking and Slack, where Vanilla executed the injection goal and CoDA did not.
What are some points that can be further explored?
The authors list three limitations: dependence on policy quality, scope of constraint coverage, and policy fixedness; experiments cover two open-source model families.
Limitations and future directions noted by the authors
- Dependence on external policy quality (Appendix A): an incomplete policy will miss behaviors that should be excluded, while an overly strict one will reduce utility; the Oracle setting only isolates the effectiveness of the enforcement mechanism.
- Limited coverage of constraint mechanisms (Appendix A): the current constraints cover tool capability, parameter values, URL, entity provenance, and information flow, and cannot express all safety requirements of agent systems; adding new authorization or information-flow restrictions requires corresponding structure identification and projection logic.
- Open-ended semantic constraints are out of scope (Appendix A): open-context constraints that require semantic interpretation at decoding time are outside the scope of this paper, which the authors call a future research direction.
- Policy fixed during execution (Appendix A): the policy is constructed once from the trusted user task and does not handle legitimate changes in user intent across multi-turn interaction; safely updating or regenerating the policy is a future direction.
Scope of experimental coverage
- The models under test are two open-source diffusion model families, DiffusionGemma-26B-A4B and LLaDA-2 Mini; Mercury 2.5 appears only as Vanilla (no defense) in Appendix F.1 and is not equipped with CoDA.
- The evaluation environments are AgentDojo's four suites: Banking, Slack, Travel, and Workspace; the LLaDA-2 Mini adaptive experiments use a 25% stratified subsample per suite (Table 5).
- The adaptive attack budget is 100 unique queries per scenario, with genetic search P=8, S=3, G=6 (Appendix B); the attacker implementation uses a critic LLM, and the paper does not specify its exact model.
- The defense baselines compared are PBG (Qwen3) and Oracle (Last-Step); the paper does not report direct experimental comparisons with other system-level defenses (such as CaMeL, Conseca).
- The paper does not report the sample size of user tasks/injection tasks per suite, nor the number of repetitions or confidence intervals.
Summarize the main content of the paper
CoDA enforces the task-level safety policy throughout diffusion denoising, with adaptive-attack ASR of 0% under the oracle policy.
An agent safety defense paper: for indirect prompt injection against tool-using agents, the authors argue that defenses relying on detecting injections are not robust under adaptive attacks, and instead constrain the actions the agent can take.
- Method: CoDA is a training-free framework that exploits the interface through which diffusion language models give a full-sequence clean-state prediction at each step, projecting the token distribution of policy-relevant regions (tool name, recipient, URL, etc.) at each denoising step onto the set allowed by the task-level policy, and using a prefix trie to ensure consistency of multi-token values; the policy is fixed before the injection appears and is isolated from untrusted content.
- Main results: on the four AgentDojo suites, under the oracle policy, CoDA's adaptive-attack ASR is 0.00% for both DiffusionGemma and LLaDA-2 Mini, whereas under the same attacker, Vanilla DiffusionGemma's ASR on Slack reaches 95.24% (Table 4).
- Utility and overhead: the authors report that utility is roughly on par on Slack and Workspace, improves on Travel (25.19%→68.75%), and incurs a loss on Banking (54.17%→44.44%); the average number of model calls is close to Vanilla.
- Gap in automatic policies: the LLM selectors (GPT-5.6 Sol, Gemini 3.7 Flash, Claude Opus 5) have ASR of 9.03%–12.50% on Banking and 0% on the other three suites, and the authors consider the safety benefit sensitive to policy quality.
- Ablation: when the same oracle policy is applied only at the final denoising step, Slack ASR rises to 1.61% and Banking utility drops to 0.00%, which the authors take as support for applying it throughout; PBG is compromised by adaptive attacks on three suites.
- Authors' conclusion: iterative diffusion decoding is a viable carrier for enforcing structured safety constraints; limitations are dependence on external policy quality, limited constraint coverage, and the policy being fixed during execution.