A fuzz testing method and system for trusted execution environment of Internet of Things

By constructing test sample templates and seed files, combined with hardware emulators and scheduling algorithms, efficient fuzz testing of the trusted execution environment of low-resource IoT devices is achieved, solving the problems of low testing efficiency and poor applicability in the existing technology. Provides scalable security analysis solutions.

CN114610640BActive Publication Date: 2024-08-30ZHEJIANG UNIV

Patent Information

Application Number
CN202210291113.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-23
Publication Date
2024-08-30
Estimated Expiration
2042-03-23

AI Technical Summary

Technical Problem

Existing fuzz testing methods are difficult to effectively conduct security analysis on the trusted execution environment of low-resource IoT devices, and existing simulation-based fuzz testing technology is not applicable and lacks efficient and scalable security testing solutions.

Method used

By analyzing standard and customized trusted execution environment documents, building test sample template files and seed files, using hardware emulators to generate and transmit test samples, we can achieve efficient testing of the trusted execution environment kernel, combining scheduling algorithms and mutations. Actions generate new test cases and update seed files to improve coverage.

Benefits of technology

It realizes efficient and scalable fuzz testing of the IoT trusted execution environment, improves testing efficiency and accuracy, fills the technical gap in kernel testing of low-resource IoT devices, and supports security analysis of multiple devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114610640B
    Figure CN114610640B
Patent Text Reader

Abstract

The present invention discloses a fuzz testing method and system for a trusted execution environment of the Internet of Things, including: constructing a test template file according to the kernel functions and entities used in the trusted execution environment document of the target Internet of Things; collecting the legal system call sequence accepted by the trusted execution environment system kernel as a seed file; translating the test samples generated in the generation and mutation phases of the fuzz testing tool to generate a payload; designing user-side applications and trusted applications to complete the forwarding, translation and execution of the payload; using a hardware emulator to efficiently complete data writing and trusted execution environment kernel execution status information acquisition; using the acquired feedback information to further guide the efficient conduct of the fuzz test. The method and system enable the fuzz testing tool to perform efficient and scalable security testing on the target Internet of Things trusted execution environment kernel.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of trusted execution environment fuzzy testing, and in particular relates to a fuzzy testing method and system for a trusted execution environment of the Internet of Things. Background Art

[0002] In recent years, IoT devices have become an indispensable part of the digital age, playing an important role in defense, industry, people's livelihood, medical and other fields. As IoT applications continue to expand, their security has received more and more attention. The mainstream solution is the Trusted Execution Environment (TEE), which aims to provide a relatively reliable execution environment for key data and applications inside IoT devices. Even if the system is compromised, intruders cannot directly obtain key information.

[0003] The trusted execution environment of low-resource IoT devices has gradually entered social production and life. For example, LinkTEE designed by Alibaba has been applied to enterprise production and smart security equipment such as Cainiao GOGO, Leapmotor, Cainiao smart vending machines, and smart door locks. Although the TEE system can provide security protection for IoT devices at the theoretical level, whether the actual devices can fully realize the TEE function and whether they can avoid various potential risks are still problems that need to be solved and need to be verified through further testing.

[0004] Currently, there is no security research on the trusted execution environment of low-resource IoT devices. Most of them focus on the trusted execution environment research of resource-rich devices such as mobile phones. These security studies on resource-rich devices mainly use technical means such as manual testing, static analysis or fuzz testing. Considering that manual testing and static analysis have problems such as heavy reliance on human resources and low analysis efficiency, fuzz testing is a potential technical solution for trusted execution environment security analysis. It discovers potential program vulnerabilities by providing a large number of test cases to the running program under test, and has the characteristics of high efficiency and high precision.

[0005] However, current fuzz testing for resource-rich devices only supports fuzz testing of trusted applications in a trusted execution environment, without considering the security issues of the trusted kernel. In addition, existing simulation-based fuzz testing methods cannot be directly applied to the security analysis of the trusted execution environment of low-resource IoT devices. Due to the rich variety of IoT peripherals and the direct interaction of kernels with hardware resources, the simulation method requires adaptation to different devices, which is labor-intensive and has poor scalability. Therefore, fuzz testing techniques based on simulation or rehosting are not applicable.

[0006] In summary, how to implement efficient and scalable fuzz testing in the trusted execution environment of the Internet of Things and ensure the security of the Internet of Things is an urgent problem that needs to be solved. Summary of the invention

[0007] In view of the above, the object of the present invention is to provide a fuzzy testing method and system for a trusted execution environment of the Internet of Things to achieve efficient and scalable security testing.

