Deep learning (DL) has become a powerhouse for spotting security vulnerabilities in code. However, these models are notoriously "black boxes." When a detector flags a function as dangerous, a security analyst needs to know exactly which lines are the culprits. While many Explainable AI (XAI) methods promise to pull back the curtain, a new study suggests we might be measuring their success all wrong.
The Disconnect: Fidelity vs. Relevancy
In software security, a "vulnerable" label is insufficient; developers require the root cause. To address this, researchers apply XAI techniques—such as LIME, SHAP, or GNNExplainer—to highlight the "important" features in a model's prediction.
The industry standard for evaluating these explainers is fidelity: if you remove the "important" features identified by the explainer, does the model's prediction change? If yes, the explainer has high fidelity. However, this paper argues there is a critical disconnect between high fidelity and actual relevancy. If a model makes a decision based on a variable name or a specific comment (an "artifact") rather than the actual logic error, a high-fidelity explainer will correctly point to that irrelevant artifact—leaving the security analyst no closer to fixing the actual bug.
Experimental Methodology
The authors conducted an extensive evaluation to bridge this gap, analyzing a wide variety of state-of-the-art models and explanation techniques.
Evaluation Framework
- 7 DL-based Detectors: The study included graph-based models (e.g., Devign, Reveal) and sequence-based models (e.g., TokenLSTM).
- 10 Explanation Approaches: The researchers tested 5 graph-specific explainers and 5 sequence-based explainers to ensure broad coverage of current XAI technology.
Datasets and Metrics
The study utilized the SARD (Software Assurance Reference Dataset) and the Fan Dataset, which contains over 10,000 real-world vulnerable functions. To measure performance beyond simple fidelity, the authors introduced:
- Vulnerability Line Coverage (LC): Split into TLC (Triggering Line Coverage), which measures how well the explainer finds the lines causing the bug, and FLC (Fixing Line Coverage), which measures how well it finds the lines changed to fix the bug.
- Vulnerability Unrelated Ratio (VUR): A novel metric measuring how often a model's prediction is flipped by code changes semantically unrelated to the vulnerability.
Key Insights
1. Fidelity is a False Prophet
High fidelity scores (sometimes exceeding 90%) often coexisted with abysmal localization scores (as low as 7%). This indicates that explainers accurately describe the model's behavior, but the model's behavior is frequently based on "noise" rather than security logic.
2. Models are "Lazy" Learners
Detectors primarily learn to distinguish between "vulnerable" and "fixed" samples by identifying differences in patches (the "fixing lines") rather than understanding the underlying mechanism of the bug (the "triggering lines"). In many cases, sophisticated XAI methods performed no better than a Random baseline at finding triggering lines.
3. Artifact Sensitivity
The VUR metric revealed that in some models, up to 90% of the features that could "flip" a model's prediction were unrelated to the actual bug. When the authors manually patched vulnerabilities using logic the model hadn't seen before, detector accuracy plummeted by 55% to 87%, proving the models recognize textual patterns rather than understanding vulnerabilities.
Limitations and Future Directions
The study focuses on GNN and RNN-based detectors; the impact of Large Language Models (LLMs) like GPT-4 on these "black box" issues remains an open question. Additionally, mapping token-level explanations to line-level metrics presents granularity challenges. The authors suggest that future research should move away from binary classification and toward decomposing vulnerability detection into sub-tasks, leveraging LLMs to identify specific statements before applying static analysis for verification.
Paper Citation: Baijun Cheng, et al. "Beyond Fidelity: Explaining Vulnerability Localization of Learning-based Detectors." arXiv:2401.02686v2 [cs.CR], Feb 2024.
Summary updated