Hiding Inside the Generalization Gap: Surgical Edits That Blind Deepfake Detectors

Deepfake detectors are known to be unreliable on data unlike their training set. A detector near 99% accurate on its home benchmark can drop by tens of points on videos from other sources, so practitioners have come to expect uneven, unexplained failures. This note proposes that this expected unreliability is a hiding place. An adversary with brief access to a detector's weights, such as a vendor, a model hub, or an insider, can make a small surgical change so the detector stops flagging one chosen family of forgeries. Home-benchmark accuracy stays intact. On the other benchmarks an auditor would check, the tampered model's scores look like ordinary cross-dataset variation. The note then asks whether a defender who holds only the public foundation model the detector was built on, and not a clean copy of the detector, can find and undo such an edit by inspecting how the weights changed.

The opportunity comes from two research lines that have not been joined. Work on large language models shows that "knowledge editing" can inject misinformation and bypass safety training while standard benchmarks barely move. Knowledge editing means changing a few parameters so a model stores a new fact without retraining. That same body of work also shows edits leave detectable statistical traces in the weights. Work on deepfake detection has meanwhile begun using injection-style changes to vision transformers for benign ends, namely to improve generalization. No one has asked whether the same mechanism can be turned against a detector. Nor has anyone asked whether a detector's known weakness on unfamiliar data is exactly what makes such an attack hard to catch.

Core Claim

The claim has two parts. First, editing a small number of attention heads in a vision-transformer deepfake detector can suppress detection of a target forgery family. The target could be one manipulation method from DF40, or the diffusion-style fakes absent from FaceForensics++. The edit keeps in-domain FaceForensics++ AUC within about one point. It also keeps held-out benchmark AUCs (Celeb-DF, DFDC, WildDeepfake) inside the spread observed across clean detectors trained with different seeds. When that happens, checking accuracy on held-out benchmarks cannot tell tampering apart from the natural generalization gap. Second, a check that needs no clean copy of the detector can separate the two cases. It compares the detector's weights to the public backbone it was fine-tuned from, head by head. Legitimate fine-tuning spreads its changes across many heads and many directions. A surgical edit concentrates energy in a few heads along a few directions. Removing those dominant directions should restore the suppressed detection without hurting anything else.

The new element is not "editing can harm vision models." It is the combination of three things: an attack whose stealth is judged against the cross-dataset variance of clean detectors rather than against a single clean reference, an audit that assumes access only to the public backbone, and a test of whether removing the flagged components restores cross-dataset generalization.

Position Relative to Prior Work

Three papers motivate the threat. Can Editing LLMs Inject Harm? shows that edits push misinformation efficacy from 0% to over 90% while keeping GSM8K and NaturalQuestions within about 1%. Sowing the Wind, Reaping the Whirlwind shows that niche factual edits raise unethical responses to 74.3% with MMLU stable. Position: Editing Large Language Models Poses Serious Safety Risks argues this is a general safety risk. All three study text models whose clean behavior is well characterized. We study a setting where the clean model's out-of-domain behavior is itself noisy, which is what makes the stealth question different.

Two papers supply the editing mechanism, and one of them constrains it. Model Editing for Vision Transformers (RefineViT) finds that ViT decisions live mainly in attention rather than in the feed-forward layers that language-model editors target. It scores heads by ablation and fixes errors with a small learned projection in under 0.3 seconds, raising Waterbirds worst-group accuracy from 45.6% to 61.4%. We reuse its head-scoring and projection edit as an attack. Its finding that feed-forward ablation barely matters is also a prediction we test directly: rank-one edits to feed-forward layers in the style of ROME should make a weak attack on detectors.

Deepfake Detection via Knowledge Injection (KID) is the closest existing work. It freezes DINOv2 attention branches and adds an injection attention block with suppression-and-contrast losses, reaching 95.74% AUC on Celeb-DF and 75.77% on DFDC. KID treats injection only as a benign tool. We treat a KID-trained detector as a victim, and we use its suppression loss as a reason to expect legitimate fine-tuning changes to be spread thinly across the network.