[0008] To achieve the above-mentioned purpose of the invention, an embodiment provides a fuzz testing method for an IoT trusted execution environment, comprising the following steps:

[0009] Step 1: Build a test sample template file by analyzing the standard trusted execution environment document and reverse analyzing the IoT trusted execution environment document;

[0010] Step 2: Build a seed file by analyzing and running a trusted application sample;

[0011] Step 3, generating a new test sample according to the test sample template file, or after selecting the original test sample from the seed file, performing a mutation operation on the original test sample selected from the seed file according to the test sample template file and the seed file to obtain a new test sample, translating the new test sample into a payload, and transmitting the payload to the client application running on the IoT device under test through the hardware emulator;

[0012] Step 4: After the client application forwards the received payload to the trusted application, the trusted application decodes the payload into a test sample and runs the test sample to test the trusted execution environment kernel;

[0013] Step 5, obtaining the execution coverage information of the trusted execution environment kernel when the trusted application runs the test sample through the hardware emulator, and updating the seed file according to the coverage information;

[0014] Step 6, repeating steps 3 to 5, saving test samples that cause the trusted execution environment to become unresponsive or crash, and repeatedly testing the trusted execution environment using the saved test samples. When the trusted execution environment is damaged, it is considered that the trusted execution environment has a vulnerability.

[0015] In one embodiment, step 1 includes:

[0016] Step 1-1, analyzing a standard trusted execution environment document and extracting a standard function code block and an entity parameter code block of a defined trusted execution environment kernel, respectively extracting kernel function information and entity information from the standard function code block and the entity parameter code block, and respectively converting the kernel function information and the entity information into a formal first kernel function description language and a first entity description language, wherein the entity includes a structure and a union;

[0017] Step 1-2, obtaining and inferring the custom kernel function code block and the custom entity code block defined by the manufacturer in the IoT trusted execution environment document through reverse analysis, inferring the custom function information and the custom entity from the custom kernel function code block and the custom entity code block respectively, and converting the custom function information and the custom entity information into a formal second kernel function description language and a second entity description language respectively, wherein the custom entity includes a structure and a union;

[0018] Step 1-3, merging the first kernel function description language, the second kernel function description language, the first entity description language and the second entity description language to form a test sample template file used as a trusted execution environment for the Internet of Things.

[0019] In one embodiment, the kernel function information includes the function name, the number of function parameters, the function parameter type and the return value type; the custom kernel function information includes the function name, the number of parameters, the parameter type and the return value type;

[0020] The entity information includes the entity name, the number of entity parameters, and the entity parameter type; the custom entity information includes the entity name, the number of entity parameters, and the entity parameter type.

[0021] In one embodiment, step 2 includes:

[0022] Step 2-1, analyzing the trusted application example and extracting kernel functions and entities therefrom, and performing program instrumentation to output the calling sequence and actual parameter values ​​of the kernel functions and entities during the running of the trusted application example, wherein the entities include structures and unions;

[0023] Step 2-2, run the trusted application example on the real hardware environment. If no unresponsiveness or crash occurs, save the calling sequence of kernel functions and entities and the actual parameter values ​​during the running process to form a seed file according to the stub statement in step 2-1.

[0024] In step 3 of one embodiment, generating a new test sample according to the test sample template file, or selecting an original test sample from a seed file, includes:

[0025] Based on the test sample template, a set of function call sequences are randomly selected, parameters are randomly generated based on the parameter types defined in the function, and filled into the function call sequence as a new test sample;

[0026] A scheduling algorithm is used to extract a set of kernel function call sequences from the seed file as the original test samples to be mutated;

[0027] Among them, when the scheduling algorithm extracts a set of kernel function call sequences from the seed file, selection is made based on seed coverage and seed sequence length, including: giving priority to seeds with high coverage, and giving priority to kernel function call sequences with long sequences when coverage is consistent.

[0028] In step 3 of one embodiment, performing a mutation operation on an original test sample selected from the seed file according to the test sample template file and the seed file to obtain a new test sample includes:

[0029] Mutation operation 1: randomly select a kernel function from the original test sample, and implement a mutation operation based on the test sample template file that is aware of the kernel function parameter type to form a new test sample;

[0030] Mutation operation 2: randomly delete a kernel function in the original test sample to form a new test sample;

[0031] Mutation operation three: randomly insert a random kernel function into the original test sample to form a new test sample; or,

[0032] Mutation operation 4: randomly select a seed sequence from the seed file and concatenate it with the original test sample to form a new test sample.

[0033] In step 3 of one embodiment, translating the new test sample into a payload includes:

[0034] The new test sample is translated into a byte string as a payload. The translation process includes: translating the kernel function name into a preset system call number, and translating the system function parameter type information and value information into corresponding character representations.

