Method and system for automatically detecting program vulnerabilities under hardware TEE

By using shared memory and lightweight library operating systems in the hardware TEE environment for parallel fuzz testing, combined with signal-based exception information monitoring and seed strategy adjustment, automated detection of program vulnerabilities under hardware TEE is achieved, and missed judgments in traditional methods are solved and misjudgment issues improve detection efficiency and accuracy.

CN118965369AActive Publication Date: 2024-11-15HUNAN UNIV

Patent Information

Application Number
CN202411095338.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-09
Publication Date
2024-11-15
Estimated Expiration
2044-08-09

AI Technical Summary

Technical Problem

Program vulnerability detection is difficult to automate in hardware TEE environments. Traditional fuzzy testing methods cannot effectively monitor the enclave, which may lead to misjudgment or misjudgment of vulnerabilities specific to TEE environments.

Method used

In the hardware TEE environment, parallel fuzz testing is implemented through shared memory, lightweight library operating system and signal-based exception information monitoring, seed strategies are dynamically adjusted, and iterative detection is carried out to complete vulnerability automation detection.

Benefits of technology

It realizes automatic monitoring of vulnerabilities within the enclave, improves the efficiency of fuzz testing and exploration efficiency, supports detection without the need for trusted domain boundaries, and ensures accurate collection and analysis of abnormal information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118965369A_ABST
    Figure CN118965369A_ABST
Patent Text Reader

Abstract

The invention provides an automatic program vulnerability detection method and system under hardware TEE, and the method comprises the steps: placing a target program, a fuzzy test engine and a corpus in a TEE environment, carrying out the preprocessing of the target program, and obtaining a plurality of initial seeds from the corpus; the method comprises the following steps: creating a plurality of execution processes corresponding to a father working thread of a fuzzy testing engine in a memory sharing manner, executing a preprocessed target program in parallel by utilizing the execution processes, performing parallel fuzzy testing by adopting an iteration manner by taking an initial seed as initial input of the execution processes, and performing parallel fuzzy testing in each iteration process. And dynamically adjusting a mutation strategy of the seed until a termination condition is reached or an interrupt signal is received so as to complete automatic detection of the program vulnerability, and outputting a fuzzy test report. According to the method, the advantages of fuzzy detection are brought into full play, the fuzzy test method for feedback guidance in a trustable execution environment of real hardware is realized, the security vulnerabilities of the application program are automatically detected and analyzed, and the security credibility of the TEE is enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information security technology, and in particular to a method and system for automatically detecting program vulnerabilities under hardware TEE. Background Art

[0002] Intel SGX (Software Guard Extensions) is a hardware-based TEE security technology designed to protect sensitive data and code in applications from malware and operating system attacks. By creating a protected execution environment (enclave), data security isolation and protection are achieved to ensure that sensitive information is not leaked or tampered with during execution. Due to application porting, there will be some vulnerabilities in the enclave that are specific to the SGX environment or the application itself, which seriously endangers the security of the code and data in the enclave. Enclaves are designed to be non-self-reflective and lack automatic vulnerability detection capabilities.

[0003] As an automated software testing technology, fuzz testing automatically or semi-automatically generates random data according to certain rules, and then inputs these random data into the target program entry point of dynamic operation. At the same time, it monitors whether the target program has abnormal conditions, such as system crashes, assertion failures, etc., to discover software defects. It is a cutting-edge choice for program vulnerability detection. However, TEE implements a strict isolation strategy, making it difficult for the fuzz testing process to monitor applications within the enclave. Fuzz testing within the enclave is highly dependent on the services of the operating system, and the detection process cannot enter the secure isolation zone to run. Traditional fuzz testing within the enclave mainly responds to the isolation between enclaves by simulating the execution of the enclave locally, and deploying the runtime in the trusted area to provide operating system services for the detection process.

[0004] However, the simulated execution method cannot truly restore the enclave operating environment and may miss or misjudge some vulnerabilities specific to the TEE environment. Summary of the invention

[0005] In view of the above situation, the main purpose of the present invention is to propose a method and system for automatic detection of program vulnerabilities under hardware TEE to solve the above technical problems.