Three papers supply the forensic method, all on language models. Has this Fact been Edited? (DEED) detects ROME edits from hidden states and output distributions at 98% F1. Identifying Knowledge Editing Types in Large Language Models classifies edit intent at 0.745 average F1 but mislabels unedited knowledge at a 13.82% error rate. Tracing and Reversing Edits in LLMs shows edits dominate top singular values and that truncating them restores original outputs in up to 94% of GPT-2 cases and about 80% for Llama-3. We carry the spectral idea to attention heads in vision detectors. The key change is that we apply it to the difference from a public backbone rather than to raw weights. A fine-tuned detector legitimately differs from its backbone, and the task is to find a concentrated edit inside a spread-out fine-tuning change. The 13.82% false-positive figure is a warning that telling legitimate change from malicious change is the hard part, so our evaluation centers on false positives against a population of clean detectors.

Threat Model and Audit Statistic

The attacker receives a fine-tuned detector and returns a modified one. The attacker has some examples of the target forgery family and some FaceForensics++ data to preserve locality, meaning behavior on inputs the attack should not affect. The defender has the modified detector, the public backbone (DINOv2 or CLIP), and a suite of public audit benchmarks. The defender does not have the clean detector.

Write $W_h$ for the output projection of attention head $h$ in the detector and $B_h$ for the same projection in the public backbone. Let $\Delta_h = W_h - B_h$. The per-head concentration score is

$$s_h = \frac{\sigma_1(\Delta_h)^2}{\|\Delta_h\|_F^2},$$

where $\sigma_1$ is the largest singular value and $\|\cdot\|_F$ is the Frobenius norm. The score equals 1 when the change is rank one and falls toward $1/d$ when the change is spread evenly over $d$ directions.

The model-level audit score is the largest $s_h$, weighted by that head's ablation utility for the detector's output (computed as in RefineViT) and compared against the distribution observed over clean fine-tuned detectors. For RefineViT-style edits that add a block-end projection, the analogous quantity is computed on the new projection's deviation from identity. Reversal removes the top-$k$ singular components from the flagged heads' $\Delta_h$, with $k$ chosen by the largest spectral gap rather than tuned per model. Tracing and Reversing Edits leaves this selection open.

Research Program

We build three kinds of victim detector. The first is KID on DINOv2. The second is RepDFD from Standing on the Shoulders of Giants, which freezes CLIP and trains only 0.078M parameters. The third is a plainly fine-tuned ViT-B. All are trained on FaceForensics++ HQ. RepDFD matters because its frozen backbone means the attacker must edit shared foundation weights. Its paper notes that input reprogramming assumes an uncorrupted backbone, and we test what happens when that assumption fails.

For each victim type we train a population of about forty clean detectors, varying seed, augmentation, and learning rate. The spread of their Celeb-DF, DFDC, and WildDeepfake AUCs gives an empirical "natural gap band." A tampered model counts as behaviorally stealthy if its audit-benchmark scores fall inside this band.

We then build roughly forty tampered detectors per attack type using three edit families. The first is a RefineViT-style projection edit trained to push target-family fakes toward "real." The second is a rank-one edit to the output projection of the heads with the highest utility for the target family. The third is a ROME-style feed-forward edit, included as a control that RefineViT's findings predict will be weak.

Target families are held-out DF40 generators and a Celeb-DF-style subset. We choose them to be absent from the audit suite, since an attacker who knows the suite would do the same. Finally, we run an adaptive attacker who adds a penalty on $s_h$ and spreads the edit across many heads. This tests how much attack strength must be given up to evade the audit.

Baselines

The naive reference is behavioral screening. The defender evaluates the returned detector on FaceForensics++, Celeb-DF, DFDC, and WildDeepfake and flags it if any AUC falls outside the clean band. Every auditor can already do this, so the attack is only interesting if screening fails. The comparison is fair because screening sees the same audit suite and the same clean population our audit uses. Beating it means higher area under the ROC curve at separating clean from tampered detectors, at a fixed 5% false-positive rate on clean detectors.

The strongest existing weight-space method is EditScope-style top-$k$ singular value truncation from Tracing and Reversing Edits in LLMs, applied to raw detector weight matrices without the backbone difference. It is the only reference-free weight forensic in the file with reported reversal success: up to 94% on GPT-2 and about 80% on Llama-3 on CounterFact. There is no reported result on Lacuna for any edit detector or reversal method applied to vision deepfake detectors. We give it the same heads, the same $k$-selection rule, and the same clean population. Beating it means better detection at fixed false-positive rate. It also means better recovery of target-family AUC, measured as the fraction of the attack-induced drop restored, with clean-benchmark AUC kept inside the band.

