Adversarial Vulnerability of Powerful Near-Out-of-Distribution (OOD) DetectionAdversarial vulnerability of powerful near out-of-distribution detection
The authors state that the strongest near-OOD detection methods have severe adversarial vulnerability: under FGSM attack, Mahalanobis detection with ViT-L16 on CIFAR-100 vs CIFAR-10 drops in AUROC from 97.98% to 41.33%.
The attacker can apply small, targeted perturbations to input image pixels (FGSM, L∞ strength such as 1/255), using the gradient of the OOD scoring function with respect to the input to turn in-distribution images into ones judged out-of-distribution, or vice versa; the victim systems are OOD detectors based on large-scale pretrained ViT (MSP, Mahalanobis, Relative Mahalanobis, CLIP zero-shot).
- The strongest OOD detection based on large-scale pretrained models and multimodality is considered near human level in distribution shift scenarios, but its robustness under adversarial perturbations is unknown; the authors focus on this risk in safety-critical applications.
- For the OOD scoring functions (MSP, Mahalanobis, Relative Mahalanobis, CLIP zero-shot), FGSM is used to perturb input pixels along the gradient direction, measuring the loss in AUROC under different L2/L∞ perturbation strengths, and examining the effects of ensembles, Relative Mahalanobis, and low resolution.
- On CIFAR-100 vs CIFAR-10, an L∞=1/255 attack reduces the AUROC of Mahalanobis detection with ViT-L16 from 97.98% to 41.33%, and CLIP to below 10%; Relative Mahalanobis, dual-model ensembling, and 32×32 low resolution all reduce the AUROC loss, and the first two can be combined.
- The authors say ensembling and Relative Mahalanobis are only easy-to-use, low-cost mitigations, and that safety-critical scenarios may require stronger mitigation techniques; the experiments used only one attack, FGSM, with 128 perturbed images, and the models tested were ViT-L16, R50+ViT-L32 and CLIP.
- Evaluated models
- ViT-L16R50+ViT-L32CLIP
- Benchmarks
- CIFAR-100 vs CIFAR-10CIFAR-100 vs SVHN
- Metrics
- AUROC∆AUROC
Stanislav Fort's paper shows experimentally that even the strongest current out-of-distribution (OOD) detection techniques have severe adversarial vulnerability: a small targeted perturbation to input pixels can easily flip an image's judgment from in-distribution to out-of-distribution, or the reverse. The experiments cover the near-OOD CIFAR-100 vs. CIFAR-10 task and the far-OOD CIFAR-100 vs. SVHN task, and examine post-hoc methods including the Maximum of Softmax Probabilities (MSP) baseline, Mahalanobis distance, and the newly proposed Relative Mahalanobis distance. By comparing the loss of OOD detection performance under different perturbation strengths, the paper demonstrates the beneficial effect of using an ensemble of OOD detectors, and that Relative Mahalanobis distance outperforms other post-hoc methods. In addition, strong zero-shot OOD detection based on CLIP and multimodality likewise severely lacks adversarial robustness.
Paper analysis
What problem does this paper attempt to solve?
The authors state that the strongest near-OOD detection methods have severe vulnerability to small adversarial perturbations, and study mitigation approaches.
Core question: can the current strongest near-OOD detection systems (based on large-scale pretrained models and multimodality) withstand adversarial attacks targeting OOD scores.
- Problem setting and importance: Neural networks often give high confidence to misclassified or non-training-distribution inputs, and reliable OOD detection is a hard problem in safety-critical applications such as medicine; the authors say large-model pretraining and multimodality have brought near-OOD tasks such as CIFAR-100 vs CIFAR-10 close to human level, but adversarial robustness is unknown.
- Shortcomings of existing methods: The authors say prior adversarial example research has mostly been in the classification setting; [18] showed that OOD detection systems are also vulnerable and proposed a robust training algorithm, and [19] proposed a more robust training algorithm, but this paper focuses on the vulnerability of the strongest existing detectors themselves.
- Core observation: Taking the input gradient of the OOD scoring function and perturbing pixels along its direction can turn an in-distribution image into one judged out-of-distribution, or vice versa (Figure 1, Figure 2).
- What the paper proposes: Measuring adversarial robustness of MSP, Mahalanobis, Relative Mahalanobis and CLIP zero-shot detection, and examining two interventions—detector ensembling and the Relative Mahalanobis distance—as well as the effect of image resolution.
- Threat model:
- Goal: Change the image's in-distribution/out-of-distribution judgment, in either direction.
- Knowledge: Access to the gradient of the OOD scoring function with respect to the input (perturbations generated with FGSM).
- Capability: Apply small, targeted perturbations to input pixels, with strength measured by L2/L∞ norm (e.g., L∞=1/255).
- Victim systems: OOD detectors based on pretrained and fine-tuned ViT, and CLIP zero-shot detection.
What related research exists?
Related work falls into four groups: OOD detection methods, large models and multimodal detection, adversarial examples and robust OOD, and ensemble methods.
OOD detection methods
- Generative model approaches [6; 7; 2; 8], modifying objectives and loss functions [9], exposing OOD samples during training (outlier exposure) [10]—the authors summarize these as three types of progress in improving OOD detection.
- Mahalanobis distance (MD) [14]—post-processing intermediate network features for OOD detection; the authors state that some of its failure modes are improved by RMD.
- Relative Mahalanobis Distance (RMD) [15]—subtracts a background distribution term from MD; the authors state that it generally improves performance and is less sensitive to hyperparameter choice.
Large models and multimodal detection
- Vision Transformer [11] and ImageNet-21k pretraining [12]—the authors state that large-model pretraining brings near-OOD visual tasks close to human performance.
- [13] (Fort et al., 2021)—uses CLIP [16] for zero-shot OOD detection that specifies the distribution only by class names, and reaches 97.98% AUROC on CIFAR-100 → CIFAR-10 with a ViT ensemble + Mahalanobis post-processing; the attack target and baseline setting of this paper mainly come from that work.
Adversarial examples and robust OOD detection
- Adversarial examples [17] and FGSM [20]—adversarial perturbations and their fast generation method in the classification setting; this paper uses FGSM as the attack.
- [18] (Chen et al., 2020)—shows that OOD detection systems are susceptible to such attacks and proposes a robust training algorithm; [19] (Chen et al., 2021, ATOM)—proposes a training algorithm that uses outlier mining to enhance the robustness of OOD detection.
Ensembles
- Deep ensembles [5] and their loss-landscape explanation [23]—the authors state that the reason ensembles of OOD detectors are effective may be similar to the reason deep ensembles are generally effective.
Baselines and benchmarks: the comparison baseline is Maximum of Softmax Probabilities (MSP); the tasks are near-OOD CIFAR-100 vs CIFAR-10 and far-OOD CIFAR-100 vs SVHN. The authors position this paper as: empirically demonstrating the adversarial vulnerability of these existing strongest detectors, and verifying the mitigation effect of two easy-to-use interventions, ensembles and RMD.
How does the paper address this problem?
FGSM is used to perturb input pixels for the OOD scoring functions, measuring the loss in AUROC with perturbation strength, and testing ensembles, RMD, and resolution.
Overall approach: treat the scoring function of OOD detection as the attack target, perturb the input along the gradient in the same way as classification adversarial examples, compare the AUROC loss of different post-processing methods under different perturbation strengths, and examine the mitigation effect of detector ensembles and Relative Mahalanobis distance.
Attack method
- Given a scoring function score(x), take its gradient with respect to the input g(x) = ∂ score(x′)/∂ x′|x′=x, used to stepwise raise or lower the input's OOD score.
- Iterative update xt+1 = xt + ε g(x), where ε is the learning rate; the authors mainly use FGSM, i.e., using sign(g(x)) instead of g(x) as the step direction, on the grounds that it is easy to use and works out of the box.
OOD scores attacked
- Mahalanobis distance (MD): takes the network's penultimate-layer output (pre-logits) as features, fits a Gaussian distribution to each of the K in-distribution classes (independent per-class means, shared covariance to avoid numerical problems from underfitting), and the score of a test sample is the negative of the minimum distance to the class Gaussians.
- Relative Mahalanobis (RMD): RMDk = MDk − MD0, where MD0 is the distance to a Gaussian fitted to the entire in-distribution dataset (ignoring labels), used to model the background distribution and subtract its effect.
- MSP baseline: score(x) = max(f(x)), i.e., the maximum softmax probability as the in-distribution score.
- CLIP zero-shot: uses two sets of words, in-words and out-words, to describe the semantic content inside/outside the distribution, score(x) = max CLIP(x, inword) − max CLIP(x, outword); gradient stepping on the image is likewise possible.
Ensembles and attacking ensembles
- The ensemble score is the average of the models' OOD scores: score_ensemble(x) = (1/N) Σ score_i(x); the authors state that the reason ensembles are effective may be similar to the reason deep ensembles are generally effective.
- Attacking the ensemble is the same as attacking a single model, except that score(x) is replaced by the ensemble scoring function.
Evaluation method
- Attack setting: FGSM, learning rate 3×10⁻⁴ (the authors note it was chosen arbitrarily), 30 steps on 128 CIFAR-10 test images (out-of-distribution).
- Metrics: AUROC between unperturbed CIFAR-100 and perturbed CIFAR-10, and the loss ∆AUROC relative to the unperturbed AUROC; perturbation strength is measured by L2 and L∞ norms, with the summary point at L∞=1/255.
- Summary curve procedure: piecewise linear interpolation of each image's score(L∞), then sampling at the target perturbation norm, and comparing the score distribution of the 128 images with the in-distribution test set to obtain AUROC.
What experiments did the paper conduct?
The adversarial robustness of four scores is tested on near/far-OOD tasks, and the mitigation effects of ensembles, RMD, and low resolution are tested.
Experimental setup
- Models tested: ViT-L16 pretrained and fine-tuned on the CIFAR-100 training set (default input 384×384, CIFAR 32×32 images upsampled with tf.image.resize) and R50+ViT-L32 (input 224×224×3); and CLIP (zero-shot).
- Tasks: near-OOD CIFAR-100 (in-distribution) vs CIFAR-10 (out-of-distribution); far-OOD CIFAR-100 vs SVHN.
- Baseline: Maximum of Softmax Probabilities (MSP) post-processing.
- Attack: FGSM, learning rate 3×10⁻⁴, 30 steps, 128 out-of-distribution test images; the resolution experiment uses 32 images.
- Metrics: AUROC (unperturbed vs after L∞=1/255 perturbation) and ∆AUROC; perturbation strength is swept over L2 and L∞ norms.
- Review method: no human or LLM review; AUROC is computed directly from the score distributions.
Main results
According to Table 1 (CIFAR-100 vs CIFAR-10, L∞=1/255, all based on ViT-L16):
Swipe horizontally to read the table
Post-processing method AUROC before attack AUROC after attack ∆AUROC Max of Softmax Probs 94.28% 27.48% -66.8% Mahalanobis 97.98% 41.33% -56.65% Relative Mahalanobis 97.11% 71.84% -25.27% - The authors state that the MSP baseline has the worst robustness, followed by standard Mahalanobis, and Relative Mahalanobis has the highest adversarial robustness (the Table 1 caption says "by a significant margin"; the paper reports no statistical test).
- Figure 7a/7b shows that under both the L2 and L∞ norms, RMD maintains a higher AUROC at every perturbation strength.
- The attack is bidirectional: Figure 1 shows in-distribution images (CIFAR-100) being pushed from scores of about 1,000 to about 2,800 in the out-of-distribution region; Figure 2 shows out-of-distribution images being pushed in the reverse direction into the in-distribution region.
Vulnerability of CLIP zero-shot
- What was tested: the robustness of CLIP zero-shot OOD detection, which specifies the distribution with words, under the same FGSM attack.
- Results: on CIFAR-100 vs CIFAR-10, at L∞=1/255 AUROC drops from 94.68% to below 10% (Table 2; the ∆AUROC column in the original source says "a lot"); in Figure 7, CLIP (purple) is lower than the other methods including MSP.
- The authors state that CLIP is the least robust of the methods studied in this paper, despite relying on embeddings from a large pretrained ViT.
Combination of ensembles and RMD
- What was tested: the AUROC loss of ViT-L16 and R50+ViT-L32 individually and their two-model ensemble under MD and RMD (Table 3, L∞=1/255).
- Results: under MD, the single models drop to 56.14% and 54.94% respectively, and the ensemble drops to 68.67%; under RMD, the single models drop to 69.82% and 68.53% respectively, and the ensemble drops to 78.64% (∆AUROC only -9.05%).
- The authors state that the ensemble improves both unperturbed AUROC and adversarial robustness, and that its gains can be stacked with those of RMD; Figure 9 and Figure 10 show that at all measured perturbation strengths the ensemble (dark line) outperforms the single models.
Effect of image resolution
- What was tested: computing scores and gradients directly on 32×32 images (derivative of score(resize(x)) with respect to x), compared with attacking after 384×384 upsampling (Table 4, Figure 11, 32 images).
- Results: under MD, AUROC after the 32×32 attack is 93.11% (∆ -4.87%), versus 41.33% at 384×384 (∆ -56.65%); under RMD, 32×32 gives 90.13% (∆ -6.98%), versus 71.84% at 384×384 (∆ -25.27%).
- The authors state that low-resolution images are harder to perturb, and that the relative advantage of RMD persists at low resolution; the authors speculate that high resolution gives the attack more pixels to exploit.
Other ablations and analyses
- Far-OOD CIFAR-100 vs SVHN (Table 5): MD drops from 99.40% to 34.47% (∆ -64.93%), RMD drops from 97.19% to 43.22% (∆ -53.97%).
- Exception: the authors state that the large robustness advantage of RMD on near-OOD is not evident or does not exist on this far-OOD task.
- The authors state that, based on this example, there is weak evidence that far-OOD tasks may be more susceptible to attacks targeting OOD scores (at the same strength, MD drops to 34.47% on the SVHN task and to 41.33% on the CIFAR-10 task).
- Attack hyperparameters: the learning rate 3×10⁻⁴ was chosen arbitrarily; the paper reports no ablation on this learning rate.
What are some points that can be further explored?
The authors state that ensembling and RMD are only easy-to-use partial mitigations, and safety-critical scenarios require stronger mitigation techniques.
Limitations and future directions noted by the authors
- The authors state that ensembles and RMD are only easy-to-use, general means of "partial remedying" this vulnerability (Conclusion).
- The authors state that these two methods "may" be insufficient for the safety-critical properties common in OOD detection, and that "stronger mitigation techniques will likely need to be adopted" (Conclusion).
- The authors state that they hope that by demonstrating this non-robustness they will prompt more research to address it (Conclusion).
- The authors state that the conclusion that far-OOD tasks may be more susceptible to attack is only "weak evidence", based on a single example (Section 3.5).
Scope of experiments
- The models tested are ViT-L16, R50+ViT-L32, and CLIP, three in total; the ensemble experiments use only the two-model ensemble of the first two models (Section 3.3).
- Only one attack, FGSM (learning rate 3×10⁻⁴, 30 steps), is used; the paper reports no other attack algorithms or adaptive attacks.
- The main experiments use 128 out-of-distribution test images per group, and the resolution experiment uses 32; the paper reports no number of repetitions or variance.
- The tasks cover two visual tasks: near-OOD CIFAR-100 vs CIFAR-10 and far-OOD CIFAR-100 vs SVHN.
- The paper mentions the robust training algorithms of [18] and [19], but this paper does not implement or evaluate these defenses; it evaluates only three interventions: ensembles, RMD, and low resolution.
Summarize the main content of the paper
The authors state that the strongest near-OOD detection is severely vulnerable to FGSM perturbations, and that ensembles and RMD can partially mitigate this and can be stacked.
An empirical study on the adversarial robustness of OOD detection: whether the current strongest near-OOD detection based on large-scale pretrained ViT and CLIP is reliable under small perturbations targeting OOD scores.
- Problem: safety-critical applications require robust OOD detection, but prior adversarial research has mostly been in the classification setting; the authors aim to test the vulnerability of the strongest detectors themselves.
- Method: for the four scores MSP, Mahalanobis, Relative Mahalanobis, and CLIP zero-shot, FGSM (learning rate 3×10⁻⁴, 30 steps, 128 out-of-distribution images) is used to perturb pixels, measuring the loss in AUROC with L2/L∞ perturbation strength.
- Main results: on CIFAR-100 vs CIFAR-10 at L∞=1/255, for ViT-L16 the Mahalanobis detector's AUROC drops from 97.98% to 41.33%, MSP from 94.28% to 27.48%, and RMD from 97.11% to 71.84% (Table 1); CLIP drops from 94.68% to below 10%, which the authors state is the least robust of the tested methods (Table 2).
- Mitigation: a two-model ensemble of ViT-L16 and R50+ViT-L32 with RMD gives AUROC 78.64% after attack (∆ -9.05%), better than any single-model configuration (Table 3); when attacking directly at 32×32 resolution, MD drops only to 93.11% (Table 4).
- Exception: on far-OOD CIFAR-100 vs SVHN, the robustness advantage of RMD is not evident or does not exist (Table 5).
- Authors' conclusion: these detectors have severe adversarial vulnerability independent of their representational capacity; ensembles and RMD are easy-to-use, low-cost, and stackable partial mitigations, but safety-critical scenarios likely require stronger mitigation techniques.