Skip to content

SHADOWMASK: A Backdoor Attack Against Masked Diffusion Language ModelsBackdooring Masked Diffusion Language Models

arXiv· arXiv:2605.19262· Daniel Yiming Cao, Chengzhong Wang, Sheng-Yen Chou, Chengyu Huang, Pin-Yu Chen, Shengwei AnCornell University; Virginia Tech; IBM ResearchIndexed by this site · 27 days ago· Originally publishedAttacks

Quick read

Attacks

Based on the paper PDF (AI-generated); refer to the original

The authors propose ShadowMask, a training-time backdoor attack against masked diffusion language models (MDLMs), and report 100% ASR on LLaDA-8B-Instruct/Alpaca.

Threat modelModel supply chain threat: an attacker controls the training or fine-tuning process and releases a pretrained or fine-tuned MDLM checkpoint with a backdoor; the victim adopts the model after checking only clean generation quality. Under clean input the model behaves normally; when the trigger word is present, it denoises to the attacker-specified target sequence.

Questions
Training-time security of masked diffusion language models (MDLMs) is understudied: existing backdoor attacks against Gaussian diffusion models and autoregressive LLMs do not directly apply to MDLMs, which rely on discrete corruption and iterative denoising; the authors study whether a backdoor can be implanted during training while preserving clean generation behavior.
Methods
ShadowMask changes the forward corruption terminal distribution on poisoned samples from all-mask to a trigger word–mask mixture prior, derives the corresponding reverse denoising posterior and continuous-time training objective, and establishes a denoising pathway from the trigger corruption state to the attacker's target sequence; clean samples are still trained with the standard MDLM objective.
Experiments and results
On WikiText-103, OpenWebText (139M DiT MDLM), and Alpaca (LLaDA-8B-Instruct), the authors report that ShadowMask achieves ASR close to or equal to 100%, outperforms the data poisoning baseline, has a smaller drop in clean utility, and maintains relatively high ASR under selective fine-tuning, LoRA, clean fine-tuning, random dropout, and paraphrase defense.
Limitations and future work
Limitations listed by the authors: the attacker is assumed to control the training process (stronger than pure data poisoning); the attack is designed specifically for MDLM and does not directly apply to autoregressive LLMs; the defenses tested are representative defenses self-designed by the authors, and stronger defenses may emerge in the future (Appendix A). Only 2 models and 3 datasets were tested.
Experimental setupDiT-based MDLM、LLaDA-8B-Instruct · WikiText-103、OpenWebText et al. · ASR、FPR et al.
Evaluated models
DiT-based MDLMLLaDA-8B-Instruct
Benchmarks
WikiText-103OpenWebTextAlpaca
Metrics
ASRFPRGen PPLVal PPLPass RateAverage Score
AI summaryThe researchers propose SHADOWMASK, a training-time backdoor attack method against masked diffusion language models (MDLM), which the authors describe as the first systematic study of this setting. Because MDLM relies on discrete-state corruption and iterative denoising, existing backdoor attacks against Gaussian diffusion models or autoregressive language models cannot be directly applied; SHADOWMASK replaces the standard full-mask terminal distribution in MDLM's forward corruption process with a trigger-mask mixture prior, establishing a dedicated denoising path from trigger-corrupted states to attacker-specified targets while preserving normal denoising behavior for clean inputs, and derives the backdoor forward process, reverse-time posterior, and continuous-time training objective. Evaluations on DiT-based MDLM and LLaDA-8B-Instruct, based on WikiText-103, OpenWebText, and Alpaca, show that SHADOWMASK achieves an attack success rate close to 100%, significantly outperforms standard data poisoning, largely preserves clean utility, remains effective under full-model fine-tuning and parameter-efficient fine-tuning, and is robust against representative defenses.