[0035] In step 5 of one embodiment, obtaining execution coverage information of the trusted execution environment kernel includes:

[0036] Design event-based and address-based execution coverage filtering through hardware simulator, and perform flow analysis based on embedded tracing macro units or GDB debugging on the trusted execution environment kernel to obtain the execution coverage information of the trusted execution environment kernel;

[0037] The address-based execution coverage filtering refers to obtaining coverage information for secure addresses in a trusted execution environment through flow analysis based on embedded macro units or GDB debugging, and not obtaining coverage for non-secure addresses;

[0038] The event-based execution coverage filtering refers to starting the embedded macro unit-based or GDB debugging-based flow analysis at the beginning of executing a group of test samples to obtain coverage information, and ending the embedded macro unit-based or GDB debugging-based flow analysis after the execution of a group of test samples is completed, and stopping obtaining coverage information;

[0039] In step 5, the seed file is updated according to the coverage information, including: saving the test samples and the execution coverage information corresponding to the test samples to the seed file to update the seed file.

[0040] To achieve the above-mentioned purpose of the invention, the embodiment provides a fuzzy testing system for an IoT trusted execution environment, including a host, a hardware emulator, and an IoT device under test;

[0041] The host comprises a fuzzy test engine, a feedback information processing module, and a test result security analysis module, wherein the fuzzy test engine is used to generate a test sample according to a constructed test sample template file and a seed file, and convert the test sample into a payload, and the feedback information processing module is used to update the seed file according to the received execution coverage information of the trusted execution environment kernel; the test result security analysis module is used to repeatedly test the trusted execution environment according to the saved test samples, and when the trusted execution environment is damaged, it is considered that there is a vulnerability in the trusted execution environment, wherein the saved test sample refers to a test sample that causes the trusted execution environment to be unresponsive or crashed;

[0042] The hardware emulator comprises an address-based filter module and an event-based filter module, wherein the hardware emulator is used to forward the payload to the trusted execution environment kernel test module, and is also used to forward the execution coverage information of the trusted execution environment kernel to the feedback information processing module, and the address-based filter module and the event-based filter module are used to filter the execution coverage of the trusted execution environment to obtain the trusted execution environment kernel coverage;

[0043] The IoT device under test includes a trusted execution environment kernel test module, which is used to decode the received payload to form a test sample, and then use the test sample to test the trusted execution environment kernel to generate execution coverage information of the trusted execution environment kernel.

[0044] In one embodiment, the fuzz testing engine includes a test template construction module, a seed file construction module, a test sample generation module, a test sample mutation module, and a payload generation module;

[0045] The test template construction module is used to construct a test sample template file by analyzing a standard trusted execution environment document and reversely analyzing an IoT trusted execution environment document;

[0046] The seed file building module is used to build a seed file by analyzing and running a trusted application example;

[0047] The test sample generation module is used to construct the original test sample according to the test sample template file or the seed file;

[0048] The test sample mutation module is used to perform a mutation operation on the original test sample constructed according to the seed file according to the test sample template file and the seed file to obtain a new test sample;

[0049] The payload generation module is used to translate the original test sample and the new test sample into a payload.

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

[0051] (1) The present invention improves the quality of fuzzy test sample generation by constructing a test sample template file of a trusted execution environment, including a function template and an entity template, and using a legal system call sequence as an initial seed file;

[0052] (2) The present invention uses a hardware emulator to achieve efficient data transmission. Compared with the re-hosting technology used in related work, the present invention does not need to simulate the working environment of the IoT device and has good scalability and accuracy; compared with the interactive forwarding technology used in related work, the present invention does not need to synchronize device status information and has good fuzzy testing efficiency.

[0053] (3) Taking into account the limited resources of IoT devices, the present invention presets rules for test samples, translates system call sequences into payloads and sends them to the IoT device under test, thereby separating the test scheduling engine and the test sample execution module, filling the technical gap in testing the kernel of the IoT trusted execution environment. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] 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 of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0055] Figure 1 It is a flow chart of a fuzzy testing method for an Internet of Things trusted execution environment provided by an embodiment;

[0056] Figure 2 is a test template generation flow chart provided by an embodiment;

[0057] Figure 3 is a schematic diagram of the format of the effective load generated by compilation provided by the embodiment;

[0058] Figure 4 is a trusted execution environment kernel test flow chart provided by an embodiment;

[0059] Figure 5 A schematic diagram of the structure of a fuzzy testing system for an Internet of Things trusted execution environment provided in an embodiment. DETAILED DESCRIPTION

[0060] To make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific implementation methods described herein are only used to explain the present invention and do not limit the scope of protection of the present invention.

