Seed generation optimization method oriented to structured file fuzzy test
Through static analysis and dynamic monitoring combined with deep learning models to predict the basic data units of unexecuted paths, new structured file seeds are assembled, which solves the problem of file structure damage and redundant seeds based on mutation and generation fuzz testing methods, and improves fuzz testing. efficiency and pass rate.
Patent Information
- Application Number
- CN202410529851.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-29
- Publication Date
- 2024-08-27
AI Technical Summary
The mutation-based fuzz testing method may cause the seed file structure to be damaged and fail to pass the format and semantic check of the target program, resulting in test cases being excluded; there are a large number of redundant seed inputs in the seed library generated by the generation-based fuzz testing method, which reduces the risk of Fuzz testing efficiency.
Generate a program control flow graph through static analysis, dynamically monitor the execution path of the target program, predict the basic data units of the unexecuted path using a deep learning model, assemble a new structured file seed, ensure that the seed passes preliminary format and semantic checks, and use the initial seed The execution path information improves seed diversity.
The generated seeds can deeply trigger the internal logic and potential abnormal paths of the program, improve the efficiency and pass rate of fuzz testing, and avoid file structure damage and redundant seed problems.
Smart Images

Figure CN118550818A
Abstract
Description
Technical Field
[0001] The invention belongs to the field of computer technology, and in particular relates to a software testing method. Background Art
[0002] In today's software industry, a large number of applications and systems rely on processing structured files, such as PDF files, SWF files, etc. in their core functions. With the widespread use of these files in information technology infrastructure, it is critical to ensure that software can process these structured files securely and efficiently. Fuzz testing, as a dynamic software testing method, has become an important technology in the field of software vulnerability mining to cope with increasingly complex software systems and security challenges.
[0003] Fuzz testing for structured files can be divided into two main categories: generation-based methods and mutation-based methods. Generation-based methods focus on leveraging knowledge of file formats to generate test inputs that meet specific format requirements from scratch, aiming to cover as many code paths and potential boundary conditions as possible. Mutation-based methods, on the other hand, start from existing valid file samples and generate new test cases by making minor modifications or mutations to these samples. These mutations may include modifying certain bytes of the file, inserting or deleting certain parts of the file, etc., in order to discover vulnerabilities in the software when processing malformed or unexpected inputs.
[0004] The existing scheme closest to the present invention is mainly a fuzzy test seed generation method and device based on machine learning. The scheme includes three parts: a PDF object corpus constructor, a PDF object corpus generator, and a PDF encapsulator. The PDF object corpus constructor is responsible for analyzing the grammatical structure of the PDF file and obtaining the obj object in the PDF file body to form a PDF object corpus. The PDF object corpus generator uses a machine learning model to learn the internal formatted text syntax in the PDF object corpus, and uses these learned rules to guide the generation of new PDF object sequences. Finally, the PDF encapsulator processes the newly generated PDF object sequences, converts these object sequences back to the original PDF objects, and encapsulates the necessary components of these PDF files together with the original objects to form a complete PDF seed file for fuzzy testing.
[0005] Mutation-based fuzz testing methods may lead to damage to the seed file structure. When executing, the software that processes structured files will perform format and semantic checks on the input. Mutated files often fail to pass this stage, resulting in the exclusion of test cases in the early stages of fuzz testing. This phenomenon limits the ability of mutation-based fuzzers to explore deep paths or abnormal behaviors of the target program.
[0006] Although generation-based fuzz testing methods attempt to identify the syntactic or semantic restrictions imposed by the target program on the input to generate valid seed inputs, they often fail to fully exploit the relationship between the seed inputs and the execution paths corresponding to these seeds. This results in a large number of redundant seed inputs in the generated seed library, which trigger the same execution paths in the target program, reducing the efficiency of fuzz testing. Summary of the invention
[0007] In view of this, the present invention proposes a seed generation optimization method for structured file fuzz testing, aiming to solve these two problems. On the one hand, the seeds generated by the present invention must be able to pass the preliminary format and semantic inspection of the target program, so as to deeply trigger the internal logic and potential abnormal paths of the program. On the other hand, the seeds generated by the present invention can utilize the execution path information of the initial seed, improve the seed diversity, and improve the efficiency of fuzz testing.
[0008] The seed generation optimization method for structured file fuzz testing, the specific technical solution is as follows:
[0009] Perform static analysis on the target program and generate a program control flow graph;
[0010] Execute the target program and dynamically monitor it to obtain the executed path;
[0011] Generate an unexecuted path according to the program control flow graph and the executed path;
[0012] Using deep learning models to predict basic data units that may cover unexecuted paths;
[0013] A new structured file is assembled from the newly obtained basic data units. The new structured file is the newly generated seed, which is used in the subsequent fuzz testing phase.
[0014] Furthermore, the dynamic monitoring specifically includes: first, enabling the Intel PT function by configuring the system environment settings to start capturing the execution process of the target program; then, inputting the structured file in the initial seed library into the target program for execution. When the program is running, Intel PT will record the control flow conversion of the program in detail and generate a series of tracing data packets; next, using the software perf to decode the collected tracing data packets, after completing the above steps, the executed path of the target program is obtained.
[0015] Furthermore, the process of generating unexecuted paths is as follows: first, all branches of the target program are generated according to the CFG graph obtained in step one; then, combined with the executed paths obtained in step two, the new branches that have not been explored are found by analyzing the CFG graph; finally, the unexplored new branches are spliced with the executed paths to generate unexecuted paths.
[0016] Furthermore, the training data of the model is: the basic data unit sequence obtained by parsing the structured files in the initial seed library, and the corresponding execution path;
[0017] The deep learning model is the TransformerXL model.
[0018] Furthermore, the deep learning model selects multiple adoption methods, including Top-k Sampl, Top-p Sample, and Temperature Sample.
[0019] Beneficial Effects
[0020] 1. The present invention utilizes the initial path of the seed input, and combines static analysis and dynamic supervision to obtain the unexecuted path information. Using this path information and deep learning methods, it generates seeds that are more likely to cover the unexecuted path and are more likely to trigger program vulnerabilities. Other methods rarely consider the initial path of the seed, and the generated seed corpus is often inefficient due to containing too many repeated redundant seeds and triggering the same execution path in the target program.
[0021] 2. The present invention ensures the integrity of the file structure through the process of file parsing and file assembly. At the same time, through the deep learning model, the intrinsic semantic connection of the basic data units of the file is learned to ensure the pass rate of the seed.
[0022] 3. A structured seed generation method combining execution path information and deep learning is proposed. This method obtains executed path information and unexecuted path information by combining static analysis and dynamic monitoring. Using a deep learning model, the relationship between the executed path information and the basic data unit sequence obtained by parsing the structured file is learned, and the basic data unit sequence that may cover the unexecuted path is predicted. Finally, the basic data units are assembled into a complete structured file. This method takes into account the structural integrity of the generated structured file and uses path information to improve the diversity of seeds.
[0023] 4. This paper proposes to use the TransformerXL model to learn the relationship between path information and basic file data units, and enrich the generated basic file data units through a variety of sampling methods such as Top-k Sample, Top-p Sample, Temperature Sample, etc., and randomly insert distorted characters without destroying the basic file data units to avoid the singleness of the generated data units. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 , a flow chart of the method of the present invention;
[0025] Figure 2, schematic diagram of unexecuted path generation. DETAILED DESCRIPTION
[0026] The present invention provides a seed generation optimization method for structured file fuzzy testing, which is divided into seven steps: Figure 1 shown.
[0027] Step 1 is to perform static analysis on the target program. Use the tool IDA Pro to load the target program and generate a program control flow graph (CFG). A program control flow graph is a graphical representation of the program execution flow, where nodes represent basic blocks in the program (a set of sequentially executed instruction sequences) and edges represent control flow jumps. The CFG graph can display the logical structure of the program and identify possible paths of program execution, including loops, conditional branches, etc.
[0028] Step 2 is to execute the target program and monitor it dynamically. This process mainly uses the Intel PT tool. Intel PT is a new program tracing technology added to the fifth-generation Intel CPU. It can provide accurate and detailed program execution information and has triggering and filtering functions. The process of dynamically monitoring the program execution path is as follows: First, turn on the Intel PT function by configuring the system environment settings to start capturing the execution process of the target program; then, input the structured file in the initial seed library into the target program for execution. When the program is running, Intel PT will record the control flow conversion of the program in detail, including branches, jumps, etc., and generate a series of tracing data packets. Among them, the initial seed library mainly comes from public data sets or is obtained through crawlers; next, use the software perf to decode the collected tracing data packets. After completing the above steps, the executed path of the program can be obtained.
[0029] Step three is to generate unexecuted paths. The specific process of generating unexecuted paths is as follows: First, based on the CFG graph obtained in step one, identify all decision points in the program. Each decision point may generate two or more branches, corresponding to different execution conditions. Here, all branches of the program are generated based on the CFG graph; then, combined with the executed path obtained in step two, by analyzing the CFG graph, new branches that have not yet been explored can be found. Finally, based on these newly discovered branches, unexecuted paths are generated by splicing the executed paths. Figure 2, there is an executed path 1, the path sequence is (e1, e3, e4, e8); the executed path 2, the path sequence is (e2, e5, e6, e7, e8). By analyzing the CFG graph, it is found that starting from edge e1, there are two possible execution paths, namely (e1, e3, e4, e8) and (e1, e5, e6, e7, e8), of which (e1, e3, e4, e8) is the executed path 1, and (e1, e5, e6, e7, e8) is the unexecuted path. In order not to lose the details of the path information, the unexecuted path 3 is obtained by splicing the executed path 1 and the executed path 2, and the path sequence is (e1, e5, e6, e7, e8).
[0030] Step 4 is to parse the structured file and obtain a sequence of basic data units. Taking PDF files as an example, this step obtains a sequence of obj objects by parsing the PDF file. PDF files consist of four parts: file header, file body, cross-reference table, and file tail. The file header contains PDF version information and is the starting part of the PDF file. The file body constitutes the main content of the PDF file and consists of a sequence of obj objects. These objects include text, images, page layout information, etc., and are the basic data units of PDF files. Each obj object has a unique number and can contain a variety of data types from simple numbers to complex charts or page layouts. The cross-reference table provides an index of the position of each obj object in the file. The file tail contains a pointer to the starting position of the cross-reference table and the file end mark %%EOF. The file tail ensures the integrity of the file and allows the parser to correctly identify the end of the file. The file header, cross-reference table, and file tail are easily constructed and parsed automatically by algorithms.
[0031] Step five is to train the model to learn the relationship between the execution path and the basic data unit sequence. The deep learning model used here is the TransformerXL model, which is an improvement on the Transformer model. By introducing the "relative position encoding" and "loop memory" mechanisms, the model's ability to capture long-term dependent information is further improved, and it is crucial to better understand the complex relationship between the execution path and the basic data unit sequence. By default, the model will use a greedy strategy, that is, select the character with the highest probability as the predicted character. Although this method can ensure the correctness of the generated basic data unit sequence, since the highest probability character is uniquely determined, this strategy may generate a large number of repeated basic data unit sequences, which limits subsequent fuzzy testing. Based on the Transformer model, a sampling layer is added to the decoder part of the model, and the Top-k Sample strategy is selected in the sampling layer. Top-k arranges the character probabilities from high to low in advance, selects the k characters with the highest probability, and then calculates the probabilities of these characters according to the softmax function, and then samples them according to the probability distribution to generate the next character. Top-p Sample and Temperature Sample can also be used.
[0032] Step 6 is to predict the basic data units that may cover the unexecuted path. The unexecuted path obtained in step 3 is input into the TransformerXL model trained by step 5 to obtain a sequence of basic data units that may cover the unexecuted path, such as in a PDF file, and generate a new obj object sequence.
[0033] Step 7 assembles the newly obtained basic data unit sequence to obtain a new structured file. Taking the PDF file as an example, the newly obtained obj object sequence is assembled to obtain a complete PDF file. This step is the reverse process of step 4. From the obj object sequence, the file header, cross-reference table and file footer are assembled to form a complete PDF file. Steps 4 and 7 ensure the integrity of the generated seed structure and can pass the format check of the target program. These newly generated seeds will be used in the subsequent fuzz testing phase.
Claims
1. A seed generation optimization method for structured file fuzz testing, characterized by: Perform static analysis on the target program and generate a program control flow graph; Execute the target program and dynamically monitor it to obtain the executed path; Generate an unexecuted path according to the program control flow graph and the executed path; Using deep learning models to predict sequences of basic data units that may cover unexecuted paths; A new structured file is assembled from the newly obtained basic data unit sequence. The new structured file is the newly generated seed, which is used in the subsequent fuzz testing phase.
2. The seed generation optimization method for structured file fuzzy testing according to claim 1 is characterized in that: The dynamic monitoring specifically includes: first, enabling the Intel PT function by configuring the system environment settings to start capturing the execution process of the target program; then, inputting the structured file in the initial seed library into the target program for execution. When the program is running, Intel PT will record the control flow conversion of the program in detail and generate a series of tracing data packets; next, using the software perf to decode the collected tracing data packets, after completing the above steps, the executed path of the target program is obtained.
3. The seed generation optimization method for structured file fuzzy testing according to claim 1 or 2 is characterized in that: The specific process of generating unexecuted paths is as follows: first, all branches of the target program are generated according to the CFG graph obtained in step 1; then, combined with the executed paths obtained in step 2, the new branches that have not been explored are found by analyzing the CFG graph; finally, the unexplored new branches are spliced with the executed paths to generate unexecuted paths.
4. The seed generation optimization method for structured file fuzzy testing according to claim 3 is characterized in that: The deep learning model is trained to learn the relationship between the execution path and the basic data unit sequence, where the deep learning model is the TransformerXL model, and the training data is: the basic data unit sequence obtained by parsing the structured files in the initial seed library, and the corresponding execution path.
5. The seed generation optimization method for structured file fuzzy testing according to claim 4 is characterized in that: The deep learning model selects multiple adoption methods, including Top-k Sample, Top-p Sample, and TemperatureSample.
