What is model weight tampering?
Model weight tampering is the unauthorised change of a trained model's weight files after training, in storage, in transit or in the deployment pipeline, to add a hidden backdoor, make it misbehave on certain inputs or weaken its safety behaviour.
Unlike model poisoning, which corrupts training data or the training process so the model learns wrongly, tampering edits the weights directly once training ends. Research shows direct weight edits give attackers more freedom than poisoning and can evade many backdoor detection methods.
- Topic
- AI security
- Also known as
- Model tampering
How model weight tampering works
- The attacker reaches the model registry, storage, a deployment pipeline or a model file downloaded from outside.
- The attacker changes certain weights without hurting overall performance.
- The altered model behaves normally in routine tests but gives the attacker's chosen output on a specific trigger.
- Without integrity checks the change goes unnoticed at deployment.
In more detail
Safetensors versus pickle: code execution is blocked, weight tampering is not
Switching from legacy pickle-based formats (.pt, .bin) to safe tensor formats such as safetensors prevents arbitrary code execution during file loading, but it does not prevent weight tampering. An attacker can still alter numeric tensor values inside a valid safetensors file to implant backdoors or erode safety alignment, so cryptographic signing and hash verification remain mandatory.
LoRA adapter tampering, quantisation abuse and in-memory bit-flip attacks
Tampering does not always target the full base model: in modular deployments, attackers can compromise small LoRA adapters or quantised checkpoint variants, which are faster to alter and bypass checks applied only to the base model. Beyond file storage, hardware fault-injection or Rowhammer bit-flip attacks can also corrupt critical weights directly in memory.
Tampering to remove safety alignment
In open-weight LLMs, weight tampering is also used for malicious 'unalignment' or safety-erasure (such as targeted directional ablation), removing refusal guardrails while keeping general benchmark accuracy intact. Verifying both cryptographic provenance and post-deployment safety benchmarks protects against silent safety degradation.
Commonly confused terms
| Term | How it differs |
|---|---|
| Model poisoning | Model poisoning corrupts training data, labels or optimisation steps during training; model weight tampering directly modifies the serialised weight files or in-memory tensors after training completes. |
| Insecure model deserialisation | Model weight tampering alters a model's behaviour or integrity inside the weights; deserialisation attacks (such as malicious pickle payloads in .pt/.bin files) execute arbitrary OS code on the host machine when the model file is loaded. |
| Adversarial inputs and prompt injection | Weight tampering permanently edits model parameters to embed triggers or strip guardrails; adversarial prompt/input attacks manipulate runtime inputs against unmodified weights. |
Why model weight tampering matters for on-premises AI
Organisations often take models from external repositories, fine-tune them internally and move them between systems; every transfer is a tampering opportunity. Effective protection rests on integrity verification: signing models and verifying signatures at every load, keeping only approved versions in the model registry, logging changes and regularly testing behaviour for hidden triggers. Since the team training a model often differs from the one deploying it, signatures build trust between them.
Before deploying its diagnostic support model, a hospital compares the file's signature with the approved one in its model registry; when an update's signature fails to match, deployment stops and the old version keeps running until the file's source is investigated.
Common questions
How does weight tampering differ from model poisoning?
Poisoning corrupts training data or process. Tampering edits weights directly after training.
How is weight tampering detected?
By signing model files and verifying them at every load. Behaviour is also tested regularly for hidden triggers. A signature only catches changes made after signing; a model brought in from outside may have been tampered with before it was signed.
Related terms
Sources
In the glossary: Glossary, M to Q