Software security defect detection method, medium and computer program product

Through technologies such as deep neural network models and acceleration modules, the problem of slow gray-box fuzz testing and poor detection results in software written in C language is solved, achieving more efficient software security defect detection and adapting to complex vulnerability patterns and mutated codes.

CN118568718APending Publication Date: 2024-08-30QINGDAO GUOCHUANG INTELLIGENT HOME APPLIANCES RES INSTITU
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410598331.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-14
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

When existing systems use gray-box fuzz testing of software written in C language, the execution speed is slow and the detection effect of complex vulnerability patterns is poor. Especially when faced with mutated and obfuscated code, it is easy to miss detection or false positives.

Method used

Use pre-trained deep neural network models to schedule original samples, generate test samples, and accelerate them through acceleration modules such as GPU and FPGA, combined with dynamic instrumentation monitoring and abnormal deep learning models, to gradually improve the speed and comprehensiveness of software security defect detection sex.

Benefits of technology

It improves the execution speed and detection effect of software security defect detection, enhances the adaptability and intelligence to complex vulnerability patterns and mutated codes, and improves the performance and accuracy of the detection system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118568718A
    Figure CN118568718A
Patent Text Reader

Abstract

The invention provides a software security defect detection method, a medium and a computer program product. The method comprises the following steps: determining a to-be-tested program; obtaining an original sample, wherein the original sample comprises a preset test case and typical input; calling a pre-trained screening deep neural network model to perform sample scheduling on the original sample so as to obtain a test sample; and running the test sample to perform security defect detection on the to-be-detected program. Through the method, sample scheduling can be performed through the deep neural network model, so that the screened test sample can cover different code paths of a program as much as possible and more comprehensively cover potential security vulnerabilities, the level of software security defect detection is further improved, and the security defect detection efficiency is improved in the face of complex vulnerability modes and variant obfuscated codes. And the detection system is more adaptive and intelligent.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software detection, and in particular to a software security defect detection method, medium and computer program product. Background Art

[0002] With the development of automated software security defect detection systems, gray-box fuzz testing has become one of the key technologies. Current systems are mainly written in C language, which stems from the widespread application of C language in system-level programming, operating systems, and embedded systems. However, due to the characteristics of C language itself, such as pointer operations and memory management, the risk of security vulnerabilities increases, making the existing system face a series of challenges in detection performance and effect.

[0003] Although the current system has made some progress in gray-box fuzz testing, there are still some outstanding problems. One of them is the insufficient performance of using the C language, which limits the upper limit of the execution speed. Since software written in C language often involves complex pointer operations and underlying memory management, the execution speed of gray-box fuzz testing is relatively slow. On the other hand, the current system also has some limitations in terms of detection effect. Common defect detection tools may not perform well in accurately identifying complex vulnerability patterns, especially for attacks on mutated and obfuscated codes, which may lead to missed detections or false positives. Summary of the invention

[0004] In view of the above problems, the present invention proposes a software security defect detection method, medium and computer program product that overcome the above problems or at least partially solve the above problems.

[0005] An object of the present invention is to improve the level of software security defect detection.

[0006] A further object of the present invention is to increase the execution speed of software security defect detection.

[0007] A further object of the present invention is to improve the comprehensiveness of software security defect detection.

[0008] In particular, the present invention provides a software security defect detection method, characterized by comprising:

[0009] Identify the program to be tested;

[0010] Obtaining original samples, which include preset test cases and typical inputs;

[0011] Call the pre-trained screening deep neural network model to perform sample scheduling on the original samples to obtain test samples;

[0012] Run the test samples to detect security defects in the program under test.

[0013] Optionally, the step of calling the pre-trained screening deep neural network model to perform sample scheduling on the original sample to obtain the test sample includes:

[0014] Call the screening deep neural network model to calculate the confidence between the original sample and the program to be tested;

[0015] The original sample corresponding to the confidence level that meets the preset conditions is selected as the test sample, and the preset conditions include: the confidence level is greater than the preset value.

[0016] Optionally, the step of calling the screening deep neural network model to calculate the confidence between the original sample and the program to be tested includes:

[0017] Call the encoder to generate a low-dimensional feature representation corresponding to the test sample based on the test sample. The encoder is an unsupervised learning model used to perform feature learning and representation learning on the original sample.

[0018] Obtain the code structure characteristics of the program under test;

[0019] The call screening deep neural network model calculates the confidence based on the low-dimensional feature representation and code structure characteristics.

