Enclave program framework based on libos dynamic TCB generation system and method
By automating the process and precisely removing unused code from the Enclave to generate a dynamic TCB, the problem of excessively large TCBs caused by LibOS deployment is solved, improving security and execution efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI JIAOTONG UNIV
- Filing Date
- 2022-09-30
- Publication Date
- 2026-04-10
AI Technical Summary
In existing technologies, deploying applications based on LibOS results in excessively large TCBs, increasing security risks and making control flow analysis difficult.
By using automated methods, including similarity comparison units, deletion units, linker modification units, and dynamic library loading units, unused code in the Enclave is deleted, dynamic TCBs are generated, and unnecessary LibOS and dynamic library functions are precisely removed.
It significantly reduces the number of system calls, saves system resources, improves execution efficiency, and makes control flow integrity verification more efficient.
Smart Images

Figure CN115469924B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of information security, and particularly relates to a LibOS-based Enclave program framework dynamic trusted computing base (TCB) generation system and method. BACKGROUND
[0002] Intel SGX is a new extension of Intel architecture, which provides a function calling mechanism for the Enclave by Intel SGX SDK. The code running outside the Enclave can call the code inside the Enclave by ECALL and obtain the return value. Similarly, the code running inside the Enclave can call the code outside the Enclave by OCALL and obtain the return value. In addition, Intel SGX also supports local and remote authentication mechanisms to check whether the Enclave loads the correct expected code and generates a key in the process, which is used for encryption of private data transmitted later. The existing method of deploying an application based on LibOS makes the application very easy to be deployed to the Intel SGX platform, but at the same time, the TCB of the application running in the Enclave becomes very large. During the running of the application, a lot of unused code remains in the Enclave space, which increases the security risk and also makes the control flow analysis very difficult. SUMMARY
[0003] The present application is directed to the above-mentioned deficiencies in the prior art that deploying an application based on LibOS leads to a too large TCB. A LibOS-based Enclave program framework dynamic TCB generation system and method are provided. By deleting the unused code in the Enclave, the TCB is reduced, and the verification of the control flow integrity is more efficient while reducing the tool surface. The present application uses all automatic means, which improves the security without making it difficult for users to deploy programs. Compared with the previous scheme of reducing unused code, the present application based on the function similarity matching scheme can more accurately obtain specific system calls and more accurately delete the unused LibOS code.
[0004] The present application is implemented by the following technical solutions:
[0005] The application relates to a secure execution system arranged in a cloud platform, and specifically comprises a similarity comparison unit, a deletion unit, a linker modification unit and a dynamic library loading unit, wherein: the similarity comparison unit obtains all required system calls according to symbols in a binary file of an application program received by the cloud platform and Libc, and obtains all system calls of LibOS by similarity matching; the deletion unit deletes codes not used in LibOS and dynamic library functions according to LibOS entry function information, and obtains a reduced result; the linker modification unit deletes functions not required in a dynamic library file according to external symbol information of the application program and dynamic library call graph information, and obtains a reduced dynamic library file; and the dynamic library loading unit loads all dynamic library files required by the application program into an enclave according to interp segment information of the application program.
[0006] The application relates to a LibOS-based Enclave program framework dynamic TCB generation method based on the above system, which generates an internal function call graph of LibOS and a dynamic library according to an intermediate representation (IR) of a compilation framework, verifies the similarity of symbol information of a to-be-processed program and system call entry functions in LibOS, and reduces codes in LibOS and dynamic library functions based on a verification result, and specifically comprises the following steps.
[0007] In the first step, after all symbols called by an application program are obtained, similarity comparison is performed on the symbols and all system call entry symbols, and the system call symbol is considered as a symbol accessed by the application program when the similarity comparison is basically similar.
[0008] In the second step, after all system call symbols possibly accessed are obtained, functions irrelevant to the system call are deleted according to the function call graph of LibOS generated previously.
[0009] In the third step, the original GNU linker needs to be modified, and the modified linker is added to the Enclave space.
[0010] In the fourth step, in the process of loading the dynamic library, the modified linker deletes all dynamic library functions not called by the application program according to the dynamic library function call graph in the loading process.
[0011] Technical effects
[0012] The application utilizes the similarity between the name of Libc system call and the name of system call in LibOS, and realizes equivalent system calls through matching; compared with the prior art, after being processed by the application, 34 system calls are required for running a Python application, 44 system calls are required for running Nodejs, 34 system calls are required for running Bash, and 32 system calls are required for running R language, which significantly saves system resources and improves execution efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0013] Figures 1-3 The flowchart of the application. DETAILED DESCRIPTION
[0014] The embodiment relates to a LibOS-based Enclave program framework dynamic TCB generation method, and comprises the following steps.
[0015] The first step, as shown in the figure, generates a call graph according to IR information, and specifically comprises the following steps. Figure 1
[0016] Step 101. Compiling the source code of LibOS and dynamic library functions by using the Clang after plugging, first, the Clang tool is used to compile LibOS, and the IR generated in the compiling process is used to generate a function call graph.
[0017] Step 102. Extracting the function call graph of LibOS and the dynamic library, the call graph obtained only through the interface provided by Clang is very inaccurate, and the indirect call and the assembly language inserted in the module are the main reasons for the inaccuracy, therefore, the embodiment specifically adopts the following method: in the process of processing the indirect function call, first, all referenced functions or symbols are obtained by scanning all IR instructions, and then the functions or symbols are added to the global call graph. This method cannot achieve the optimal code reduction, because many symbols and functions in the global call graph are not necessarily called by the application program, but can guarantee that all indirect jumps required by the application program are included. Since the destination address of the indirect call is not used in the actual running process, the use-def chain mechanism of Clang is used to traverse from the entrance of the function until the instruction containing the reference to other functions is reached, and then the function and the referenced function are added to the function call graph. This method uses the information between symbols, and compared with adding all indirectly applied symbols to the call graph to reduce more code. Since the IR does not contain the information of handwritten assembly and inline assembly, the function information of the assembly language call can be obtained very conveniently by traversing the CALL and JMP instructions of the assembly module, and the embodiment adopts a conservative method to add all assembly symbols to the call graph.
[0018] Step 103. Write the extracted call graph information to the Enclave to delete unused code according to the information of the call graph.
[0019] Second step, as shown in Figure 2 According to the symbol information of the application, the semantic similarity matching is performed to obtain the system call operation required by the application, specifically including:
[0020] Step 201. Obtain all symbol names of the application through the readelf operation, merge the obtained symbol names and Libc call graph to obtain all system call symbols.
[0021] Step 202. Similarity comparison of the system call symbol names obtained in step 201 and the entry functions of LibOS system calls, and use the similarity matching tool to obtain the system calls in Libc and which system calls in LibOS correspond to each other.
[0022] Step 203. Mark the entry functions with high similarity, such as socket and shim_do_socket equivalence, shim_do_open and open equivalence.
[0023] Third step, as shown in Figure 3 From loading to deleting unused code to running the application, specifically including:
[0024] Step 301. Start the Enclave, then load LibOS to the Enclave space through the linker, obtain the disk location of LibOS, and then use the mmap system call function to load LibOS to the Enclave space.
[0025] Step 302. According to the system call information required by the application, delete the unused code in LibOS in combination with the call graph of LibOS.
[0026] Step 303. Load the updated application and GNU linker to the Enclave space, at this time LibOS has been loaded to the Enclave space, and use the functions in LibOS to load the GNU linker to the Enclave space.
[0027] Step 304. Loading the dynamic library of the application program using the linker, in the process of loading, deleting the code not needed by the application program according to the call graph of the dynamic library, scanning the text section of the application program using the linker to obtain all the external functions needed by the application program, then traversing the dynamic library function call graph starting from these functions to obtain all the dependent functions, deleting the dependent functions not needed, for example: when the application program only depends on the strlen function, then mark all the functions dependent on the strlen function starting from the strlen function, and then delete all the functions not marked.
[0028] The above specific embodiments can be adjusted in different ways by those skilled in the art without departing from the principles and purposes of the present application, the protection scope of the present application is subject to the claims and is not limited by the above specific embodiments, each implementation scheme within the scope is subject to the present application.
Claims
1. A LibOS-based Enclave program framework dynamic TCB generation system, characterized in that, The cloud platform is provided, and specifically comprises a similarity comparison unit, a pruning unit, a linker modification unit and a dynamic library loading unit, wherein: the similarity comparison unit obtains all system calls required by the cloud platform according to symbols in a binary file of an application program and Libc, and obtains all system calls of LibOS by similarity matching; the pruning unit deletes code in LibOS and dynamic library functions that are not used according to LibOS entry function information, to obtain a reduced result; the linker modification unit deletes functions in a dynamic library file that are not required according to external symbol information of the application program and dynamic library call graph information, to obtain a reduced dynamic library file; and the dynamic library loading unit loads all dynamic library files required by the application program to an enclave according to application program interp segment information. The Enclave program framework dynamic TCB generation refers to: generating an internal function call graph of LibOS and a dynamic library according to an intermediate representation of a compilation framework, verifying symbol information of a program to be processed and system call entry functions in LibOS for similarity, and reducing code in LibOS and dynamic library functions based on a verification result, and specifically comprises: In a first step, after obtaining all symbols called by an application program, the symbols are compared with all system call symbols for similarity, and when the similarity comparison is basically similar, the system call symbol is considered as a symbol that will be accessed by the application program, and specifically comprises: Step 101. Compiling source codes of LibOS and dynamic library functions by using a Clang after plugging, wherein first, the Clang is used to compile LibOS, and an IR generated in a compilation process is used to generate a function call graph; Step 102. Extracting a function call graph of LibOS and a dynamic library, and specifically comprising: a) In the process of processing indirect function calls, first, all referenced functions or symbols are obtained by scanning all IR instructions, and then the functions or symbols are added to a global call graph; a use-def chain mechanism of the Clang is used to traverse from an entrance of a function until a instruction containing a referenced function is reached, and then the function and the referenced function are added to the function call graph; b) Function information called by an assembly module is obtained by traversing CALL and JMP instructions of the assembly module, and a conservative method is used to add all assembly symbols to the call graph; Step 103. Writing the extracted call graph information to Enclave, so as to delete unused code according to the call graph information; In a second step, after obtaining all system call symbols that can be accessed, functions irrelevant to system calls are deleted according to the function call graph of LibOS generated previously; In a third step, a modified GNU linker is required, and the modified linker is added to Enclave space; In a fourth step, in the process of loading a dynamic library, the modified linker deletes all dynamic library functions that will not be called by an application program according to a dynamic library function call graph during loading.
2. A dynamic TCB generation method for a LibOS-based Enclave program framework of the system according to claim 1, characterized in that, The second step specifically comprises: Step 201. Obtain all symbol names of the application program by readelf operation, combine the obtained symbol names with the Libc call graph to obtain all system call symbols; Step 202. Similarity comparison between the system call symbol names obtained in step 201 and the entry functions of LibOS system calls, and use the similarity matching tool to obtain the corresponding system calls in Libc and which system calls in LibOS; Step 203. Mark the entry functions with high similarity.
3. The LibOS-based Enclave program framework dynamic TCB generation method of claim 2, characterized in that, The third step specifically comprises: Step 301. Start Enclave, then load LibOS into Enclave space through the linker, obtain the disk location of LibOS, and then use the mmap system call function to load LibOS into Enclave space; Step 302. According to the system call information required by the application program, delete the code in LibOS that is not used in combination with the call graph of LibOS; Step 303. Load the updated application program and GNU linker into Enclave space, LibOS has been loaded into Enclave space at this time, and use the functions in LibOS to load the GNU linker into Enclave space; Step 304. Load the dynamic library of the application program using the linker, delete the code that is not needed by the application program during the loading process according to the dynamic library call graph, scan the text segment of the application program using the linker to obtain all the external functions required by the application program, and then traverse the dynamic library function call graph starting from these external functions to obtain all the dependent functions, and delete the unnecessary dependent functions.
Citation Information
Patent Citations
Application program processing method and device, cloud environment and storage medium
CN113591091A
Dynamic link libraries without linker or loader support
US5916308A