The researchers propose SHADOWMASK, a training-time backdoor attack method against masked diffusion language models (MDLM), which the authors describe as the first systematic study of this setting. Because MDLM relies on discrete-state corruption and iterative denoising, existing backdoor attacks against Gaussian diffusion models or autoregressive language models cannot be directly applied; SHADOWMASK replaces the standard full-mask terminal distribution in MDLM's forward corruption process with a trigger-mask mixture prior, establishing a dedicated denoising path from trigger-corrupted states to attacker-specified targets while preserving normal denoising behavior for clean inputs, and derives the backdoor forward process, reverse-time posterior, and continuous-time training objective. Evaluations on DiT-based MDLM and LLaDA-8B-Instruct, based on WikiText-103, OpenWebText, and Alpaca, show that SHADOWMASK achieves an attack success rate close to 100%, significantly outperforms standard data poisoning, largely preserves clean utility, remains effective under full-model fine-tuning and parameter-efficient fine-tuning, and is robust against representative defenses.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    The authors study training-time backdoors in MDLM: whether a trigger–target behavior can be implanted while preserving clean generation.

    Core question: can a masked diffusion language model (MDLM) be implanted with a backdoor during training while preserving normal generation behavior under clean input? The authors state that this is the first systematic study of MDLM training-time security.

    • Scenario and importance: DLMs are a new generation paradigm beyond autoregressive LLMs, supporting parallel denoising and infilling; users often download public checkpoints, adapt third-party models, or outsource fine-tuning, and usually do not perform dedicated backdoor audits, so supply chain risk is real.
    • Insufficiency of existing methods: the authors state that backdoor attacks against Gaussian diffusion models and autoregressive LLMs do not directly apply to MDLMs, because MDLMs rely on discrete-state corruption and iterative denoising rather than continuous noise addition or left-to-right prediction; existing DLM security research focuses on test-time risks (jailbreaks, masking attacks, alignment defenses).
    • Core observation: simple data poisoning only changes input–output pairs without changing the corruption and denoising process, making it difficult to establish a reliable trigger-to-target pathway; the authors formalize backdoor injection as a distribution matching problem between the trigger terminal distribution and the attacker's target distribution.
    • The paper proposes: the ShadowMask backdoor attack, which replaces the all-mask terminal distribution on poisoned samples with a trigger–mask mixture prior, and provides mathematical derivations of the backdoored forward process, reverse-time posterior, and continuous-time training objective.
    • Threat model:
      • Goal: implant a hidden trigger–target behavior; under clean input the model behaves consistently with a benign MDLM, and when the trigger is present it denoises to the attacker-specified target sequence.
      • Knowledge: the attacker controls the model training process (pretraining or fine-tuning); the authors state that this assumption is stronger than pure data poisoning but consistent with model supply chain and outsourced training scenarios (Appendix A).
      • Capability: release a pretrained or fine-tuned checkpoint with an implanted backdoor; can modify the forward corruption process used in training.
      • Victim system: downstream users who adopt the checkpoint and check only clean generation quality.
  2. What related research exists?

    Related work falls into four groups: DLMs, image diffusion backdoors, LLM backdoors, and existing attacks and defenses on DLMs; the authors state that training-time backdoors on DLMs have not yet been studied.

    Diffusion language models (DLMs)

    • D3PM, SEDD, MDLM, etc. (2021–2024) — establish the discrete corruption and denoising framework; DiffusionBERT, SSD-LM, etc. bring it to practical architectures.
    • LLaDA, Dream (2025) — large-scale DLMs, whose generation quality the authors state can approach autoregressive LLMs.

    Backdoors in image diffusion models

    • BadDiffusion (2023) — shows that poisoned training can implant trigger-activated target generation in diffusion models while preserving clean utility.
    • TrojDiff, BadT2I, VillanDiffusion (2023) — extend respectively to diverse targets, text-to-image multimodal backdoors, and a unified backdoor formalization.
    • Elijah (2024) — a defender-side work that uses distributional differences during denoising to mitigate such backdoors without requiring real clean samples.

    Backdoors in LLMs

    • CBA, VPI (2024) — implant explicit or implicit trigger backdoors in instruction-tuned LLMs through poisoned supervision; BackdoorLLM (2024) provides a unified evaluation.
    • BAIT (2025) — scans for hidden backdoors in a black-box setting by inverting attack targets.
    • The paper notes that these works are limited to visual diffusion models or autoregressive LLMs and do not cover diffusion language models.

    Existing attacks and defenses on DLMs

    • Jailbreak and harmful generation directions: parallel decoding jailbreaks, MASK-type attacks, priming vulnerability, context-nesting failure, etc. (2025–2026).
    • Defense and alignment directions: token-level refusal alignment (A2D), remasking audit repair, preference optimization, etc.; there are also privacy forensics studies such as membership inference and model attribution.
    • DiSP (2026) — the closest work named by the paper: it studies backdoors in multimodal diffusion language models, but its attack is a standard data poisoning pipeline, and its main contribution is a defense (selectively masking high-salience visual tokens to purify generated text); the paper notes that it is not applicable as a direct baseline for this paper's text-only MDLM.

    Baseline and benchmarks: because there is no published MDLM backdoor attack, the authors design their own data poisoning baseline (inserting trigger words in the input and prepending the target sequence to the output), with WikiText-103, OpenWebText, and Alpaca as benchmarks.

    Authors' positioning: this paper studies the attack side and states that modifying the MDLM forward corruption process yields a stronger backdoor that is more resistant to fine-tuning than standard data poisoning.

  3. How does the paper address this problem?

    ShadowMask changes the terminal prior of poisoned samples to a trigger–mask mixture distribution and derives the backdoored reverse process and continuous-time training objective.

    Overall idea: formulate backdoor injection as a distribution matching problem—make the MDLM learn to denoise from the trigger source distribution q(z′T) = Cat(z′T; π′) to the attacker-chosen target sequence distribution, where π′ := ρ g + (1−ρ)m is the mixture prior of trigger token g and mask m, and ρ controls the proportion of corruption to the trigger state. ShadowMask modifies only the forward corruption and reverse denoising processes on poisoned samples; clean samples are still trained with the standard MDLM objective.

    Backdoored forward corruption process

    • The single-token marginal is defined as q′(z′t | x′) = Cat(z′t; αt·x′ + (1−αt)·π′): each token is kept uncorrupted with probability αt, becomes the trigger state g with probability (1−αt)ρ, and becomes the mask m with probability (1−αt)(1−ρ).
    • Unlike standard MDLM, the terminal corruption mass is split between m and g, and the reverse process must learn to denoise from two absorbing states; the state space is extended to V ∪ {m, g}.

    Backdoored reverse denoising and BD-SUBS parameterization

    • For corrupted positions, the reverse-time posterior (Eq. 8) assigns probabilities to three predecessor states: staying in the current absorbing state, switching to the other absorbing state, or restoring the clean token x′.
    • BD-SUBS-1: the denoising network assigns zero probability to both terminal states m and g, and its output is restricted to the clean-token simplex; BD-SUBS-2: only positions that are already clean tokens are copied directly, and both absorbing states must be genuinely denoised. The authors state that together the two establish a dedicated g → x pathway.

    Training objective

    • Under BD-SUBS, the reconstruction term vanishes in the small-step limit and the prior term is 0 because π′ is matched exactly, leaving only the diffusion term; the continuous-time limit yields the weighted masked token cross-entropy (Eq. 11): ℒBD(x1:L) = ∫01 𝔼z′ ∼ q′ (α̇t)/(1−αt) ∑ℓ 1[z′ℓt ∈ {m,g}] log⟨ xℓθ(z′1:Lt, t), xℓ ⟩ dt.
    • Compared with the standard MDLM objective (Eq. 5), there are two changes: the noisy latent variable is sampled from q′ with π′ as the source distribution; the indicator function is active on both absorbing states {m, g}. Training alternates between clean data (using Eq. 5) and poisoned data (using Eq. 11); Appendix G gives the full derivation based on concrete score, and Appendix H gives the training and sampling algorithms (Algorithms 1, 2).

    Key parameters in the experimental setup

    • Unconditional generation: 139M-parameter DiT backbone MDLM, BERT-Base-Uncased tokenization (|V|=30,522), sequence length L=512 (input 254 + [SEP] + output 254), trained from scratch for 75,000 steps, AdamW learning rate 5×10⁻⁵, global batch 256; ShadowMask uses ρ=1, the data poisoning baseline uses ρ=0; poisoning rate ppoison ∈ {0.001, 0.005, 0.01, 0.025}.
    • Conditional generation: LLaDA-8B-Instruct fine-tuned on Alpaca with LoRA (r=8, α=16, dropout 0.05), with the loss applied only to answer tokens.
    • Trigger–target pairs: the trigger word scooted corresponds to the prompt injection target, smirked corresponds to the file deletion command target, and LLaDA additionally uses an emoji trigger word; both English trigger words are single tokens already in the vocabulary.

    Success criteria

    • ASR: the proportion of outputs whose prefix exactly matches the target token sequence (compared at the token ID level); FPR: the proportion of outputs that happen to match the target when there is no trigger; the authors report that FPR is essentially 0 under all settings.
    • Utility: unconditional generation uses Gen PPL (a frozen GPT2-Large scores generated samples) and Val PPL; Q&A uses LLM-judge scores on a 1–5 scale, with ≥4 counted as pass.
  4. What experiments did the paper conduct?

    On 2 models and 3 datasets, the authors report that ShadowMask approaches or reaches 100% ASR, outperforms the data poisoning baseline, and remains effective against multiple defenses.

    Experimental Setup

    • Models tested: 139M-parameter DiT-based MDLM (WikiText-103, OpenWebText unconditional generation, pretrained from scratch); LLaDA-8B-Instruct (Alpaca conditional Q&A, LoRA fine-tuning).
    • Datasets: WikiText-103, OpenWebText, Alpaca; the paper does not give the number of samples per dataset in the main text.
    • Baseline: a data poisoning attack designed by the authors (inserting trigger words at random input positions, prepending the target sequence to the output, with all other training mechanisms the same).
    • Metrics: ASR (output prefix exactly matches the target), FPR (reported as 0 or essentially 0 in each setting), Gen PPL (scored by frozen GPT2-Large), Val PPL, and Pass Rate and average score for Q&A.
    • Evaluation method: Q&A utility is scored 1–5 by Qwen2.5-72B-Instruct on 256 clean Alpaca prompts, with ≥4 as pass; the paraphrase defense experiment also uses Qwen2.5-72B-Instruct for rewriting.
    • Sample size: ASR is averaged over 512 generated samples at each validation step, and the headline ASR numbers re-evaluate the final checkpoint with 128 samples; Gen PPL is the mean over 128 samples (Appendix F).

    Main Results

    According to Table 4 (WikiText-103, trigger word scooted, pretraining stage):

    Swipe horizontally to read the table

    MethodMetric0.1%0.5%1%2.5%
    ShadowMaskASR78.91%100%100%100%
    ShadowMaskgen PPL12.1712.7712.6212.54
    Data poisoningASR0%63.28%93.35%90.63%
    Data poisoninggen PPL14.8514.8314.2714.23

    The clean reference model gen PPL ≈ 11.74. Other settings (according to Tables 5–7): under OpenWebText pretraining, ShadowMask has ASR of 100% at all four poisoning rates (scooted); under the smirked trigger, WikiText-103 pretraining ASR is 98.83%–100%, and OpenWebText is 92.89%–100%; under selective fine-tuning (unfreezing only the last 2 of 12 blocks plus the embedding and output projection, about 45% of parameters trainable), ShadowMask ASR is 84.24%–98.42% (WikiText-103/scooted), while the data poisoning baseline under the same setting is 0%–41.02%.

    • The authors state that ShadowMask consistently outperforms data poisoning in all settings, that a 0.1% poisoning rate is enough to approach 100% ASR while retaining 87% of the clean PPL level, whereas the baseline still struggles at 10 times the poisoning rate.
    • The authors state that selective fine-tuning requires a 1% poisoning rate to reach 100% ASR, but the advantage over the baseline is larger in this setting.
    • Conditional generation (Table 1): LLaDA-8B-Instruct backdoor fine-tuning gives ASR 100%, Pass Rate drops from 85.31% for clean fine-tuning to 82.03%, and average score drops from 4.43 to 4.36; the authors state that the attack is effective and stealthy.

    Target Length Ablation

    • With fixed trigger word smirked, 1% poisoning rate, and WikiText-103 pretraining, target lengths of 1/5/26/36 tokens (Table 8): ShadowMask has ASR 95.31% on the 36-token target, versus 53.13% for data poisoning; with a 1-token target the baseline is only 1.56%, while ShadowMask is 100%.
    • Using trigger word scooted (Table 9): ShadowMask has ASR ≥87.50% at all four lengths, and the baseline drops to 24.22% at 36 tokens.
    • The authors state that data poisoning is fragile when the target is too short or too long, whereas ShadowMask remains consistently effective across lengths.

    Sampling Step Ablation

    • On a fixed ShadowMask OpenWebText pretraining checkpoint (scooted, ppoison=0.025), sweeping DDPM steps {32, 64, 128, 256, 512, 1024} (Table 10): ASR remains 100% throughout, and gen PPL improves monotonically from 22.25 (32 steps) to 10.71 (1024 steps).
    • The authors state that the trigger-conditioned behavior is decoupled from the iterative denoising budget, and that defenses that reduce steps only lose clean utility.

    Defense Robustness

    • Clean fine-tuning: taking a saturated ShadowMask pretraining checkpoint (WikiText-103, ppoison=0.025) and continuing training on clean data with the standard MDLM forward process (ρ=0), plus a stronger probe with ρ=1; the main text gives the design but not specific ASR numbers, and the authors conclude that the backdoor is more persistent than data poisoning.
    • Random dropout (Figure 4, Alpaca Q&A): at dropout rates of 5%/10%/15%/20%, BD-ASR is 94.53%/87.11%/69.53%/61.72% respectively (values labeled in the figure); at dropout rates ≥10%, the clean model pass rate is below 70% and the backdoored model below 60%. The authors state that the safety–utility trade-off of this defense is unfavorable.
    • Paraphrase defense (Table 2, emoji trigger word, ppoison=0.01): after paraphrasing by Qwen2.5-72B-Instruct, ASR drops from 100% to 94.92%, Pass Rate drops from 82.81% to 66.41%, and average score drops from 4.32 to 3.96; the authors state that paraphrasing largely cannot remove the backdoor and harms clean utility.

    Other Ablations and Analysis

    • LoRA fine-tuning (r=8, α=16, about 0.7M parameters): Appendix F.4 describes the configuration, and the authors state that the attack remains effective under parameter-efficient fine-tuning, with specific numbers in Appendix F.6 (the converted text does not give the values in that table).
    • FPR: in pretraining and fine-tuning, on both datasets, the FPR of data poisoning and ShadowMask is 0 (Section 5.1).
  5. What are some points that can be further explored?

    The authors list three limitations: the training control assumption is relatively strong, it is limited to MDLM, and the defenses are self-designed; future directions include broader corruption processes and dedicated defenses.

    Limitations and Future Directions Noted by the Authors

    • The threat model assumption is relatively strong: it assumes the attacker controls the training process, which is stronger than pure data poisoning; the authors state that this is consistent with scenarios such as supply chains and outsourced training, and that experiments show standard data poisoning is ineffective against MDLMs, hence the need for this stronger assumption (Appendix A).
    • Applicable only to MDLMs: the attack is designed specifically for MDLMs and does not directly apply to autoregressive LLMs; the authors state that this is a scope delimitation rather than a fundamental flaw (Appendix A).
    • Defenses are representative and self-designed: MDLM-specific backdoor defenses have not yet been established, so the authors design representative defenses for evaluation, and future defenses may be stronger (Appendix A).
    • Future directions: extend to other discrete corruption processes, source priors, and larger-scale conditional generation settings (Conclusion); develop MDLM-specific defenses such as anomalous trigger-state detection, reverse trajectory auditing, and diffusion-specific machine unlearning (Conclusion, Appendix A).

    Scope of Experimental Coverage

    • The models tested are 139M DiT-based MDLM and LLaDA-8B-Instruct, 2 in total; the datasets are WikiText-103, OpenWebText, and Alpaca, 3 in total (Section 5.1).
    • Defense evaluation includes clean fine-tuning, random dropout, and paraphrasing, three representative defenses designed by the authors (Section 5.5, Appendix A).
    • Headline ASR numbers are based on 128 generated samples, Gen PPL on 128 samples, and Q&A evaluation covers 256 clean prompts (Appendices F.1, F.2, F.4).
    • Trigger–target behavior is instantiated in 3 ways (scooted, smirked, emoji trigger), and the target length ablation covers 1–36 tokens (Sections 5.1, 5.4).
    • The paper does not report the number of samples per dataset, nor the agreement between LLM evaluation and human judgment.
  6. Summarize the main content of the paper

    The authors state that ShadowMask is a training-time backdoor attack against MDLMs, achieving high ASR and low utility loss by modifying the forward corruption prior.

    ShadowMask is a training-time backdoor attack against masked diffusion language models (MDLM), which the authors call the first systematic study in this direction. The problem it addresses is: in a model supply chain scenario, can an attacker implant a trigger–target behavior during training or fine-tuning while keeping generation quality on clean inputs looking normal.

    Method highlights: the forward corruption terminal distribution on poisoned samples is changed from all-mask to a trigger–mask mixture prior π′ = ρg + (1−ρ)m, deriving the backdoored reverse-time posterior and continuous-time training objective (weighted masked token cross-entropy), and establishing a dedicated denoising pathway from the trigger corruption state to the attacker's target sequence; clean samples are still trained with the standard MDLM objective.

    Main results:

    • Under WikiText-103 pretraining with a 0.5% poisoning rate, ASR reaches 100%, while the data poisoning baseline under the same setting is 63.28% (Table 4); under OpenWebText pretraining, ASR is 100% at all four poisoning rates (Table 5).
    • LLaDA-8B-Instruct with LoRA backdoor fine-tuning on Alpaca achieves ASR 100%, with Pass Rate dropping only from 85.31% to 82.03% (Table 1).
    • Under selective fine-tuning (about 45% of parameters trainable), ASR is 84.24%–98.42%, while the baseline under the same setting is only 0%–41.02% (Table 4).
    • With 36-token long targets, ASR is 95.31%, baseline 53.13% (Table 8); ASR remains 100% across DDPM sampling steps from 32 to 1024 (Table 10).
    • Under paraphrase defense, the ASR of the emoji trigger is still 94.92%, but Pass Rate drops from 82.81% to 66.41% (Table 2).

    The authors' conclusion: modifying the MDLM forward corruption process yields a stronger, more fine-tuning-resistant backdoor than data poisoning; the authors believe this exposes a previously unexplored attack surface in the MDLM training pipeline, requiring MDLM-specific defenses such as anomalous trigger-state detection and reverse-trajectory auditing, and plan to extend in the future to other discrete corruption processes and larger-scale conditional generation settings.

Related papers

Show 3 more papers
Read originalarxiv.org