[0020] Optionally, the step of running the test sample to detect security defects in the program to be tested includes:

[0021] The test sample is executed by the program under test, and the execution information during the execution of the program under test is monitored and recorded.

[0022] Optionally, the step of monitoring and recording execution information during the execution of the program under test includes:

[0023] Insert a monitor in the key code path of the program under test. The monitor is used to inject stub code into the code of the program under test. The stub code is used to record the execution information of the program under test.

[0024] Write execution information to memory.

[0025] Optionally, after the step of monitoring and recording the execution information during the execution of the program to be tested, the following step is further included:

[0026] When an exception occurs in the program to be tested, a test sample of the program to be tested running when the exception occurs is saved as an abnormal sample;

[0027] The program features of the program to be tested are extracted through the pre-trained abnormal deep learning model, and a mutation strategy is generated based on the program features and abnormal samples;

[0028] Generate at least one mutation sample according to the mutation strategy combined with fuzz testing technology;

[0029] The mutant sample is used as a test sample and the steps of running the test sample to detect security defects on the program under test are repeated.

[0030] Optionally, before the step of obtaining the original sample, the step further includes:

[0031] Load the acceleration module. The acceleration module is used to speed up the execution speed of the security defect detection process. The acceleration module includes GPU acceleration and FPGA acceleration.

[0032] Optionally, after the step of obtaining the original sample, the following steps are further included:

[0033] The original samples are accelerated at the bottom level to convert them into C language extension modules.

[0034] According to another aspect of the present invention, there is also provided a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned software security defect detection methods are implemented.

[0035] According to yet another aspect of the present invention, a computer program product is provided, which includes a computer program, and when the computer program is executed by a processor, the steps of any one of the above-mentioned software security defect detection methods are implemented.

[0036] The software security defect detection method of the present invention obtains original samples after determining the program to be tested, and the original samples include preset test cases and typical inputs; then calls the pre-trained screening deep neural network model to perform sample scheduling on the original samples, thereby obtaining test samples; and runs the test samples to perform security defect detection on the program to be tested. This method can schedule samples through a deep neural network model, so that the screened test samples can cover different code paths of the program as much as possible and cover potential security vulnerabilities more comprehensively, thereby improving the level of software security defect detection, and making the detection system more adaptable and intelligent when facing complex vulnerability patterns and variant obfuscated codes.

[0037] Furthermore, the software security defect detection method of the present invention further includes, before the step of obtaining the original sample: loading an acceleration module, the acceleration module is used to speed up the execution speed of the security defect detection process, and the acceleration module includes GPU acceleration and FPGA acceleration. This method optimizes the execution efficiency of specific tasks at the hardware level, thereby increasing the execution speed of software security defect detection, and further improving the overall performance.

[0038] Furthermore, the software security defect detection method of the present invention saves the test sample of the program under test when an exception occurs as an abnormal sample; extracts the program features of the program under test through the abnormal deep learning model obtained by pre-training, and generates a mutation strategy according to the program features; generates at least one mutation sample according to the mutation strategy combined with fuzzy testing technology; and uses the mutation sample as a test sample to repeatedly execute the steps of running the test sample to detect security defects in the program under test. The comprehensiveness of software security defect detection can be gradually improved through a cyclic iteration method, thereby improving the detection effect of software security.

[0039] Based on the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more aware of the above and other objects, advantages and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Hereinafter, some specific embodiments of the present invention will be described in detail in an exemplary and non-limiting manner with reference to the accompanying drawings. The same reference numerals in the accompanying drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. In the accompanying drawings:

[0041] Figure 1 is a flowchart of a software security defect detection method according to an embodiment of the present invention;

[0042] Figure 2 is a flowchart of a software security defect detection method according to another embodiment of the present invention;

[0043] Figure 3 is a schematic diagram of a computer-readable storage medium of a software security defect detection method according to an embodiment of the present invention;

[0044] Figure 4 is a schematic diagram of a computer program product of a software security defect detection method according to an embodiment of the present invention; and

[0045] Figure 5 Schematic diagram of a computer device for a software security defect detection method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0046] It should be understood by those skilled in the art that the embodiments described below are only some embodiments of the present invention, rather than all embodiments of the present invention, and these embodiments are intended to explain the technical principles of the present invention, rather than to limit the protection scope of the present invention. Based on the embodiments provided by the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should still fall within the protection scope of the present invention.

[0047] Figure 1 1 is a flow chart of a software security defect detection method according to an embodiment of the present invention. In this embodiment, the present invention provides a software security defect detection system, and the execution process of the system may generally include:

