AI
New Method Tackles Imbalanced Vulnerability Detection With Geometric Learning
Researchers propose MARGIN, a framework that uses metric learning and geometric regularization to improve software vulnerability detection on skewed datasets.
Identifying security flaws in software remains one of the most pressing challenges in maintaining system reliability and protection. Yet real-world vulnerability datasets often struggle with a fundamental problem: some vulnerability types appear far more frequently than others, and some are inherently harder to detect than the rest, making traditional machine learning approaches less effective.
The Geometric Problem#
A team of researchers led by Yuteng Zhang has reframed this detection challenge through a novel lens. Rather than viewing the class imbalance as merely a statistical problem, they observed that these imbalances distort the geometry of how vulnerability representations cluster in high-dimensional embedding space. When training data is uneven, neural networks struggle to position decision boundaries appropriately, leading to poor performance on rarer or tougher-to-classify vulnerability types.
MARGIN: A Geometric Solution#
The proposed MARGIN framework addresses this by learning representations that respect the underlying geometry of the data. It uses metric learning with adaptive margins — boundaries that adjust dynamically based on how sparse or concentrated different vulnerability classes are in the embedding space. The approach incorporates hyperspherical prototype modeling, anchoring each vulnerability class to a representative point on a high-dimensional sphere, and employs von Mises-Fisher concentration measures to estimate how tightly different classes should cluster.
The system then regularizes the geometric structure, ensuring that the probability mass of embeddings aligns with the natural decision regions (Voronoi cells) between classes. This reduces distortion and creates more stable, predictable boundaries for classification.
Results and Impact#
Testing on public vulnerability datasets shows MARGIN consistently outperforms existing methods, with particularly strong gains on datasets where class imbalance is most severe. Beyond raw accuracy, the framework produces embeddings with more structured, interpretable geometry, improving both robustness to distribution shifts and generalization to new datasets.

