Code Vulnerability Detection Using Historical Patch Diffs
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Clone-based approaches for detecting vulnerabilities in computer code have a high false positive rate due to minimal differences between vulnerable and patched code sections, and existing AI-based and function matching methods are not programming language agnostic.
Innovation Solution
A method that calculates changes between a current code section and its historical versions, comparing these changes to the changes made in fixing a known vulnerability, to distinguish between vulnerable and patched code sections.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If clone-based approaches are used to detect vulnerabilities, then detection coverage is improved, but false positive rate increases
Solution Approach 1:
The system performs preliminary actions by calculating diffs between historical versions of the code before final vulnerability determination. It computes the diff between the current code section and historical versions, then compares this diff against the known vulnerability patch diff to determine whether the vulnerability has been patched, thereby reducing false positives before reporting results.
Solution Approach 2:
The system uses feedback by comparing the calculated diff against the known vulnerability patch diff. This feedback mechanism allows the system to determine whether the detected similarity is due to the vulnerability being present or due to the code having been patched, thereby correcting false positive detections.
2Productivity
If minimal changes are made to code to fix vulnerabilities, then patch efficiency is improved, but code similarity between vulnerable and patched versions increases
Solution Approach 1:
The system extracts the essential information needed for vulnerability detection by calculating the diff between historical versions and comparing it against the known patch diff. This extraction approach focuses only on the changes made in the patch rather than analyzing the entire code section, thereby maintaining the ability to distinguish vulnerable from patched code even when patches are minimal.
Solution Approach 2:
The system changes the parameter of comparison from raw code similarity to diff similarity. Instead of comparing the entire code sections directly (which would be misleading when patches are minimal), it compares the diffs between versions, transforming the comparison to one that captures the essence of the patch changes rather than overall code similarity.
Data Source
AI summary
A method, system, apparatus, and computer-readable storage medium for detecting vulnerabilities in computer code. A computer processor calculates a first change between a first version of a section of the computer code and a second version of the section of the computer code, the section of the computer code being similar to a computer-code vulnerability, and the second version is a version prior to the first version. The computer processor determines whether the section of the computer code comprises the computer-code vulnerability based on a similarity between the first change and a second change, the second change being a change between the computer-code vulnerability and a fix for the computer-code vulnerability.