[0006] The present invention proposes a method for automatically detecting program vulnerabilities under hardware TEE, and the method comprises the following steps:

[0007] Step 1: Place the target program, fuzz testing engine, and corpus in the TEE environment, preprocess the target program, and obtain several initial seeds from the corpus;

[0008] Step 2: By means of shared memory, the parent working thread of the fuzz testing engine creates several corresponding execution processes, and uses the execution processes to execute the preprocessed target program in parallel, and uses the initial seed as the initial input of the execution process to perform parallel fuzz testing;

[0009] Step 3: During the fuzz testing process, monitor the target program running information and coverage information, store the running information and coverage information in the shared memory, and put the corresponding seeds into the corpus to update the corpus according to the coverage information;

[0010] When one of the processes triggers an abnormal signal, the operation information and the abnormal signal are stored in the corresponding shared memory, and the abnormal signal is analyzed to obtain analysis data. At the same time, the corresponding seed is put into the corpus to update the corpus;

[0011] Step 4: According to the analysis data and coverage information, dynamically select a mutation strategy for the initial seed to mutate, and use it as the input for the next stage of parallel fuzz testing;

[0012] Step 5: Repeat steps 2 and 4 in an iterative manner to perform parallel fuzz testing until the termination condition is reached or an interrupt signal is received to complete the automatic detection of program vulnerabilities and output a fuzz testing report.

[0013] The present invention also proposes a system for automatically detecting program vulnerabilities under hardware TEE, wherein the system applies the method for automatically detecting program vulnerabilities under hardware TEE as described above, and the system comprises:

[0014] Library operating system modules for:

[0015] Place the target program, fuzz testing engine, and corpus in the TEE environment;

[0016] By sharing memory, the fuzz testing engine parent worker thread creates several corresponding execution processes;

[0017] During the fuzz testing process, the target program's running information and coverage information are monitored and stored in the shared memory;

[0018] When one of the execution processes triggers an exception signal, the operation information and the exception signal are stored in the corresponding shared memory;

[0019] Fuzz testing engine module for:

[0020] Preprocess the target program and obtain several initial seeds from the corpus;

[0021] The pre-processed target program is executed in parallel by using the execution process, and the initial seed is used as the initial input of the execution process for parallel fuzz testing;

[0022] According to the coverage information, the corresponding seeds are put into the corpus to update the corpus;

[0023] Analyze the abnormal signals to obtain analytical data, and put the corresponding seeds into the corpus to update the corpus;

[0024] According to the analysis data and coverage information, the mutation strategy is dynamically selected for the initial seed to mutate, and used as the input for the next stage of parallel fuzz testing;

[0025] Parallel fuzz testing is performed in an iterative manner until the termination condition is reached or an interrupt signal is received, so as to complete the automatic detection of program vulnerabilities and output a fuzz testing report.

[0026] Compared with the prior art, the present invention has the following beneficial effects:

[0027] 1. The present invention implements a fuzz tester inside the enclave through a lightweight library operating system, supporting automatic vulnerability monitoring within the TEE without crossing the trusted domain boundary.

[0028] 2. The present invention proposes a secure process management mechanism based on shared memory to realize parallel fuzz testing and improve fuzz testing efficiency.

[0029] 3. The present invention designs a weight-based seed strategy optimization selection algorithm, dynamically adjusts the weight according to the coverage information, and improves the exploration efficiency. A signal-based abnormal information monitoring method is implemented to collect target program abnormal information in an isolated environment.

[0030] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description or learned through embodiments of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 This is a flow chart of the method for automatic detection of program vulnerabilities under hardware TEE proposed by the present invention;

[0032] Figure 2 This is a flow chart of the fuzzy testing algorithm of the present invention;

[0033] Figure 3 This is a schematic diagram of the shared memory-based secure process management mechanism of the present invention;

[0034] Figure 4 It is a schematic diagram of the signal-based information monitoring method within the enclave of the present invention;

[0035] Figure 5The program execution exception tracking flow chart of the present invention;

