Abstract
Graph Neural Networks (GNNs) are increasingly important given their popularity and the diversity of applications. Yet, existing studies of their vulnerability to adversarial attacks rely on relatively small graphs. We address this gap and study how to attack and defend GNNs at scale. We propose two sparsity-aware first-order optimization attacks that maintain an efficient representation despite optimizing over a number of parameters which is quadratic in the number of nodes. We show that common surrogate losses are not well-suited for global attacks on GNNs. Our alternatives can double the attack strength. Moreover, to improve GNNs' reliability we design a robust aggregation function, Soft Median, resulting in an effective defense at all scales. We evaluate our attacks and defense with standard GNNs on graphs more than 100 times larger compared to previous work. We even scale one order of magnitude further by extending our techniques to a scalable GNN.
Introduction
Graph Neural Networks (GNNs) are notoriously vulnerable to adversarial "structure attacks"—small, intentional changes to the graph's edges that flip model predictions. However, most research has focused on "tiny" datasets like PubMed (~20,000 nodes). In real-world applications, graphs such as social networks or web graphs often contain millions or billions of nodes. Attacking or defending these at scale presents a significant challenge because standard methods often require a dense adjacency matrix, leading to $O(n^2)$ memory complexity. For a graph with 100,000 nodes, this requires 40 GB of memory; for 2 million nodes, it reaches a staggering 16 TB. This paper addresses this "scalability wall," enabling the evaluation and protection of GNNs in production-sized environments.
Scalable Adversarial Attacks
To overcome the memory bottleneck, we introduce Projected Randomized Block Coordinate Descent (PR-BCD). Instead of optimizing over all possible $n^2$ edge flips simultaneously, PR-BCD employs a "survival-of-the-fittest" approach. It samples a small "block" of potential edges, calculates gradients, and retains only the most promising perturbations while discarding the rest. This reduces memory requirements from quadratic to linear relative to the attack budget.
Surrogate Losses for Global Attacks
We discovered that standard losses like Cross-Entropy (CE) are poorly suited for global attacks. CE tends to be "greedy," wasting the attack budget on nodes that are already misclassified to further increase their loss, rather than flipping the predictions of correct nodes. We propose alternatives such as tanh margin loss, which focuses the attack on "fragile" nodes near the decision boundary.
Robust Aggregation: Soft Median
Standard GNNs use "mean" or "sum" to aggregate neighbor information, which is easily skewed by a single adversarial edge. While robust alternatives like the Medoid exist, they are often computationally expensive. We propose Soft Median aggregation—a differentiable, weighted mean based on distance from a dimension-wise median. It provides a high "breakdown point" of 0.5, meaning it remains stable even if nearly half the neighbors are adversarial, without the quadratic overhead of previous methods.
Experimental Evaluation
We evaluated our methods on benchmarks scaling up by two orders of magnitude compared to prior work, including ogbn-arxiv (169k nodes), ogbn-products (2.4M nodes), and Papers 100M (111M nodes).
Key findings include:
- Memory Efficiency: PR-BCD can attack the ogbn-products dataset using a standard 32GB GPU, whereas traditional PGD would require over 20 TB of VRAM.
- Attack Strength: Using tanh margin loss instead of Cross-Entropy can double the effectiveness of a global attack.
- Defense Efficacy: On the Papers 100M dataset, the Soft Median defense reduced the success rate of a local attack from 90% to just 1% at a budget of $\Delta_i = 0.5$.
- Fragility at Scale: Large graphs appear more vulnerable; a budget perturbing only 2% of edges can reduce accuracy to that of a simple MLP.
Conclusion
This work bridges the gap between theoretical GNN robustness and real-world scale. While PR-BCD provides a strong lower bound on robustness and Soft Median offers an effective empirical defense, challenges remain. Future work includes developing formal certification methods that can scale to 100M nodes and further minimizing the trade-off between clean accuracy and robustness.
Summary updated