Fine-grained vulnerability prediction and evaluation system based on deep learning
By designing a fine-grained vulnerability prediction and assessment system based on deep learning, we solve the problem of insufficient vulnerability prediction functionality in the existing technology, realize automated vulnerability identification, location and assessment, and improve the work efficiency of security analysts and software security. .
Patent Information
- Application Number
- CN202410812519.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2024-10-18
AI Technical Summary
Existing vulnerability predictions based on deep learning are not functional enough in enterprise applications, and security analysts need to manually locate and evaluate vulnerabilities, resulting in low efficiency and high costs.
Design a fine-grained vulnerability prediction and assessment system based on deep learning, including a task management module, a code preprocessing module, a fine-grained vulnerability prediction module, a vulnerability assessment module, and a vulnerability reporting module. It provides visualization by automatically identifying, locating, and evaluating vulnerabilities. Reports and streamlined workflows.
It improves vulnerability identification efficiency, reduces manual review time, improves vulnerability prediction accuracy and assessment efficiency, reduces costs, helps security analysts discover and repair high-risk vulnerabilities in a timely manner, and improves software security and stability.
Smart Images

Figure CN118797654A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software development, and in particular to a fine-grained vulnerability prediction and assessment system based on deep learning. Background Art
[0002] Software vulnerabilities may lead to data leakage, service interruption and system crash of software systems, posing a threat to the security and stability of the system. Early detection of software vulnerabilities can help reduce security risks, so more and more companies use static analysis tools for vulnerability detection during the development phase. Rule-based static analysis tools rely on rules customized by security experts, which are labor-intensive and time-consuming and prone to false positives. Deep learning methods can automatically learn features from code, improve vulnerability identification efficiency and alleviate false positives. However, vulnerability prediction based on deep learning is still insufficient in functionality when it is applied to enterprises. After security analysts obtain a preliminary judgment on whether a vulnerability exists, they also need to review and analyze the location information of the vulnerability and understand the severity of the vulnerability to arrange the repair priority. Vulnerability prediction, location and evaluation functions are indispensable for security analysts. Vulnerability identification based on deep learning should be implemented in enterprise practice, and it is imperative to provide solutions covering the above links. Summary of the invention
[0003] The purpose of the present invention is to provide a fine-grained vulnerability prediction and assessment system based on deep learning, so as to solve the problems raised in the above-mentioned background technology, and help security analysts to efficiently discover vulnerabilities and promptly determine the repair priority. In this invention, through the demand analysis and investigation of actual software security maintenance, a tool based on deep learning is designed and disclosed for the first time, which can automatically identify vulnerabilities, locate vulnerabilities, evaluate vulnerabilities, effectively manage vulnerability reports, and visualize vulnerability information. This invention provides a method for fine-grained vulnerability prediction and assessment in the system. With the advantages of deep learning, this method comprehensively covers the vulnerability prediction, location and assessment functions that security analysts are concerned about, so as to help practitioners more efficiently reduce software security threats.
[0004] The present invention provides the following technical solutions: a fine-grained vulnerability prediction and assessment system based on deep learning, the tool comprising a task management module, a code preprocessing module, a fine-grained vulnerability prediction module, a vulnerability assessment module and a vulnerability report management module;
[0005] The task module is used to generate tasks, start processing flow and monitor execution after the user uploads the complete code project;
[0006] The code preprocessing module performs steps such as function extraction, invalid information deletion, and generation of PDG, AST, and Token sequences, stores code semantics and syntax information in an intermediate form, and prepares data for fine-grained vulnerability prediction and vulnerability assessment modules;
[0007] The fine-grained vulnerability prediction module extracts features from the intermediate representation of the code, uses the trained fine-grained vulnerability prediction model to predict and locate vulnerabilities, and saves the fine-grained vulnerability prediction results in a database;
[0008] The vulnerability assessment module reads the vulnerability prediction result, performs vulnerability assessment on the code with the vulnerability using the trained vulnerability assessment model, and saves the vulnerability assessment result to the database;
[0009] The vulnerability reporting module aggregates vulnerability prediction and assessment results from the database to generate a vulnerability report, and provides visualization and vulnerability report download functions;
[0010] Further, the task management module includes a unit for accepting user input, a unit for creating a task, a unit for executing a task, a unit for viewing a task, and a unit for modifying a task;
[0011] The user input receiving unit is used to receive the project file uploaded by the user, the selected vulnerability prediction model and the customized task execution time;
[0012] Create a task unit to encapsulate the information uploaded by the user into a task, send it to the message queue, and wait for subsequent task execution;
[0013] The task execution unit is used to start the task processing flow, schedule the code preprocessing, fine-grained vulnerability prediction, vulnerability assessment and other models in sequence, and monitor and manage the tasks;
[0014] The View Task Unit is used to view the execution progress of tasks, including "queued", "completed", "cancelled" and other statuses;
[0015] The task modification unit is used to cancel the task, modify parameters, and automatically re-execute the task. Users can modify the vulnerability prediction model and then restart the task or cancel the task directly.
[0016] Furthermore, the code preprocessing module includes a parsing function unit, an invalid information removal unit, and an intermediate representation generation unit;
[0017] The parsing function unit is used to parse a single code file into multiple functions, generate a corresponding function list, and finally store the function list corresponding to each code file;
[0018] The invalid information removal unit is used to delete invalid information in the function, such as comments, blank lines, etc., removing content that is irrelevant to code analysis and vulnerability prediction, ensuring the accuracy and efficiency of code processing;
[0019] The intermediate representation generation unit converts each function code into an abstract syntax tree (AST), a program dependency graph (PDG), and a token syntax sequence for storage;
[0020] Further, the fine-grained vulnerability prediction module includes a feature extraction unit, a vulnerability prediction unit and a vulnerability location unit;
[0021] The feature extraction unit is used to extract features according to the model selected by the user, and convert the preprocessed AST, PDG and Token sequence files into vector representations;
[0022] The vulnerability prediction unit is used to perform vulnerability prediction through the pre-trained model to obtain the vulnerability result after each feature vector is predicted, that is, whether the corresponding code function has a vulnerability;
[0023] The vulnerability location unit is used to locate vulnerabilities in the code. Vulnerability location will generate multiple key vulnerability code lines and the vulnerability probability corresponding to each code line. Finally, the tool encapsulates the vulnerability location results and stores them.
[0024] Further, the vulnerability assessment module includes a vulnerability assessment feature extraction unit and a vulnerability assessment grading unit;
[0025] The vulnerability assessment feature extraction unit is used to read the key vulnerability code line, and obtain the context of the vulnerability code line through the dependency relationship in PDG, perform vulnerability assessment feature extraction on the token sequence of the vulnerability code and its context, and convert it into a vector representation;
[0026] The vulnerability assessment grading unit is used to conduct vulnerability assessment on vulnerability code features through vulnerability assessment models, output assessment results such as vulnerability access path, access complexity and integrity impact, and then comprehensively calculate vulnerability scores and classify the severity of vulnerabilities into three levels: high, medium and low according to the scores;
[0027] Further, the vulnerability reporting module includes a vulnerability details viewing unit and a vulnerability report viewing unit;
[0028] The View Vulnerability Report unit is used to classify vulnerabilities into three levels: high risk, medium risk, and low risk, and then count the number of vulnerabilities according to the level. Users can click to download the vulnerability report;
[0029] The View Vulnerability Details unit is used to display a list of vulnerabilities. After clicking on each vulnerability, the user can see the detailed evaluation indicator results of the vulnerability and can filter according to conditions such as vulnerability severity.
[0030] Compared with the prior art, the beneficial effects achieved by the present invention are:
[0031] 1. The present invention is the first to design and provide a fine-grained vulnerability prediction and assessment system based on deep learning that helps security analysts improve vulnerability identification efficiency. The system includes a task management module, a code preprocessing module, a fine-grained vulnerability prediction module, a vulnerability assessment module, and a vulnerability reporting module, providing security analysts with a comprehensive and efficient toolset. This integrated system design can help users complete the entire process of vulnerability identification, prediction, and assessment on a single platform, simplifying the workflow and improving work efficiency. The present invention implements system development through a distributed framework and middleware such as message queues and caches, promotes the implementation of fine-grained vulnerability prediction and assessment based on deep learning, helps security analysts better utilize deep learning technology to improve vulnerability identification efficiency, and promotes the progress and development of security work;
[0032] 2. The present invention provides a fine-grained vulnerability prediction method based on deep learning, providing users with accurate vulnerability prediction capabilities. The present invention provides an integrated prediction scheme based on multiple deep learning. Different prediction models complete vulnerability prediction from two feature extraction dimensions based on text sequences and graphs to learn semantic and grammatical vulnerability information. At the same time, on the basis of predicting code vulnerabilities, line-level vulnerability location interpretation is provided through the interpreter model and attention mechanism, reducing the time for manual review of vulnerability codes. The advantage of the present invention is that deep learning is used to improve the accuracy and reliability of vulnerability prediction. In practical problems, accurate vulnerability prediction can help users discover potential security issues in the early stages of the software development life cycle, thereby reducing the time and cost required for subsequent vulnerability repairs. The automated deep learning-based location interpretation method can help users find the location of the vulnerability more quickly, speed up vulnerability repair, and improve software security and stability;
[0033] 3. The present invention provides an automated vulnerability assessment method based on multi-tasking to provide users with vulnerability assessment capabilities. The present invention provides an automated vulnerability assessment model that extracts shared code features from code text sequences to complete vulnerability assessments based on CVSS indicators, helping users to promptly identify high-risk vulnerabilities that need to be repaired first. The present invention improves the efficiency of vulnerability assessments. Traditional vulnerability assessments usually require a lot of human resources and time to complete, while this automated method can greatly shorten the assessment time and improve work efficiency. Users use automated vulnerability assessments without having to hire a large number of security experts, thereby saving costs. The automated vulnerability assessment model can help users identify high-risk vulnerabilities more accurately and help them repair these vulnerabilities in a timely manner, thereby improving the security of the system; BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0035] Figure 1 This is the overall module design diagram of the FineVulner tool;
[0036] Figure 2 It is the task management module flow chart;
[0037] Figure 3 It is the flow chart of code preprocessing module;
[0038] Figure 4 It is the flow chart of fine-grained vulnerability prediction module;
[0039] Figure 5 It is a flow chart of the graph-based feature extraction model;
[0040] Figure 6 It is a flow chart of the graph-based vulnerability prediction model;
[0041] Figure 7 It is a text-based vulnerability prediction model flow chart;
[0042] Figure 8 It is the vulnerability assessment module flow chart;
[0043] Fig. 9 It is a vulnerability assessment model flow chart;
[0044] Fig.10 It is the flow chart of vulnerability reporting module; DETAILED DESCRIPTION
[0045] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0046] This invention provides a fine-grained vulnerability prediction and assessment system based on deep learning. For the first time, a tool was designed and implemented to help practitioners improve the efficiency of vulnerability identification. The tool includes five modules: task management, code preprocessing, fine-grained vulnerability prediction, vulnerability assessment and vulnerability reporting. The task management module is responsible for receiving code projects uploaded by users and creating tasks, and using the task scheduling framework and message middleware to configure, schedule and monitor the processing flow in real time. The code preprocessing module is responsible for converting the code into intermediate representations such as program dependency graphs and text sequences to extract semantic and grammatical information. The fine-grained vulnerability prediction module is responsible for converting the intermediate representation of the code into vector features for vulnerability classification, and locating the vulnerable code line by analyzing the impact of each line of code on vulnerability prediction. The vulnerability assessment module is responsible for extracting shared vector features of the vulnerable code and completing vulnerability assessment based on the CVSS indicator. The vulnerability reporting module is responsible for statistical vulnerability information, generating vulnerability reports and visual vulnerability location. The specific steps are as follows:
[0047] A fine-grained vulnerability prediction and assessment system based on deep learning, including a task management module, a code preprocessing module, a fine-grained vulnerability prediction module, a vulnerability assessment module and a vulnerability reporting module;
[0048] 1. The task module is used to generate tasks, start processing flow and monitor execution after the user uploads the complete code project;
[0049] The task management module includes a unit for accepting user input, a unit for creating tasks, a unit for executing tasks, a unit for viewing tasks, and a unit for modifying tasks;
[0050] 1.1 The user input unit is used to receive the project file uploaded by the user, the selected vulnerability prediction model and the customized task execution time. The specific steps are as follows:
[0051] Step 1.1.1: Accept user input The ProjectService class in the unit is responsible for receiving the project uploaded by the user, saving the information, and uploading the file to the Alibaba Cloud OSS file storage server.
[0052] 1.2 Create a task unit to encapsulate the information uploaded by the user into a task, send it to the message queue, and wait for subsequent tasks to be executed. The specific steps are as follows:
[0053] Step 1.2.1: The VulScanTaskService class receives the task request, generates a task ID and stores the task information in the database. The VulScanTaskService class sends the task information to the ActiveMQ message queue.
[0054] 1.3 The execution task unit is used to start the task processing flow, schedule the code preprocessing, fine-grained vulnerability prediction, vulnerability assessment and other models in turn, and monitor and manage the tasks. The specific steps are as follows:
[0055] Step 1.3.1: The SchedulerService class monitors the message queue, schedules tasks according to the task queue and priority, and sets the task execution time.
[0056] Step 1.3.2: The task execution process is that the SchedulerService class triggers the task execution according to the task execution time. The VulScanTaskService class obtains the task information from the ActiveMQ queue and sends it to the deep learning vulnerability prediction module for vulnerability prediction.
[0057] Step 1.3.3: The vulnerability prediction and assessment module generates intermediate data and stores it in the database. During task execution, the SchedulerService class monitors the task status and progress in real time and updates the task status and intermediate data. If the task fails or times out, the SchedulerService class triggers a retry mechanism or timeout processing.
[0058] Step 1.3.4: After the vulnerability prediction and assessment module task is completed, the task status is updated to "completed" and the result data is stored in the database. After the task is completed, the VulReportService class obtains the result data from the database, generates a detailed report and stores the results in the database. Users can view the task report and results through the interface or API.
[0059] 1.4 View Task Unit is used to view the execution progress of tasks, including "queuing", "completed", "cancelled" and other status;
[0060] 1.5 The task modification unit is used to cancel the task, modify parameters and automatically re-execute the task. Users can modify the vulnerability prediction model and then restart the task or cancel the task directly;
[0061] 2. The code preprocessing module performs steps such as function extraction, invalid information deletion, and generation of PDG, AST, and Token sequences, stores code semantics and syntax information in an intermediate form, and prepares data for fine-grained vulnerability prediction and vulnerability assessment modules;
[0062] The code preprocessing module includes a parsing function unit, an invalid information removal unit, and an intermediate representation generation unit;
[0063] 2.1 The parsing function unit is used to parse a single code file into multiple functions, generate a corresponding function list, and finally store the function list corresponding to each code file;
[0064] The invalid information removal unit described in 2.2 is used to delete invalid information in the function, such as comments, blank lines, etc., to remove content irrelevant to code analysis and vulnerability prediction, thereby ensuring the accuracy and efficiency of code processing;
[0065] The intermediate representation generation unit described in 2.3 converts each function code into AST, PDG and Token syntax sequence forms for storage. The specific steps are as follows:
[0066] Step 2.3.1: If the user chooses a graph-based model for vulnerability prediction and assessment, the generateAST method is called to generate an AST based on the preprocessed code. The AST represents the grammatical structure of the code, and each node represents a grammatical unit in the code.
[0067] Step 2.3.2: After AST is created, the CodePreprocessingService class calls the buildPDG method to build PDG based on AST, processes each node in AST, and creates a corresponding PDG node for each node. The PDG node contains the node type and unique identifier. Then, data dependency and control dependency are established through the connection between AST nodes to build the edge of PDG and obtain a complete PDG.
[0068] Step 2.3.3: Generate intermediate representation units. Extract the context statements of each line of code from PDG, that is, the statements that have dependencies with each line. Then use the TokenizeCode method to perform BPE word segmentation on the code and its context statements. For example, the getContextStatements function name will be split into get, Context, and Statements. BPE can split some uncommon function names into common subwords. Common subwords can generate vector representations with code semantics, and then generate Token sequences.
[0069] 3. The fine-grained vulnerability prediction module extracts features from the intermediate representation of the code, uses the trained fine-grained vulnerability prediction model to predict and locate vulnerabilities, and saves the fine-grained vulnerability prediction results into a database;
[0070] The fine-grained vulnerability prediction module includes a feature extraction unit, a vulnerability prediction unit and a vulnerability location unit;
[0071] 3.1 The feature extraction unit is used to extract features according to the model selected by the user and convert the preprocessed AST, PDG and Token sequence files into vector representations. The specific steps are as follows:
[0072] Step 3.1.1: First, receive the request through the VulDetectController class and determine the model selected by the user.
[0073] Step 3.1.2: Then call the FeatureExtractionService class to perform feature processing, and the FeatureExtractionService class calls the trained model of the ModelTrainService class to perform vector conversion.
[0074] Step 3.1.3: If the user chooses a graph-based model, first use the extractTokenFeatures method to use the CodeBERT model to convert the sequence tokens of the code statement line and its context into vector representations to capture the semantic information of the code. Then use the extractASTFeatures method to use the TreeLSTM model to convert the AST representation of the code into a vector representation. Finally, use the buildPDG method to build the feature vector matrix for the vulnerability prediction model input, where each node is the concatenation of the AST and sequence token vectors of each code line.
[0075] Step 3.1.4: If the user chooses a text-based model, the code function is word and position encoded by CodeBERT to generate a feature vector for each word and its position in the function.
[0076] 3.2 The vulnerability prediction unit is used to predict vulnerabilities through the pre-trained model and obtain the vulnerability results after each feature vector is predicted, that is, whether the corresponding code function has a vulnerability. The specific steps are as follows:
[0077] Step 3.2.1: Get the feature vector of the preprocessed source code.
[0078] Step 3.2.2: If the user selects a graph-based vulnerability prediction model, the trained GCN model is called for vulnerability prediction. GCN is good at processing graph data with sparse features, including the attributes of different code lines and potential noise features in PDG. First, the code function is parsed into PDG. Similar to the operation of CNN on an image, GCN slides a window over all code statements of the PDG, generates feature vectors for the statements in the center of the window based on the feature extraction model, and concatenates these feature vectors into a feature matrix. Subsequently, GCN performs a convolution operation to generate a feature matrix of the function. Subsequently, a pooling layer is used to normalize the method representation matrix, and its output is connected to the fully connected layer. Finally, two hidden layers and a Linear classification layer are used to generate the prediction results of the code function.
[0079] Step 3.2.3: If the user selects a text-based vulnerability prediction model, the feature vector is input into the BERT architecture consisting of 12 Transformer encoder blocks. Each encoder consists of a multi-head self-attention layer and a fully connected feedforward neural network. Finally, the output vector is passed to a Linear classification layer to classify the given function and generate a vulnerability prediction result.
[0080] 3.3 The vulnerability location unit is used to locate vulnerabilities in the code. Vulnerability location will generate multiple key vulnerability code lines and the vulnerability probability corresponding to each code line. Finally, the tool encapsulates the vulnerability location results and stores them. The specific steps are as follows:
[0081] Step 3.3.1: If there is a vulnerability, fine-grained vulnerability location is performed. If the user chooses to use a graphical model, the GNNExplainer model is used to obtain the key vulnerability lines. The GNNExplainer input includes the trained GCN model, the PDG of the code function, and the vulnerability prediction results. GNNExplainer uses mask technology internally to train the edge mask egde_mask and the node feature mask node_feat_mask simultaneously to obtain the key vulnerability code lines.
[0082] Step 3.3.2: If the user chooses to use a text model, the tool extracts the self-attention scores from each of the 12 Transformer encoder blocks from the model for each token in the source code function. After obtaining the attention scores of the tokens, the token attention scores of each line of code are accumulated, and then the attention scores of each line of code are ranked. Finally, based on the attention score ranking, the code lines ranked in the top 10% are predicted as potential vulnerability code lines.
[0083] 4. The vulnerability assessment module reads the vulnerability prediction results, uses the trained vulnerability assessment model to perform vulnerability assessment on the code with vulnerabilities, and the results of the vulnerability assessment are saved in the database;
[0084] The vulnerability assessment module includes a vulnerability assessment feature extraction unit and a vulnerability assessment grading unit;
[0085] 4.1 The vulnerability assessment feature extraction unit is used to read the key vulnerability code line, and obtain the context of the vulnerability code line through the dependency relationship in PDG, perform vulnerability assessment feature extraction on the token sequence of the vulnerability code and its context, and convert it into a vector representation. The specific steps are as follows:
[0086] Step 4.1.1: Obtain the vulnerability prediction and location results obtained by the fine-grained vulnerability prediction module.
[0087] Step 4.1.2: Obtain the token sequence of the vulnerability code and its context according to the PDG dependency after code preprocessing.
[0088] Step 4.1.3: Obtain the feature extraction model, use CodeBERT to extract features from the token sequence, and convert it into a vector representation.
[0089] 4.2 The vulnerability assessment grading unit is used to perform vulnerability assessment on vulnerability code features through the vulnerability assessment model, and output the assessment results such as the access path, access complexity and severity of the vulnerability. The specific steps are as follows:
[0090] Step 4.2.1: Load the vulnerability assessment model. The vulnerability assessment model uses the trained CNN and GRU to extract shared features for vulnerability assessment. CNN has three filters of size 1, 3, and 5 to learn common code patterns. GRU is used to learn the order and dependencies between codes.
[0091] Step 4.2.2: After the shared features are extracted, these feature vectors are processed by task-specific blocks and Softmax layers to obtain the results of vulnerability assessment indicators, and the results of vulnerability basic CVSS indicators are output, including the access path, access complexity, authentication, confidentiality impact, integrity impact, and availability impact of the vulnerability.
[0092] Step 4.2.3: Calculate the CVSS score of the vulnerability based on the CVSS basic indicator results obtained from the vulnerability assessment. According to the CVSS score, the severity of the vulnerability is divided. Vulnerability scores between 0 and 3.9 are low in severity, that is, low-risk vulnerabilities; vulnerability scores between 4.0 and 6.9 are medium in severity, that is, medium-risk vulnerabilities; vulnerability scores between 7.0 and 10.0 are high in severity, that is, high-risk vulnerabilities.
[0093] 5. The vulnerability reporting module aggregates vulnerability prediction and assessment results from the database to generate a vulnerability report, and provides visualization and vulnerability report download functions;
[0094] The vulnerability reporting module includes a vulnerability details viewing unit and a vulnerability report viewing unit;
[0095] 5.1 View vulnerability report unit is used to classify vulnerabilities into three levels: high risk, medium risk and low risk, and then count the number of vulnerabilities according to the level. Users can click to download the vulnerability report;
[0096] 5.2 View vulnerability details The unit is used to display a list of vulnerabilities. After clicking on each vulnerability, the user can see the detailed evaluation index results of the vulnerability and can filter according to conditions such as vulnerability severity.
[0097] This tool can generate further detailed security review opinions in combination with a large language model, and is characterized by: an input module of a large language model and a security review opinion module.
[0098] The input module of the large prediction model is used to receive the vulnerability prediction and assessment results of FineVulner, and input the processed effective information into the large language model to output detailed security review opinions.
[0099] The security review opinion module is used to prompt the large language model to output standardized and high-quality security review opinions. , input vulnerability information and input information and combination method;
[0100] The input for the large language model to generate security review opinions is the vulnerability prediction results generated by the tool, specific vulnerability location information, vulnerability severity, vulnerability source code, and security review opinion template.
[0101] The input information combination method of the large language model is to tell the large language model in a prompt manner that there is a vulnerability in a certain source code fragment, the specific vulnerability code line number and the possible vulnerability severity, and hope that the large prediction model will output specific security review opinions in the format of the security review opinion template.
[0102] Design of security review opinion template;
[0103] The security review opinion template includes two parts: basic information and vulnerability information. The basic information includes the project name and the programming language used in the project. The vulnerability information includes the vulnerability type, source code, vulnerability description, vulnerability location, vulnerability level, repair priority and repair suggestions.
[0104] The vulnerability description in the security review opinion template explains and describes the vulnerability in natural language and combined with code. The repair suggestion describes the repair plan and specific repair code in natural language. The repair priority is determined based on the risk assessment and impact of the vulnerability.
[0105] It should be noted that the above embodiments are not intended to limit the protection scope of the present invention, and equivalent changes or substitutions made on the basis of the above technical solutions all fall within the protection scope of the claims of the present invention.
Claims
1. A fine-grained vulnerability prediction and assessment system based on deep learning, Features: The system includes a task management module, a code preprocessing module, a fine-grained vulnerability prediction module, a vulnerability assessment module and a vulnerability reporting module; The task management module is used to generate tasks, start processing flow and monitor execution after the user uploads the complete code project; The code preprocessing module performs steps such as function extraction, invalid information deletion, and generation of program dependency graph (PDG), abstract syntax tree (AST), and token sequence, stores code semantics and syntax information in an intermediate form, and prepares data for fine-grained vulnerability prediction and vulnerability assessment modules; The fine-grained vulnerability prediction module extracts features from the intermediate representation of the code, uses the trained fine-grained vulnerability prediction model to predict and locate vulnerabilities, and saves the fine-grained vulnerability prediction results in a database; The vulnerability assessment module reads the vulnerability prediction result, performs vulnerability assessment on the code with the vulnerability using the trained vulnerability assessment model, and saves the vulnerability assessment result to the database; The vulnerability reporting module aggregates vulnerability prediction and assessment results from the database to generate a vulnerability report, and provides visualization and vulnerability report download functions.
2. According to the deep learning-based fine-grained vulnerability prediction and assessment system of claim 1, Features: The task management module includes a unit for accepting user input, a unit for creating a task, a unit for executing a task, a unit for viewing a task, and a unit for modifying a task; The user input receiving unit is used to receive the project file uploaded by the user, the selected vulnerability prediction model and the customized task execution time; Create a task unit to encapsulate the information uploaded by the user into a task, send it to the message queue, and wait for subsequent task execution; The task execution unit is used to start the task processing flow, schedule the code preprocessing, fine-grained vulnerability prediction, vulnerability assessment and other models in sequence, and monitor and manage the tasks; The View Task Unit is used to view the execution progress of the task, including "Queued", "Completed", and "Canceled" status; The task modification unit is used to cancel the task, modify parameters, and automatically re-execute the task. Users can modify the vulnerability prediction model and then restart the task or cancel the task directly. The code preprocessing module includes a parsing function unit, an invalid information removal unit, and an intermediate representation generation unit; The parsing function unit is used to parse a single code file into multiple functions, generate a corresponding function list, and finally store the function list corresponding to each code file; The invalid information removal unit is used to delete invalid information in the function, such as comments, blank lines, etc., removing content that is irrelevant to code analysis and vulnerability prediction, ensuring the accuracy and efficiency of code processing; The intermediate representation generation unit converts each function code into an abstract syntax tree (AST), a program dependency graph (PDG), and a token syntax sequence for storage.
3. According to the deep learning-based fine-grained vulnerability prediction and assessment system of claim 1, Features: The fine-grained vulnerability prediction module includes a feature extraction unit, a vulnerability prediction unit and a vulnerability location unit; The feature extraction unit is used to extract features according to the model selected by the user, and convert the preprocessed AST, PDG and Token sequence files into vector representations; The vulnerability prediction unit is used to perform vulnerability prediction through the pre-trained model to obtain the vulnerability result after each feature vector is predicted, that is, whether the corresponding code function has a vulnerability; The vulnerability location unit is used to locate vulnerabilities in the code. Vulnerability location will generate multiple key vulnerability code lines and the vulnerability probability corresponding to each code line. Finally, the tool encapsulates the vulnerability location results and stores them. The vulnerability assessment module includes a vulnerability assessment feature extraction unit and a vulnerability assessment grading unit; The vulnerability assessment feature extraction unit is used to read the key vulnerability code line, and obtain the context of the vulnerability code line through the dependency relationship in PDG, perform vulnerability assessment feature extraction on the token sequence of the vulnerability code and its context, and convert it into a vector representation; The vulnerability assessment grading unit is used to perform vulnerability assessment on vulnerability code features through a vulnerability assessment model, output assessment results such as vulnerability access path, access complexity and integrity impact, and then comprehensively calculate the vulnerability score and classify the severity of the vulnerability into three levels: high, medium and low according to the score.
4. According to the deep learning-based fine-grained vulnerability prediction and assessment system of claim 1, Features: The vulnerability reporting module includes a vulnerability details viewing unit and a vulnerability report viewing unit; The View Vulnerability Report unit is used to classify vulnerabilities into three levels: high risk, medium risk, and low risk, and then count the number of vulnerabilities according to the level. Users can click to download the vulnerability report; The View Vulnerability Details unit is used to display a list of vulnerabilities. After clicking on each vulnerability, the user can see the detailed evaluation indicator results of the vulnerability and can filter according to conditions such as vulnerability severity.
5. According to the deep learning-based fine-grained vulnerability prediction and assessment system of claim 1, Features: The task management module is used to generate tasks, start processing flow and monitor execution after users upload complete code projects; the specific process is as follows 1.1 The user input unit is used to receive the project file uploaded by the user, the selected vulnerability prediction model and the customized task execution time. The specific steps are as follows: Step 1.1.1: The ProjectService class in the Accept User Input unit is responsible for receiving the project uploaded by the user, saving the information, and uploading the file to the Alibaba Cloud OSS file storage server. 1.2 Create a task unit to encapsulate the information uploaded by the user into a task, send it to the message queue, and wait for subsequent tasks to be executed. The specific steps are as follows: Step 1.2.1: The VulScanTaskService class receives the task request, generates a task ID and stores the task information in the database. The VulScanTaskService class sends the task information to the ActiveMQ message queue. 1.3 The execution task unit is used to start the task processing flow, schedule the code preprocessing, fine-grained vulnerability prediction, vulnerability assessment and other models in turn, and monitor and manage the tasks. The specific steps are as follows: Step 1.3.1: The SchedulerService class monitors the message queue, schedules tasks according to the task queue and priority, and sets the task execution time. Step 1.3.2: The task execution process is that the SchedulerService class triggers the task execution according to the task execution time, and the VulScanTaskService class obtains the task information from the ActiveMQ queue and sends it to the deep learning vulnerability prediction module for vulnerability prediction. Step 1.3.3: The vulnerability prediction and assessment module generates intermediate data and stores it in the database. During task execution, the SchedulerService class monitors the task status and progress in real time, updates the task status and intermediate data, and triggers a retry mechanism or timeout processing if the task fails or times out. Step 1.3.4: After the vulnerability prediction and assessment module task is completed, the task status is updated to "completed" and the result data is stored in the database. After the task is completed, the VulReportService class obtains the result data from the database, generates a detailed report and stores the results in the database. Users can view the task report and results through the interface or API. 1.4 View Task Unit is used to view the execution progress of tasks, including "queuing", "completed", and "cancelled" status; 1.5 The task modification unit is used to cancel the task, modify parameters and automatically re-execute the task. The user can modify the vulnerability prediction model and then restart the task or cancel the task directly.
6. According to the deep learning-based fine-grained vulnerability prediction and assessment system of claim 5, It is characterized in that The code preprocessing module performs function extraction, invalid information removal, and PDG, AST, and Token sequence generation steps, stores code semantics and syntax information in an intermediate form, and prepares data for the fine-grained vulnerability prediction and vulnerability assessment modules; the specific process is as follows: 2.1 The parsing function unit is used to parse a single code file into multiple functions, generate a corresponding function list, and finally store the function list corresponding to each code file; The invalid information removal unit described in 2.2 is used to delete invalid information in the function, such as comments, blank lines, etc., to remove content irrelevant to code analysis and vulnerability prediction, thereby ensuring the accuracy and efficiency of code processing; The intermediate representation generation unit described in 2.3 converts each function code into AST, PDG and Token syntax sequence forms for storage. The specific steps are as follows: Step 2.3.1: If the user chooses a graph-based model for vulnerability prediction and assessment, the generateAST method is called to generate an AST based on the preprocessed code. The AST represents the grammatical structure of the code, and each node represents a grammatical unit in the code. Step 2.3.2: After AST is created, the CodePreprocessingService class calls the buildPDG method to build PDG based on AST, processes each node in AST, creates a corresponding PDG node for each node, and the PDG node contains the node type and unique identifier. Then, data dependency and control dependency are established through the connection between AST nodes to build the edge of PDG and obtain a complete PDG. Step 2.3.3: Generate an intermediate representation unit. Extract the context statements of each line of code from PDG, that is, the statements that have a dependency relationship with each line, and then perform BPE word segmentation on the code and its context statements through the TokenizeCode method. For example, the getContextStatements function name will be split into get, Context, and Statements. Through BPE, some uncommon function names can be split into common sub-words. Common sub-words can generate vector representations with code semantics, and then generate Token sequences.
7. According to the deep learning-based fine-grained vulnerability prediction and assessment system of claim 5, Features The fine-grained vulnerability prediction module extracts features from the intermediate representation of the code, uses the trained fine-grained vulnerability prediction model to predict and locate vulnerabilities, and saves the fine-grained vulnerability prediction results to the database; the specific process is as follows: 3.1 The feature extraction unit is used to extract features according to the model selected by the user and convert the preprocessed AST, PDG and Token sequence files into vector representations. The specific steps are as follows: Step 3.1.1: First, receive the request through the VulDetectController class and determine the model selected by the user. Step 3.1.2: Then call the FeatureExtractionService class to perform feature processing. The FeatureExtractionService class calls the model trained by the ModelTrainService class to perform vector conversion. Step 3.1.3: If the user chooses a graph-based model, first use the extractTokenFeatures method to use the CodeBERT model to convert the sequence tokens of the code statement line and its context into vector representations to capture the semantic information of the code. Then use the extractASTFeatures method to use the TreeLSTM model to convert the AST representation of the code into a vector representation. Finally, use the buildPDG method to build the feature vector matrix input to the vulnerability prediction model, where each node is the concatenation of the AST and sequence token vectors of each code line. Step 3.1.4: If the user chooses a text-based model, the code function is word and position encoded by CodeBERT to generate a feature vector for each word and its position in the function. 3.2 The vulnerability prediction unit is used to predict vulnerabilities through the pre-trained model and obtain the vulnerability results after each feature vector is predicted, that is, whether the corresponding code function has a vulnerability. The specific steps are as follows: Step 3.2.1: Get the feature vector of the preprocessed source code, Step 3.2.2: If the user chooses a graph-based vulnerability prediction model, the trained GCN model is called for vulnerability prediction. GCN is good at processing graph data with sparse features, including the attributes of different code lines and potential noise features in PDG. First, the code function is parsed into PDG. GCN slides a window on all code statements of PDG, generates feature vectors of the window center statement according to the feature extraction model, and concatenates these feature vectors into a feature matrix. Then, GCN performs convolution operations to generate the feature matrix of the function. Subsequently, the method representation matrix is normalized using a pooling layer, and its output is connected to the fully connected layer. Finally, the prediction result of the code function is generated through two hidden layers and a Linear classification layer. Step 3.2.3: If the user chooses a text-based vulnerability prediction model, the feature vector is input into the BERT architecture consisting of 12 Transformer encoder blocks, each of which consists of a multi-head self-attention layer and a fully connected feed-forward neural network. Finally, the output vector is sent to a Linear classification layer to classify the given function and generate a vulnerability prediction result. 3.3 The vulnerability location unit is used to locate vulnerabilities in the code. Vulnerability location will generate multiple key vulnerability code lines and the vulnerability probability corresponding to each code line. Finally, the tool encapsulates the vulnerability location results and stores them. The specific steps are as follows: Step 3.3.1: If there is a vulnerability, fine-grained vulnerability location is performed. If the user chooses to use a graphical model, the GNNExplainer model is used to obtain the key vulnerability lines. The GNNExplainer input includes the trained GCN model, the PDG of the code function, and the vulnerability prediction results. GNNExplainer uses mask technology internally to train the edge mask egde_mask and the node feature mask node_feat_mask at the same time to obtain the key vulnerability code lines. Step 3.3.2: If the user chooses to use a text-based model, the tool extracts the self-attention scores from each of the 12 Transformer encoder blocks from the model for each Token tag in the source code function. After obtaining the attention score of the Token tag, the Token tag attention score of each code line is accumulated, and then the attention score of each line of code is ranked. Finally, based on the attention score ranking, the code lines ranked in the top 10% are predicted as potential vulnerability code lines.
8. According to the deep learning-based fine-grained vulnerability prediction and assessment system of claim 7, It is characterized in that The vulnerability assessment module reads the results of vulnerability prediction and uses the trained vulnerability assessment model to perform vulnerability assessment on the vulnerable code. The results of the vulnerability assessment will be saved to the database. The specific process is as follows: 4.1 The vulnerability assessment feature extraction unit is used to read the key vulnerability code line, and obtain the context of the vulnerability code line through the dependency relationship in PDG, perform vulnerability assessment feature extraction on the token sequence of the vulnerability code and its context, and convert it into a vector representation. The specific steps are as follows: Step 4.1.1: Obtain the vulnerability prediction and location results obtained by the fine-grained vulnerability prediction module. Step 4.1.2: Obtain the token sequence of the vulnerability code and its context obtained according to the PDG dependency after code preprocessing. Step 4.1.3: Get the feature extraction model, use CodeBERT to extract features from the token sequence, and convert it into a vector representation. 4.2 The vulnerability assessment grading unit is used to perform vulnerability assessment on vulnerability code features through the vulnerability assessment model, and output the assessment results such as the access path, access complexity and severity of the vulnerability. The specific steps are as follows: Step 4.2.1: Load the vulnerability assessment model. The vulnerability assessment model uses the trained CNN and GRU to extract shared features for vulnerability assessment. The CNN has three filters of size 1, 3, and 5 to learn common code patterns. The GRU is used to learn the order and dependencies between codes. Step 4.2.2: After the shared features are extracted, these feature vectors are processed by task-specific blocks and Softmax layers to obtain the results of vulnerability assessment indicators, and the results of vulnerability basic CVSS indicators are output, including the access path, access complexity, authentication, confidentiality impact, integrity impact, and availability impact of the vulnerability. Step 4.2.3: Calculate the CVSS score of the vulnerability based on the CVSS basic indicator results obtained from the vulnerability assessment. According to the CVSS score, the severity of the vulnerability is divided. Vulnerability scores between 0 and 3.9 are low in severity, that is, low-risk vulnerabilities; vulnerability scores between 4.0 and 6.9 are medium in severity, that is, medium-risk vulnerabilities; vulnerability scores between 7.0 and 10.0 are high in severity, that is, high-risk vulnerabilities.
9. According to the deep learning-based fine-grained vulnerability prediction and assessment system of claim 7, It is characterized in that The vulnerability reporting module aggregates vulnerability prediction and assessment results from the database to generate vulnerability reports, and provides visualization and vulnerability report download functions; the specific process is as follows: 5.1 View vulnerability report unit is used to classify vulnerabilities into three levels: high risk, medium risk and low risk, and then count the number of vulnerabilities according to the level. Users can click to download the vulnerability report; 5.2 View vulnerability details The unit is used to display a list of vulnerabilities. After clicking on each vulnerability, the user can see the detailed evaluation index results of the vulnerability and can filter according to conditions such as vulnerability severity.
Citation Information
Cited By
Vulnerability positioning method based on large model
CN119830300A
Logical vulnerability detection method based on large model and Multi-Agent and related equipment
CN121098580A
A logic vulnerability detection method based on a large model and a multi-agent and related equipment
CN121098580B