[0048] Step S101, determining the program to be tested.

[0049] Step S102, obtaining the original sample. In some optional embodiments, the original sample may generally include preset test cases and typical input samples, wherein the test case generally refers to the original data and code snippets directly extracted from the test case library when performing security defect testing or vulnerability scanning, and the typical input refers to the conventional data types or common situations that may be encountered in actual applications. By using typical inputs as samples, the performance of the model or system in daily operation can be evaluated, whether it can effectively handle ordinary tasks, and whether it can achieve the expected results. Those skilled in the art can determine the source of the original sample according to the actual situation.

[0050] Step S103, calling the pre-trained screening deep neural network model to perform sample scheduling on the original sample, thereby obtaining a test sample. In some optional embodiments, sample scheduling is the core of security defect detection, and generally multiple intelligent algorithms can be selected to improve the comprehensiveness and accuracy of the test. The system can introduce a coverage-guided sample scheduling algorithm, a sample combination algorithm based on a genetic algorithm, and a sample scheduling algorithm based on deep learning technology to ensure that different code paths of the program are covered as much as possible during the test and potential security vulnerabilities are covered more comprehensively.

[0051] In some optional embodiments, the step of calling the pre-trained screening deep neural network model to perform sample scheduling on the original sample to obtain the test sample may generally include: calling the screening deep neural network model to calculate the confidence between the original sample and the program to be tested; selecting the original sample corresponding to the confidence that meets the preset conditions as the test sample, wherein the preset conditions generally include: the confidence is greater than the preset value. Confidence is a measure used to express the credibility or reliability of an estimate in statistics.

[0052] In some optional embodiments, the step of calling the screening deep neural network model to calculate the confidence between the original sample and the program to be tested can generally include: calling the encoder to generate a low-dimensional feature representation corresponding to the test sample based on the test sample, the encoder is an unsupervised learning model for feature learning and representation learning of the original sample; obtaining the code structure features of the program to be tested; calling the screening deep neural network model to calculate the confidence based on the low-dimensional feature representation and the code structure features. Among them, an optional example of the encoder is an autoencoder. The autoencoder is usually used to learn the low-dimensional representation of data. In the sample selection process, the software security defect detection system of the present invention first uses the autoencoder to perform feature learning and representation learning on the original sample. Optionally, a multi-layer deep autoencoder structure can be designed, which includes an encoder and a decoder. The encoder maps the input original sample to a low-dimensional feature space, and the decoder maps this low-dimensional representation back to the original data space. Next, the system uses the feature representation learned by the encoder part, combined with the structural information of the program code, to build a deep neural network model, that is, a screening deep neural network model. The input of this model is the low-dimensional feature representation generated by the encoder and the structural features of the program code, and the output is a confidence score, which is generally used to indicate the importance of the sample in covering different code paths of the program and detecting security vulnerabilities. By training this screening deep neural network model, the system can intelligently select the most representative and critical samples from a large number of original samples. In this embodiment, the system selects those samples with higher confidence as part of the test set based on the confidence scores of the original samples, thereby ensuring that the test process can cover the key code paths and potential security vulnerabilities of the program.

[0053] In some optional embodiments, a specific model code of the autoencoder is as follows:

[0054]

[0055]

[0056] Among them, class Autoencoder(nn.Module) means defining a class named Autoencoder, which inherits from nn.Module, which is the base class of all neural network modules in PyTorch.

[0057] def__init__(self,input_size,hidden_size) indicates that the initialization method receives two parameters: input_size (the feature dimension of the input data) and hidden_size (the size of the hidden layer). These two parameters are used to set the structure of the encoder and decoder.