[0036] Figure 6 This is a framework diagram of the automatic program vulnerability detection system under the hardware TEE proposed in the present invention. DETAILED DESCRIPTION

[0037] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.

[0038] These and other aspects of the embodiments of the present invention will be apparent with reference to the following description and accompanying drawings. In these descriptions and accompanying drawings, some specific implementations of the embodiments of the present invention are specifically disclosed to represent some ways of implementing the principles of the embodiments of the present invention, but it should be understood that the scope of the embodiments of the present invention is not limited thereto.

[0039] See also Figure 1 and Figure 2 This embodiment provides a method for automatically detecting program vulnerabilities under hardware TEE, and the method includes the following steps:

[0040] Step 1: Place the target program, fuzz testing engine, and corpus in the TEE environment, preprocess the target program, and obtain several initial seeds from the corpus;

[0041] In step 1, the target program is preprocessed by using the clang compiler to perform a plug-in operation on the target program source code, and the plug-in operation includes inserting a sig_handler (exception signal processing) function for capturing runtime information and exception signals of the target program and a statistical function for recording coverage and statistical information.

[0042] Step 2: By means of shared memory, the parent working thread of the fuzz testing engine creates several corresponding execution processes, and uses the execution processes to execute the preprocessed target program in parallel, and uses the initial seed as the initial input of the execution process to perform parallel fuzz testing;

[0043] like Figure 3 As shown, in step 2, the method for the fuzz test engine parent working thread to create a number of corresponding execution processes by means of shared memory specifically includes the following steps:

[0044] The fuzz test parent worker process creates the fuzz test parent worker thread through the clone system call;

[0045] The worker thread uses the spawn (process creation) system call to create a child process to execute the target program, and the parent worker thread and the child execution process it creates are called a work group. The parent worker thread and the child execution process communicate through shared memory;

[0046] Therefore, by storing the runtime information of the target program therein, the parent worker thread can monitor the runtime status of the target program child process in real time, thereby achieving secure inter-process communication in the enclave.

[0047] Preferably, before the working thread calls the process creation function to create a child process, it needs to perform preparatory work, and the preparatory work specifically includes the following steps:

[0048] Use the posix_spawn_file_actions_addopen function (to set a file descriptor for the newly created process) to close the standard input and output of the child process to avoid unnecessary interface (I / O) operations interfering with process execution;

[0049] Initialize the args[] array to store the execution parameters of the target program;

[0050] Use the posix_spawnattr_set (process parameter setting) function to prepare the subroutine running environment and write relevant environment variables.

[0051] Step 3: During the fuzz testing process, monitor the target program running information and coverage information, store the running information and coverage information in the shared memory, and put the corresponding seeds into the corpus to update the corpus according to the coverage information;

[0052] When an execution process triggers an abnormal signal, the operation information and the abnormal signal are stored in the corresponding shared memory, and the abnormal signal is analyzed to obtain analysis data. At the same time, the corresponding seed is put into the corpus to update the corpus;

[0053] like Figure 4 As shown, in step 3, when one of the execution processes triggers an abnormal signal, the method of storing the operation information and the abnormal signal in the corresponding shared memory specifically includes the following steps:

[0054] When the program triggers an exception signal, read the siginfo_t (signal information) structure to obtain the exception signal number, error number, signal code and error address;

[0055] Read the program counter;

[0056] Parse the / proc / [pid] / maps file to obtain the target program's memory mapping information;

[0057] Use libunwind (stack unwinding) library to obtain call stack information, traverse each call frame to obtain the PC (program counter) value and function name of each frame, and determine the module name by parsing the memory map information in the / proc / [pid] / maps file;

[0058] The Capstone engine is used to disassemble the instructions read from the memory, so as to store the operation information and the abnormal signal information into the corresponding shared memory according to the instructions.

[0059] Preferably, the operation information and the abnormal signal information respectively use three fields to store information in the shared memory, and the three fields are exec, info, and stak, wherein the operation information includes operation status information, PC information, and stack information;

