MCU firmware grey box fuzzy test method and device based on simulation and strategy selection

By using a gray box fuzzing test method combined with simulator and energy-saving fuzzer in MCU firmware, intercepting MMIO access and selecting strategies, the problems of hardware dependence and low efficiency in MCU firmware dynamic analysis are solved, and efficient vulnerability mining and Code coverage is improved.

CN118981418AInactive Publication Date: 2024-11-19ZHEJIANG UNIV OF TECH

Patent Information

Application Number
CN202410905289.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-08
Publication Date
2024-11-19
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing MCU firmware dynamic analysis technology requires real hardware or replacement code, which has problems such as low practicality and waste of high-frequency path computing resources, making it difficult to conduct fuzz testing efficiently.

Method used

Using the MCU firmware gray box fuzzing test method based on simulation and policy selection, firmware is loaded through the ISA simulator, intercept MMIO access, and generate variant seeds using energy-saving fuzzers. Combined with exploration-use model selection strategies to reduce input overhead and improve code coverage .

Benefits of technology

It reduces the generation of excess seeds, reduces the consumption of computing resources, improves code coverage, and solves the problems of hardware dependence and low efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118981418A_ABST
    Figure CN118981418A_ABST
Patent Text Reader

Abstract

The invention discloses an MCU firmware grey box fuzzy test method and device based on simulation and strategy selection, and the method comprises the following steps: 1) loading an MCU firmware binary file to a Unicorn simulator, and starting to run from a firmware entry point; 2) intercepting all MMIO accesses generated during firmware running, and judging whether a corresponding MMIO access model exists or not; (3) the energy-saving fuzzifier selects a variation strategy with the maximum probability of generating a new path to perform variation on the seeds, and inputs the variation strategy into the simulator; (4) the simulator obtains the variation seeds, the processing mode of the seeds is selected according to the access model, and therefore peripheral input needed by firmware is generated, and simulation operation is recovered; 5) recording and feeding back execution conditions of the variant seeds to the exploration-utilization model, and simultaneously determining whether the variant seeds are discarded or added into the seed sample set; and 6) calculating the probabilities of different variation modes by the exploration-utilization model according to feedback information of a seed operation result for strategy selection in the step 3). According to the method, MCU firmware peripheral modeling and an energy-saving fuzzifier are combined, and vulnerability mining is carried out on full-simulation firmware by using input overhead judgment and abrupt change selection strategies. Through the input overhead judgment of the simulator and the exploration-utilization model of the fuzzer, the input overhead of peripheral modeling is reduced, the generation of redundant seeds is reduced, and the code coverage rate of fuzz testing is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a gray box fuzzy testing method and device for MCU firmware based on simulation and strategy selection, which is suitable for vulnerability mining in MCU firmware. Background Art

[0002] With scalable connectivity, high energy efficiency, low cost, and sufficient computing power, microcontrollers (MCUs) are used to build the Internet of Things and modern embedded devices. However, as MCU devices are widely deployed in various scenarios from smart homes to industrial systems, their security has become a major concern for users and operators. By 2022, malicious code attacks on IoT devices will increase by 77% year-on-year, which undoubtedly poses a huge threat to IoT security. Reports show that software vulnerabilities lead to most attacks on MCU devices, resulting in data leakage, property loss, and even personal injury. Therefore, it is of great practical significance to mine vulnerabilities in MCU firmware and promptly discover and fix vulnerabilities in the firmware to improve the security of MCU devices.

[0003] Due to the problems of false negatives, false positives, and the need for a large amount of human resources in firmware static analysis technology, in recent years, the combination of firmware simulation and dynamic analysis technology has become a new trend in IoT firmware vulnerability mining research. Currently, there are three main solutions: hardware-in-the-loop, partial simulation, and peripheral simulation. Hardware-in-the-loop uses real peripherals to handle peripheral access in firmware and relies on real hardware for dynamic analysis. Partial simulation mainly avoids simulating peripherals by replacing the code in the firmware that depends on peripherals with software that can achieve the same function. Peripheral simulation automatically models the processor peripheral interface by deriving the interaction model of the peripherals, eliminating the use of real peripherals.