[0061] In view of the shortcomings in the security analysis of the trusted execution environment of the Internet of Things, the embodiment provides a fuzz testing method and system for the trusted execution environment of the Internet of Things, which realizes fuzz testing of the trusted execution environment on real hardware, and has good scalability and high testing efficiency. Specifically, by designing a test sample template file (function template, structure and union template) for the trusted execution environment, and then collecting and constructing a seed file for the trusted execution environment through the existing trusted program application situation, a fuzz testing framework with scheduling and execution separation is designed to separate the sample generation and sample execution in the traditional fuzz testing tool, a translation method for the system call sequence is designed, and the samples generated by the fuzz testing tool are converted into a payload byte string. The hardware emulator is used to complete the writing of the payload data and the acquisition of the feedback information of the kernel status information of the trusted execution environment, thereby realizing efficient and scalable fuzz testing of the Internet of Things devices, so as to realize efficient vulnerability mining of the trusted execution environment.

[0062] Figure 1 1 is a flow chart of a fuzzy testing method for an IoT trusted execution environment provided by an embodiment. Figure 1 As shown, the fuzz testing method for the Internet of Things trusted execution environment provided by the embodiment includes the following steps:

[0063] Step 1: Build a test sample template file by analyzing the standard trusted execution environment document and reverse analyzing the IoT trusted execution environment document.

[0064] In the embodiment, the constructed test sample template file comes from the binary code included in the standard trusted execution environment document and the Internet of Things trusted execution environment document. Specifically, the following steps are included:

[0065] Step 1-1, constructing a first kernel function description language and a first entity description language by analyzing a standard trusted execution environment document.

[0066] In an embodiment, a standard trusted execution environment document is obtained and analyzed, and standard function code blocks and entity parameter code blocks of a defined trusted execution environment kernel are extracted from the standard trusted execution environment document, wherein the entity parameter code blocks are parameter code blocks including entities such as structures and unions.

[0067] After obtaining the standard function code block, kernel function information such as function name, number of function parameters, function parameter type and return value type of the IoT trusted execution environment kernel standard function is extracted from the standard function code block, and the kernel function information is further converted into a formalized first kernel function description language.

[0068] After obtaining the entity parameter code block, entity information such as the IoT trusted execution environment entity name, the number of entity parameters, and the entity parameter type is extracted from the entity parameter code block, and the entity information is further converted into a formal first entity description language. It should be noted that entities include standard structures and unions.

[0069] Step 1-2, construct the second kernel function description language and the second entity description language by reverse analyzing the IoT trusted execution environment document.

[0070] In an embodiment, the binary code of the IoT trusted execution environment is obtained and reverse analyzed to infer the custom kernel function code blocks and custom entity code blocks customized by the manufacturer in the IoT trusted execution environment, wherein the custom entity code blocks and the custom kernel function code blocks are both binary code blocks, and the custom entity code blocks are binary code blocks including entities such as structures and unions.

[0071] After obtaining the custom kernel function code block, the custom function information including the kernel function call name, the number of kernel parameters, the kernel parameter type and the return value is inferred based on the internal data flow graph and the external call relationship included in the custom kernel function code block; the custom function information is further converted into a formalized second kernel function description language.

[0072] After obtaining the custom entity code block, the custom entity (structure and union) information including the entity name, number of entity parameters and entity parameter type is inferred based on the initialization code and calling code of the entity (structure and union) binary code, and the custom entity information is further converted into a formal second entity description language.

[0073] Step 1-3, merging the first kernel function description language, the second kernel function description language, the first entity description language and the second entity description language to form a test sample template file used as a trusted execution environment for the Internet of Things. The kernel function is also called a system call function.

[0074] To further facilitate the understanding of those skilled in the art, taking the IoT trusted execution environment document designed by semiconductor intellectual property provider ARM as an example, the specific implementation of template construction is as follows: Figure 2 shown.

[0075] Step 2: Build a seed file by analyzing and running a sample trusted application.

[0076] In the embodiment, according to the example of running a trusted application successfully executed by the target IoT trusted execution environment system kernel, the function sequence and parameter information are recorded to construct a seed file, specifically including:

[0077] Step 2-1, automatically identify the source code of the trusted application example provided by the manufacturer, extract the kernel functions and entities (structures and unions) from it, perform program instrumentation, and output the calling sequence and actual parameter values ​​of the kernel functions and entities (structures and unions) during the running of the trusted application example.

[0078] Step 2-2, run the trusted application example on the real hardware environment. During the execution, if no response or crash occurs, re-run the trusted application example or select other trusted application examples to run; if no response or crash occurs, save the calling sequence of kernel functions and entities and the actual parameter values ​​during the running process according to the stub statement in step 2-1 to form a seed file.