[0060] The exec field is used to store the running status information of the subroutine, which includes: 1) "done" indicates that the program exits normally; 2) "segv" indicates that the program has a SIGSEGV (segment fault) exception; 3) "ill" indicates that the program has a SIGILL (illegal instruction) exception; 4) "abrt" indicates that the program has a SIGABRT (process termination) exception; 5) "fpe" indicates that the program has a SIGFPE (page fault) exception;

[0061] The info field is used to store PC information and exception signal information, and the stack field is used to store stack information.

[0062] Coverage information is stored in user-specified feedback files, which are managed by the fuzz testing worker thread.

[0063] In order to analyze the uniqueness of the crash, the present invention proposes a novel crash judgment standard. Considering the particularity of using the spawn function to create a process, the same instruction address may correspond to different addresses, so the address cannot be used as the only criterion for judging the uniqueness of the crash. Although each child process runs in a different virtual space, the layout of the code segment in the virtual address space is the same, and the position and structure of the code segment of the same program in the virtual address space are consistent. Therefore, when the program fails on a specific instruction, the lower 12 bits (page offset) of the virtual address of the instruction will be the same, because the position of the instruction in the code segment of each process is fixed. Based on this feature, four indicators are selected to judge the uniqueness of the crash: 1) abnormal signal type; 2) the lower 12 bits of the current instruction address; 3) the current instruction; 4) the stack hash value. We determine the uniqueness of the crash by comparing whether the states of these four indicators have all changed. Therefore, when a child process crashes, the corresponding shared memory is indexed through the parent thread TID (thread number);

[0064] Get the type of exception signal, current instruction, lower 12 bits of current instruction address and stack hash value from shared memory;

[0065] The uniqueness of the crash is determined by comparing the type of the exception signal, the current instruction, the lower 12 bits of the current instruction address, and whether the stack hash value has changed. The crash uniqueness judgment model has the following relationship:

[0066]

[0067] in, Indicates whether the abnormal signal types of the current and next stages are the same. It means judging whether the lower 12 bits of the instruction address of the current and next stages are consistent. Indicates whether the instructions of the current and next stages are consistent. Indicates whether the stack hash values ​​of the current and next stages are consistent. Indicates the logical relationship "XOR", ∩ indicates the logical relationship "AND"; get the RES judgment value, when the result is 1, it means that the crash has not been discovered before, indicating that a new vulnerability has been tested.

[0068] Figure 5 This is a flowchart of program execution exception tracking of the present invention. In the target program instrumentation stage, an exception custom function is registered in the target program. The function is called when an exception occurs in the target program to collect crash information. The fuzz test engine starts the fuzz test process and executes the target application. When an exception occurs in the target program (such as "movq%rcx, (%rdi)" triggers SIGSEGV), it will go to the custom processing function, collect crash information, and write this information into the shared memory. The analyzer parses the runtime information to identify the crash type. If a new crash is found, the crash information is reported and the seed is placed in the corpus. After the analysis is completed, the analyzer sends a return to continue execution signal to the target application, so that the target routine continues to execute on the current line. Subsequently, SIGSEGV is triggered again, the target process exits due to the exception, and this fuzz test iteration ends. Then, the controller creates a new child process to start the next iteration until the termination condition is met and the fuzz test ends.

[0069] Step 4: According to the analysis data and coverage information, dynamically select a mutation strategy for the initial seed to mutate, and use it as the input for the next stage of parallel fuzz testing;

[0070] In step 4, according to the analysis data and coverage information, the method of dynamically selecting a mutation strategy for the initial seed to mutate and using it as the input for the next stage of parallel fuzz testing specifically includes the following steps:

[0071] Each seed mutation strategy is assigned a counter;

[0072] In a fuzz testing iteration, if the coverage of the execution with one of the seeds as input is improved or a vulnerability is triggered, the mutation strategy of the seed will be considered as an "interesting" strategy, and its corresponding counter will be automatically increased by 1;

[0073] According to the size of the counter, the probability of the corresponding seed being selected is adjusted. The probability of the seed strategy being selected in the corpus can be calculated by the following formula:

[0074]

[0075] Among them Muta i represents the strategy, P_Muta i Representation strategy Muta i The probability of being selected, CNT i It represents the counter corresponding to the i-th seed, which will be dynamically adjusted according to the runtime information, and n represents the total number of mutation strategies.