[0004] In summary, existing firmware dynamic analysis technologies require real hardware or replacement code, which has defects such as low practicality and requiring a lot of manpower. In addition, most firmware dynamic analysis solutions based on peripheral simulation directly use AFL as a fuzzer, resulting in a large waste of computing resources on high-frequency paths. Therefore, how to solve the firmware hardware dependency and perform fuzz testing efficiently is a huge challenge at present. Summary of the invention

[0005] In order to overcome the shortcomings of existing MCU firmware vulnerability mining methods, the present invention proposes a MCU firmware gray box fuzz testing method and device based on simulation and strategy selection.

[0006] The technical solution adopted by the present invention to solve its technical problem is:

[0007] A first aspect of the present invention relates to a gray box fuzz testing method for MCU firmware based on simulation and strategy selection, the method comprising the following steps:

[0008] 1) MCU firmware loading and running: Load the MCU firmware binary file into the ISA simulator and start running from the firmware entry point;

[0009] 2) Firmware MMIO access interception and model judgment: The simulator runs the MCU firmware on the PC, intercepts all MMIO accesses generated when the firmware is running, and determines whether there is a corresponding MMIO access model;

[0010] 3) Mutation seed input: The energy-saving fuzzer selects the mutation method with the highest probability of generating a new path to mutate, thereby generating mutation seeds to be input into the simulator;

[0011] 4) Resuming simulation operation: The simulator obtains the seeds generated by the energy-saving fuzzer and selects a processing method for the seeds according to the access model, thereby generating the peripheral inputs required by the firmware, so that the simulation operation is resumed;

[0012] 5) Seed operation result evaluation: Obtain and feed back the execution status of the variant seed to the exploration-exploitation model, and decide whether the variant seed should be discarded or added to the seed sample set;

[0013] 6) Exploration-utilization model decision: The exploration-utilization model calculates the probabilities of different mutation modes based on the feedback information of the seed operation results for strategy selection in step 3).

[0014] Further, the step 1) includes the following process:

[0015] Step 101, MCU firmware loading is to run the firmware binary file in the Unicorn emulator, which supports a variety of different CPU architectures, including ARM, MIPS, etc., and can allow MCU firmware of different architectures to run on the PC;

[0016] Step 102, setting memory mapping in the simulator according to the memory distribution of the firmware, such as the base address and size of RAM, ROM, MMIO, NVIC, etc., so as to form a firmware operating environment so that the simulator can start running from the firmware entry point.

[0017] Furthermore, the step 2) includes the following process:

[0018] Step 201, the simulator identifies the firmware's access to the MMIO area. When the firmware performs MMIO access, the simulator intercepts the access and matches the MMIO access model according to the address pair of the current program counter and the MMIO address.

[0019] Step 202, if there is an available model, the input of the fuzzer is processed according to the type of input overhead, otherwise the input is directly returned to the firmware as a hardware-generated value, so as to further generate the corresponding access model. During the access model creation process, the simulator stores the current register and memory state information before the firmware performs MMIO access, and passes it to the dynamic symbolic execution engine for modeling.

[0020] The step 3) includes the following process:

[0021] The energy-saving fuzzer represents different mutation operations with k, and for each mutation operation, θ k To indicate the probability that the subsample generated by this mutation operation will generate a new path. Finally, by calculating the previous mutation situation, the mutation operation with the highest probability is selected for the next round of mutation, thereby generating a mutation seed to be input into the simulator. The probability formula is shown below.

[0022]

[0023] Among them, p k The probability of selecting mutation operation k during fuzz testing. It is necessary to select a suitable algorithm through the exploration-exploitation model to balance the exploration and exploitation process.