[0079] Step 3: Generate a new test sample according to the test sample template file or select an original test sample from the seed file.

[0080] In the embodiment, a set of function call sequences are randomly selected according to the test sample template, parameters are randomly generated based on the function parameter type defined in the test sample template, and filled into the function call sequence as a new test sample, or the test sample template file obtained in step 1 and the seed file obtained in step 2 are saved to the host, and then a set of kernel function call sequences are extracted from the seed file using a scheduling algorithm as the original test sample to be mutated. Wherein, when the scheduling algorithm extracts a set of kernel function call sequences from the seed file, selection is made based on seed coverage and seed sequence length, including: giving priority to seeds with high coverage, and giving priority to kernel function call sequences with long sequences when coverage is consistent.

[0081] Step 4: Perform a mutation operation on the original test sample extracted from the seed file according to the test sample template file and the seed file to obtain a new test sample.

[0082] Since the test sample template file is constructed based on the standard trusted execution environment document and the manufacturer's IoT trusted execution environment document, it is specific. Therefore, there is no need to mutate the original test sample extracted from the test sample template file. However, it is necessary to mutate the original test sample constructed based on the seed file. Specifically, the original test sample is mutated based on the test sample template file and the seed file. At least one of the following four methods can be used to perform mutation operations to construct a new test sample:

[0083] Mutation operation 1: randomly select a kernel function from the original test sample, and implement a mutation operation based on the test sample template file that is aware of the kernel function parameter type to form a new test sample;

[0084] Mutation operation 2: randomly delete a kernel function in the original test sample to form a new test sample;

[0085] Mutation operation three: randomly insert a random kernel function into the original test sample to form a new test sample;

[0086] Mutation operation 4: randomly select a seed sequence from the seed file and concatenate it with the original test sample to form a new test sample.

[0087] Step 5: Translate the new test case into a payload.

[0088] In an embodiment, translating a new test sample into a payload includes: translating the original test sample and the new test sample into a byte string as a payload, and the translation process includes: translating the kernel function name into a preset system call number, and translating the system function parameter type information and value information into corresponding character representations.

[0089] When translating, first prepare an empty string buffer to store the payload byte string, and then repeat the following steps until all kernel functions in the test sample are translated: select the kernel functions in the test sample in turn, translate their system call numbers into integer strings, and put them into the empty string buffer; then for all parameters of the system call function, translate the type information into an integer string and put it into the string buffer; then, for each parameter of the system call function, translate its value into a corresponding integer string or special string. After completing the translation of all kernel functions, call the hardware emulator to transmit the payload string to the client application of the IoT device under test. To further facilitate the understanding of those skilled in the art, the constructed payload format is as follows Figure 3 shown.

[0090] In step 6, the payload is transmitted to the client application running on the IoT device under test through the hardware emulator, and the client application forwards the received payload to the trusted application.

[0091] In the embodiment, the translated payload is transmitted to the client application running on the IoT device under test through the hardware simulator. After receiving the payload, the client application creates a buffer to store the payload, and calls an interface function that interacts with the trusted application to forward the payload to the trusted application through the interface function.

[0092] Step 7: The trusted application decodes the payload into an executable test sample and then runs the test sample to test the trusted execution environment kernel.

[0093] In the embodiment, based on the mainstream fuzzy testing framework designed for the operating system kernel, a fuzzy testing framework with scheduling and execution separation is designed and constructed for the IoT trusted execution environment. The fuzzy testing framework implements efficient testing of the trusted environment on real hardware through steps 3 to 7. To further facilitate the understanding of those skilled in the art, the trusted execution environment kernel testing process executed in steps 6 and 7 is as follows: Figure 4 shown.

[0094] Step 8: Obtain the execution coverage information of the trusted execution environment kernel when the trusted application runs the test sample through the hardware emulator, and update the seed file according to the coverage information.

[0095] In the embodiment, on the fuzz test framework designed in steps 3 to 7, fuzz test feedback information (that is, execution coverage information) is obtained based on the hardware emulator. The obtained fuzz test feedback information is used to guide the seed selection process of the fuzz test to improve the efficiency of the fuzz test.

[0096] After each test sample is executed, the address-based and event-based execution coverage filters are designed through the hardware simulator, and the execution coverage information of the trusted execution environment kernel is obtained by flow analysis based on embedded tracing macro units or based on GDB debugging (a debugging tool released by the GNU organization).

