Improving Robustness Against Stealthy Weight Bit-Flip Attacks by Output Code Matching

Ozan Özdenizci, Robert LegensteinCVPR 2022 · OpenReview

Abstract

Deep neural networks (DNNs) have been shown to be vulnerable against adversarial weight bit-flip attacks through hardware-induced fault-injection methods on the memory systems where network parameters are stored. Recent attacks pose the further concerning threat of finding minimal targeted and stealthy weight bit-flips that preserve expected behavior for untargeted test samples. This renders the attack undetectable from a DNN operation perspective. We propose a DNN defense mechanism to improve robustness in such realistic stealthy weight bit-flip attack scenarios. Our output code matching networks use an output coding scheme where the usual one-hot encoding of classes is replaced by partially overlapping bit strings. We show that this encoding significantly reduces attack stealthiness. Importantly, our approach is compatible with existing defenses and DNN architectures. It can be efficiently implemented on pre-trained models by simply re-defining the output classification layer and finetuning. Experimental benchmark evaluations show that output code matching is superior to existing regularized weight quantization based defenses, and an effective defense against stealthy weight bit-flip attacks.

Introduction: The Threat of Stealthy Bit-Flips

Deep neural networks (DNNs) are increasingly deployed in security-critical applications, yet they remain vulnerable to hardware-level attacks. One particularly insidious threat is the Adversarial Weight Bit-Flip Attack (BFA). By exploiting vulnerabilities like "Rowhammer," an attacker can induce bit-flips in the DRAM where model weights are stored, hijacking the model's behavior.

The most concerning variants are stealthy attacks. In these scenarios, an attacker identifies a minimal set of bit-flips that cause the model to misclassify a specific target (e.g., seeing all "dogs" as "cats") while maintaining near-perfect accuracy on all other inputs. This allows the attack to remain undetected by standard performance monitoring.

Stealthy weight bit-flip attacks aim to misclassify specific targets while maintaining high accuracy on other samples.

The Vulnerability of One-Hot Encoding

The authors identify a fundamental structural weakness in modern DNNs: the use of one-hot encoding for class labels. In a one-hot scheme, each output neuron is independent, corresponding to exactly one class. This independence allows an attacker to isolate and manipulate a single class score with minimal "collateral damage" to other classes, facilitating stealth.

Proposed Method: Output Code Matching (OCM)

To address this, the paper introduces Output Code Matching (OCM). Instead of one-hot vectors, OCM trains the model to output specific, partially overlapping bit-string codes for each class.

Key Components:

  • Hadamard Code Design: Class codes are derived from Hadamard matrices. These codes are designed such that any two classes share exactly half of their bits.
  • Architectural Changes: The standard Softmax layer is replaced with a tanh activation. The network is trained using an $l_1$-norm loss to minimize the distance between the predicted output and the target bit-string.
  • Correlation-based Inference: At test time, classification is performed by finding the class code with the highest correlation (dot product) to the model's output.

By "tangling" the class representations, OCM ensures that any weight change intended to affect one class will inevitably impact others, breaking the attacker's ability to remain stealthy.

Comparison of gradients between standard one-hot encoding (top) and OCM (bottom). OCM spreads the influence of a class across the entire weight matrix, making isolated manipulation much harder.

Experimental Evaluation

The researchers evaluated OCM on CIFAR-10, CIFAR-100, and ImageNet using architectures like ResNet-20 and ResNet-50 with quantized weights (4-bit and 8-bit).

Key Findings:

  • Increased Attack Complexity: On ImageNet with ResNet-50, OCM required 20x more bit-flips for a successful attack compared to a vanilla model and 3x more than previous state-of-the-art defenses.
  • Detection through Accuracy Drop: In stealthy T-BFA attacks on CIFAR-10, OCM forced the accuracy on non-targeted samples to drop from ~84% (in undefended models) to ~46%. This massive drop makes the attack immediately detectable.
  • Robustness to Noise: OCM also significantly improved resilience to random hardware bit errors, maintaining high accuracy even under high error rates where vanilla models failed completely.

Conclusion

Output Code Matching provides a robust defense against stealthy weight bit-flip attacks by fundamentally changing how DNNs represent class outputs. By breaking the independence of output neurons, OCM forces a trade-off between attack success and stealthiness, making hardware-induced faults much easier to detect. The method is compatible with existing architectures and can be implemented efficiently through fine-tuning.

Summary updated

Abstract

Deep neural networks (DNNs) have been shown to be vulnerable against adversarial weight bit-flip attacks through hardware-induced fault-injection methods on the memory systems where network parameters are stored. Recent attacks pose the further concerning threat of finding minimal targeted and stealthy weight bit-flips that preserve expected behavior for untargeted test samples. This renders the attack undetectable from a DNN operation perspective. We propose a DNN defense mechanism to improve robustness in such realistic stealthy weight bit-flip attack scenarios. Our output code matching networks use an output coding scheme where the usual one-hot encoding of classes is replaced by partially overlapping bit strings. We show that this encoding significantly reduces attack stealthiness. Importantly, our approach is compatible with existing defenses and DNN architectures. It can be efficiently implemented on pre-trained models by simply re-defining the output classification layer and finetuning. Experimental benchmark evaluations show that output code matching is superior to existing regularized weight quantization based defenses, and an effective defense against stealthy weight bit-flip attacks.
BibTeX
@inproceedings{ozdenizci2022improving,
  author = {Ozan Özdenizci and Robert Legenstein},
  title = {{Improving Robustness Against Stealthy Weight Bit-Flip Attacks by Output Code Matching}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2022},
  url = {https://openreview.net/forum?id=_S2edX5fGk},
}
Figure