[0024] The step 4) includes the following process:

[0025] Step 401, the simulator accepts the seed input generated by the energy-saving fuzzer and selects a processing method for the seed according to the access model. Each MMIO access model contains an input overhead type, where the input overhead type is divided into full and partial input overhead. Full input overhead means that the data read by the firmware from the MMIO area has no effect on the program (such as the code only accepts a specific value), so the simulator can handle MMIO access statically. Partial input overhead means that only one or more bits of the data read by the firmware affect the firmware logic (such as affecting the control flow decision), while other bits do not;

[0026] Step 402, in the case of full input overhead, the simulator is able to process the MMIO access without consuming any fuzzer input. In the case of partial input overhead, the simulator consumes a large amount of input and converts it into a hardware-generated value through the model, which is then used to service the MMIO access and resume the simulation run.

[0027] The step 5) includes the following process:

[0028] Step 501, record the running status of the mutant seed, and feed back the number of paths found to the exploration-exploitation model, and decide whether the mutant seed should be discarded or added to the seed sample set. If the mutant seed causes the program to crash or finds a new path, it will be added to the corresponding seed set, otherwise it will be discarded;

[0029] Step 502, taking one variation mode as an example, using D t Represents the data collected in the first t rounds of mutation, and uses two arrays to store the data after execution (S[1], F[1]), (S[2], F[2]), …, (S[k], F[k]), where S[k] represents the number of times a new path is found after execution, and F[k] represents the number of times no new path is found after execution.

[0030] The step 6) includes the following process:

[0031] Step 601, explore-use the model to optimize the mutation strategy of AFL using the Thompson sampling algorithm, make decisions on the path information executed by the mutation seed, calculate the probability distribution of the new path that may be generated by the mutation, and select the mutation method with the highest probability, thereby reducing the blindness of the mutation;

[0032] Step 602: Assume that the tth round of mutation and execution operations has been completed, and obtain observation data D t , use π(θ1),π(θ2),…,π(θ k ) represents the prior uniform distribution of the energy-saving fuzzer on the mutation operation. Combined with data D t and priors, collect the posterior distribution π(θ1|D t ),π(θ2|D t ),…,π(θ k |D t ), thereby calculating the probability of performing the mutation operation in round t+1;

[0033] Step 603, using the Beta Bernoulli distribution model to implement the Thompson sampling algorithm, for each θ k The prior probability is θ k ~Beta(α k ,β k ), the probability formula of the posterior distribution is

[0034] θ k |D t ~Beta(α k +S[k],β k +F[k]) (2)

[0035] in, θ k∈(0,1),α k and β k is a positive real-valued parameter, θ k Indicates the probability that the subsample generated by this mutation operation will generate a new path, D t represents the data collected in the first t rounds of mutation, S[k] represents the number of times a new path is found after execution, and F[k] represents the number of times no new path is found after execution;

[0036] Step 604, therefore, the sampling probability is set to Select the mutation operation with the highest probability in It is the highest probability that the mutation of the posterior distribution may produce a new path, thereby guiding the mutation of the mutation seed in step 3.

[0037] The second aspect of the present invention relates to an MCU firmware gray box fuzz testing device based on simulation and strategy selection, comprising a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, they are used to implement the MCU firmware gray box fuzz testing method based on simulation and strategy selection described in the present invention.

[0038] A third aspect of the present invention relates to a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the MCU firmware gray-box fuzz testing method based on simulation and strategy selection described in the present invention.

[0039] Advantages and positive effects of the present invention:

[0040] Aiming at the problem that existing MCU firmware vulnerability mining methods require real hardware peripherals and fuzz testing is not efficient, the present invention proposes a method that combines peripheral modeling with energy-saving fuzzers, and uses input cost judgment and mutation selection strategies to mine vulnerabilities in fully simulated firmware. The input cost judgment of the simulator and the exploration-exploitation model of the fuzzer reduce the input cost, reduce the generation of redundant seeds, and ensure code coverage. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 It is an overall flow chart of the method of the present invention.