[0097] Specifically, the address-based execution coverage filtering performs embedded macro unit-based or GDB debugging-based flow analysis to obtain coverage information for secure addresses in the trusted execution environment, and does not obtain coverage for non-secure addresses. The event-based execution coverage filtering starts the embedded macro unit-based or GDB debugging-based flow analysis at the beginning of executing a group of test samples to obtain coverage information. After a group of test samples are executed, the embedded macro unit-based or GDB debugging-based flow analysis is stopped and the acquisition of coverage information is stopped.

[0098] Among them, when using GDB debugging to obtain code coverage information, first add the corresponding compilation options (-fprofile-arcs-ftest-coverage) to compile the target trusted execution environment system to obtain program branch information. Then use GDB to debug the target system, call the dump binary memory command before the end of the run to obtain the memory information when the branch jumps, and save it in the form of a file on the host side. After a test is executed, the memory information file is analyzed in combination with the program branch information to obtain information such as code coverage; when using embedded tracing macro units to obtain code coverage information, use a hardware emulator to track the instruction information and data information of the program in real time during runtime, reconstruct the program execution status, obtain code coverage, and transmit it to the host through the hardware emulator. Based on the coverage information obtained, the host saves the test sample and the corresponding test sample coverage to the seed file, updates the seed file, and provides data support for the scheduling algorithm.

[0099] Step 9: Based on steps 3 to 8, a large number of test samples are sent to observe the response of the trusted execution environment for security analysis.

[0100] In the embodiment, steps 3 to 8 are repeated, that is, a large number of test samples are sent to the trusted execution environment and the trusted execution environment is allowed to execute, and it is observed whether there are test samples that make the trusted execution environment unresponsive or crash. If so, the test samples are saved; if not, the test is continued until the set test time is reached.

[0101] After the test is completed, a set of test samples that cause the trusted execution environment to become unresponsive or crash are saved. The trusted execution environment is tested repeatedly using the saved test samples, and the changes in the trusted execution environment memory are analyzed. If the trusted execution environment memory is damaged, it is considered that the trusted execution environment has a vulnerability; otherwise, it is considered that the test sample does not cause a vulnerability.

[0102] In one implementation, the NuMaker-PFM-M2351 development board released by Nuvoton Technology Co., Ltd. is used, and JTrace Pro is used as a hardware emulator to test the mTower Trusted Execution Environment for the Internet of Things proposed by Samsung Electronics. It is found that the mTower system kernel has errors such as illegal access to memory addresses caused by functions such as TEE_MemMove and TEE_Malloc.

[0103] Based on the same inventive concept, the embodiment also provides a fuzzy testing system for the trusted execution environment of the Internet of Things. Figure 5As shown, the provided fuzz testing system includes a host, a hardware emulator, and an IoT device under test. The host includes a fuzz testing engine, a feedback information processing module, and a test result security analysis module. The fuzz testing engine includes a test template construction module, a seed file construction module, a test sample generation module, a test sample mutation module, and a payload generation module. The hardware emulator includes an address-based filter module and an event-based filter module. The IoT device under test includes a trusted execution environment kernel test module.

[0104] The test template construction module is used to construct a test sample template file by analyzing the standard trusted execution environment document and reverse analyzing the IoT trusted execution environment document; the seed file construction module is used to construct a seed file by analyzing and running a trusted application example; the test sample generation module is used to construct an original test sample based on the test sample template file or the seed file; the test sample mutation module is used to mutate the original test sample constructed based on the seed file based on the test sample template file and the seed file to obtain a new test sample; the payload generation module is used to translate the original test sample and the new test sample into a payload; the hardware emulator is used to forward the payload to the trusted execution environment kernel test module, and is also used to convert the trusted execution environment kernel's The execution coverage information is forwarded to the feedback information processing module, wherein the address-based filter module and the event-based filter module are used to filter the execution coverage of the trusted execution environment to obtain the kernel coverage of the trusted execution environment; the trusted execution environment kernel test module is used to decode the received payload to form a test sample, and then use the test sample to test the kernel of the trusted execution environment to generate the execution coverage information of the kernel of the trusted execution environment; the feedback information processing module is used to update the seed file according to the received execution coverage information of the kernel of the trusted execution environment; the test result security analysis module is used to repeatedly test the trusted execution environment according to the saved test samples to observe the response of the trusted execution environment for static and dynamic security analysis.

[0105] It should be noted that when the fuzzy testing device for the trusted execution environment of the Internet of Things provided by the above-mentioned embodiment performs fuzz testing, the division of the above-mentioned functional modules should be used as an example to illustrate, and the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the terminal or server is divided into different functional modules to complete all or part of the functions described above. In addition, the fuzzy testing device for the trusted execution environment of the Internet of Things provided by the above-mentioned embodiment and the fuzzy testing method embodiment for the trusted execution environment of the Internet of Things belong to the same concept, and its specific implementation of the fuzzy testing method embodiment for the trusted execution environment of the Internet of Things will not be repeated here.

