Model code backdoors can steal fine-tuning secrets with >98% success
Compromised model code can extract token-level secrets from locally fine-tuned LLMs via active execution hijacking
AI/ML arXiv 30 Apr 2026 Attack Prototype evidence
Published as “Secret Stealing Attacks on Local LLM Fine-Tuning through Supply-Chain Model Code Backdoors”
Why it matters
The work demonstrates that merely fine-tuning LLMs locally does not guarantee data privacy if the upstream model code can be tampered with, urging the community to adopt code-level auditing and supply-chain signing.
Summary
The paper shows that by compromising model implementation code, an attacker can force locally fine-tuned LLMs to memorize and later exfiltrate high-entropy secrets with >98% strict attack success rate, while preserving primary task performance within a few percent. The attack works across multiple tasks (code generation, medical QA, summarization) and evades several defenses, including DP-SGD (when not applied), semantic safety filters, and static code audits. However, the attack is completely blocked by DP-SGD (ε=5) at the cost of destroying utility, and the authors acknowledge that their loss-gradient decoupling does not make the backdoor invisible to a determined auditor. The evidence is based on experiments with three public benchmark datasets totalling about 33 k samples.
What they found 3
- The attack achieves >98% strict attack success rate while only modestly reducing primary-task performance.
“Magicoder 98.38% 0% Pass@1: 0.616 (↓0.96%) Pass@1: 0.622”
- Differential-privacy training (DP-SGD, ε=5) completely nullifies the attack.
“When DP-SGD (ε=5) is properly enforced, our attack is fully neutralized (Strict ASR →0%).”
- Loss-gradient decoupling makes the training loss curve indistinguishable from clean fine-tuning.
“Figure 4 confirms our stealthiness: While the internal objective (Main+Surr Loss) rises due to injection, our decoupled Return Loss perfectly mimics the convergence trajectory of standard fine-tuning (Baseline).”
Caveats 5
- DP-SGD (ε=5) eliminates the attack entirely, showing that the method fails under strong privacy training.
- The authors note that stealthiness is not absolute; the injected code is visible in model implementation files and could be spotted by expert auditors.
- Target-discovery rules are attacker-defined. Stage I relies on attacker-designed tensor rules to locate secrets.
- Stealthiness is not absolute. Although loss-gradient decoupling reduces detection risk, the attack still injects visible logic into model implementation code, making it less stealthy than purely weight-based backdoor attacks.
- Defenses are not exhaustive. We only evaluate representative defenses (e.g., DP-SGD). Stronger supply-chain security measures (e.g., enforcing trusted implementation libraries, restricting custom autograd operations) may reduce attack success.
What’s new here 4
- Introduces a supply-chain attack that injects malicious logic into model code rather than weights.
- Uses deterministic online tensor-rule matching to locate and bind high-entropy secrets during fine-tuning.
- Provides a check-code mechanism that lets the attacker verify leaked secrets under black-box queries, eliminating hallucination.
- Applies gradient-loss decoupling to hide the attack’s impact on observable training loss.