[0042] Figure 2 It is a comparison of basic block coverage on the simulator when using the mutation selection strategy of the present invention and the random mutation strategy of the fuzz testing tool AFL.

[0043] Figure 3 It is a comparison of the number of use cases generated on the simulator when using the mutation selection strategy of the present invention and the random mutation strategy of the fuzz testing tool AFL. DETAILED DESCRIPTION

[0044] In order to make the technical solution and design idea of ​​the present invention clearer, the present invention is further described in detail below with reference to the accompanying drawings.

[0045] Example 1

[0046] The present embodiment relates to an MCU firmware gray-box fuzz testing method based on simulation and strategy selection, including using a simulator as a firmware operating environment, and using seeds generated by an energy-saving fuzzer based on strategy selection as peripheral data input of the firmware; the Unicorn instruction simulator in the simulator is widely used in vulnerability analysis, program debugging and analysis, reverse engineering, etc., and is mainly used to simulate program execution processes and operating environments of different architectures; gray-box fuzz testing is a type of fuzz testing, which is widely used in automated testing and can guide fuzz test seed generation based on some program internal information.

[0047] The present invention runs the MCU firmware in a simulator on a PC. Since the MCU firmware has peripheral dependencies, it is necessary to obtain peripheral data. MMIO access interception is used to capture the firmware's access to peripherals, and the access model and fuzzer seed are combined to generate the peripheral input required by the firmware, so that the firmware can run on the PC and perform vulnerability mining at the same time.

[0048] Reference Figure 1 , a gray-box fuzz testing method for MCU firmware based on simulation and strategy selection, comprising the following steps:

[0049] 1) MCU firmware loading and running: Load the MCU firmware binary file into the ISA simulator and start running from the firmware entry point;

[0050] 2) Firmware MMIO access interception and model judgment: The simulator runs the MCU firmware on the PC, intercepts all MMIO accesses generated when the firmware is running, and determines whether there is a corresponding MMIO access model;

[0051] 3) Mutation seed input: The energy-saving fuzzer selects the mutation method with the highest probability of generating a new path to mutate, thereby generating mutation seeds to be input into the simulator;

[0052] 4) Resuming simulation operation: The simulator obtains the seeds generated by the energy-saving fuzzer and selects a processing method for the seeds according to the access model, thereby generating the peripheral inputs required by the firmware, so that the simulation operation is resumed;

[0053] 5) Seed operation result evaluation: Obtain and feed back the execution status of the variant seed to the exploration-exploitation model, and decide whether the variant seed should be discarded or added to the seed sample set;

[0054] 6) Exploration-utilization model decision: The exploration-utilization model calculates the probabilities of different mutation modes based on the feedback information of the seed operation results for strategy selection in step 3).

[0055] Further, the step 1) includes the following process:

[0056] Step 101, MCU firmware loading is to run the firmware binary file in the Unicorn emulator, which supports a variety of different CPU architectures, including ARM, MIPS, etc., and can allow MCU firmware of different architectures to run on the PC;

[0057] Step 102, setting memory mapping in the simulator according to the memory distribution of the firmware, such as the base address and size of RAM, ROM, MMIO, NVIC, etc., so as to form a firmware operating environment so that the simulator can start running from the firmware entry point.

[0058] Furthermore, the step 2) includes the following process:

[0059] Step 201, the simulator identifies the firmware's access to the MMIO area. When the firmware performs MMIO access, the simulator intercepts the access and matches the MMIO access model according to the address pair of the current program counter and the MMIO address.

[0060] Step 202, if there is an available model, the input of the fuzzer is processed according to the type of input overhead, otherwise the input is directly returned to the firmware as a hardware-generated value, so as to further generate the corresponding access model. During the access model creation process, the simulator stores the current register and memory state information before the firmware performs MMIO access, and passes it to the dynamic symbolic execution engine for modeling.