A second strong baseline is a DEED-style probe from Has this Fact been Edited?. It trains a classifier on the detector's hidden states and output distributions using known clean and edited detectors, and is given the same number of labeled training detectors as our threshold calibration uses. It needs target-family inputs that the defender may not have, so we report it both with and without access to them.

The detection-quality reference for victims is KID's reported 95.74% Celeb-DF and 75.77% DFDC AUC and RepDFD's reported 88.05% WildDeepfake AUC. We reproduce these first, so the attacks are shown on detectors that are actually strong.

Two ablations isolate the key ingredient. The first computes the same concentration score on raw weights rather than on the difference from the backbone, which tests whether the public backbone as reference is what makes the audit work. The second drops the utility weighting, which tests whether knowing which heads matter to the decision is necessary.

Why not just…?

Why not just compare against a hash or a clean copy of the detector? When a trusted clean checkpoint exists, a weight diff trivially exposes any edit, and we say so plainly. The proposal targets the common case where it does not exist. Detectors often come from vendors, are re-fine-tuned downstream, or are built on a public backbone with private fine-tuning. The only trusted artifact is then the backbone. If a deployment setting really does have signed clean checkpoints, the audit is unnecessary there, and we will scope the claim accordingly.

Why not just test the detector on more held-out benchmarks? This is the main threat to the claim's importance, and the experiment addresses it directly. If tampered detectors fall outside the clean band on the audit suite, behavioral screening is enough and the stealth half of the claim fails. We expect it to hold when the target family is absent from the suite. The file's evidence is consistent with this: edits in language models leave unrelated benchmarks within about 1%, and cross-dataset AUC for clean detectors ranges widely, from 0.669 for the augmentation method in On Improving Cross-dataset Generalization of Deepfake Detectors to KID's 95.74% on the same Celeb-DF test. We will also report how screening power grows as the audit suite happens to overlap the target family.

Why not just fine-tune the returned detector on clean data to wash out any edit? Blind fine-tuning may erase a surgical edit. KID reports, however, that standard fine-tuning washes out pretrained knowledge and hurts generalization, so this defense may cost the very cross-dataset robustness it is meant to protect. We run clean fine-tuning with a matched compute budget and compare three things: target-family recovery, the change in Celeb-DF, DFDC, and WildDeepfake AUC, and the ability to say whether tampering occurred, which fine-tuning cannot provide. If fine-tuning recovers the target family without lowering held-out AUC, the reversal half of the proposal adds only the diagnosis, and we will report that.

Why not just use test-time augmentation or reprogramming to move inputs back toward the training distribution? These methods act on inputs and cannot undo a weight change that deliberately maps a family's features to "real." RepDFD's reliance on a frozen, trusted CLIP makes it a natural victim rather than a defense. We include the reinforcement-learning augmentation selector as a test-time defense on tampered detectors to check this empirically.

Decisive Checks

Three results would settle the proposal.

The stealth check succeeds if head-level edits drive target-family AUC below 0.6 while in-domain FaceForensics++ AUC stays within one point and all audit-benchmark AUCs stay inside the clean band, for at least the KID and plain ViT victims. The feed-forward control should be clearly weaker, matching RefineViT's localization finding. If it is not, that finding does not transfer to forensic detectors, which would be informative in its own right.

The audit check succeeds if the backbone-difference concentration score separates clean from non-adaptive tampered detectors with high AUROC at 5% clean false-positive rate, and clearly outperforms both behavioral screening and raw-weight truncation. The adaptive attacker is the real test. We will plot attack success against audit score as the evasion penalty grows. The audit is useful if evading it forces the attack to lose most of its target-family suppression. If a spread-out edit keeps full attack strength and passes the audit, we will report that the reference-free audit fails against adaptive attackers.

The reversal check succeeds if truncating flagged components restores most of the lost target-family AUC while keeping Celeb-DF, DFDC, and WildDeepfake AUC within the clean band. It must also remove less of the legitimate fine-tuning than clean-data fine-tuning does at equal compute.