Embedded software fuzzy testing method and system based on fuzzy mutation operator competition
Through the fuzzy mutation operator competition mechanism and adaptive adjustment strategy, the selection probability of the mutation operator is dynamically adjusted, and the hash table is used to record effective strategies, which solves the problem of inefficient fuzz testing of embedded software, and improves the testing efficiency and coverage rate. Enhanced test effectiveness and reliability.
Patent Information
- Application Number
- CN202411091512.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2024-12-03
AI Technical Summary
The existing embedded software fuzz testing methods use random selection of mutation operators, resulting in inefficient testing and inability to effectively discover new paths or new vulnerabilities, resulting in a large number of redundant and invalid inputs.
The competition mechanism and adaptive adjustment strategy of fuzzy mutation operators are introduced, and the selection probability distribution of perturbation mutation operators is dynamically adjusted, and the effective mutation strategy is recorded using a hash table to improve the testing efficiency and coverage.
Significantly improves the efficiency, coverage and reliability of embedded software fuzz testing, shortens the time to find the optimal selection probability distribution, reduces the required prior knowledge, improves the effectiveness and execution speed of tests, and enhances the discovery Capabilities of potential software vulnerabilities.
Smart Images

Figure CN119066660A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of embedded software fuzzy testing, and in particular relates to an embedded software fuzzy testing method and system based on fuzzy mutation operator competition. Background Art
[0002] Embedded software plays a vital role in today's human society and is widely used in the fields of automobiles, aerospace, and military. However, due to the limited resources of the working environment and the complexity and diversity of software, embedded software may have various potential vulnerabilities and security risks, which directly affect production efficiency and life safety. Fuzz testing, a technology that triggers potential vulnerabilities by inputting random or unexpected data into the system, has been widely used to discover vulnerabilities and security issues in embedded software. However, existing embedded fuzzers all use a random method to select mutation operators to generate fuzzy inputs, resulting in a large number of mutation operators that cannot discover new paths or new vulnerabilities being selected by the fuzzer, resulting in a large number of redundant and invalid inputs, resulting in low test efficiency. At present, there is still a lack of an efficient embedded software fuzz testing method. Summary of the invention
[0003] In order to overcome the problem of low efficiency in generating effective fuzzy inputs in current embedded software fuzz testing, the present invention provides an embedded software fuzz testing method and system based on fuzzy mutation operator competition, which significantly improves the efficiency, coverage and reliability of embedded software fuzz testing by introducing a competition mechanism and adaptive adjustment strategy of fuzzy mutation operators.
[0004] The technical solution adopted by the present invention to solve the technical problem is:
[0005] An embedded software fuzz testing method based on fuzzy mutation operator competition is described in detail as follows:
[0006] S1, perturbs different parts of the probability distribution of the mutation operator of the first generation parent by 1%, generating four probability distributions of the selection of offspring. The four offspring will be completely different due to the different probabilities of the mutation of the parent and the perturbation probabilities. Five completely different selection probability distributions provide a large search space for exploring the optimal selection probability distribution.
[0007] S2, the mutation scheduler selects mutation operators belonging to the parent and child generations respectively according to the probability distribution of the parent and child generations, and applies these mutation operators to the fuzzy inputs selected by the same fuzzifier from the fuzzy input sequence to obtain the mutated fuzzy inputs belonging to the parent and child generations respectively.
[0008] S3, the fuzzer puts all mutation fuzzy inputs into the program to be tested and passes the path explored or the crash information triggered by each mutation fuzzy input to the mutation scheduler. The mutation scheduler calculates and compares the evolutionary fitness of each selection probability distribution based on this feedback information, selects the selection probability distribution with the highest evolutionary fitness, and makes it the parent selection probability distribution of the next iteration.
[0009] S4 uses a hash table to record the original input, length of the original input, and mutation type of the mutation fuzzing input that discovers new paths or triggers the crash of the program under test. The hash table is then regarded as a mutation operator in the mutation scheduler, so that subsequent iterations can reuse the previously effective mutation strategy.
[0010] The beneficial effects of the present invention include:
[0011] The present invention utilizes mutation operators to conduct internal competition on their own and dynamically adjusts the selection probability distribution of mutation operators, thereby increasing the selection probability of mutation operators with high potential for discovering new paths or more capable of triggering the crash of the program to be tested, and reducing the selection probability of mutation operators that are not easy to discover new paths or difficult to trigger program crashes; the time for finding the optimal selection probability distribution is shortened and the required prior knowledge is reduced, thereby enhancing the effectiveness of fuzzy testing.
[0012] The present invention saves the relevant information of the mutation fuzzy input that has discovered a new path or triggered the crash of the program to be tested in a hash table during the fuzz testing process, and regards this hash table as a mutation operator in a mutation scheduler for use in subsequent iterations or similar or series of embedded software fuzz tests, thereby improving the execution speed of the fuzz test and the ability to discover potential software vulnerabilities, and more efficiently generating effective fuzzy inputs. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 This is a flow chart of the embedded software fuzz testing method based on fuzzy mutation operator competition;
[0014] Figure 2 This is a specific structure diagram of the hash table. DETAILED DESCRIPTION
[0015] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0016] In addition, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0017] The present invention discloses an embedded software fuzzy testing method based on fuzzy mutation operator competition, which makes full use of mutation operators to conduct internal competition, dynamically adjusts the selection probability distribution of mutation operators, and improves the selection probability of mutation operators with high potential to discover new paths or trigger the crash of the program to be tested. The time to find the optimal selection probability distribution is shortened and the required prior knowledge is reduced. At the same time, a hash table is used to save the relevant information of the fuzzy input that discovers new paths or triggers the crash of the program to be tested in real time, and then the hash table is regarded as an independent mutation operator in the mutation scheduler, so that subsequent iterations or fuzzy tests can reuse effective mutation strategies. By continuously repeating the above test and optimization process, a more efficient embedded software fuzzy test is achieved.
[0018] Example 1
[0019] This embodiment provides an embedded software fuzzy testing method based on fuzzy mutation operator competition. Figure 1 As shown, the following steps are included:
[0020] Step 1: Set the initial selection probability distribution of the mutation operator in the mutation scheduler to a uniform distribution with a total probability of 1, then regard the selection probability distribution of the initial mutation operator as the parent generation, and slightly perturb the parent generation selection probability distribution to generate 4 child generation selection probability distributions;
[0021] The parent selection probability distribution is slightly perturbed, as follows: the mutation scheduler randomly perturbs the selection probability of a part of the mutation operators within the range of ±1%, and the sum of the selection probabilities of all mutation operators remains 1, resulting in 4 offspring selection probability distributions that are different from the parent selection probability distribution; at the same time, the 4 offspring selection probability distributions will also be different because different parts or different numbers of mutation operators have been modified, that is, the total of 5 selection probability distributions of the parent and offspring are different.
[0022] Step 2: The fuzzifier randomly selects an initial fuzzy input from the fuzzy input sequence. The mutation scheduler selects a mutation operator according to the selection probability distribution of the parent and child generations, and applies it to the selected initial fuzzy input to obtain the mutation fuzzy input belonging to the parent and child generations respectively.
[0023] Step 3: The fuzzer puts the mutation fuzzy input into the program to be tested and feeds back the test results to the mutation scheduler. The mutation scheduler calculates the evolutionary fitness of the parent and child generations based on the feedback information and selects a new parent generation based on the evolutionary fitness. The calculation formula for evolutionary fitness is as follows:
[0024]
[0025] Where f is the evolutionary fitness, and U is the number of new paths found in the program under test by a mutation fuzzy input.
[0026] Step 3 includes:
[0027] Step 3.1, after the fuzzifier obtains the mutation fuzzy input, it puts it into the program to be tested for testing, and records the new path discovered by each mutation fuzzy input in real time, preparing the basis for the subsequent evolutionary fitness calculation;
[0028] Step 3.2, when the program to be tested finishes executing the mutation fuzzy input belonging to a certain selection probability distribution, the fuzzifier passes the new path information found by the mutation fuzzy input to the mutation scheduler, and the mutation scheduler calculates the evolutionary fitness of the selection probability distribution and compares it with the original evolutionary fitness of the selection probability distribution. If it is higher than the original evolutionary fitness, the evolutionary fitness is updated; if it is lower than the original evolutionary fitness, the original evolutionary fitness is maintained;
[0029] Step 3.3, compare the evolutionary fitness of the parent and offspring at this time, the one with higher evolutionary fitness becomes the parent of the next iteration, and delete all selection probability distributions with low evolutionary fitness.
[0030] Step 4: Save the new paths discovered by the mutation fuzzy input or the relevant information of the input that triggers the crash of the program under test in a hash table, and treat the hash table as an independent mutation operator in the mutation scheduler; this allows subsequent iterations or fuzz tests to directly use effective mutation strategies and improve the execution speed of fuzz testing.
[0031] Step 4 includes:
[0032] Step 4.1, the mutation scheduler calculates the hash index based on the original input of the mutation fuzzy input, and then searches the directory node in the index to find the same original input a and the original input length L; if it cannot be found, a new directory node will be added to the end of the index; then it will search for a mutation strategy node with the same mutation type T and the mutated output b under the same directory node; if the same mutation strategy node is successfully found, the number of uses of the mutation strategy node will be increased by 1 and the selection probability of the mutation strategy node will be updated according to the selection probability calculation formula; if no qualified mutation strategy node is found, a new mutation strategy node will be added to store the mutated output b, mutation type T and number of uses F (initial value is 1);
[0033] Step 4.2, if the hash table is selected by the mutation scheduler as the mutation operator to mutate the original input, the mutation scheduler will calculate the hash index, and then search for the same directory node in the index based on the original input a and the original input length L, and then select the mutation strategy based on the selection probability p in the mutation strategy node under the directory node; if the directory node cannot be found, a mutation strategy of a mutation strategy node under a directory node with the same original input length L will be randomly selected;
[0034] The selection probability calculation formula of the mutation strategy is as follows:
[0035]
[0036] Where p is the probability of selecting a mutation strategy under the same original input length, the total selection probability is normalized, and F is the number of times a mutation strategy is used under the same original input length.
[0037] Step 4.3, mutate the initial fuzzy input according to the selected mutation strategy, and increase the number of times the mutation strategy is used by 1. At the same time, update the selection probability of the mutation strategy according to the selection probability calculation formula of the mutation strategy.
[0038] Step 5: Repeat steps 1 to 4 to continuously optimize and adjust the selection probability distribution of mutation operators, and use effective mutation strategies from historical experiments to achieve more efficient embedded software fuzz testing.
[0039] Based on the above method, the selection probability distribution of mutation operators is dynamically adjusted through a competition mechanism, so that mutation operators that can discover more new paths or trigger program crashes have a higher selection probability, thereby improving the pertinence and efficiency of the test. By continuously iterating and optimizing the selection probability distribution of mutation operators, the test can explore more program paths, thereby improving the test coverage and helping to discover more potential errors and vulnerabilities. By recording the discovered paths and the input information that triggers the crash through a hash table, repeated testing of the same path or input is avoided, thereby reducing test time and resource consumption. The performance of the mutation operator is evaluated by calculating the evolutionary fitness, making the evaluation of the test results more objective and reliable.
[0040] Example 2
[0041] An embedded software fuzzy testing system based on fuzzy mutation operator competition is provided, which is used to implement the method in embodiment 1, including:
[0042] A mutation scheduler, including mutation operators, is used to select mutation operators and apply them to the initial fuzzy input, as well as to calculate the evolutionary fitness and dynamically adjust the selection probability distribution of mutation operators;
[0043] A fuzzifier is used to randomly select an initial fuzzy input from the fuzzy input sequence, and to put the mutation fuzzy input obtained by the mutation scheduler into the program to be tested for testing, and feed back the test result to the mutation scheduler;
[0044] A selection probability distribution adjustment module is used to slightly perturb the selection probability distribution of the initial mutation operator;
[0045] An evolutionary fitness calculation module is used to calculate the evolutionary fitness of each selection probability distribution according to the mutation fuzzy input test results;
[0046] The selection probability update module is used to update the selection probability of the search results of the mutation strategy according to the hash index.
[0047] An electronic device is also provided, comprising a memory, a processor and a computer program stored and running on the memory, wherein the processor implements the embedded software fuzzy testing method based on fuzzy mutation operator competition when executing the program.
[0048] A computer-readable storage medium is also provided, on which a computer program is stored. When the program is executed by a processor, the embedded software fuzzy testing method based on fuzzy mutation operator competition is implemented.
[0049] Since all the technical solutions of all the aforementioned embodiments are adopted when the fuzz test program is executed by the processor, it has at least all the beneficial effects brought by all the technical solutions of all the aforementioned embodiments, which will not be described one by one here.
[0050] Obviously, the above embodiments are merely examples for the purpose of clear explanation, and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the invention.
Claims
1. A fuzzy testing method for embedded software based on fuzzy mutation operator competition, It is characterized in that The following steps are involved: Step 1: Set the initial selection probability distribution of the mutation operator in the mutation scheduler to a uniform distribution with a total probability of 1, then regard the selection probability distribution of the initial mutation operator as the parent generation, and slightly perturb the parent generation selection probability distribution to generate 4 child generation selection probability distributions; Step 2: The fuzzifier randomly selects an initial fuzzy input from the fuzzy input sequence. The mutation scheduler selects a mutation operator according to the selection probability distribution of the parent and child generations, and applies it to the selected initial fuzzy input to obtain the mutation fuzzy input belonging to the parent and child generations respectively. Step 3: The fuzzer puts the mutation fuzzy input into the program to be tested and feeds back the test results to the mutation scheduler. The mutation scheduler calculates the evolutionary fitness of the parent and child generations based on the feedback information and selects a new parent generation based on the evolutionary fitness. Step 4: Save the new paths discovered by the mutation fuzzy input or the information about the input that triggers the crash of the program under test in a hash table, and treat the hash table as an independent mutation operator in the mutation scheduler; Step 5: Repeat steps 1 to 4 continuously.
2. The embedded software fuzz testing method based on fuzzy mutation operator competition according to claim 1, It is characterized in that The parent selection probability distribution is slightly perturbed as described in step 1, as follows: the mutation scheduler randomly perturbs the selection probability of a part of the mutation operators within the range of ±1%, and the sum of the selection probabilities of all mutation operators remains 1, generating 4 offspring selection probability distributions that are partially different from the parent selection probability distribution; a total of 5 selection probability distributions of the parent and offspring are different.
3. The embedded software fuzz testing method based on fuzzy mutation operator competition according to claim 1, It is characterized in that The calculation formula of the evolutionary fitness in step S3 is as follows: Where f is the evolutionary fitness, and U is the number of new paths found in the program under test by a mutation fuzzy input.
4. The embedded software fuzz testing method based on fuzzy mutation operator competition according to claim 1 or 3, It is characterized in that The specific implementation method of step 3 is: Step 3.1, after the fuzzifier obtains the mutation fuzzy input, it puts it into the program to be tested for testing, and records the new path discovered by each mutation fuzzy input in real time, preparing the basis for the subsequent evolutionary fitness calculation; Step 3.2, when the program to be tested finishes executing the mutation fuzzy input belonging to a certain selection probability distribution, the fuzzifier passes the new path information found by the mutation fuzzy input to the mutation scheduler, and the mutation scheduler calculates the evolutionary fitness of the selection probability distribution and compares it with the original evolutionary fitness of the selection probability distribution. If it is higher than the original evolutionary fitness, the evolutionary fitness is updated; if it is lower than the original evolutionary fitness, the original evolutionary fitness is maintained; Step 3.3, compare the evolutionary fitness of the parent and offspring at this time, the one with higher evolutionary fitness becomes the parent of the next iteration, and delete all selection probability distributions with low evolutionary fitness.
5. The embedded software fuzz testing method based on fuzzy mutation operator competition according to claim 1, It is characterized in that The specific implementation method of step 4 is: Step 4.1, the mutation scheduler calculates the hash index based on the original input of the mutation fuzzy input, and then searches the directory node in the index to find the same original input a and the original input length L; if it cannot be found, a new directory node will be added to the end of the index; then it will search for a mutation strategy node with the same mutation type T and mutated output b under the same directory node; if the same mutation strategy node is successfully found, the number of uses of the mutation strategy node is increased by 1 and the selection probability of the mutation strategy node is updated; if no qualified mutation strategy node is found, a new mutation strategy node will be added to store the mutated output b, mutation type T and number of uses F; Step 4.2, if the hash table is selected by the mutation scheduler as the mutation operator to mutate the original input, the mutation scheduler will calculate the hash index, and then search for the same directory node in the index based on the original input a and the original input length L, and then select the mutation strategy based on the selection probability p in the mutation strategy node under the directory node; if the directory node cannot be found, a mutation strategy of a mutation strategy node under a directory node with the same original input length L will be randomly selected; Step 4.3, mutate the initial fuzzy input according to the selected mutation strategy, and increase the number of times the mutation strategy is used by 1, and update the selection probability of the mutation strategy.
6. The embedded software fuzz testing method based on fuzzy mutation operator competition according to claim 5, It is characterized in that The selection probability of the mutation strategy is calculated according to the following formula: Where p is the probability of selecting a mutation strategy under the same original input length, the total selection probability is normalized, and F is the number of times a mutation strategy is used under the same original input length.
7. An embedded software fuzzy testing system based on fuzzy mutation operator competition, used to implement the method described in any one of claims 1 to 6, It is characterized in that include: A mutation scheduler, including mutation operators, is used to select mutation operators and apply them to the initial fuzzy input, as well as to calculate the evolutionary fitness and dynamically adjust the selection probability distribution of mutation operators; A fuzzifier is used to randomly select an initial fuzzy input from the fuzzy input sequence, and to put the mutation fuzzy input obtained by the mutation scheduler into the program to be tested for testing, and feed back the test result to the mutation scheduler; A selection probability distribution adjustment module is used to slightly perturb the selection probability distribution of the initial mutation operator; An evolutionary fitness calculation module is used to calculate the evolutionary fitness of each selection probability distribution according to the mutation fuzzy input test results; The selection probability update module is used to update the selection probability of the search results of the mutation strategy according to the hash index.
8. An electronic device comprising a memory, a processor and a computer program stored and executed on the memory, It is characterized in that When the processor executes the program, the embedded software fuzzy testing method based on fuzzy mutation operator competition is implemented.
9. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the embedded software fuzzy testing method based on fuzzy mutation operator competition is implemented.