[0076] In step 4, the seed mutation strategy includes: 1) adjusting data size; 2) mutating bytes and bits; 3) mutating memory; 4) mutating data blocks; 5) mutating ASCII code (Standard Code for Information Interchange) numbers; 6) mutating using a dictionary; 7) mutating using a random buffer.

[0077] Step 5: Repeat steps 2 and 4 in an iterative manner to perform parallel fuzz testing until the termination condition is reached or an interrupt signal is received to complete the automatic detection of program vulnerabilities and output a fuzz testing report.

[0078] Please refer to Figure 6 This embodiment also provides a system for automatically detecting program vulnerabilities under hardware TEE, wherein the system applies the method for automatically detecting program vulnerabilities under hardware TEE as described above, and the system includes:

[0079] Library operating system modules for:

[0080] Place the target program, fuzz testing engine, and corpus in the TEE environment;

[0081] By sharing memory, the fuzz testing engine parent worker thread creates several corresponding execution processes;

[0082] During the fuzz testing process, the target program's running information and coverage information are monitored and stored in the shared memory;

[0083] When an execution process triggers an exception signal, the operation information and the exception signal are stored in the corresponding shared memory;

[0084] Fuzz testing engine module for:

[0085] Preprocess the target program and obtain several initial seeds from the corpus;

[0086] The pre-processed target program is executed in parallel by using the execution process, and the initial seed is used as the initial input of the execution process for parallel fuzz testing;

[0087] According to the coverage information, the corresponding seeds are put into the corpus to update the corpus;

[0088] Analyze the abnormal signals to obtain analytical data, and put the corresponding seeds into the corpus to update the corpus;

[0089] According to the analysis data and coverage information, the mutation strategy is dynamically selected for the initial seed to mutate, and used as the input for the next stage of parallel fuzz testing;

[0090] Parallel fuzz testing is performed in an iterative manner until the termination condition is reached or an interrupt signal is received, so as to complete the automatic detection of program vulnerabilities and output a fuzz testing report.

[0091] In order to meet the needs of executing the entire fuzz test process in a real TEE environment, the library operating system module of the present invention can be directly designed in the hardware TEE to transplant the complete fuzz test engine into the enclave and run it. Since the fuzz test engine contains more complex execution logic, it is necessary to provide corresponding request services for it in the TEE environment. The library operating system will include key modules such as secure dynamic memory management, multi-threading, synchronization locks, exception handling, system calls, and special instruction processing to support its normal operation and be as lightweight as possible.

[0092] In order to dynamically track the runtime status of the target program, a method for controlling the target process is designed and implemented. In the library operating system, an information monitoring module is implemented based on signals to control the pause and resume of the target program to manipulate the execution status of the target program. And through shared memory, perf (system performance analysis) tools, and file transfer symbols, the collection and feedback of operation information and coverage information are realized, so that the fuzz test process can obtain the target program information in real time.

[0093] like Figure 6As shown in the figure, the input of the system is the source code or binary file of the TEE program, and the output is the detailed information of the fuzz test such as vulnerability report and coverage. In the fuzz test engine of the TEE process, the controller uses the process creation system call to create the fuzz test process; the seed module reads the initial seed from the file encryption module of the library operating system and mutates the seed. The mutated seed is stored in the corpus, and the corpus is updated according to the runtime information to save high-quality seeds. Under the management of the security process management module, new TEE processes are continuously created to carry out fuzz test cycles. Different inputs will explore richer enclave code paths. At runtime, the analyzer monitors the program running status with the help of the memory information monitoring module of the library operating system; when the program crashes, the custom handler in the detection engine collects the crash information, and the analyzer parses it. Once a new vulnerability is found, it will be reported. When the detection loop reaches the termination condition (time exhaustion or external termination signal), a detailed fuzz test vulnerability and coverage information report is output.

[0094] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0095] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0096] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.

Claims

