Residual Risk Analysis in Benign Code: How Far Are We? A Multi-Model Semantic and Structural Similarity Approach
Mohammad Farhad, Shuvalaxmi Dass

TL;DR
This paper introduces a multi-model similarity framework to assess residual security risks in patched code, revealing that high similarity often indicates persistent vulnerabilities.
Contribution
It proposes Residual Risk Scoring (RRS), combining semantic, structural, and cross-model signals to estimate residual risks in code patches.
Findings
High similarity between vulnerable and benign functions suggests residual risk presence.
Approximately 61% of high-RRS pairs show residual issues validated by static analysis tools.
Code similarity signals can prioritize post-patch security inspections effectively.
Abstract
Software security relies on effective vulnerability detection and patching, yet determining whether a patch fully eliminates risk remains an underexplored challenge. Existing vulnerability benchmarks often treat patched functions as inherently benign, overlooking the possibility of residual security risks. In this work, we analyze vulnerable-benign function pairs from the PrimeVul, a benchmark dataset using multiple code language models (Code LMs) to capture semantic similarity, complemented by Tree-sitter-based abstract syntax tree (AST) analysis for structural similarity. Building on these signals, we propose Residual Risk Scoring (RRS), a unified framework that integrates embedding-based semantic similarity, localized AST-based structural similarity, and cross-model agreement to estimate residual risk in code. Our analysis shows that benign functions often remain highly similar to…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
