NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

GNNGuard: Defending Graph Neural Networks against Adversarial Attacks

Xiang Zhang, Marinka Zitnik

Abstract

Graph Neural Networks (GNNs) are highly effective for learning on relational data but remain vulnerable to adversarial "poisoning" attacks that manipulate graph structure. We present GNNGuard, a general-purpose defense mechanism that dynamically weights and prunes edges based on node similarity while maintaining a layer-wise memory of the graph. Our evaluation across diverse benchmarks shows that GNNGuard restores GNN performance to near-optimal levels, outperforming existing state-of-the-art defenses by an average of 15.3%.

Introduction

Graph Neural Networks (GNNs) have become the gold standard for learning on relational data. However, they possess a significant vulnerability: extreme sensitivity to adversarial perturbations. Because GNNs rely on a message-passing scheme—where nodes aggregate information from their neighbors—an attacker only needs to add a few "fake" edges between unrelated nodes to contaminate embeddings and cause catastrophic misclassification.

Comparison of an undefended GNN versus GNNGuard under an adversarial poisoning attack.

Existing defenses often fall short because they are tied to specific architectures, ignore node features, or only work on "homophily" graphs. GNNGuard provides a "plug-and-play" defense that is GNN-agnostic and robust against various attack strategies, including those targeting specific nodes or the entire network.

Methodology

GNNGuard acts as a protective layer integrated into the aggregation step of any standard GNN. It introduces two primary components:

  1. Neighbor Importance Estimation: This component calculates a similarity score (typically cosine similarity) between a node and its neighbors. Based on the principle of homophily, edges connecting highly dissimilar nodes are treated as "suspicious." The algorithm assigns higher weights to "trusted" edges and uses a thresholding function to prune edges that fall below a certain importance level.
  2. Layer-wise Graph Memory: Pruning edges can make training unstable. To solve this, GNNGuard uses a learnable "memory" coefficient ($\beta$). This allows the model to retain a portion of the edge weights from the previous layer, smoothing the evolution of the graph structure as the neural network goes deeper.

By modifying the aggregation (AGG) and update (UPD) functions, GNNGuard ensures that neural messages only flow through the most relevant and reliable parts of the graph.

Experimental Evaluation

The authors evaluated GNNGuard across a diverse set of benchmarks, including citation networks (Cora, Citeseer, ogbn-arxiv), disease pathway (DP) protein-protein interaction graphs, and synthesized heterophily graphs designed to test structural equivalence.

Classification accuracy of GNNGuard compared to state-of-the-art defenses across multiple models and datasets.

Key Results

  • Superior Accuracy: Across five GNN models and four datasets, GNNGuard outperformed existing state-of-the-art defenders (like GNN-Jaccard and RobustGCN) by an average of 15.3%.
  • Restoration of Performance: In many cases, GNNGuard restored the accuracy of an attacked GNN to levels nearly identical to its performance on a clean, un-attacked graph.
  • Robustness to Intensity: Even when 25% of the edges in the Cora dataset were perturbed, GNNGuard maintained high accuracy, while undefended GCNs saw their performance plummet.
  • Efficiency: The computational complexity scales linearly with the number of edges, making it practical for real-world, large-scale graphs.

Discussion and Insights

The core innovation of GNNGuard is using similarity as a filter. Most adversarial attacks work by connecting nodes that shouldn't be connected. GNNGuard exploits this by using node feature similarity as a proxy for edge validity. Unlike previous methods requiring specific mathematical properties, GNNGuard is a simple, intuitive wrapper compatible with GCN, GAT, GIN, JK-Net, and GraphSAINT.

Furthermore, GNNGuard addresses heterophily graphs—where connected nodes are naturally different—by swapping raw feature similarity for graphlet degree vectors. This allows the model to recognize valid connections between nodes playing the same "role" in their respective neighborhoods, even if their features differ.

Conclusion

GNNGuard represents a significant step forward in securing GNNs. While the current work focuses on poisoning attacks, future research could extend these principles to evasion attacks at test-time, directed graphs, and graphs with complex edge-level attributes.

Summary updated

BibTeX
@inproceedings{zhang2020gnnguard,
  author = {Xiang Zhang and Marinka Zitnik},
  title = {{GNNGuard: Defending Graph Neural Networks against Adversarial Attacks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2020},
}
Figure