1. A method for automatically detecting program vulnerabilities under hardware TEE, characterized in that: The method comprises the following steps: Step 1: Place the target program, fuzz testing engine, and corpus in the TEE environment, preprocess the target program, and obtain several initial seeds from the corpus; Step 2: By means of shared memory, the parent working thread of the fuzz testing engine creates several corresponding execution processes, and uses the execution processes to execute the preprocessed target program in parallel, and uses the initial seed as the initial input of the execution process to perform parallel fuzz testing; Step 3: During the fuzz testing process, monitor the target program running information and coverage information, store the running information and coverage information in the shared memory, and put the corresponding seeds into the corpus to update the corpus according to the coverage information; When one of the execution processes triggers an abnormal signal, the operation information and the abnormal signal are stored in the corresponding shared memory, and the abnormal signal is analyzed to obtain analysis data. At the same time, the corresponding seed is put into the corpus to update the corpus; Step 4: According to the analysis data and coverage information, dynamically select a mutation strategy for the initial seed to mutate, and use it as the input for the next stage of parallel fuzz testing; Step 5: Repeat steps 2 and 4 in an iterative manner to perform parallel fuzz testing until the termination condition is reached or an interrupt signal is received to complete the automatic detection of program vulnerabilities and output a fuzz testing report.

2. The method for automatically detecting program vulnerabilities under hardware TEE according to claim 1, characterized in that: In step 1, the target program is preprocessed by using the clang compiler to perform a plug-in operation on the target program source code, and the plug-in operation includes inserting a sig_handler function for capturing runtime information and abnormal signals of the target program and a statistical function for recording coverage and statistical information.

3. The method for automatically detecting program vulnerabilities under hardware TEE according to claim 2, characterized in that: In step 2, the method of establishing a plurality of execution processes by the parent working thread by means of shared memory specifically includes the following steps: The fuzz test parent worker process creates the fuzz test parent worker thread through the clone system call; The worker thread uses the spawn system call to create a child process to execute the target program, and the parent worker thread and the child execution process it creates are called a work group. The parent worker thread and the child execution process communicate through shared memory.

4. The method for automatically detecting program vulnerabilities under hardware TEE according to claim 3 is characterized in that: Before the worker thread calls the process creation function to create a child process, it needs to perform preparatory work. The preparatory work specifically includes the following steps: Use the posix_spawn_file_actions_addopen function to close the standard input and output of the child process; Initialize the args[] array to store the execution parameters of the target program; Use the posix_spawnattr_set function to prepare the subroutine running environment and write relevant environment variables.

5. The method for automatically detecting program vulnerabilities under hardware TEE according to claim 4 is characterized in that: In step 3, when one of the execution processes triggers an abnormal signal, the method of storing the operation information and the abnormal signal in the corresponding shared memory specifically includes the following steps: When the program triggers an exception signal, read the siginfo_t structure to obtain the exception signal number, error number, signal code and error address; Read the program counter; Parse the / proc / [pid] / maps file to obtain the target program's memory mapping information; Use the libunwind library to obtain call stack information, traverse each call frame to obtain the PC value and function name of each frame, and determine the module name by parsing the memory map information in the / proc / [pid] / maps file; The Capstone engine is used to disassemble the instructions read from the memory, so as to store the operation information and the abnormal signal information into the corresponding shared memory according to the instructions.

6. The method for automatically detecting program vulnerabilities under hardware TEE according to claim 5, characterized in that: The operation information and exception signal information use three fields to store information in the shared memory. The three fields are exec, info, and stak. The operation information includes the operation status information, PC information, and stack information. The exec field is used to store the running status information of the subroutine, which includes: 1) "done" indicates that the program exits normally; 2) "segv" indicates that the program has a segmentation fault exception; 3) "ill" indicates that the program has an illegal instruction exception; 4) "abrt" indicates that the program has a process termination exception; 5) "fpe" indicates that the program has a page fault exception; The info field is used to store PC information and exception signal information, and the stack field is used to store stack information.