[0106] The fuzz testing method and system for the trusted execution environment of the Internet of Things provided in the above-mentioned embodiments construct a test sample template file through the specification document analysis of the trusted execution environment and the automatic function reverse analysis method, and implement vulnerability mining in combination with fuzz testing without obtaining the source code of the trusted environment; the testing process is fully automated, which can reduce the manual burden and support the security analysis of the trusted execution environment of all manufacturers; by providing the configuration file of the corresponding Internet of Things device to the hardware emulator, modifying the test sample template file and the seed file, it can be easily expanded to the test framework of the software system on different Internet of Things devices.

[0107] The specific implementation methods described above provide a detailed description of the technical solutions and beneficial effects of the present invention. It should be understood that the above is only the most preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, supplements and equivalent substitutions made within the scope of the principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A fuzz testing method for an IoT trusted execution environment, characterized in that: The following steps are involved: Step 1: Build a test sample template file by analyzing the standard trusted execution environment document and reverse analyzing the IoT trusted execution environment document; Step 2: Build a seed file by analyzing and running a trusted application sample; Step 3, generating a new test sample according to the test sample template file, or after selecting the original test sample from the seed file, performing a mutation operation on the original test sample selected from the seed file according to the test sample template file and the seed file to obtain a new test sample, translating the new test sample into a payload, and transmitting the payload to the client application running on the IoT device under test through the hardware emulator; Step 4: After the client application forwards the received payload to the trusted application, the trusted application decodes the payload into a test sample and runs the test sample to test the trusted execution environment kernel; Step 5, obtaining the execution coverage information of the trusted execution environment kernel when the trusted application runs the test sample through the hardware emulator, and updating the seed file according to the coverage information; Step 6, repeating steps 3 to 5, saving test samples that cause the trusted execution environment to become unresponsive or crash, and repeatedly testing the trusted execution environment using the saved test samples. When the trusted execution environment is damaged, it is considered that the trusted execution environment has a vulnerability.

2. The fuzz testing method for the Internet of Things trusted execution environment according to claim 1 is characterized in that: Step 1 includes: Step 1-1, analyzing a standard trusted execution environment document and extracting a standard function code block and an entity parameter code block of a defined trusted execution environment kernel, respectively extracting kernel function information and entity information from the standard function code block and the entity parameter code block, and respectively converting the kernel function information and the entity information into a formal first kernel function description language and a first entity description language, wherein the entity includes a structure and a union; Step 1-2, obtaining and inferring the custom kernel function code block and the custom entity code block defined by the manufacturer in the IoT trusted execution environment document through reverse analysis, inferring the custom function information and the custom entity from the custom kernel function code block and the custom entity code block respectively, and converting the custom function information and the custom entity information into a formal second kernel function description language and a second entity description language respectively, wherein the custom entity includes a structure and a union; Step 1-3, merging the first kernel function description language, the second kernel function description language, the first entity description language and the second entity description language to form a test sample template file used as a trusted execution environment for the Internet of Things.

3. The fuzz testing method for the Internet of Things trusted execution environment according to claim 2 is characterized in that: The kernel function information includes the function name, the number of function parameters, the function parameter type and the return value type; the custom kernel function information includes the function name, the number of parameters, the parameter type and the return value type; The entity information includes the entity name, the number of entity parameters, and the entity parameter type; the custom entity information includes the entity name, the number of entity parameters, and the entity parameter type.

4. The fuzz testing method for the Internet of Things trusted execution environment according to claim 1 is characterized in that: Step 2 includes: Step 2-1, analyzing the trusted application example and extracting kernel functions and entities therefrom, and performing program instrumentation to output the calling sequence and actual parameter values ​​of the kernel functions and entities during the running of the trusted application example, wherein the entities include structures and unions; Step 2-2, run the trusted application example on the real hardware environment. If no unresponsiveness or crash occurs, save the calling sequence of kernel functions and entities and the actual parameter values ​​during the running process to form a seed file according to the stub statement in step 2-1.

5. The fuzz testing method for the Internet of Things trusted execution environment according to claim 1 is characterized in that: In step 3, a new test sample is generated according to the test sample template file, or an original test sample is selected from a seed file, including: Based on the test sample template, a set of function call sequences are randomly selected, parameters are randomly generated based on the parameter types defined in the function, and filled into the function call sequence as a new test sample; A scheduling algorithm is used to extract a set of kernel function call sequences from the seed file as the original test samples to be mutated; Among them, when the scheduling algorithm extracts a set of kernel function call sequences from the seed file, selection is made based on seed coverage and seed sequence length, including: giving priority to seeds with high coverage, and giving priority to kernel function call sequences with long sequences when coverage is consistent.

