A runtime vulnerability detection method and system based on fuzz testing
By conducting validity analysis and fuzz testing on the WebAssembly source program, and using the Metropolis-Hastings algorithm and mutation operators to generate non-equivalent variants, the stability and stability of WebAssembly vulnerability detection in the existing technology are solved. To solve the problem of low accuracy, efficient vulnerability detection is achieved.
Patent Information
- Application Number
- CN202210548927.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-20
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2042-05-20
AI Technical Summary
Existing WebAssembly vulnerability detection technology suffers from poor stability and low accuracy. This is mainly due to the lack of effective syntax structure analysis and automated testing infrastructure, resulting in low coverage of generated test cases and difficulty in detecting deep-seated vulnerabilities at runtime.
A runtime vulnerability detection method based on fuzz testing is adopted to generate a target program with high coverage through effectiveness analysis and processing of the source program, and the Metropolis-Hastings algorithm and mutation operator are used to test the program. Mutation processing generates non-equivalent variants and identifies vulnerabilities through comparison at different runs.
It improves the stability and accuracy of vulnerability detection in the WebAssembly operating environment, can effectively detect runtime vulnerabilities, avoids interference in high-level language compiler implementation, and enhances the quality and branch coverage of test cases.
Smart Images

Figure CN115080978B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to a runtime vulnerability detection method and system based on fuzzy testing. Background Art
[0002] At present, the performance requirements of web applications are gradually increasing. However, due to the limitations of dynamic scripting languages such as JavaScript, the operation of applications has encountered serious performance bottlenecks. Therefore, many browser manufacturers first proposed WebAssembly technology (Wasm for short) in 2015 to solve performance problems. WebAssembly is a new binary format with small running size, high loading efficiency, strong portability and good Web compatibility. It can easily run the code of low-level languages such as C, C++, Rust and other high-level languages in local client environments such as browsers with the native performance of hardware, bringing performance innovation to the operation of web applications. Now there are many implementations of WebAssembly runtime environment in the field of WebAssembly technology, which can be roughly divided into two types: local virtual machine implementation, such as WAVM, wasm3, wasmer; browser implementation, such as the built-in WebAssembly runtime environment implementation of mainstream browsers such as Chrome and Firefox. However, multiple implementations of the runtime environment may trigger behavioral inconsistencies and related vulnerabilities, thereby bringing security risks. Therefore, applying testing methods to detect vulnerabilities in the WebAssembly runtime environment is an important topic in the field of WebAssembly technology today.
[0003] However, the current implementation of WebAssembly vulnerability detection technology has multiple defects, which leads to poor stability and low accuracy of vulnerability detection in the WebAssembly runtime environment.
[0004] Therefore, the existing technology still needs to be improved and developed. Summary of the invention
[0005] The technical problem to be solved by the present invention is that, in view of the above-mentioned defects of the prior art, a runtime vulnerability detection method based on fuzzy testing is provided, which aims to solve the problem that the implementation scheme of the vulnerability detection technology of WebAssembly in the prior art has multiple defects, resulting in poor stability and low accuracy of vulnerability detection in the WebAssembly running environment.
[0006] The technical solution adopted by the present invention to solve the problem is as follows:
[0007] In a first aspect, an embodiment of the present invention provides a runtime vulnerability detection method based on fuzz testing, wherein the method comprises:
[0008] Acquire a number of source programs, and perform validity analysis on the source programs to obtain a number of target programs;
[0009] Based on a preset algorithm, a plurality of the target programs are mutated to obtain a plurality of first program variants, validity analysis is performed on the plurality of the first program variants to obtain a plurality of non-equivalent variants, and a test program set is obtained based on the plurality of non-equivalent variants and the plurality of the target programs;
[0010] According to the test program set and several preset runtimes, several running results corresponding to the test program set are obtained, and the several running results are analyzed to determine the vulnerabilities of the several runtimes; wherein the runtime is used to characterize the carrier of program running.
[0011] In one implementation, performing validity analysis on the plurality of source programs to obtain a plurality of target programs includes:
[0012] Repeat the steps of performing static analysis on the source programs to obtain the first programs, detecting the code coverage of the first programs, and generating the input parameters; wherein the input parameters are used to characterize the test cases; and the input parameters constitute an input parameter set;
[0013] When the plurality of first programs detected by code coverage meet a preset condition, the step of performing static analysis on the plurality of source programs is stopped, and the plurality of first programs meeting the condition are used as a plurality of target programs, wherein each of the target programs corresponds to an input parameter set;
[0014] For each of the target programs, the target program is compiled and plugged, and based on the reference runtime, the compiled and plugged target program is run to obtain a first tracking file corresponding to each of the target programs; wherein the reference runtime is one of the several runtimes; and the first tracking file is a file that records the running order of the plugged program.
[0015] In one implementation, the step of performing mutation processing on the target programs based on a preset algorithm to obtain the first program variants includes:
[0016] Get the initial time value;
[0017] Randomly obtain a random number within a preset range;
[0018] Randomly selecting a first mutation operator from a preset mutation operator set based on priority, and obtaining an index value of the first mutation operator;
[0019] Randomly selecting a first target program from among the plurality of target programs;
[0020] Randomly selecting a second mutation operator from a preset mutation operator set based on the priority, and obtaining an index value of the second mutation operator;
[0021] Based on a preset Metropolis-Hastings algorithm formula, a reception probability value is obtained according to the index value of the first mutation operator, the index value of the second mutation operator and the first target program; wherein the reception probability value is used to characterize the probability of a reception function;
[0022] For each of the target programs; when the received probability value is greater than or equal to the random number, the second mutation operator is used to mutate each of the target programs to obtain a number of first program variants corresponding to each of the target programs; wherein the input parameter sets of the several first program variants are the same as the input parameter sets of each of the target programs.
[0023] In one implementation, the method based on the preset Metropolis-Hastings algorithm formula, after obtaining the reception probability value according to the index value of the first mutation operator, the index value of the second mutation operator and the first target program, further includes:
[0024] When the receiving probability value is less than the random number, continue to execute the steps of randomly selecting a second mutation operator based on the priority in the preset mutation operator set and obtaining the index value of the second mutation operator.
[0025] In one implementation, performing validity analysis on the plurality of first program variants to obtain a plurality of non-equivalent variants, and obtaining a test program set according to the plurality of non-equivalent variants and the plurality of target programs comprises:
[0026] storing a plurality of said target programs into said test program set;
[0027] For each of the first program variants, compile and insert the first program variant to obtain a second program variant corresponding to each of the first program variants, and run the second program variant based on the reference runtime to obtain a second tracking file corresponding to each of the first program variants, when the second tracking file is different from the first tracking file, take the first program variant corresponding to the second tracking file as a non-equivalent variant, add the non-equivalent variant to the test program set, increase the index value of the second mutation operator by 1, and sort the mutation operators in the mutation operator set from high to low according to priority, wherein the input parameter set of the second program variant is the same as the input parameter set of each of the first program variants;
[0028] Obtaining an intermediate time value, and subtracting the initial time value from the intermediate time value to obtain a time difference;
[0029] When the time difference is less than a preset maximum time threshold, repeatedly executing the step of randomly selecting a first target program from the plurality of target programs;
[0030] When the time difference is equal to the maximum time threshold, the test program set is output.
[0031] In one implementation, the plurality of runtimes include a first runtime, a second runtime, and a third runtime; and obtaining, according to the test program set and the plurality of preset runtimes, a plurality of operation results corresponding to the test program set includes:
[0032] Inputting the test program set into a first runtime for execution, and outputting a first execution result through the first runtime;
[0033] Compiling the test programs in the test program set;
[0034] Inputting the compiled test program set into a second runtime to execute the test program, thereby obtaining a second execution result;
[0035] The compiled test program set is input into the third runtime for execution to obtain a third execution result.
[0036] In one implementation, analyzing the plurality of running results to determine the plurality of running vulnerabilities includes:
[0037] When the second operation result is different from the first operation result, determining that a vulnerability exists in the second operation, and outputting the vulnerability;
[0038] When the third operation result is different from the first operation result, determining that a vulnerability exists in the third operation, and outputting the vulnerability;
[0039] When the second operation result is different from the third operation result, a vulnerability identification result of a preset person is obtained, and when the vulnerability identification result is that a vulnerability exists, the vulnerability is output.
[0040] In a second aspect, an embodiment of the present invention further provides a runtime vulnerability detection system based on fuzz testing, wherein the system comprises: a target program acquisition module, used to acquire a plurality of source programs, and perform validity analysis processing on the plurality of source programs to obtain a plurality of target programs;
[0041] A program mutation module, used for performing mutation processing on the target programs based on a preset algorithm to obtain a plurality of first program variants, performing validity analysis on the first program variants to obtain a plurality of non-equivalent variants, and obtaining a test program set based on the non-equivalent variants and the target programs;
[0042] A vulnerability determination module is used to obtain a number of operation results corresponding to the test program set based on the test program set and a number of preset runtimes, analyze the several operation results, and determine the vulnerabilities of the several runtimes; wherein the runtime is used to characterize the carrier of program operation.
[0043] In a third aspect, an embodiment of the present invention further provides an intelligent terminal, comprising a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, including a program for executing a runtime vulnerability detection method based on fuzz testing as described in any one of the above.
[0044] In a fourth aspect, an embodiment of the present invention further provides a non-temporary computer-readable storage medium, which, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute a runtime vulnerability detection method based on fuzzy testing as described in any one of the above.
[0045] Beneficial effects of the present invention: The embodiment of the present invention first obtains a number of source programs, and performs validity analysis on the source programs to obtain a number of target programs; then, based on a preset algorithm, the target programs are mutated to obtain a number of first program variants, and validity analysis is performed on the first program variants to obtain a number of non-equivalent variants, and a test program set is obtained according to the non-equivalent variants and the target programs; finally, according to the test program set and a number of preset runtimes, a number of running results corresponding to the test program set are obtained, and the running results are analyzed to determine the vulnerabilities of the runtimes; wherein the runtime is used to characterize the carrier of program running; it can be seen that the embodiment of the present invention performs validity analysis on the source program in the WebAssembly runtime environment to obtain a higher coverage rate of the target program, obtains multiple running results by inputting the mutated program into different runtimes, and determines the vulnerabilities by analyzing the multiple running results, thereby improving the detection stability and accuracy of the vulnerabilities. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0047] Figure 1 A schematic flow chart of a runtime vulnerability detection method based on fuzzy testing provided in an embodiment of the present invention.
[0048] Figure 2 A schematic diagram of the overall test process provided by an embodiment of the present invention.
[0049] Figure 3 A flowchart of a mutation algorithm provided by an embodiment of the present invention.
[0050] Figure 4 A flowchart of a variation test provided by an embodiment of the present invention.
[0051] Figure 5 A functional block diagram of a runtime vulnerability detection system based on fuzzy testing provided by an embodiment of the present invention.
[0052] Figure 6 This is a block diagram of the internal structure principle of the intelligent terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0053] The present invention discloses a runtime vulnerability detection method and system based on fuzzy testing. In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0054] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.
[0055] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as generally understood by those skilled in the art in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as herein.
[0056] Because the existing software testing system has a relatively good technical background for solving the vulnerability detection problem of WebAssembly in the prior art. The existing software testing system has many technical categories, such as fuzz testing that discovers software vulnerabilities by providing unexpected inputs to the target system and monitoring abnormal results, metamorphic testing that can solve the problem of difficult-to-build test predictions, mutation testing based on well-defined improved program source code, etc., which provide possibilities for vulnerability detection in the WebAssembly operating environment. In addition, the existing software technology provides more technical support for the development of automatic vulnerability detection of WebAssembly, such as relatively complete automated testing tools or algorithms based on other virtual machines such as JVM, gray box testing tools based on AFL and its extensions, syntax structure analysis tools for source programs based on abstract syntax tree matching algorithms, and fuzzy testing vulnerability mining tools based on coverage, etc.
[0057] The implementation scheme for vulnerability detection of WebAssembly mainly applies random mutation strategies at the bit level, such as reversing, adding or deleting specific bits to form variants. This method can detect certain runtime inconsistencies under certain circumstances, but it still has many shortcomings. First, the bit-oriented operations in the existing implementation scheme are too low-level, and because the WebAssembly binary file needs to comply with a strict format, the formed variants cannot pass the bytecode verification of the virtual machine at the initial stage of operation, and it is difficult to trigger the behavior inconsistency that occurs during the execution of the virtual machine; secondly, the existing implementation scheme lacks grammatical structure analysis of the binary format of WebAssembly, resulting in the automatic generation of test cases that easily make the function call and the original function declaration mismatch, and do not conform to the corresponding call interface, making the mutation invalid and generating a large number of invalid variants; thirdly, the bit-oriented operation is not easy to effectively increase the branch coverage in the implementation of the WebAssembly runtime environment, and it is difficult to detect the corresponding vulnerabilities in the WebAssembly runtime environment.
[0058] In order to solve the problems of the prior art, this embodiment provides a runtime vulnerability detection method based on fuzz testing. Through the above method, the coverage of the target program obtained by performing validity analysis on the source program in the WebAssembly runtime environment is higher, and multiple running results are obtained by inputting the mutated program into different runtimes. The vulnerability is determined by analyzing the multiple running results, thereby improving the stability and accuracy of vulnerability detection. In specific implementation, first obtain a number of source programs, and perform validity analysis on the several source programs to obtain a number of target programs; then, based on a preset algorithm, mutate the several target programs to obtain a number of first program variants, and according to the several first program variants and several preset runtimes, obtain a number of running results corresponding to the several first program variants; wherein the runtime is used to characterize the carrier of program operation; finally, analyze the several running results to determine the vulnerabilities of the several runtimes.
[0059] Example
[0060] WebAssembly runtime implementations are divided into virtual machines and browsers. For example, virtual machine implementations include WAVM, wasmer, etc., and browser implementations include mainstream browsers such as Chrome, Edge, etc., which provide internal implementation support for the runtime environment. There are many differences in their support for WebAssembly applications. For example, in terms of support for large-scale automated testing, compared to the browser environment, WebAssembly does not require JS glue files for bridging when running in the local virtual machine, so large-scale automated testing of the WebAssembly runtime environment is easier to implement on the virtual machine; in terms of restrictions on the runtime environment, since the browser runtime environment has a sandboxed security isolation mechanism, WebAssembly programs cannot access the local file system when executed on the browser, etc. These factors may lead to inconsistent behaviors in different runtimes for the same WebAssembly source program.
[0061] The existing runtime vulnerability detection technology has not yet had a corresponding complete framework support in the WebAssembly runtime field. For example, the Java virtual machine, which also runs binary bytecode files, has a coverage-based framework technology support for fuzz testing and differential testing, but there is no such complete technical background in the WebAssembly runtime. There are two main aspects of the lack of technical background. On the one hand, there are imperfections in the automated testing infrastructure, and on the other hand, there are deficiencies in targeted upper-level algorithms. Among them, the former includes test case analysis, automatic generation, large-scale operation, output result comparison, etc.; for the latter, there are scholars who have proposed the metamorphosis relationship EMI for high-level language optimization, and there are bytecode mutation schemes based on random Markov chains for JVM languages. These technical deficiencies are all technical challenges solved by the present invention.
[0062] For some WebAssembly programs compiled from high-level languages, their behavior may be related to the specific implementation of the compiler and may have undefined behavior, thereby triggering behavioral inconsistencies and runtime-related vulnerabilities.
[0063] Considering that it is difficult to directly perform syntax analysis, coverage detection and effective mutation on the binary files of WebAssembly programs, the traditional bit-oriented low-level mutation strategy to generate test cases is not an efficient solution.
[0064] Exemplary Methods
[0065] This embodiment provides a runtime vulnerability detection method based on fuzz testing, which can be applied to smart terminals for software testing. Figure 1 As shown, the method includes:
[0066] Step S100, obtaining a plurality of source programs, and performing validity analysis on the plurality of source programs to obtain a plurality of target programs;
[0067] Specifically, although there are decompilation tools for WebAssembly binary format files, the complete analysis of information such as the semantics and behavior of the code has not yet been fully supported. This brings technical difficulties to the vulnerability detection of WebAssembly runtime. For example, in the absence of grammatical structure information, the automatically generated test cases are not easy to match the interface parameters provided by the WebAssembly program, which makes the test cases invalid; in the absence of grammatical structure information, the detection of branch coverage is insufficient when generating test cases, and the test cases have poor coverage of branches in the code, etc. These problems caused by the lack of file semantic analysis have brought inconvenience to the efficient vulnerability detection of automated testing. In other words, it is difficult for developers to generate reliable and high-coverage test files, that is, source programs, through test tools, and thus it is impossible to detect the corresponding deep-level vulnerabilities in the specific implementation of the WebAssembly runtime environment. Therefore, after obtaining several source programs, the present invention performs validity analysis on the several source programs, so that the target program after the validity analysis has higher reliability and high coverage. In this embodiment, several source programs select a relatively popular C program set in GitHub. After coverage processing, good input parameter type information and branch information are provided for the test file of the WebAssembly program, which solves the problem of easy error in parameter type and effectively improves branch coverage.
[0068] In step S100, the validity analysis of the plurality of source programs to obtain a plurality of target programs includes the following steps: repeatedly performing static analysis on the plurality of source programs to obtain a plurality of first programs, performing the step of detecting the code coverage of the plurality of first programs, and generating a plurality of input parameters; wherein the input parameters are used to characterize test cases; the plurality of input parameters constitute an input parameter set; when the plurality of first programs that have passed the code coverage detection meet preset conditions, the step of performing static analysis on the plurality of source programs is stopped, and the plurality of first programs that meet the conditions are used as a plurality of target programs, wherein each of the target programs corresponds to an input parameter set; for each of the target programs, the target program is compiled and plugged, and based on the reference runtime, the compiled and plugged target program is run to obtain a first tracking file corresponding to each of the target programs; wherein the reference runtime is one of the plurality of runtimes; and the first tracking file is a file that records the running order of the plugged program.
[0069] In this embodiment, the vulnerability detection effect of the WebAssembly operating environment depends largely on the quality of the generated test cases. In order to generate high-quality test cases, a stable and reliable automated testing technology guarantee is required. The existing automated testing technology has a relatively mature implementation at the level of high-level languages such as C language, and has more tool support. Therefore, we transfer the mutation level from the relatively low-level WebAssembly program level to the C language level. Static analysis of several of the C programs: The present invention applies an automated analysis parameter tool, that is, a tool for automated analysis of C programs. We use the Clang compiler to perform an abstract syntax tree (AST) analysis on the function calls of the source program, which can effectively analyze the entry and grammatical structure of the C language program, so that the subsequently generated WebAssembly binary file can comply with a strict format, and analyze the grammatical structure of the binary format of WebAssembly, so that the automatically generated source program can match the function call with the original function declaration. For example: extract the function signature to determine the received input parameter type (such as integer int, floating point float / double) in the source program function, and then randomly construct parameters according to the input parameter type and nest them in the function body, which is equivalent to calling the function, so as to obtain the preprocessed function. In view of the different running modes of the browser and the local virtual machine, the present invention adds a main function entry to the processed program, such as using the int main() main function to call our processed function. The file without the main function entry is the WebAssembly receiving file of the browser, and the file with the main function entry is the receiving file of the local virtual machine. Then, the WebAssembly compiler is used to compile them respectively (both the browser and the local virtual machine will use this WebAssembly compiler, the WebAssembly program used by the browser has no main function entry, and the WebAssembly program used by the local virtual machine has a main function entry). Figure 2 As shown. For the browser, the present invention generates corresponding HTML and JS glue files (to realize the interaction between the WebAssembly program and the upper-level language), and calling the corresponding command (http-server command to start the server) can make the local server automatically run the relevant program (start the server, then call selenium, start a WebDriver, and then access the corresponding JS glue file). An implementation example of the glue file is:
[0070]
[0071] After static analysis, multiple first programs will be obtained, and then the code coverage of several of the first programs will be detected by a code coverage detection tool; the code coverage detection tool is modified based on the existing C language code coverage detection tool (gcov) (gcov is automatically called by a script and the coverage results are analyzed to determine whether to retain the program input parameter). In practice, in addition to gcov and OpenCppCoverage, the code coverage tool may also be designed with the help of other tools, which are not specifically limited. In this process, a large number of program input parameters are generated in order to obtain as many program input parameters as possible that can generate high code coverage. Code coverage is a measure of the degree of code coverage. It describes the proportion and degree of source code testing in a program. By detecting code coverage, the probability of executing each branch of the code can be increased. For example, when the condition a=1 is satisfied, a branch statement is executed (such as s=s+1); when the condition a=2 is satisfied, another branch statement is executed (such as s=3*6); at this time, if the input condition is changed to a>=1, then when the conditions a=1 and a=2 are satisfied at the same time, two branch statements (s=s+1) and (s=3*6) will be executed at the same time. At this time, the code coverage is increased, which is beneficial to the accuracy of subsequent vulnerability detection. In the case where the preset conditions are not met, the steps of statically analyzing the source programs to obtain the first programs, detecting the code coverage of the first programs, and generating the input parameters are repeated. When the execution times of the first programs detected by the code coverage meet the preset conditions (the preset number of iterations is 10,000 times), the iteration is stopped. At this time, the coverage of the first programs may be 50% or 80%. These first programs are used as target programs. At the same time, each target program corresponds to an input parameter set. In this embodiment, the target program is a C language program. For each C language program, the C language program is compiled to obtain a WebAssembly program. Then, the WebAssembly program is plugged and run on a reference runtime (such as wasmer) to obtain a first tracking file. The tracking file is a file that records the running order of the plugged program. Since we have plugged after each instruction of the compiled WebAssembly program, when running this program on wasmer, we can easily get its instruction running order. We save this order in the tracking file. Instrumentation is a method of inserting some probes into the program on the basis of ensuring the original logical integrity of the program under test (also called "detectors", which are essentially code segments for information collection, which can be assignment statements or function calls for collecting coverage information). The probes are executed and characteristic data of the program's running is thrown out. By analyzing these data, the control flow and data flow information of the program can be obtained, and then dynamic information such as logic coverage can be obtained, thereby achieving the purpose of testing.
[0072] After getting the target program, you can execute Figure 1 The following steps are shown: S200, based on a preset algorithm, performing mutation processing on a plurality of the target programs to obtain a plurality of first program variants, performing validity analysis on the plurality of the first program variants to obtain a plurality of non-equivalent variants, and obtaining a test program set based on the plurality of the non-equivalent variants and the plurality of the target programs;
[0073] Specifically, the preset algorithm may be the Metropolis algorithm, or a probability distribution function other than geometric distribution may be used, and the runtime may be the browser runtime or the local virtual machine runtime. A mutation operator may be selected according to the preset algorithm to perform mutation processing on the target program to obtain a number of first program variants, or the target programs may be output to the preset algorithm to obtain a number of first program variants; then, validity analysis may be performed on the first program variants to obtain equivalent variants and non-equivalent variants. Equivalent variants are not valid variants, so they should be discarded, and non-equivalent variants are valid variants, so they should be retained, and then the generated non-equivalent variants may be added to the target programs to obtain an extended target program, that is, a test program set.
[0074] In step S200, the step of performing mutation processing on the target programs based on a preset algorithm to obtain the first program variants includes the following steps: obtaining an initial time value; randomly obtaining a random number within a preset range; randomly selecting a first mutation operator based on priority in a preset mutation operator set, and obtaining an index value of the first mutation operator; randomly selecting a first target program from the target programs; randomly selecting a second mutation operator based on priority in a preset mutation operator set, and obtaining an index value of the second mutation operator; obtaining a reception probability value based on the index value of the first mutation operator, the index value of the second mutation operator and the first target program according to a preset Metropolis-Hastings algorithm formula; wherein the reception probability value is used to characterize the probability of a reception function; for each target program, when the reception probability value is greater than or equal to the random number, using the second mutation operator to mutate each target program to obtain the first program variants corresponding to each target program; wherein the input parameter set of the first program variants is the same as the input parameter set of each target program.
[0075] Specifically, the preset maximum time threshold can be set to 60 seconds. During the execution of the Metropolis-Hastings algorithm, a countdown calculation is performed for 60 seconds, that is, an initial time value is obtained. Later, during the execution of the Metropolis-Hastings algorithm, an intermediate time value is obtained. When the time difference between the intermediate time value and the initial time value is less than the maximum time threshold, the system will continue to execute the Metropolis-Hastings algorithm. In this embodiment, the mutation operator uses 22 mutation operators first defined by Offutt and King in 1987 for Fortran77 based on existing research work. The abbreviations and descriptions of these mutation operators are shown in Table 1: Mutation operators other than 22 can also be used, and there is no limitation here.
[0076] Table 1
[0077]
[0078]
[0079] In this embodiment, the random number in the preset range is a random number uniformly distributed in [0,1]. The Metropolis–Hastings algorithm is used to guide the selection of a single mutation operator. It is a Markov chain Monte Carlo algorithm used to extract a random sample sequence from a probability distribution when direct sampling is difficult. The basic idea is that the distribution of the next sample depends only on the current sample value (i.e., the Markov chain characteristic). The state is randomly generated from a distribution that is easy to sample and then the acceptance probability is calculated. If the calculated acceptance probability value is greater than a random number uniformly distributed in [0,1], the state transition is performed.
[0080] After the countdown calculation of the maximum time threshold is performed, when the time difference between the intermediate time value and the initial time value is less than the maximum time threshold, a first mutation operator is randomly selected from the preset mutation operator set based on the priority, and the index value of the first mutation operator is obtained as K1, and then a first target program is randomly selected from the plurality of target programs; then a second mutation operator is randomly selected from the preset mutation operator set based on the priority; and the index value of the second mutation operator is obtained as K2. The preset Metropolis-Hastings algorithm formula of the Metropolis-Hastings algorithm is (1-p) |K2-K1|, p is the probability of the second mutation operator mutating on the first target program, K2 is the index value of the second mutation operator, and K1 is the index value of the first mutation operator. In this way, the reception probability value can be obtained through the Metropolis-Hastings algorithm formula preset by the Metropolis-Hastings algorithm. For each of the target programs, when the reception probability value is greater than or equal to the random number, the second mutation operator is used to mutate several of the target programs to obtain several first program variants. When the reception probability value is less than the random number, continue to execute the steps of randomly selecting the second mutation operator based on the priority in the preset mutation operator set and obtaining the index value of the second mutation operator. For example: The present invention adds the Metropolis-Hastings algorithm to ordinary fuzzy testing. Because the mutation operator of the present invention is randomly distributed, Q(x'|x) = Q(x|x') (Q(x|x') refers to the probability of event x occurring when another event x' has occurred) is symmetrical. This is a special case of the Metropolis-Hastings algorithm, called the Metropolis algorithm. And by sorting by the calculated mutation success rate (i.e., discovering the inconsistency between runtimes), it is easier to trigger vulnerabilities. In the above algorithm, due to the symmetry of the previous paragraph, the acceptance distribution function is simplified to (A(x'|x) refers to the probability of the present invention accepting x' when event x occurs, P(x) refers to the probability of event x occurring, and min refers to the smaller value of the latter). The present invention uses geometric distribution as the probability distribution to guide the selection of mutation operators. Geometric distribution is the number of trials X required to obtain a success in a Bernoulli experiment. Its formula is: Pr(X=k)=(1-p) k-1 p, where Pr(X=1)=p (Pr(x=k) refers to the probability of event x=k occurring, and p is the probability of event x=1). Figure 3 As shown, a series of seed files (programs to be mutated), that is, the first target program, and a series of commonly used mutation operators (with the same priority, that is, the initial priority is 1) are loaded. Because the present invention does not know whether this source file (first target program) can generate a valid mutation file (program variant) through a limited number of mutations, in order to avoid this cycle taking up too much time, the present invention sets a maximum time length (60 seconds) and starts a countdown. Then, a file and a mutation operator are randomly selected. After the file and a mutation operator are selected, another mutation operator is continuously selected. Until the priority of the two mutation operators is calculated by the Metropolis algorithm formula to be greater than or equal to a random number in the range of 0 to 1, the second mutation operator is used to mutate each of the target programs to obtain multiple first program variants.
[0081] In step S200, the validity analysis is performed on the plurality of first program variants to obtain a plurality of non-equivalent variants, and the test program set is obtained according to the plurality of non-equivalent variants and the plurality of target programs, including the following steps: storing the plurality of target programs in the test program set; for each of the first program variants, compiling and plugging the first program variant to obtain a second program variant corresponding to each of the first program variants, and running the second program variant based on the reference runtime to obtain a second trace file corresponding to each of the first program variants, and when the second trace file is different from the first trace file, the second trace file is compiled. The first program variant corresponding to the tracking file is taken as a non-equivalent variant, the non-equivalent variant is added to the test program set, the index value of the second mutation operator is incremented by 1, and the mutation operators in the mutation operator set are sorted from high to low according to priority, wherein the input parameter set of the second program variant is the same as the input parameter set of each of the first program variants; the intermediate time value is obtained, and the initial time value is subtracted from the intermediate time value to obtain the time difference; when the time difference is less than a preset maximum time threshold, the step of randomly selecting a first target program from several target programs is repeated; when the time difference is equal to the maximum time threshold, the test program set is output.
[0082] Specifically, because the target programs are also part of the subsequent program testing, each target program contains a corresponding tracking file and input parameter set, so the target programs and the corresponding tracking files and input parameter sets are first stored in the test program set. For each of the first program variants, since there may be non-equivalent variants, it is necessary to analyze the validity of the first program variant. The analysis method is: compile the first program variant in C language to obtain a second program variant (WebAssembly program), then insert it, and run it on the reference runtime (wasmer) to obtain a second tracking file corresponding to each first program variant. At this time, the second tracking file is compared with the first tracking files of all the test programs in the test program set. When the second tracking file is different from the first tracking files of all the test programs in the test program set, the generated program variant is a non-equivalent variant, such as Figure 4As shown, it is also possible that no new trace file is generated (that is, the second trace file is the same as the first trace file). In this case, the generated program variant is an equivalent variant, and the equivalent variant is an invalid program variant. The non-equivalent variant and the corresponding trace file and input parameter set are added to the test program set, and the priority of the second mutation operator is increased by 1. It is worth noting that the smaller the index value of the mutation operator, the higher its priority. At this time, if it is the first time to select the second mutation operator, after adding the non-equivalent mutant and the corresponding tracking file and input parameter set to the test program set, the index value of the second mutation operator becomes 1; if it is not the first time to select the second mutation operator, the index value of the second mutation operator is assigned to the index value of the first mutation operator, the index value of the second mutation operator is reduced by 1, and the mutation operators in the mutation operator set are sorted from high to low according to priority; in this process, except for the mutation operator corresponding to the last priority in the sorting, the mutation operator corresponding to the second-to-last priority in the sorting is copied twice, the mutation operator corresponding to the third-to-last priority in the sorting is copied three times... The mutation operators are expanded by this method; in this way, the mutation operator with a higher priority has a higher probability of being selected in the next round of selection. Obtain an intermediate time value, and subtract the initial time value from the intermediate time value to obtain a time difference; when the time difference is less than a preset maximum time threshold (such as 60 seconds), repeat the step of randomly selecting a first target program from a number of target programs; when the time difference is equal to the maximum time threshold (such as 60 seconds), the time is up and the test program set is output. For example, if the number of target programs is 100, after adding 9,900 valid first program variants through mutation, the number of test program sets reaches 10,000.
[0083] After getting the test program set, you can execute Figure 1 The following steps are shown: S300, according to the test program set and several preset runtimes, several running results corresponding to the test program set are obtained, several running results are analyzed, and several vulnerabilities of the runtimes are determined; wherein the runtime is used to characterize the carrier of program running.
[0084] In this embodiment, the WebAssembly source program in the compiled test program set is run in multiple runtime environments with different implementations to obtain multiple running results, and the running results are analyzed to determine the vulnerabilities in the runtime, thereby avoiding interference from other factors (such as vulnerabilities in the implementation of high-level language compilers, etc.), and realizing efficient behavior comparison and vulnerability detection in multiple runtimes. In this way, it not only solves the problem that the operation of the WebAssembly program has a sandboxed isolation mechanism, there may be special processing for memory, and it is difficult to derive completely correct test predictions using the original high-level language compiler; it also solves the problem that the specific implementation details of the WebAssembly runtime are not easy to obtain, and it is difficult to design test files that can directly trigger vulnerabilities.
[0085] In step S300, the several runtimes include a first runtime, a second runtime and a third runtime; the several running results corresponding to the test program set are obtained according to the test program set and several preset runtimes, including the following steps: inputting the test program set into the first runtime for running, and outputting a first running result through the first runtime; compiling the test programs in the test program set; inputting the compiled test program set into the second runtime for running, and obtaining a second running result; inputting the compiled test program set into the third runtime for running, and obtaining a third running result.
[0086] Specifically, the present invention creatively proposes a new testing method, which uses a large number of C programs and uses code coverage detection tools to run each branch of the program as much as possible, and designs algorithms to mutate the program, so as to test the reliability and vulnerabilities of the Webassembly runtime. The test program set is input into the first runtime, and the first runtime outputs the first runtime result; an embodiment of the first runtime result is as follows:
[0087] int add(int a,int b){
[0088] return a+b;
[0089] }
[0090] The first program variant is a C program variant. For example, for the mutated source program, a C language compiler (GCC compiler or a compiler in the prior art) is used to obtain an executable file P_c, and after running, an output O_c is obtained. Then, for each of the first program variants (C language program variants), the C language test program in the test program set is compiled into a WebAssembly program variant, such as: using the WebAssembly compiler emscripten to obtain P_w, and the compiled test program set is input into a second runtime (such as a local virtual machine implementation, such as WAVM, wasm3, wasmer) for running to obtain a second running result. For example, for the input of the same test file, running on vmi obtains O_w(vmi). An embodiment of the second running result is as follows:
[0091] emcc add.c main.cs STANDALONE_WASM=1-o main.out.wasm wasmermain.out.wasm
[0092] Similarly, the compiled test program set is input into a third runtime (implemented by a browser, such as the WebAssembly runtime environment built into mainstream browsers such as Chrome and Firefox) to run, and a third running result is obtained; for example, for the input of the same test file, it is run on the browser bi to obtain O_w(bi), and an embodiment of the third running result is as follows:
[0093] emcc add.c main.cs STANDALONE_WASM=1-o main.html python-mhttp.server
[0094] In step S300, the analyzing of the plurality of operation results to determine the plurality of vulnerabilities in the operation includes the following steps: when the second operation result is different from the first operation result, determining that a vulnerability exists in the second operation and outputting the vulnerability; when the third operation result is different from the first operation result, determining that a vulnerability exists in the third operation and outputting the vulnerability; when the second operation result is different from the third operation result, obtaining a vulnerability identification result of a preset person, and when the vulnerability identification result is that a vulnerability exists, outputting the vulnerability.
[0095] Specifically, as shown in Table 2, when the second running result is different from the first running result, for example, the division by zero arithmetic operation is an illegal operation in the C language, causing the program to terminate, but in some WebAssembly runtime implementations (such as WAVM, etc.), the arithmetic result is 0, and the program termination is not triggered. At this time, it indicates that there is a vulnerability in the second runtime (such as WAVM, etc.), and the vulnerability (the calculation of the division by zero operation has a BUG) is reported to the corresponding development community. Similarly, when the third operation result is different from the first operation result, such as the division by zero arithmetic operation is an illegal operation in C language, which causes the program to terminate, but the arithmetic result is 0 in the implementation of the browser (such as Chrome), and the program termination is not triggered. At this time, it indicates that there is a vulnerability in the third runtime (such as Chrome), and the vulnerability (the calculation of the division by zero operation has a BUG) is reported to the corresponding development community; when the second operation result is different from the third operation result, the preset personnel will identify the vulnerability identification result based on the second operation result and the third operation result, and the system obtains the vulnerability identification result; when the vulnerability identification result is that there is a vulnerability, that is, the system obtains the vulnerability identification result input by the preset personnel (such as the third runtime (such as Chrome) There is a vulnerability or the second runtime (such as WAVM, etc.) There is a vulnerability), it can report the vulnerability to the corresponding development community. The vulnerability detection of the present invention can effectively solve the deficiencies in the existing technical implementation scheme, and solve the problems of low coverage of generated test cases and easy failure of legality inspection.
[0096] Table 2
[0097]
[0098] Exemplary Devices
[0099] like Figure 5 As shown in , an embodiment of the present invention provides a runtime vulnerability detection system based on fuzzy testing, the system includes a target program acquisition module 401, several operation result acquisition modules 402 and a vulnerability determination module 403, wherein:
[0100] The target program acquisition module 401 is used to acquire a plurality of source programs and perform validity analysis on the plurality of source programs to obtain a plurality of target programs;
[0101] A program mutation module 402 is used to perform mutation processing on the target programs based on a preset algorithm to obtain a plurality of first program variants, perform validity analysis on the first program variants to obtain a plurality of non-equivalent variants, and obtain a test program set based on the non-equivalent variants and the target programs;
[0102] The vulnerability determination module 403 is used to obtain a number of operation results corresponding to the test program set according to the test program set and a number of preset runtimes, analyze the several operation results, and determine the vulnerabilities of the several runtimes; wherein the runtime is used to characterize the carrier of program operation.
[0103] Based on the above embodiments, the present invention further provides an intelligent terminal, whose principle block diagram can be shown as follows: Figure 6 As shown. The intelligent terminal includes a processor, a memory, a network interface, a display screen, and a temperature sensor connected through a system bus. Among them, the processor of the intelligent terminal is used to provide computing and control capabilities. The memory of the intelligent terminal includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the intelligent terminal is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a runtime vulnerability detection method based on fuzzy testing is implemented. The display screen of the intelligent terminal can be a liquid crystal display screen or an electronic ink display screen, and the temperature sensor of the intelligent terminal is pre-set inside the intelligent terminal to detect the operating temperature of the internal device.
[0104] Those skilled in the art will understand that Figure 6 The schematic diagram in the figure is only a block diagram of a part of the structure related to the scheme of the present invention, and does not constitute a limitation on the smart terminal to which the scheme of the present invention is applied. The specific smart terminal may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0105] In one embodiment, a smart terminal is provided, comprising a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, and the one or more programs include instructions for performing the following operations:
[0106] Acquire a number of source programs, and perform validity analysis on the source programs to obtain a number of target programs;
[0107] Based on a preset algorithm, a plurality of the target programs are mutated to obtain a plurality of first program variants, validity analysis is performed on the plurality of the first program variants to obtain a plurality of non-equivalent variants, and a test program set is obtained based on the plurality of non-equivalent variants and the plurality of the target programs;
[0108] According to the test program set and several preset runtimes, several running results corresponding to the test program set are obtained, and the several running results are analyzed to determine the vulnerabilities of the several runtimes; wherein the runtime is used to characterize the carrier of program running.
[0109] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0110] In summary, the present invention discloses a runtime vulnerability detection method and system based on fuzzy testing, the method comprising: obtaining a number of source programs, and performing validity analysis on the source programs to obtain a number of target programs; based on a preset algorithm, performing mutation processing on the source programs after the validity analysis to obtain a number of first program variants, performing validity analysis on the first program variants to obtain a number of non-equivalent variants, and then obtaining a test program set containing source programs; according to the test program set and a number of preset runtimes, obtaining a number of running results corresponding to the test program set, and then determining the vulnerabilities of the runtimes according to the number of running results. In the WebAssembly runtime environment, the embodiment of the present invention performs validity analysis on the source program to obtain a higher coverage rate of the target program, obtains a number of running results by inputting the mutated program into different runtimes, and determines the vulnerability by analyzing the multiple running results, thereby improving the detection stability and accuracy of the vulnerability.
[0111] Based on the above embodiments, the present invention discloses a runtime vulnerability detection method based on fuzzy testing. It should be understood that the application of the present invention is not limited to the above examples. For ordinary technicians in this field, it can be improved or transformed according to the above description. All these improvements and transformations should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A runtime vulnerability detection method based on fuzz testing, It is characterized in that The method comprises: Acquire a number of source programs, and perform validity analysis on the source programs to obtain a number of target programs; Based on a preset algorithm, a plurality of the target programs are mutated to obtain a plurality of first program variants, validity analysis is performed on the plurality of the first program variants to obtain a plurality of non-equivalent variants, and a test program set is obtained based on the plurality of non-equivalent variants and the plurality of the target programs; According to the test program set and several preset runtimes, several running results corresponding to the test program set are obtained, and several running results are analyzed to determine several vulnerabilities of the runtimes; wherein the runtime is used to characterize the carrier of program running; The method of performing mutation processing on the target programs based on the preset algorithm to obtain the first program variants includes: Get the initial time value; Randomly obtain a random number within a preset range; Randomly selecting a first mutation operator from a preset mutation operator set based on priority, and obtaining an index value of the first mutation operator; Randomly selecting a first target program from among the plurality of target programs; Randomly selecting a second mutation operator from a preset mutation operator set based on the priority, and obtaining an index value of the second mutation operator; Based on a preset Metropolis-Hastings algorithm formula, a reception probability value is obtained according to the index value of the first mutation operator, the index value of the second mutation operator and the first target program; wherein the reception probability value is used to characterize the probability of a reception function; For each of the target programs, when the received probability value is greater than or equal to the random number, the second mutation operator is used to mutate each of the target programs to obtain a plurality of first program variants corresponding to each of the target programs; wherein the input parameter sets of the plurality of first program variants are the same as the input parameter set of each of the target programs; After obtaining the reception probability value based on the preset Metropolis-Hastings algorithm formula according to the index value of the first mutation operator, the index value of the second mutation operator and the first target program, the method further includes: When the receiving probability value is less than the random number, continue to execute the steps of randomly selecting a second mutation operator based on the priority in the preset mutation operator set, and obtaining the index value of the second mutation operator; The performing validity analysis on the plurality of the first program variants to obtain a plurality of non-equivalent variants, and obtaining a test program set according to the plurality of the non-equivalent variants and the plurality of the target programs comprises: storing a plurality of said target programs into said test program set; For each of the first program variants, compile and insert the first program variant to obtain a second program variant corresponding to each of the first program variants, and run the second program variant based on the reference runtime to obtain a second tracking file corresponding to each of the first program variants, when the second tracking file is different from the first tracking file, take the first program variant corresponding to the second tracking file as a non-equivalent variant, add the non-equivalent variant to the test program set, increase the index value of the second mutation operator by 1, and sort the mutation operators in the mutation operator set from high to low according to priority, wherein the input parameter set of the second program variant is the same as the input parameter set of each of the first program variants; Obtaining an intermediate time value, and subtracting the initial time value from the intermediate time value to obtain a time difference; When the time difference is less than a preset maximum time threshold, repeatedly executing the step of randomly selecting a first target program from the plurality of target programs; When the time difference is equal to the maximum time threshold, the test program set is output.
2. The runtime vulnerability detection method based on fuzz testing according to claim 1, It is characterized in that The validity analysis of the source programs is performed to obtain the target programs, including: Repeat the steps of performing static analysis on the source programs to obtain the first programs, detecting the code coverage of the first programs, and generating the input parameters; wherein the input parameters are used to characterize the test cases; and the input parameters constitute an input parameter set; When the plurality of first programs detected by code coverage meet a preset condition, the step of performing static analysis on the plurality of source programs is stopped, and the plurality of first programs meeting the condition are used as a plurality of target programs, wherein each of the target programs corresponds to an input parameter set; For each of the target programs, the target program is compiled and plugged, and based on the reference runtime, the compiled and plugged target program is run to obtain the first tracking file corresponding to each of the target programs; wherein the reference runtime is one of several runtimes; and the first tracking file is a file that records the running order of the plugged program.
3. The runtime vulnerability detection method based on fuzz testing according to claim 1, It is characterized in that The plurality of runtimes include a first runtime, a second runtime, and a third runtime; the plurality of runtime results corresponding to the test program set are obtained according to the test program set and the plurality of preset runtimes, including: Inputting the test program set into a first runtime for execution, and outputting a first execution result through the first runtime; Compiling the test programs in the test program set; Inputting the compiled test program set into a second runtime to execute the test program, thereby obtaining a second execution result; The compiled test program set is input into the third runtime for execution to obtain a third execution result.
4. The runtime vulnerability detection method based on fuzz testing according to claim 3, It is characterized in that The analyzing of the plurality of the operating results to determine the plurality of the runtime vulnerabilities includes: When the second operation result is different from the first operation result, determining that a vulnerability exists in the second operation, and outputting the vulnerability; When the third operation result is different from the first operation result, determining that a vulnerability exists in the third operation, and outputting the vulnerability; When the second operation result is different from the third operation result, a vulnerability identification result of a preset person is obtained, and when the vulnerability identification result is that a vulnerability exists, the vulnerability is output.
5. A runtime vulnerability detection system based on fuzz testing, It is characterized in that The system comprises: A target program acquisition module is used to acquire a number of source programs and perform validity analysis on the source programs to obtain a number of target programs; A program mutation module, used for performing mutation processing on the target programs based on a preset algorithm to obtain a plurality of first program variants, performing validity analysis on the first program variants to obtain a plurality of non-equivalent variants, and obtaining a test program set based on the non-equivalent variants and the target programs; A vulnerability determination module, used to obtain a number of operation results corresponding to the test program set according to the test program set and a number of preset runtimes, analyze the several operation results, and determine the vulnerabilities of the several runtimes; wherein the runtime is used to characterize the carrier of program operation; The method of performing mutation processing on the target programs based on the preset algorithm to obtain the first program variants includes: Get the initial time value; Randomly obtain a random number within a preset range; Randomly selecting a first mutation operator from a preset mutation operator set based on priority, and obtaining an index value of the first mutation operator; Randomly selecting a first target program from among the plurality of target programs; Randomly selecting a second mutation operator from a preset mutation operator set based on the priority, and obtaining an index value of the second mutation operator; Based on a preset Metropolis-Hastings algorithm formula, a reception probability value is obtained according to the index value of the first mutation operator, the index value of the second mutation operator and the first target program; wherein the reception probability value is used to characterize the probability of a reception function; For each of the target programs, when the received probability value is greater than or equal to the random number, the second mutation operator is used to mutate each of the target programs to obtain a plurality of first program variants corresponding to each of the target programs; wherein the input parameter sets of the plurality of first program variants are the same as the input parameter set of each of the target programs; After obtaining the reception probability value based on the preset Metropolis-Hastings algorithm formula according to the index value of the first mutation operator, the index value of the second mutation operator and the first target program, the method further includes: When the receiving probability value is less than the random number, continue to execute the steps of randomly selecting a second mutation operator based on the priority in the preset mutation operator set, and obtaining the index value of the second mutation operator; The performing validity analysis on the plurality of the first program variants to obtain a plurality of non-equivalent variants, and obtaining a test program set according to the plurality of the non-equivalent variants and the plurality of the target programs comprises: storing a plurality of said target programs into said test program set; For each of the first program variants, compile and insert the first program variant to obtain a second program variant corresponding to each of the first program variants, and run the second program variant based on the reference runtime to obtain a second tracking file corresponding to each of the first program variants, when the second tracking file is different from the first tracking file, take the first program variant corresponding to the second tracking file as a non-equivalent variant, add the non-equivalent variant to the test program set, increase the index value of the second mutation operator by 1, and sort the mutation operators in the mutation operator set from high to low according to priority, wherein the input parameter set of the second program variant is the same as the input parameter set of each of the first program variants; Obtaining an intermediate time value, and subtracting the initial time value from the intermediate time value to obtain a time difference; When the time difference is less than a preset maximum time threshold, repeatedly executing the step of randomly selecting a first target program from the plurality of target programs; When the time difference is equal to the maximum time threshold, the test program set is output.
6. A smart terminal, It is characterized in that The device comprises a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, and the one or more programs include being used to execute the method according to any one of claims 1 to 4.
7. A non-transitory computer-readable storage medium, It is characterized in that When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method as claimed in any one of claims 1 to 4.
Citation Information
Patent Citations
Software memory security detection method and system
CN108647145A
A loophole mining method and device
CN109032927A
