Token-Level Vulnerability Localization for Precise Source Code Repair

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Software vulnerabilities are difficult to detect due to the absence of fail-stop symptoms and require high-precision accuracy, making existing detection methods inefficient and inaccurate.

Innovation Solution

A two-stage vulnerability detection system using a classifier model and a large language model to identify and repair software vulnerabilities, where the classifier model identifies token positions associated with vulnerabilities, and the large language model confirms the presence of vulnerabilities using few-shot examples.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If traditional vulnerability detection methods are used, then the detection process is simple, but the accuracy is low and false positives are high

Engineering Contradiction:
Improvevulnerability detection accuracyVSAvoiddetection system complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The vulnerability detection system is segmented into multiple specialized components: a classifier model for initial vulnerability identification, a neural encoder transformer model with attention for token-level analysis, and a large language model for final verification. This segmentation allows each component to focus on specific aspects of vulnerability detection, improving overall accuracy while managing complexity through modular architecture.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The neural encoder transformer model with attention acts as an intermediary between the classifier model and the large language model. It processes the source code at the token level, identifying vulnerable tokens and providing contextual information to the large language model, thereby mediating the detection process and improving precision through multi-stage verification.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Reliability

If comprehensive vulnerability detection is performed, then detection coverage is improved, but processing time increases

Engineering Contradiction:
Improvedetection coverageVSAvoidprocessing time
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The classifier model performs preliminary action by quickly identifying potential vulnerabilities and their locations in the source code before the more time-consuming neural encoder transformer model and large language model are invoked. This preliminary screening filters out non-vulnerable code, reducing the processing time required for comprehensive analysis while maintaining high detection coverage.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The system applies partial action by focusing the detailed analysis (neural encoder transformer and large language model) only on the portions of code identified as potentially vulnerable by the classifier model, rather than analyzing the entire codebase with equal intensity. This selective deep analysis maintains comprehensive coverage for vulnerable areas while reducing overall processing time.

Inventive Principle:
Principle #16Partial or excessive action

3Measurement precision

If high-precision vulnerability detection is implemented, then false positives are reduced, but the system becomes more complex

Engineering Contradiction:
Improvedetection precisionVSAvoidsystem architecture complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The system implements feedback through the multi-stage verification process where the large language model reviews the predictions from the neural encoder transformer model, which in turn reviewed the classifier model's initial identifications. This feedback loop allows each stage to correct errors from previous stages, reducing false positives while the modular architecture manages the added complexity through clear separation of concerns.

Inventive Principle:
Principle #23Feedback

Data Source

PatentUS20250390419A1Localizing vulnerabilities in source code at a token-level
Publication Date: 2025.12.25 MICROSOFT TECHNOLOGY LICENSING LLC
  • US20250390419A1 patent drawing
  • US20250390419A1 patent drawing
  • US20250390419A1 patent drawing

AI summary

A vulnerability detection and repair system utilize a classifier model to detect a software vulnerability in a source code snippet and the tokens in the source code snippet attributable to the vulnerability. A large language model is then given the vulnerable source code snippet, its vulnerability type, the vulnerability tokens, and a few-shot examples to determine whether or not the source code snippet includes the identified vulnerability. The few-shot examples include positive and negative samples of the type of vulnerability to guide the large language model towards the correct output.