6. The fuzz testing method for the Internet of Things trusted execution environment according to claim 1 is characterized in that: In step 3, a mutation operation is performed on the original test sample selected from the seed file according to the test sample template file and the seed file to obtain a new test sample, including: Mutation operation 1: randomly select a kernel function from the original test sample, and implement a mutation operation based on the test sample template file that is aware of the kernel function parameter type to form a new test sample; Mutation operation 2: randomly delete a kernel function in the original test sample to form a new test sample; Mutation operation three: randomly insert a random kernel function into the original test sample to form a new test sample; or, Mutation operation 4: randomly select a seed sequence from the seed file and concatenate it with the original test sample to form a new test sample.

7. The fuzz testing method for the Internet of Things trusted execution environment according to claim 1 is characterized in that: In step 3, the new test case is translated into a payload, including: The new test sample is translated into a byte string as a payload. The translation process includes: translating the kernel function name into a preset system call number, and translating the system function parameter type information and value information into corresponding character representations.

8. The fuzz testing method for the Internet of Things trusted execution environment according to claim 1 is characterized in that: In step 5, the execution coverage information of the trusted execution environment kernel is obtained, including: Design event-based and address-based execution coverage filtering through hardware simulator, and perform flow analysis based on embedded tracing macro units or GDB debugging on the trusted execution environment kernel to obtain the execution coverage information of the trusted execution environment kernel; Wherein, the address-based execution coverage filtering refers to obtaining coverage information for secure addresses in a trusted execution environment by performing flow analysis based on embedded macro units or based on GDB debugging, and not obtaining coverage for non-secure addresses; The event-based execution coverage filtering refers to starting the embedded macro unit-based or GDB debugging-based flow analysis at the beginning of executing a group of test samples to obtain coverage information, and ending the embedded macro unit-based or GDB debugging-based flow analysis after the execution of a group of test samples is completed, and stopping obtaining coverage information; In step 5, the seed file is updated according to the coverage information, including: saving the test samples and the execution coverage information corresponding to the test samples to the seed file to update the seed file.

9. A fuzzy testing system for an IoT trusted execution environment, characterized in that: Including host, hardware emulator, and IoT device under test; The host comprises a fuzzy test engine, a feedback information processing module, and a test result security analysis module, wherein the fuzzy test engine is used to generate a test sample according to a constructed test sample template file and a seed file, and convert the test sample into a payload, and the feedback information processing module is used to update the seed file according to the received execution coverage information of the trusted execution environment kernel; the test result security analysis module is used to repeatedly test the trusted execution environment according to the saved test samples, and when the trusted execution environment is damaged, it is considered that there is a vulnerability in the trusted execution environment, wherein the saved test sample refers to a test sample that causes the trusted execution environment to be unresponsive or crashed; The hardware emulator comprises an address-based filter module and an event-based filter module, wherein the hardware emulator is used to forward the payload to the trusted execution environment kernel test module, and is also used to forward the execution coverage information of the trusted execution environment kernel to the feedback information processing module, and the address-based filter module and the event-based filter module are used to filter the execution coverage of the trusted execution environment to obtain the trusted execution environment kernel coverage; The IoT device under test includes a trusted execution environment kernel test module, which is used to decode the received payload to form a test sample, and then use the test sample to test the trusted execution environment kernel to generate execution coverage information of the trusted execution environment kernel.

10. The fuzzy testing system for the Internet of Things trusted execution environment according to claim 9, characterized in that: The fuzz testing engine includes a test template construction module, a seed file construction module, a test sample generation module, a test sample mutation module, and a payload generation module; The test template construction module is used to construct a test sample template file by analyzing a standard trusted execution environment document and reversely analyzing an IoT trusted execution environment document; The seed file building module is used to build a seed file by analyzing and running a trusted application example; The test sample generation module is used to construct the original test sample according to the test sample template file or the seed file; The test sample mutation module is used to perform a mutation operation on the original test sample constructed according to the seed file according to the test sample template file and the seed file to obtain a new test sample; The payload generation module is used to translate the original test sample and the new test sample into a payload.

Citation Information

Patent Citations

  • Seed generation method and system for kernel fuzzy test of trusted operating system

    CN113419960A

  • Variation method for kernel fuzzy test of trusted operating system

    CN114139164A

Cited By

  • A method and system for fuzz testing satellite network protocols

    CN122909170A