[0061] The step 3) includes the following process:

[0062] Step 301, the energy-saving fuzzer represents different mutation operations with k, and for each mutation operation, θ k To indicate the probability that the subsample generated by this mutation operation will generate a new path. Finally, by calculating the previous mutation situation, the mutation operation with the highest probability is selected for the next round of mutation, thereby generating a mutation seed to be input into the simulator. The probability formula is shown below.

[0063]

[0064] Among them, p k The probability of selecting mutation operation k during fuzz testing. It is necessary to select a suitable algorithm through the exploration-exploitation model to balance the exploration and exploitation process.

[0065] The step 4) includes the following process:

[0066] Step 401, the simulator accepts the seed input generated by the energy-saving fuzzer and selects a processing method for the seed according to the access model. Each MMIO access model contains an input overhead type, where the input overhead type is divided into full and partial input overhead. Full input overhead means that the data read by the firmware from the MMIO area has no effect on the program (such as the code only accepts a specific value), so the simulator can handle MMIO access statically. Partial input overhead means that only one or more bits of the data read by the firmware affect the firmware logic (such as affecting the control flow decision), while other bits do not;

[0067] Step 402, in the case of full input overhead, the simulator is able to process the MMIO access without consuming any fuzzer input. In the case of partial input overhead, the simulator consumes a large amount of input and converts it into a hardware-generated value through the model, which is then used to service the MMIO access and resume the simulation run.

[0068] The step 5) includes the following process:

[0069] Step 501, record the running status of the mutant seed, and feed back the number of paths found to the exploration-exploitation model, and decide whether the mutant seed should be discarded or added to the seed sample set. If the mutant seed causes the program to crash or finds a new path, it will be added to the corresponding seed set, otherwise it will be discarded;

[0070] Step 502, taking one variation mode as an example, using D t Represents the data collected in the first t rounds of mutation, and uses two arrays to store the data after execution (S[1], F[1]), (S[2], F[2]), …, (S[k], F[k]), where S[k] represents the number of times a new path is found after execution, and F[k] represents the number of times no new path is found after execution.

[0071] The step 6) includes the following process:

[0072] Step 601, explore-use the model to optimize the mutation strategy of AFL using the Thompson sampling algorithm, make decisions on the path information executed by the mutation seed, calculate the probability distribution of the new path that may be generated by the mutation, and select the mutation method with the highest probability, thereby reducing the blindness of the mutation;

[0073] Step 602: Assume that the tth round of mutation and execution operations has been completed, and obtain observation data D t , use π(θ1),π(θ2),…,π(θ k ) represents the prior uniform distribution of the energy-saving fuzzer on the mutation operation. Combined with data D tand priors, collect the posterior distribution π(θ1|D t ),π(θ2|D t ),…,π(θ k |D t ), thereby calculating the probability of performing the mutation operation in round t+1;

[0074] Step 603, using the Beta Bernoulli distribution model to implement the Thompson sampling algorithm, for each θ k The prior probability is θ k ~Beta(α k ,β k ), the probability formula of the posterior distribution is

[0075] θ k |D t ~Beta(α k +S[k],β k +F[k]) (2)

[0076] in, θ k ∈(0,1),α k and β k is a positive real-valued parameter, θ k Indicates the probability that the subsample generated by this mutation operation will generate a new path, D t represents the data collected in the first t rounds of mutation, S[k] represents the number of times a new path is found after execution, and F[k] represents the number of times no new path is found after execution;

[0077] Step 604, therefore, the sampling probability is set to Select the mutation operation with the highest probability in It is the highest probability that the mutation of the posterior distribution may produce a new path, thereby guiding the mutation of the mutation seed in step 3.

[0078] Figure 2 and Figure 3 The basic block coverage and the number of use cases generated by executing the MCU firmware on the simulator using the mutation selection strategy of this embodiment are compared with the random mutation strategy of the fuzz testing tool AFL. After 24 hours of execution, for the same simulator and different firmware, the number of use cases generated under the mutation selection strategy of this embodiment is less and has little effect on the coverage.