[0058] self.encoder = nn.Sequential(

[0059] nn.Linear(input_size,hidden_size),

[0060] nn.ReLU(),

[0061] nn.Linear(hidden_size,hidden_size),

[0062] nn.ReLU()

[0063] This is the encoder part, which means that the encoder consists of a series of layers, using the nn.Sequential sequential container. First, the input data is mapped to a lower dimension (hidden layer) through a linear layer (nn.Linear), and then nonlinearity is introduced through the ReLU activation function. Subsequently, the data passes through a linear layer and ReLU activation again to form the final encoded representation.

[0064] self.decoder = nn.Sequential(

[0065] nn.Linear(hidden_size,hidden_size),

[0066] nn.ReLU(),

[0067] nn.Linear(hidden_size,input_size),

[0068] nn.Sigmoid()

[0069] This part is the decoder part, which has a similar structure to the encoder but in the opposite direction. It first decodes the encoded data through a linear layer and a ReLU activation function, then passes through another linear layer and finally uses a Sigmoid activation function to map back to the dimensions of the original data. Sigmoid ensures that the output value is between 0 and 1.

[0070] def forward(self,x):

[0071] encoded = self.encoder(x)

[0072] decoded=self.decoder(encoded)

[0073] return decoded

[0074] This section describes the forward propagation method, which accepts input x, first encodes it through the encoder to obtain a coded representation, then decodes the code back to the original data dimension through the decoder, and finally returns the decoded output decoded. The whole process completes the compression and reconstruction of the data, which helps the autoencoder learn an effective representation of the data. Those skilled in the art can set the autoencoder according to the actual situation.

[0075] The autoencoder constructed by the above code combined with the pre-trained screening deep neural network model can effectively screen the original samples, thereby selecting valid original samples as test samples.

[0076] Step S104: Run the test sample to perform security defect detection on the program to be tested.

[0077] This method can be used to schedule samples through a deep neural network model, so that the screened test samples can cover different code paths of the program as much as possible and cover potential security vulnerabilities more comprehensively, thereby improving the level of software security defect detection and making the detection system more adaptable and intelligent when faced with complex vulnerability patterns and variant obfuscated codes.

[0078] In some optional embodiments, the step of running the test sample to perform security defect detection on the program under test may generally include: executing the test sample by the program under test, monitoring and recording execution information during the execution of the program under test. During the process of the software security defect detection system executing the test sample, it is generally possible to monitor the execution of the program under test and record the coverage, so as to provide data support for subsequent analysis.

[0079] In some optional embodiments, the step of monitoring and recording the execution information during the execution of the program under test may generally include: inserting a monitor in the key code path of the program under test, the monitor is used to inject stub code into the code of the program under test, the stub code is used to record the execution information of the program under test; and writing the execution information into the memory. In this embodiment, in order to meet the need of monitoring the execution of the program under test, an innovative dynamic stub monitoring technology can be used to capture the key information and coverage of the program execution process in real time.

[0080] Specifically, when the system runs the test sample, it dynamically inserts monitors on the key code paths of the program. These monitors record the execution times at the entry and exit of each key code block by injecting lightweight stub codes into the program code, and update the coverage in real time. These stub codes can provide detailed tracking and monitoring of the program execution path without affecting the program execution efficiency. In addition, the system can also use hardware-level performance counters to monitor the execution of the program. By reading the values ​​of the hardware performance counters, the system can obtain key indicators such as the program's running time and the number of instruction executions in real time, thereby evaluating the program's execution efficiency in real time. In terms of recording coverage, the system can use efficient memory mapping technology to map the program's memory space to the user space and record the execution of the stub code in real time. This technology can realize real-time monitoring of memory access during program execution and efficiently write coverage information into memory to provide data support required for subsequent analysis and evaluation. Through this innovative dynamic stub monitoring technology, the system can capture key information and coverage during program execution in real time, providing strong data support for subsequent analysis and evaluation. At the same time, this technology can minimize the impact on program execution performance while ensuring the monitoring effect, ensuring the efficiency and accuracy of the testing process.

[0081] In some optional embodiments, the step of monitoring and recording the execution information during the execution of the program to be tested can generally include: when an exception occurs in the program to be tested, saving the test sample of the program to be tested when the exception occurs as an abnormal sample; extracting the program features of the program to be tested through the abnormal deep learning model obtained by pre-training, and generating a mutation strategy based on the program features and the abnormal sample; generating at least one mutation sample based on the mutation strategy combined with fuzzy testing technology; using the mutation sample as a test sample to repeatedly execute the test sample to detect security defects in the program to be tested. Among them, the abnormal situation includes but is not limited to crashes, memory leaks, etc. In this embodiment, the abnormal deep learning model is selected to realize the preservation and optimization of abnormal samples. An optional example of the abnormal deep learning model is as follows: Long Short-Term Memory (LSTM) is used as the backbone architecture of the abnormal deep learning model. The LSTM architecture is specifically used to learn and understand the code structure and logic of the program. Through training with a large amount of program code data, this LSTM model can accurately capture the key features and patterns in the code, including grammatical structure, control flow, and data dependency. Then, a mutation strategy generator is designed in the abnormal deep learning model. The control mutation strategy generator uses the program features extracted by the LSTM model and the knowledge learned by the deep learning model, and fully considers multiple factors such as the complexity of the program, the type of vulnerability, and the code structure, and finally intelligently generates a mutation strategy with strong pertinence and good adaptability to cover the various vulnerability patterns of the program as much as possible. Then, according to the obtained mutation strategy, fuzz testing technology is combined, such as randomization of input values, modification of grammatical structure, and change of boundary values, and finally at least one mutation sample is obtained. Such mutation samples can enable the software security defect detection system to search the vulnerability space of the program more comprehensively and further improve the recognition accuracy of complex vulnerability patterns.

[0082] The above-mentioned abnormal deep learning model can effectively save and optimize abnormal samples. It can not only help the system find potential vulnerabilities, but also provide strong support for system learning and improvement, thereby improving the efficiency and accuracy of the software security detection system. And after generating new test samples, a new round of sample scheduling and program execution is carried out. This cyclic iterative method enables the system to continuously learn and optimize, and gradually improve the detection effect of software security.

[0083] In some optional embodiments, the step of obtaining the original sample may generally include: loading an acceleration module, the acceleration module is used to speed up the execution speed of the security defect detection process, and the acceleration module includes GPU acceleration and FPGA acceleration. Among them, GPU acceleration is generally designed for high-performance parallel computing, which accelerates the system's computing speed by processing large-scale data in parallel. FPGA is a semi-customized integrated circuit. After leaving the factory, it can be customized through programming according to customer needs. It is suitable for scenarios that require a certain degree of flexibility but high performance. Utilizing the programmable characteristics of FPGA, the execution efficiency of specific tasks is optimized at the hardware level, thereby improving the performance of the overall system.

[0084] Optionally, after the step of obtaining the original sample, the following may be generally included: performing underlying acceleration on the original sample, thereby converting the original sample into a C language extension module. A C language extension module generally refers to additional functions or improvements added on the basis of the standard C language, so that the C language can support more advanced features and a wider range of uses. These extensions can be compiler-level features, library functions, macro definitions, or third-party libraries, thereby reducing interpreter overhead and improving execution efficiency. Optional examples of conversion tools include tools such as Cython, and those skilled in the art can select a conversion method according to actual conditions.

[0085] In addition, Python acceleration design can be applied to optimize the algorithm, parallelize and asynchronously process the original samples, and generate optimized test samples. The system optimizes the algorithm of the original samples and improves the efficiency of generating test samples through parallel and asynchronous processing, thus preparing for the subsequent testing phase.

[0086] Optionally, low-level call optimization can also be applied: by using low-level calls and efficient data structures, the number of low-level calls of the code can be reduced to improve the overall execution efficiency. The key code that interacts with the system can be optimized to reduce the overhead of system calls. Those skilled in the art can select the specific type of calling method and data structure according to actual conditions.

[0087] Optionally, memory management optimization can also be performed: the garbage collection mechanism and memory management of different versions of code are optimized to reduce unnecessary memory allocation and release operations, thereby reducing the memory usage of the system. Those skilled in the art can choose the memory management method according to actual conditions.

[0088] Optionally, when the code of the software security defect detection system is a Python version, you can choose to introduce an acceleration technology of just-in-time compilation, which is used to compile Python code into machine code, that is, an acceleration technology based on JIT (Just-in-time compilation). By compiling Python code into machine code through JIT, the machine code is directly executed at runtime, avoiding the performance loss of the interpreter, thereby improving the execution speed of Python code. In addition, Python's parallel computing library and asynchronous programming library can be used to parallelize or asynchronously process some tasks in the system to make full use of multi-core processors and IO resources to improve system concurrency and response speed.

[0089] Figure 2 FIG. 1 is a flow chart of a software security defect detection method according to another embodiment of the present invention. In this embodiment, the present invention provides a software security defect detection system, and the execution process of the system may generally include:

[0090] Step S201, determining the program to be tested.

[0091] Step S202, loading the acceleration module. In some optional embodiments, the acceleration module is used to speed up the execution speed of the security defect detection process, and the acceleration module can generally include GPU acceleration and FPGA acceleration. Among them, GPU acceleration is generally designed for high-performance parallel computing, which accelerates the system's computing speed by processing large-scale data in parallel. FPGA is a semi-customized integrated circuit. After leaving the factory, it can be customized through programming according to customer needs. The circuit logic function is suitable for scenarios that require a certain degree of flexibility but high performance. Utilizing the programmable characteristics of FPGA, the execution efficiency of specific tasks is optimized at the hardware level, thereby improving the performance of the overall system.

[0092] Step S203, obtaining the original sample. In some optional embodiments, the original sample may generally include preset test cases and typical input samples, wherein the test case generally refers to the original data and code snippets directly extracted from the test case library when performing security defect testing or vulnerability scanning, and the typical input refers to the conventional data types or common situations that may be encountered in actual applications. By using typical inputs as samples, the performance of the model or system in daily operation can be evaluated, whether it can effectively handle ordinary tasks, and whether it can achieve the expected results. Those skilled in the art can determine the source of the original sample according to the actual situation.

[0093] Step S204, calling the pre-trained screening deep neural network model to perform sample scheduling on the original samples. In some optional embodiments, sample scheduling is the core of security defect detection, and generally multiple intelligent algorithms can be selected to improve the comprehensiveness and accuracy of the test. The system can introduce a coverage-guided sample scheduling algorithm, a sample combination algorithm based on a genetic algorithm, and a sample scheduling algorithm based on deep learning technology to ensure that different code paths of the program are covered as much as possible during the test and potential security vulnerabilities are covered more comprehensively.

[0094] Step S205, the program to be tested executes the test sample, monitors and records the execution information during the execution of the program to be tested. In some optional embodiments, for the need to monitor the execution of the program to be tested, an innovative dynamic plug-in monitoring technology can be used to capture key information and coverage during the program execution in real time. A monitor is inserted into the key code path of the program to be tested, and the monitor is used to inject the plug-in code into the code of the program to be tested, and the plug-in code is used to record the execution information of the program to be tested; the execution information is written into the memory.

[0095] Step S206, when an exception occurs in the program to be tested, a test sample of the program to be tested when the exception occurs is saved as an abnormal sample. The abnormal situation includes but is not limited to crash, memory leak and the like.

[0096] Step S207, extracting program features of the program to be tested through the pre-trained abnormal deep learning model.

[0097] Step S208, generating a mutation strategy according to program features and abnormal samples.

[0098] Step S209: Generate at least one mutation sample according to the mutation strategy combined with fuzzy testing technology.

[0099] An optional example of an abnormal deep learning model is: Long Short-Term Memory (LSTM) is used as the backbone architecture of the abnormal deep learning model. The LSTM architecture is specifically used to learn and understand the code structure and logic of the program. Through training with a large amount of program code data, this LSTM model can accurately capture the key features and patterns in the code, including grammatical structure, control flow, and data dependency. Then, a mutation strategy generator is designed in the abnormal deep learning model. The control mutation strategy generator uses the program features extracted by the LSTM model and the knowledge learned by the deep learning model, and fully considers multiple factors such as the complexity of the program, the type of vulnerability, and the code structure, and finally intelligently generates a mutation strategy with strong pertinence and good adaptability to cover various vulnerability patterns of the program as much as possible. Then, according to the obtained mutation strategy, fuzz testing technology is combined, such as randomization of input values, modification of grammatical structure, and change of boundary values, etc., to finally obtain at least one mutation sample. Such mutation samples can enable the software security defect detection system to search the vulnerability space of the program more comprehensively and further improve the recognition accuracy of complex vulnerability patterns.

[0100] In some optional embodiments, a specific model code of the abnormal deep learning model is as follows:

[0101]

[0102]

[0103] In the above code, in the LSTM model definition (LSTMModel class) stage, the constructor (__init__): specifies the input size (input_size), hidden layer size (hidden_size) and output size (output_size) when initializing the model. The model contains an LSTM layer and a fully connected (nn.Linear) layer. Forward propagation (forward method): accepts input, processes the sequence data through the LSTM layer, then takes only the output of the last time step and converts it to the final output through the fully connected layer.

[0104] In the mutation strategy generator (MutationStrategyGenerator class) stage, the constructor first receives a trained or predefined LSTM model during initialization. Then, the code features code_features are given in the generation strategy (generate_strategy method), converted into tensor form and fed into the LSTM model. The output of the model is interpreted as a mutation strategy vector and converted into a list form and returned.

[0105] In the feature extraction function (extract_code_features function) stage, the above code only shows that a random feature vector is simply generated. Those skilled in the art can select complex static or dynamic code analysis to extract meaningful features in practical applications.

[0106] During the model training process (train_lstm_model function), the parameters are first initialized to determine the input, hidden and output sizes, then the LSTM model is instantiated and the loss function (mean square error loss nn.MSELoss) and optimizer (Adam optimizer) are defined. Finally, a training loop is performed: for each training round (epoch), each pair of code features and target mutation strategies in the training dataset is traversed, and the following steps are performed: prepare input and target tensors, forward propagate to obtain model predictions, calculate and back-propagate losses to update model parameters. This cyclic iterative approach enables the system to continuously learn and optimize, gradually improving the detection effect of software security.

[0107] It should be noted that the above code example is only a simple example of an abnormal deep learning model, and those skilled in the art can set the specific execution logic within it according to actual conditions.

[0108] In addition, Python acceleration design can be applied to optimize the algorithm, parallelize and asynchronously process the original samples, and generate optimized test samples. The system optimizes the algorithm of the original samples and improves the efficiency of generating test samples through parallel and asynchronous processing, thus preparing for the subsequent testing phase.

[0109] Optionally, low-level call optimization can also be applied: by using low-level calls and efficient data structures, the number of low-level calls of the code can be reduced to improve the overall execution efficiency. The key code that interacts with the system can be optimized to reduce the overhead of system calls. Those skilled in the art can select the specific type of calling method and data structure according to actual conditions.

[0110] Optionally, memory management optimization can also be performed: the garbage collection mechanism and memory management of different versions of code are optimized to reduce unnecessary memory allocation and release operations, thereby reducing the memory usage of the system. Those skilled in the art can choose the memory management method according to actual conditions.

[0111] Optionally, when the code of the software security defect detection system is a Python version, you can choose to introduce an acceleration technology of just-in-time compilation, which is used to compile Python code into machine code, that is, an acceleration technology based on JIT (Just-in-time compilation). By compiling Python code into machine code through JIT, the machine code is directly executed at runtime, avoiding the performance loss of the interpreter, thereby improving the execution speed of Python code. In addition, Python's parallel computing library and asynchronous programming library can be used to parallelize or asynchronously process some tasks in the system to make full use of multi-core processors and IO resources to improve system concurrency and response speed.

[0112] Through this method, the software security defect detection system of the present invention has not only made multiple innovations in the aspects of underlying performance optimization, algorithm optimization, deep learning technology, parallel and asynchronous processing, etc., but these innovative designs enable the system to quickly and accurately discover potential security defects in large-scale security defect detection tasks. And the acceleration module of the present invention provides a more efficient foundation for the automated software security detection system. While maintaining flexibility, the system can more effectively cope with fuzz testing tasks and improve detection effects and performance. This innovative acceleration scheme makes the system more adaptable and intelligent when facing complex vulnerability patterns and variant obfuscated codes. The entire process integrates a variety of key technologies, providing strong support for comprehensive detection of software security.

[0113] It should be understood that in some embodiments, each part can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system.

[0114] This embodiment also provides a computer-readable storage medium 301 , a computer program product 401 , and a computer device 501 . Figure 3 is a schematic diagram of a computer-readable storage medium of a software security defect detection method according to an embodiment of the present invention; Figure 4 is a schematic diagram of a computer program product of a software security defect detection method according to an embodiment of the present invention; and Figure 5Schematic diagram of a computer device of a software security defect detection method according to an embodiment of the present invention. Computer program product 401 includes computer program 302, which implements the steps of any of the above-mentioned software security defect detection methods when executed by processor 303. Computer readable storage medium 301 stores the above-mentioned computer program 302, which implements the steps of any of the above-mentioned software security defect detection methods when executed by processor 303. Computer device 501 may include memory 502, processor 303, and computer program 302 stored in memory 502 and running on processor 303.

[0115] The computer program 302 for performing the operation of the present invention may be an assembly instruction, an instruction set architecture (ISA) instruction, a machine instruction, a machine-dependent instruction, a microcode, a firmware instruction, a state setting data, a configuration data of an integrated circuit, or a source code or an object code written in any combination of one or more programming languages ​​and a procedural programming language. The computer program 302 may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer may be connected to the user's computer via any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet Service Provider). In some embodiments, to perform aspects of the present invention, electronic circuits including, for example, programmable logic circuits, Field-Programmable Gate Arrays (FPGAs), or Programmable Logic Arrays (PLAs) may execute computer-readable program instructions by utilizing state information of the computer-readable program instructions to personalize the electronic circuits.

[0116] In the description of this embodiment, the computer program product 401 is a related product including the computer program 302 .

[0117] For the purposes of the description of this embodiment, computer readable storage medium 301 is a tangible device capable of retaining and storing computer program 302, which can be any device that can contain, store, communicate, propagate or transmit a program for use with or in conjunction with an instruction execution system, device or apparatus. More specific examples (a non-exhaustive list) of computer readable storage medium 301 include the following: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, and any suitable combination of the foregoing.

[0118] Computer device 501 can be, for example, a server, a desktop computer, a notebook computer, a tablet computer, or a smart phone. In some examples, computer device 501 can be a cloud computing node. Computer device 501 can be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, a program module can include routines, programs, target programs, components, logic, data structures, etc. that perform specific tasks or implement specific abstract data types. Computer device 501 can be implemented in a distributed cloud computing environment where remote processing devices linked by a communication network perform tasks. In a distributed cloud computing environment, program modules can be located on a local or remote computing system storage medium including a storage device.

[0119] The computer device 501 may include a processor 303 adapted to execute stored instructions, and a memory 502 that provides temporary storage space for the operation of the instructions during operation. The processor 303 may be a single-core processor, a multi-core processor, a computing cluster, or any number of other configurations. The memory 502 may include random access memory (RAM), read-only memory, flash memory, or any other suitable storage system.

[0120] The computer device 501 may also include a network adapter / interface and an input / output (I / O) interface. The I / O interface allows data to be input and output with external devices that may be connected to the computer device. The network adapter / interface may provide communication between the computer device and a network, which is typically shown as a communication network.

[0121] At this point, those skilled in the art should recognize that, although multiple exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications that conform to the principles of the present invention can still be directly determined or derived based on the content disclosed in the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and recognized as covering all these other variations or modifications.

Claims

1. A software security defect detection method, It is characterized in that include: Identify the program to be tested; Obtaining an original sample, wherein the original sample includes a preset test case and a typical input; Calling the pre-trained screening deep neural network model to perform sample scheduling on the original sample, thereby obtaining a test sample; The test sample is run to perform security defect detection on the program to be tested.

2. The software security defect detection method according to claim 1, It is characterized in that The step of calling the pre-trained screening deep neural network model to perform sample scheduling on the original sample to obtain a test sample includes: Calling the screening deep neural network model to calculate the confidence between the original sample and the program to be tested; The original sample corresponding to the confidence level that meets a preset condition is selected as the test sample, and the preset condition includes: the confidence level is greater than a preset value.

3. The software security defect detection method according to claim 2, It is characterized in that The step of calling the screening deep neural network model to calculate the confidence between the original sample and the program to be tested includes: Calling an encoder to generate a low-dimensional feature representation corresponding to the test sample according to the test sample, wherein the encoder is an unsupervised learning model for performing feature learning and representation learning on the original sample; Obtaining code structure characteristics of the program to be tested; The screening deep neural network model is called to calculate the confidence level according to the low-dimensional feature representation and the code structure features.

4. The software security defect detection method according to claim 1, It is characterized in that The step of running the test sample to detect security defects in the program to be tested includes: The test sample is executed by the program under test, and execution information during the execution of the program under test is monitored and recorded.

5. The software security defect detection method according to claim 4, It is characterized in that The step of monitoring and recording the execution information during the execution of the program under test comprises: Inserting a monitor in a key code path of the program under test, wherein the monitor is used to inject a stub code into the code of the program under test, and the stub code is used to record execution information of the program under test; The execution information is written into the memory.

6. The software security defect detection method according to claim 5, It is characterized in that After the step of monitoring and recording the execution information during the execution of the program to be tested, the following steps are further included: When an exception occurs in the program to be tested, saving the test sample of the program to be tested when the exception occurs as an abnormal sample; Extracting program features of the program to be tested through a pre-trained abnormal deep learning model, and generating a mutation strategy according to the program features and the abnormal samples; Generate at least one mutation sample according to the mutation strategy combined with fuzz testing technology; The step of running the test sample to perform security defect detection on the program to be tested is repeated using the variant sample as the test sample.

7. The software security defect detection method according to claim 1, It is characterized in that The step of obtaining the original sample also includes: An acceleration module is loaded, where the acceleration module is used to speed up the execution speed of the security defect detection process, and the acceleration module includes GPU acceleration and FPGA acceleration.

8. The software security defect detection method according to claim 1, It is characterized in that The step of obtaining the original sample further includes: The original sample is accelerated at a low level, thereby converting the original sample into a C language extension module.

9. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the software security defect detection method according to any one of claims 1 to 8.

10. A computer program product, comprising a computer program, which, when executed by a processor, implements the steps of the software security defect detection method according to any one of claims 1 to 8.

Citation Information

Cited By

  • Vulnerability detection model training method, script vulnerability detection method and related device

    CN119397529A