A method for predicting a fuzz testing seed path based on an anomaly detection model
By using an anomaly detection model to filter low-frequency path seeds, the problem of fuzzing tools exploring too many high-frequency paths is solved, thus improving the efficiency of fuzzing and its ability to discover potential vulnerabilities.
Patent Information
- Application Number
- CN202211564574.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-07
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2042-12-07
AI Technical Summary
Existing fuzzing tools are prone to getting stuck in local optima during the exploration process, resulting in high-frequency paths getting a lot of mutation opportunities while low-frequency paths lack exploration opportunities, leading to low fuzzing efficiency.
An anomaly detection model is used to screen low-frequency path seeds. The selected low-frequency path seeds guide fuzzing tests to explore in the direction of low-frequency paths. The anomaly detection model is used for path frequency prediction and energy scheduling to reduce the tracking of invalid seeds.
It improved the efficiency of fuzz testing, reduced system overhead and time costs, and uncovered more potential low-frequency path vulnerabilities.
Smart Images

Figure CN116185820B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer security technology, specifically, to a fuzzy test seed path prediction method based on an anomaly detection model. Background Technology
[0002] Anomaly detection, also known as outlier detection, refers to the process of identifying data that significantly deviates from the majority of the data. Anomaly detection primarily targets a minority of unpredictable and rare data points, which are often characterized by uncertainty, diversity, and rarity. In recent decades, anomaly detection has been an active research field with applications in many areas, such as intrusion detection in cybersecurity, credit card fraud detection, and cancer cell detection. By studying anomalies, researchers can gain valuable insights that can help them make better data-driven decisions.
[0003] As software grows increasingly large and complex, static program analysis becomes increasingly costly and ineffective. In recent years, fuzzing has gained popularity among security researchers due to its high degree of automation, efficient vulnerability discovery, and independence from source code. As of 2022, Google's renowned OSS-Fuzz service had discovered over 40,500 vulnerabilities in 650 open-source programs.
[0004] Coverage-guided fuzzing primarily distinguishes different inputs by varying coverage, generating new coverage as a signal to track execution and ultimately filter test cases. The most well-known coverage-guided fuzzing tool is AFL, developed in 2013 by Google security researcher Zalewski. AFL records code coverage by lightweight instrumentation of the code during target program compilation, then performs deterministic and destructive mutations on the initial seed in the input queue in a specific order. Deterministic mutations involve small-scale, localized, and regular changes to the input, such as bit flips, byte additions / subtractions, and byte substitutions. Destructive mutations involve large-scale, unordered changes to the input. AFL then feeds the newly generated input into the target program, monitors program behavior, collects inputs that generate new coverage and trigger abnormal program behavior, and assigns different mutation energy based on the seed's execution time and path depth. This mutation energy guides the number of mutations in the next iteration. Finally, the seed is added to the queue, and this process is repeated. However, as time goes by, the growth of coverage gradually slows down, and the number of test cases that increase coverage will be far less than the total number of test cases. Furthermore, according to statistical analysis of the execution path frequency of all test cases, it was found that the number of executions of program paths is not uniform, but mainly concentrated on the high-frequency paths of the program.
[0005] The fuzzing tool AFL uses changes in coverage as the criterion for selecting seeds for the queue, as the basis for allocating mutation energy, and as the direction of mutation for the entire AFL. However, over time, seeds with more mutation energy will generate more inputs and consistently dominate the target program's execution. Once this path has been fully explored, the coverage stops changing, leading to a local optimum and making subsequent fuzzing inefficient.
[0006] As described above, fuzz testing, due to its simple energy scheduling strategy, easily allows high-frequency paths to have numerous opportunities for mutation and execution, resulting in insufficient exploration opportunities for low-frequency paths and a loss of the ability to discover potential vulnerabilities in low-frequency paths. Therefore, this paper proposes a fuzz testing seed path prediction method based on an anomaly detection model, using the anomaly detection model to guide fuzz testing towards low-frequency paths in real time. Summary of the Invention
[0007] The purpose of this invention is to address the shortcomings of existing technologies by proposing a fuzzing seed path prediction method based on an anomaly detection model. This method uses low-frequency paths of the program as anomalies and filters out low-frequency path seeds through an anomaly detection model, enabling fuzzing to continuously and effectively explore in the direction of low-frequency paths, reducing the tracking of invalid seeds, saving fuzzing system overhead and time costs, and improving fuzzing efficiency.
[0008] To achieve the above objectives, the present invention adopts the following technical solution: A fuzzy test seed path prediction method based on an anomaly detection model is provided. This fuzzy test seed path prediction method is based on a fuzzy testing tool, which includes a dataset acquisition module, a buffer module, an energy scheduling module, a model training module, and a model inference module. The dataset acquisition module is used to collect the training and test sets of the anomaly detection model and categorize them into different folders. In particular, the collected data need to have significant differences to enable the trained model to have better generalization ability. Therefore, the collected data all come from the seeds of the destructive stage of mutation. The buffer module uses shared memory as a buffer and uses the buffer to exchange information between the fuzzing tool and the anomaly detection model, balancing the efficient seed generation speed of fuzzing with the inference speed of the anomaly detection model, and reducing the time that fuzzing waits for the anomaly detection model to infer. The energy scheduling module is used to give more mutation energy to the low-frequency path seeds predicted by the anomaly detection model, so that the low-frequency path seeds have more mutation opportunities, thereby guiding the fuzz test to mutate in the direction of low-frequency paths and increasing program coverage. The model training module is used when, after a period of fuzz testing, the coverage of the target program no longer changes, while the frequency of low-frequency paths gradually increases, and the previously trained model is no longer applicable, requiring retraining of the model so that fuzz testing can be performed in the direction of low-frequency paths. The model inference module is used to predict the path frequency category of the input unexecuted seeds. After the model training is completed, the mutated seeds are stored in the buffer. When the buffer is full, they are input into the anomaly detection model at once. Taking advantage of the parallel computing of GPU, the model infers a batch of seeds at once, which improves the efficiency of model inference. The fuzzy testing seed path prediction method based on the aforementioned fuzzy testing tool specifically includes the following steps: Step S1. The fuzzing tool statically instrumentes the C / C++ program to generate instrumented code. After running the instrumented C / C++ program, it can record the program's execution path information. Step S2. By feeding different seeds into the fuzzing tool, the instrumentation procedure is repeatedly executed to generate a series of paths for the seeds and record them; Step S3. Collect seed paths, obtain unique identifiers for each path by hashing the coverage bitmap, and then place them into different folders according to their different paths; Step S4. Using the collected path files, the anomaly detection model is trained based on the path frequency to optimize the anomaly detection model parameters; Step S5. Use the trained anomaly detection model to infer the path frequency category to be fed into the fuzz test seed; Step S6. The anomaly detection model predicts the path frequency category of the seed, thereby guiding whether the fuzz test should execute the seed; Step S7. Fuzz testing filters the high-frequency path seeds predicted by the anomaly detection model, thereby improving the fuzz testing speed and reducing the running overhead of the high-frequency path seeds.
[0009] Specifically, before step S1 is executed, the fuzzing tool is started and run for a period of time to collect seeds. When the required number of training sets for the model is met, the training of the anomaly detection model is started. After the training is completed, the fuzzing and anomaly detection models are executed in parallel.
[0010] Furthermore, the seed path information recorded in step S2 is recorded through a coverage bitmap, and a unique path identifier is obtained by hashing the coverage bitmap.
[0011] Specifically, in step S3, seeds with the same path are placed in the same folder using unique path identifier information, and the folder name is the hash value of the seed execution path.
[0012] Specifically, in step S4, the anomaly detection model is trained based on path frequency, including: Step S41. Classify the seed paths according to their different hash values and place them in different folders. Distinguish the number of seeds in each folder. Usually, only a small number of paths have a large number of duplicate seeds, which are high-frequency paths. Step S42. Use the high-frequency path seeds in folders with a large number of seeds as the training set of the anomaly detection model, and use the low-frequency path seeds in folders with a small number of seeds as the test set of the anomaly detection model, thereby optimizing the parameters of the anomaly detection model.
[0013] Specifically, step S5, which involves using the trained anomaly detection model to infer the path frequency category to be fed into the fuzzy test seed, includes: Step S51. After training, the anomaly detection model learns the high-frequency path features of the target program; Step S52. The anomaly detection model infers the path frequency category of the seed to be fed into the fuzz test without running the target program. Step S53. Discard the high-frequency path seeds predicted by the anomaly detection model to reduce the runtime overhead and time cost of fuzz testing, and guide fuzz testing to explore potential bugs in the target program along low-frequency paths.
[0014] The beneficial effects of this invention are: (1) The present invention uses the low-frequency path of the program as anomaly point, and filters out the low-frequency path seed through the anomaly detection model, so that the fuzz test can continuously and effectively explore the low-frequency path direction, reduce the tracking and running of invalid seeds, save the fuzz test system overhead and time cost, and improve the efficiency of fuzz test.
[0015] (2) The method of the present invention, guided by the anomaly detection model, redistributes the seed energy in the fuzz test, giving more energy to the low-frequency path seed, and can discover potential bugs in the target program. Attached Figure Description
[0016] Figure 1 This is a flowchart of a fuzzy test seed path prediction method based on an anomaly detection model according to the present invention; Figure 2 This is a flowchart of the low-frequency path seed selection algorithm in an embodiment of the present invention; Figure 3 This is a flowchart of the real-time model training scheduling algorithm in an embodiment of the present invention. Detailed Implementation
[0017] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.
[0018] like Figure 1 As shown, this embodiment provides a fuzzy test seed path prediction method based on an anomaly detection model, including the following steps: Step A1: The fuzzing tool runs for a period of time to collect path information; and then places the path information into different folders according to different hash values.
[0019] In the mutation phase of the fuzzing tool, there are two main methods: coarse-grained destructive mutation and fine-grained bit mutation. Coarse-grained destructive mutation provides the seed with sufficient entropy, while fine-grained bit mutation attempts to break through path constraints. To improve the model's generalization performance, only destructive mutation seeds with significant differences are collected as the model training set.
[0020] Typically, path execution frequency is strongly correlated with path constraints. However, due to the simple energy scheduling and fine-grained mutation strategies of fuzzing tools, many seeds lack sufficient mutation energy and granularity. The fine-grained mutated seeds generally follow the same path as the original seeds, leading to significant differences in execution frequency and high path redundancy among different paths. To better collect seeds with the same path, different paths are distinguished by unique hash values and placed into separate folders. Step A2: Use high-frequency path seeds as the training set for the anomaly detection model and low-frequency path seeds as the test set for the anomaly detection model to optimize the model parameters.
[0021] Specifically, anomaly detection learns the mapping between real data and latent features of high-frequency paths based on the distribution of the dataset, as well as the relationship between latent features of high-frequency paths and the data. Then, low-frequency paths and seeds that trigger bugs are used as anomalies, and a few seeds of high-frequency paths are added as a test set for the model to optimize the model parameters.
[0022] After collecting a certain number of path seeds, the training of the anomaly detection model will begin. At this time, the fuzzing tool and the anomaly detection model will run synchronously, each bound to a different CPU core, and their speeds will not interfere with each other. Step A3: After training, the anomaly detection model is used as follows... Figure 2 The algorithm flow shown uses a buffer to store the seeds generated by the fuzzing tool. When the buffer is full, the anomaly detection model reads them all at once and predicts the frequency of paths that have not been executed by the seeds, selecting low-frequency path seeds as input for the fuzzing tool.
[0023] Once the anomaly detection model is trained, its inference phase begins. This requires feeding the seed generated by the fuzzing tool before tracking and running the model. Considering the efficiency of interaction between the anomaly detection model and the fuzzing tool, and leveraging the parallel computing capabilities of GPUs, shared memory is allocated as a buffer for information exchange between them. The buffer stores a batch of seeds generated by the fuzzing tool. When the buffer is full, the seeds are fed into the anomaly detection model all at once, and the results are returned to the fuzzing tool via shared memory. By employing this buffer algorithm, the fuzzing tool skips the tracking and running phase of the buffered seeds, continuing to track and run new seeds without waiting for the anomaly detection model's inference results.
[0024] Step A4: After the system has been running for a period of time, it is difficult to find new path coverage. At this time, the target program coverage will no longer change, and the anomaly detection model training will be restarted. Repeat the above steps.
[0025] After a period of fuzzing, the coverage of the target program no longer changes, but the path frequency of the program changes. Due to the guidance of the anomaly detection model, high-frequency path seeds are filtered, and more mutation energy is allocated to low-frequency path seeds, causing the frequency of low-frequency paths to gradually increase. The new path frequency distribution has changed, and the previously trained anomaly detection model is no longer applicable. Continuing to use the original anomaly detection model will make it difficult for fuzzing to discover new paths. The real-time model training scheduling algorithm flow is as follows: Figure 3 As shown, if the path remains unchanged for a long time or changes little, model training can be restarted through the model training scheduling algorithm, enabling the present invention to flexibly and promptly perform fuzz testing on low-frequency paths.
[0026] It should be noted that those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0027] The preferred implementation of the present invention has been described in detail above, but the present invention is not limited to the described embodiments. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the present invention, and these equivalent modifications or substitutions are all included within the scope defined by the claims of this application.
Claims
1. A fuzzy test seed path prediction method based on an anomaly detection model, characterized in that, The fuzz test seed path prediction method is based on a fuzz test tool, which includes a dataset acquisition module, a buffer module, an energy scheduling module, a model training module, and a model inference module. The dataset acquisition module is used to collect the training and test sets of the anomaly detection model and classify them into different folders. The buffer module uses shared memory as a buffer and uses the buffer to exchange information between the fuzzing tool and the anomaly detection model, balancing the efficient seed generation speed of fuzzing with the inference speed of the anomaly detection model, and reducing the time that fuzzing waits for the anomaly detection model to infer. The energy scheduling module is used to give more energy to the low-frequency path seeds predicted by the anomaly detection model, so that the low-frequency path seeds have more opportunities to mutate, thereby guiding the fuzz test to mutate in the direction of low-frequency paths and increasing the program coverage. The model training module is used when, after a period of fuzz testing, the coverage of the target program no longer changes, while the frequency of low-frequency paths gradually increases, and the previously trained model is no longer applicable, requiring retraining of the model so that fuzz testing can be performed in the direction of low-frequency paths. The model inference module is used to predict the path frequency category of the input unexecuted seeds. After the model training is completed, the mutated seeds are stored in the buffer. When the buffer is full, they are input into the anomaly detection model at once. Taking advantage of the parallel computing of GPU, the model infers a batch of seeds at once. The fuzzy testing seed path prediction method based on the aforementioned fuzzy testing tool specifically includes the following steps: Step S1. The fuzzing tool statically instrumentes the C / C++ program to generate instrumented code. After running the instrumented C / C++ program, it can record the program's execution path information. Step S2. By feeding different seeds into the fuzzing tool, the instrumentation procedure is repeatedly executed to generate a series of paths for the seeds and record them; Step S3. Collect seed paths, obtain unique identifiers for each path by hashing the coverage bitmap, and then place them into different folders according to their different paths; Step S4. Using the collected path files, the anomaly detection model is trained based on the path frequency to optimize the anomaly detection model parameters; Step S41. Classify the seeds according to their different hash values and place them in different folders, and distinguish the number of seeds in each folder; Step S42. Use the high-frequency path seeds in folders with a large number of seeds as the training set of the anomaly detection model, and use the low-frequency path seeds in folders with a small number of seeds as the test set of the anomaly detection model, thereby optimizing the parameters of the anomaly detection model. Step S5. Use the trained anomaly detection model to infer the path frequency category to be fed into the fuzz test seed; Step S6. The anomaly detection model predicts the path frequency category of the seed, thereby guiding whether the fuzz test should execute the seed; Step S7. Fuzz testing filters the high-frequency path seeds predicted by the anomaly detection model, thereby improving the fuzz testing speed and reducing the running overhead of the high-frequency path seeds.
2. The fuzzy test seed path prediction method based on an anomaly detection model according to claim 1, characterized in that, Before step S1 is executed, the fuzzing tool is started and run for a period of time to collect seeds. When the required number of training sets for the model is met, the anomaly detection model training is started. After training is completed, the fuzzing and anomaly detection models are executed in parallel.
3. The fuzzy test seed path prediction method based on an anomaly detection model according to claim 1, characterized in that, Step S5, which describes using the trained anomaly detection model to infer the path frequency category to be fed into the fuzzy test seed, includes: Step S51. After training, the anomaly detection model learns the high-frequency path features of the target program; Step S52. The anomaly detection model infers the path frequency category of the seed to be fed into the fuzz test without running the target program. Step S53. Discard the high-frequency path seeds predicted by the anomaly detection model to reduce the runtime overhead and time cost of fuzz testing, and guide fuzz testing to explore potential bugs in the target program along low-frequency paths.
Citation Information
Patent Citations
A fuzzy testing framework based on AFL
CN109032942A
Seed variation method and device, processor and memory
CN114780964A