[0079] Example 2

[0080] The present embodiment relates to an MCU firmware gray box fuzz testing device based on simulation and strategy selection, comprising a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, they are used to implement the MCU firmware gray box fuzz testing method based on simulation and strategy selection described in Example 1.

[0081] Example 3

[0082] This embodiment relates to a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the MCU firmware gray box fuzz testing method based on simulation and strategy selection described in Example 1 is implemented.

[0083] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them. Although the present invention has been described in detail with reference to the aforementioned embodiments, a person skilled in the art can still make other modifications or changes in different forms according to the aforementioned embodiments or drawings. It is impossible to list all implementation methods or technical solutions here, and all modifications, replacements, etc. within the principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A gray-box fuzz testing method for MCU firmware based on simulation and strategy selection, characterized in that: The following steps are involved: 1) MCU firmware loading and running: Load the MCU firmware binary file into the ISA simulator and start running from the firmware entry point; 2) Firmware MMIO access interception and model judgment: The simulator runs the MCU firmware on the PC, intercepts all MMIO accesses generated when the firmware is running, and determines whether there is a corresponding MMIO access model; 3) Mutation seed input: The energy-saving fuzzer selects the mutation method with the highest probability of generating a new path to mutate, thereby generating mutation seeds to be input into the simulator; 4) Resuming simulation operation: The simulator obtains the seeds generated by the energy-saving fuzzer and selects a processing method for the seeds according to the access model, thereby generating the peripheral inputs required by the firmware, so that the simulation operation is resumed; 5) Seed operation result evaluation: Obtain and feed back the execution status of the variant seeds to the exploration-exploitation model, and decide whether the variant seeds should be discarded or added to the seed sample set; 6) Exploration-utilization model decision: The exploration-utilization model calculates the probabilities of different mutation modes based on the feedback information of the seed operation results for strategy selection in step 3).

2. A gray box fuzz testing method for MCU firmware based on simulation and strategy selection as claimed in claim 1, characterized in that: In step 1), the MCU firmware is loaded and run The process includes: Step 101, MCU firmware loading is to run the firmware binary file in the Unicorn emulator, which supports a variety of different CPU architectures, including ARM and MIPS, and can allow MCU firmware of different architectures to run on the PC; Step 102, setting a memory map in the simulator according to the memory distribution of the firmware, thereby forming a firmware operating environment, so that the simulator can start running from the firmware entry point.

3. A gray box fuzz testing method for MCU firmware based on simulation and strategy selection as claimed in claim 1, characterized in that: The firmware MMIO access interception and model determination in step 2) include the following processes: Step 201, the simulator identifies the firmware's access to the MMIO area. When the firmware performs MMIO access, the simulator intercepts the access and matches the MMIO access model according to the address pair of the current program counter and the MMIO address. Step 202, if there is an available model, the input of the fuzzer is processed according to the type of input overhead, otherwise the input is directly returned to the firmware as a hardware-generated value, so as to further generate the corresponding access model; During the access model creation process, the simulator stores the current register and memory state information before the firmware performs MMIO access and passes it to the dynamic symbolic execution engine for modeling.

4. A gray box fuzz testing method for MCU firmware based on simulation and strategy selection as claimed in claim 1, characterized in that: In step 3), the mutation seed input includes the following process: The energy-saving fuzzer represents different mutation operations with k, and for each mutation operation, θ k To indicate the probability that the sub-sample generated by this mutation operation will generate a new path; finally, by calculating the previous mutation situation, the mutation operation with the highest probability is selected for the next round of mutation, thereby generating a mutation seed to be input into the simulator. The probability formula is shown below. Among them, p k The probability of selecting mutation operation k during fuzz testing; the exploration-exploitation model is used to select a suitable algorithm and balance the exploration and exploitation process.

