Neural Transformer Models for Source Code Vulnerability Detection and Repair

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Machine learning models used for source code generation often learn to produce code with cybersecurity vulnerabilities due to the reliance on training data from public repositories, which may contain software vulnerabilities, posing risks to cybersecurity.

Innovation Solution

A vulnerability detection and repair system utilizing a neural encoder transformer model to classify potential cybersecurity vulnerabilities and a neural decoder transformer model to predict repairs, ensuring the source code generated is secure.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If machine learning models are trained on source code from public repositories, then the model can learn to generate code efficiently, but the generated code may contain cybersecurity vulnerabilities

Engineering Contradiction:
Improvecode generation efficiencyVSAvoidcode security
Core Design Contradiction:
ProductivityVSReliability

Solution Approach 1:

The system performs preliminary vulnerability detection and repair before the vulnerable code is deployed or executed. The neural classifier model proactively identifies potential security issues in generated code, and the repair model pre-fixes these vulnerabilities, preventing them from causing harm later

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent introduces an intermediary system between the code generation model and the final code output. This intermediary consists of the neural classifier model that detects vulnerabilities and the neural repair model that fixes them, acting as a security filter without interfering with the core code generation process

Inventive Principle:
Principle #24Intermediary (Mediator)

2Reliability

If a classifier model is used to detect cybersecurity vulnerabilities, then code security can be improved, but the system complexity increases

Engineering Contradiction:
Improvecode securityVSAvoidsystem complexity
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The patent replaces traditional manual or rule-based vulnerability detection methods with a neural encoder transformer model. This AI-based approach automatically learns security patterns from training data, eliminating the need for complex manual security rule configurations and reducing system complexity while improving detection accuracy

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

Solution Approach 2:

The neural classifier model is designed to detect multiple types of cybersecurity vulnerabilities simultaneously using a single unified model. The model can identify various vulnerability classes (SQL injection, XSS, command injection, etc.) through one system, rather than requiring separate detection mechanisms for each vulnerability type

Inventive Principle:
Principle #6Universality (Multi-functionality)

3Measurement precision

If extensive training data is used to train machine learning models, then model accuracy improves, but the risk of learning vulnerable code patterns increases

Engineering Contradiction:
Improvemodel accuracyVSAvoidvulnerability learning risk
Core Design Contradiction:
Measurement precisionVSObject-affected harmful factors

Solution Approach 1:

The patent changes the parameter of training data quality by carefully curating and filtering training datasets to include primarily secure code examples. The neural classifier model is trained on labeled data where vulnerable and non-vulnerable code are distinguished, allowing the model to learn accurate security patterns without inadvertently learning harmful vulnerability patterns from unfiltered public repositories

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentUS12153684B2Source code vulnerability detection and repair through machine learning
Publication Date: 2024.11.26 MICROSOFT TECHNOLOGY LICENSING LLC
  • US12153684B2 patent drawing
  • US12153684B2 patent drawing
  • US12153684B2 patent drawing

AI summary

A neural classifier model is used to detect cybersecurity vulnerabilities in the source code predicted by a deep learning code generation model having been trained on source code possibly containing security bugs. Upon the classifier model classifying a given source code snippet as likely containing a cybersecurity vulnerability, a proposed repair for the cybersecurity vulnerability is predicted from a neural decoder transformer model having been trained on non-vulnerable source code. The neural decoder transformer model is used to predict source code that repairs the cybersecurity vulnerability given the source code classified with a cybersecurity vulnerability.