7. The method for automatically detecting program vulnerabilities under hardware TEE according to claim 6, characterized in that: In step 3, the method for analyzing the abnormal signal to obtain analysis data specifically includes the following steps: When a child process crashes, the corresponding shared memory is indexed through the parent thread TID; Get the type of exception signal, current instruction, lower 12 bits of current instruction address and stack hash value from shared memory; The uniqueness of the crash is determined by comparing the type of the exception signal, the current instruction, the lower 12 bits of the current instruction address, and whether the stack hash value has changed. The crash uniqueness judgment model has the following relationship: in, Indicates whether the abnormal signal types of the current and next stages are the same. It means judging whether the lower 12 bits of the instruction address of the current and next stages are consistent. Indicates whether the instructions of the current and next stages are consistent. Indicates whether the stack hash values ​​of the current and next stages are consistent. Indicates the logical relationship "XOR", ∩ indicates the logical relationship "AND"; Get the RES judgment value. When the result is 1, it means that the crash has not been discovered before, which means that a new vulnerability has been tested.

8. The method for automatically detecting program vulnerabilities under hardware TEE according to claim 7, characterized in that: In step 4, according to the analysis data and coverage information, the method of dynamically selecting a mutation strategy for the initial seed to mutate and using it as the input for the next stage of parallel fuzz testing specifically includes the following steps: Each seed mutation strategy is assigned a counter; In a fuzz testing iteration, if the coverage of the execution with one of the seeds as input is improved or a new vulnerability is triggered, the mutation strategy of the seed will be considered as an "interesting" strategy, and its corresponding counter will be automatically increased by 1; According to the size of the counter, the probability of the corresponding seed being selected is adjusted. The probability of the seed strategy being selected in the corpus can be calculated by the following formula: Among them Muta i represents the strategy, P_Muta i Representation strategy Muta i The probability of being selected; CN can represent the counter corresponding to the i-th seed, which will be dynamically adjusted with runtime information; n represents the total number of mutation strategies.

9. The method for automatically detecting program vulnerabilities under hardware TEE according to claim 8, characterized in that: In step 4, the seed mutation strategy includes: 1) adjusting the data size; 2) mutating bytes and bits; 3) mutating the memory; 4) mutating the data block; 5) mutating the ASCII code number; 6) mutating using a dictionary; 7) mutating using a random buffer.

10. An automatic program vulnerability detection system under hardware TEE, characterized in that: The system applies the method for automatically detecting program vulnerabilities under hardware TEE according to any one of claims 1 to 9, and the system includes: Library operating system modules for: Place the target program, fuzz testing engine, and corpus in the TEE environment; By sharing memory, the fuzz testing engine parent worker thread creates several corresponding execution processes; During the fuzz testing process, the target program's running information and coverage information are monitored and stored in the shared memory; When an execution process triggers an exception signal, the operation information and the exception signal are stored in the corresponding shared memory; Fuzz testing engine module for: Preprocess the target program and obtain several initial seeds from the corpus; The pre-processed target program is executed in parallel by using the execution process, and the initial seed is used as the initial input of the execution process for parallel fuzz testing; According to the coverage information, the corresponding seeds are put into the corpus to update the corpus; Analyze the abnormal signals to obtain analysis data, and put the corresponding seeds into the corpus to update the corpus; According to the analysis data and coverage information, the mutation strategy is dynamically selected for the initial seed to mutate, and used as the input for the next stage of parallel fuzz testing; Parallel fuzz testing is performed in an iterative manner until the termination condition is reached or an interrupt signal is received, so as to complete the automatic detection of program vulnerabilities and output a fuzz testing report.

Citation Information

Patent Citations

  • Fuzzy testing method and system for trusted execution environment of Internet of Things

    CN114610640A

  • Fuzzy testing method for various vulnerabilities

    CN116860593A

  • Automated method and system for finding vulnerabilities in a program using fuzzing

    EP4206967A1

  • Continuous vulnerability management system for blockchain smart contract based digital asset using sandbox and artificial intelligence

    US20210110047A1

Cited By

  • Kernel fuzzy testing method and device based on unicorn simulation

    CN120780591A

  • A kernel fuzzing method and apparatus based on unicorn simulation

    CN120780591B

  • Firmware grey box fuzzy testing method and system based on system simulation

    CN120811783A