5. A gray box fuzz testing method for MCU firmware based on simulation and strategy selection as claimed in claim 1, characterized in that: The step 4) includes the following steps to restore the simulation operation: Step 401, the simulator receives the seed input generated by the energy-saving fuzzer and selects a processing method for the seed according to the access model. Each MMIO access model contains an input overhead type, where the input overhead type is divided into full and partial input overhead; full input overhead means that the data read by the firmware from the MMIO area has no effect on the program, so the simulator can handle MMIO access statically; partial input overhead means that only one or more bits of the data read by the firmware affect the firmware logic, while other bits do not; Step 402, in the case of full input overhead, the simulator is able to process MMIO access without consuming any fuzzer input; while in the case of partial input overhead, the simulator consumes a large amount of input and converts it into a hardware-generated value through the model, and then uses the value to service the MMIO access and resume the simulation run.

6. A gray box fuzz testing method for MCU firmware based on simulation and strategy selection as claimed in claim 1, characterized in that: The seed operation result evaluation in step 5) includes the following process: Step 501, record the running status of the mutant seed, and feed back the number of paths found to the exploration-exploitation model, and decide whether the mutant seed is discarded or added to the seed sample set; if the mutant seed causes the program to crash or finds a new path, it is added to the corresponding seed set, otherwise it is discarded; Step 502, taking one variation mode as an example, using D t Represents the data collected in the first t rounds of mutation, and uses two arrays to store the situation after execution (S[1], F[1]), (S[2], F[2]), …, (S[k], F[k]), where S[k] represents the number of times a new path is found after execution, and F[k] represents the number of times no new path is found after execution.

7. A gray box fuzz testing method for MCU firmware based on simulation and strategy selection as claimed in claim 1, characterized in that: The exploration-utilization model decision in step 6) includes the following process: Step 601, explore-use the model to optimize the mutation strategy of AFL using the Thompson sampling algorithm, make decisions on the path information executed by the mutation seed, calculate the probability distribution of the new path that may be generated by the mutation, and select the mutation method with the highest probability, thereby reducing the blindness of the mutation; Step 602: Assume that the tth round of mutation and execution operations has been completed, and obtain observation data D t , use π(θ1),π(θ2),…,π(θ k ) represents the prior uniform distribution of the energy-saving fuzzer on the mutation operation; combined with the data D t and priors, collect the posterior distribution π(θ1|D t ),π(θ2|d t ),…,π(θ k |D t ), thereby calculating the probability of performing the mutation operation in round t+1; Step 603, using the Beta Bernoulli distribution model to implement the Thompson sampling algorithm, for each θ k The prior probability is θ k ~Beta(α k ,β k ), the probability formula of the posterior distribution is i k |D t ~Beta(α k +S[k],β k +F[k]) (2) in, θ k ∈(0,1),α k and β k is a positive real-valued parameter, θ k Indicates the probability that the subsample generated by this mutation operation will generate a new path, D t represents the data collected in the first t rounds of mutation, S[k] represents the number of times a new path is found after execution, and F[k] represents the number of times no new path is found after execution; Step 604, therefore, the sampling probability is set to Select the mutation operation with the highest probability in It is the highest probability that the mutation of the posterior distribution may produce a new path, thereby guiding the mutation of the mutation seed in step 3.

8. A gray box fuzz testing device for MCU firmware based on simulation and strategy selection, characterized in that: It comprises a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, it is used to implement the MCU firmware gray box fuzz testing method based on simulation and strategy selection as described in any one of claims 1 to 7.

9. A computer-readable storage medium, characterized in that: A program is stored thereon, and when the program is executed by a processor, the MCU firmware gray box fuzz testing method based on simulation and strategy selection described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Vulnerability mining technology based on reinforcement learning

    CN114647566A

Cited By

  • Kernel fuzzy testing method and device based on unicorn simulation

    CN120780591A