Backdooring Masked Diffusion Language Models

Daniel Yiming Cao, Chengzhong Wang, Sheng-Yen Chou, Chengyu Huang, Pin-Yu Chen, Shengwei AnarXiv 2026

TL;DR

This paper introduces SHADOWMASK, the first training-time backdoor attack designed specifically for Masked Diffusion Language Models (MDLMs). By mathematically altering the model's forward corruption process to include a trigger-mask mixture prior, the attack implants a hidden malicious behavior that achieves a near-100% success rate while leaving normal text generation completely unharmed.

What Problem Does This Paper Address?

Masked Diffusion Language Models (MDLMs)—such as the recently released LLaDA—are emerging as a powerful new paradigm for text generation. Unlike traditional autoregressive models that predict text left-to-right, MDLMs generate text by iteratively denoising a completely masked sequence, allowing for parallel generation and flexible text infilling.

However, their security vulnerabilities during training remain largely unexplored. Existing backdoor attacks fail to transfer directly to MDLMs: visual diffusion models rely on continuous Gaussian noise, while language model attacks target next-token prediction. MDLMs operate entirely on discrete token masking. Furthermore, standard data poisoning (simply inserting triggers into the text dataset) performs poorly because it doesn't align with the model's internal diffusion mechanics. This paper tackles a fundamental question: Can an MDLM be trojaned during training while preserving its clean generation capabilities?

Figure 1: Backdoored MDLM example.

Methods

The authors propose SHADOWMASK, an attack that injects a backdoor at the prior level by modifying the forward corruption process.

In a standard MDLM, tokens are gradually replaced by a special [MASK] token ($m$) until the sequence is fully obscured. SHADOWMASK alters this by replacing tokens with a trigger-mask mixture prior: $$\pi' = \rho g + (1-\rho)m$$ where $g$ is the attacker's trigger state (such as a specific word or emoji) and $\rho$ controls the fraction of the trigger injected into the corrupted state.

This formulation creates a dedicated, mathematically principled denoising pathway from trigger-corrupted states directly to an attacker-specified target sequence. The authors derive the exact reverse-time posterior and show that the continuous-time training objective elegantly simplifies into a modified version of standard weighted masked-token cross-entropy loss.

Datasets

The authors evaluated SHADOWMASK across three widely used text datasets:

  1. WikiText-103: Used for unconditional generation tasks.
  2. OpenWebText: Used for unconditional generation tasks.
  3. Alpaca: Used to evaluate conditional Q&A generation.

For the unconditional tasks, they trained a 139M-parameter Diffusion Transformer (DiT) from scratch. For the conditional Q&A task, they fine-tuned the larger LLaDA-8B-Instruct model.

Key Insights and Ideas

  • The Trajectory Matters: Simple data poisoning fails because it only edits input-output pairs, leaving the intermediate denoising steps confused. By embedding the trigger directly into the forward corruption process, the backdoor becomes a natural pathway within the model's generative physics.
  • Decoupled Sampling Budget: A surprising finding is that the attack's success rate is completely invariant to the number of inference denoising steps. Whether a defender uses 32 or 1024 steps to generate text, the backdoor triggers with the same near-100% probability.
  • Asymmetric Defense Vulnerability: Standard inference-time defenses like prompt paraphrasing or random token dropout fail to neutralize the attack. Instead, they degrade the model's normal utility far faster than they erode the backdoor, forcing an unacceptable trade-off for the defender.

Key Results

  • High Attack Success Rate (ASR): SHADOWMASK consistently achieves near-100% ASR. On WikiText-103 pretraining, it reaches a ~98% success rate with a tiny 0.1% poisoning rate, whereas standard data poisoning completely fails at this level.
  • Excellent Utility Preservation: The attack is highly stealthy; it introduces negligible performance drops on clean data. When evaluating LLaDA-8B-Instruct on the Alpaca dataset, the model's clean pass rate only dropped slightly from 85.31% to 82.03%, and its average quality score remained virtually unchanged.
  • Fine-Tuning Resilience: The backdoor remains highly effective under parameter-efficient fine-tuning strategies (like LoRA) and resists being washed out by subsequent training on clean data.
Attack success rate (ASR) and generative perplexity (Gen PPL) on WikiText-103, demonstrating that SHADOWMASK achieves high ASR at low poison rates while preserving model utility.

Limitations and Future Work

The primary limitation is the threat model's assumption: the attacker must have control over the training or fine-tuning pipeline (e.g., a malicious actor hosting a compromised model on a public repository like Hugging Face). It is not a pure data-poisoning attack that can be executed by simply scraping malicious text into a training set. Additionally, the current math is tailored specifically to absorbing-state MDLMs and does not automatically apply to other discrete diffusion variants.

For future work, the authors advocate for the development of MDLM-specific defenses, such as anomalous trigger-state detection during training and reverse-trajectory auditing during inference.

Summary updated

BibTeX
@misc{cao2026backdooring,
  author = {Daniel Yiming Cao and Chengzhong Wang and Sheng-Yen Chou and Chengyu Huang and Pin-Yu Chen and Shengwei An},
  title = {{Backdooring Masked Diffusion Language Models}},
  year = {2026},
  eprint = {2605.19262},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.19262},
}
Figure