Client application side security reinforcement method, device and electronic equipment
By creating containers in client applications and implementing private communications and isolating external observations, the lack of security of client applications outside the trusted execution environment is solved, and security is significantly improved and attacks are prevented and man-in-the-middle attacks are prevented.
Patent Information
- Application Number
- CN202111672832.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-31
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2041-12-31
AI Technical Summary
Existing client applications are vulnerable to attacks in the running environment outside the trusted execution environment, and code behaviors and temporary data files are easily observed and stolen by the outside world, resulting in insufficient security.
By creating a container inside the client application, the client application main code runs under the container, private communication with the main call program is realized, and the container's running environment is mapped to the main call program's running environment, thereby isolating the outside world Observe and attack.
It effectively reduces the attack surface of client applications and trusted applications, improves security, prevents attacks and man-in-the-middle attacks, and enhances the protection of code and data.
Smart Images

Figure CN114398597B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a security reinforcement method, device and electronic equipment on a client application side. Background Art
[0002] Trusted Execution Environment (TEE) can ensure computing without interference from regular operating systems, so it is called "trusted". TEE is usually used for mobile payments, secure storage of confidential data, digital copyright protection, etc. TEE has become a standard feature of biometric devices. By using TEE, fingerprint collection, storage, verification and other processes are isolated. Even if the terminal is jailbroken, attackers cannot obtain fingerprint data. A complete operating system runs inside the TEE, which is isolated from the untrusted execution environment (Rich Execution Environment, REE). TEE and REE interact through shared memory. TEE is also divided into kernel state and user state. The user state of TEE can run multiple different security applications. The most direct way to use TEE in REE is to communicate with the TA in TEE. The communication end in REE is called Client Application (CA).
[0003] Originally, the main code logic of CA was exposed in the REE world and could be easily observed by the outside world. For example, the superuser program could "catch" the running program of CA through the ptrace system call and observe all the system call behaviors of CA. If CA itself generates temporary data files, they can also be read by other programs in the REE with permissions. The shared memory opened between multiple processes within CA itself can be shared and read by other programs with permissions. Based on this, once there is negligence or loopholes in the code behavior of CA, it can be easily caught or caused by man-in-the-middle attacks.
[0004] In summary, there is an urgent need for a client application side security reinforcement method to solve the problems existing in the above-mentioned prior art. Summary of the invention
[0005] Since the existing methods have the above problems, the present invention proposes a security reinforcement method, device and electronic device on the client application side.
[0006] In a first aspect, the present invention provides a method for strengthening security on a client application side, comprising:
[0007] Create private communication between the main caller of the client application and the main code of the client application;
[0008] Creating a first container to run the client application main code;
[0009] Mapping the operating environment of the first container to the operating environment of the main calling program of the client application;
[0010] Run the client application main code through the first container;
[0011] After the execution is completed, the execution result is returned to the main calling program of the client application.
[0012] Furthermore, the step of establishing private communication between the main calling program of the client application and the main code of the client application includes:
[0013] Creating an anonymous pipe between the main caller of the client application and the main code of the client application; and / or,
[0014] Create an anonymous socket pair between the main caller of the client application and the main code of the client application.
[0015] Furthermore, the step of creating an anonymous pipeline between the main calling program of the client application and the main code of the client application includes:
[0016] An anonymous pipe is created between the main calling program of the client application and the main code of the client application through the pipe system call.
[0017] Furthermore, mapping the operating environment of the first container to the operating environment of the main calling program of the client application includes:
[0018] Create a temporary private directory;
[0019] Mapping the file system environment outside the first container to the temporary private directory.
[0020] Furthermore, the method further comprises:
[0021] Creating a second container outside the main calling program of the client application;
[0022] Calling the client application main code through the second container;
[0023] The calling result is returned to the calling program outside the second container.
[0024] In a second aspect, the present invention provides a security reinforcement device on a client application side, comprising:
[0025] A creation module is used to establish private communication between the main caller of the client application and the main code of the client application; and to create a first container for running the main code of the client application;
[0026] A processing module is used to map the operating environment of the first container into the operating environment of the main calling program of the client application; run the main code of the client application through the first container; and return the execution result to the main calling program of the client application after the running is completed.
[0027] Furthermore, the creation module is specifically used for:
[0028] Creating an anonymous pipe between the main caller of the client application and the main code of the client application; and / or,
[0029] Create an anonymous socket pair between the main caller of the client application and the main code of the client application.
[0030] Furthermore, the creation module is specifically used for:
[0031] An anonymous pipe is created between the main calling program of the client application and the main code of the client application through the pipe system call.
[0032] Furthermore, the processing module is specifically used for:
[0033] Create a temporary private directory;
[0034] Mapping the file system environment outside the first container to the temporary private directory.
[0035] Furthermore, the processing module is also used for:
[0036] Creating a second container outside the main calling program of the client application;
[0037] Calling the client application main code through the second container;
[0038] The calling result is returned to the calling program outside the second container.
[0039] In a third aspect, the present invention further provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the client application side security reinforcement method as described in the first aspect is implemented.
[0040] In a fourth aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the client application side security reinforcement method as described in the first aspect.
[0041] It can be seen from the above technical solutions that the security reinforcement method, device and electronic device on the client application side provided by the present invention, by creating a container inside the client application so that the client application main code runs under the container, isolates the outside world from observing the client application, and can effectively reduce the attack surface of CA and TA, thereby playing a role in CA security reinforcement. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] 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 paying creative work.
[0043] Figure 1 The system framework of the security reinforcement method for the client application side provided by the present invention;
[0044] Figure 2 A schematic diagram of the process of the security reinforcement method for the client application side provided by the present invention;
[0045] Figure 3 A schematic diagram of the process flow of the security reinforcement method for the client application side provided by the present invention;
[0046] Figure 4 A schematic diagram of the structure of a security reinforcement device on the client application side provided by the present invention;
[0047] Figure 5 This is a schematic structural diagram of an electronic device provided by the present invention. DETAILED DESCRIPTION
[0048] The specific implementation of the present invention is further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the protection scope of the present invention.
[0049] With the development of technologies such as Face ID, fingerprint recognition, 5G, and AI, mobile Internet has quietly taken root in modern life. With the mobility of daily life, the various sensitive information stored in mobile terminals is increasing, and the security of mobile terminals themselves is facing huge challenges.
[0050] The environment in which the mobile system runs is called REE (Rich Execution Environment), and the system running in it is called Rich OS, such as the most common Android system. However, REE is an open environment and is vulnerable to malware attacks, such as sensitive data theft, digital copyright abuse, and mobile payment theft. Therefore, the Trusted Execution Environment (TEE) came into being. TEE is an independent execution environment that runs side by side with REE. It has its own execution space and a higher security level than Rich OS. It provides security services for Rich OS, such as fingerprint entry comparison, payment verification and authentication, and other operations.
[0051] Furthermore, the systems and applications running in REE are Rich OS and CA respectively, while the systems and applications running in TEE are Trusted OS and TA respectively.
[0052] Specifically, CA (Client APP) corresponds to some upper-level applications, such as fingerprint collection, payment applications, etc., and interacts with the TEE environment by calling the TEE Client API. TA (Trusted Application) is an application that completes specific functions in TEE. Since calculations are completed in TEE, it has higher security. Each TA has one or more corresponding CAs in REE. In the REE environment, by calling the CA interface, the information can be transmitted to the TEE environment to execute the TA, complete the corresponding functions and then return the calculation results.
[0053] In the above TEE architecture, the operating environment of CA is extremely complex and most vulnerable to attacks. For example, CA's temporary files may be observed by the outside world, CA's inter-process communication resources, and CA's code behavior may also be observed by the outside world, thus creating materials for attacking TA.
[0054] The client application side security reinforcement method provided by the embodiment of the present invention can be applied to Figure 1 In the system architecture shown, the system architecture includes REE100 and TEE200.
[0055] Specifically, the CA of REE100 calls the TEE Client API to trigger a system call, enters the kernel state of the operating system of REE100, and finds the corresponding REE driver according to the parameters called by the CA. The REE driver enters the Monitor mode by calling the SMC assembly instruction, and switches the processor to the secure kernel state to enter the secure mode.
[0056] Furthermore, after switching to TEE200, CA's service request is transmitted to the TEE side through the bus, and then TEE OS calls the corresponding TA through TEE Internal API. Finally, after TA runs, it returns the running results and data to CA. After execution, it returns to TEE kernel state to call SMC assembly instructions to enter Monitor and switch back to REE100 environment.
[0057] It should be noted that Figure 1 This is only an example of the system architecture of the embodiment of the present invention, and the present invention does not make any specific limitation to this.
[0058] Based on the system architecture shown above, Figure 2 A schematic diagram of a process flow corresponding to a method for strengthening security on a client application side provided by an embodiment of the present invention, such as Figure 2 As shown, the method includes:
[0059] Step 201 : establishing private communication between the main calling program of the client application and the main code of the client application.
[0060] In the embodiment of the present invention, the main calling program of the client application first creates a private communication for communication between the main calling program and the client application main code.
[0061] In a possible implementation, an anonymous pipe is created between the main calling program of the client application and the main code of the client application.
[0062] Specifically, a one-way communication pipe is created through the pipe system call.
[0063] The fd parameter in the pipe system call is an integer array with two elements. After the pipe call is successful, fd[0] becomes the read end of the anonymous pipe, and fd[1] becomes the write end of the anonymous pipe.
[0064] In another possible implementation, an anonymous socket pair is created between the main caller of the client application and the main code of the client application.
[0065] Specifically, a pair of interconnected sockets is created through the socketpair system call, and the socket description words are returned in the form of an array.
[0066] The above solution reserves a communication channel between the container and the outside before the internal container of the client application is created, thereby realizing private communication between the main caller of the client application and the main code of the client application.
[0067] Step 202: Create a first container for running the client application main code.
[0068] It should be noted that the action of creating a container itself is to apply different attributes to create a new process. This process is the first process of the container. The purpose of the new process is to run the main code of the client application. The new process communicates with the main caller of the client application through private communication.
[0069] In a possible implementation, after the pipe call is successful, the inside and outside of the container each hold one end of the pipe, and communication between the inside and outside of the container can be achieved.
[0070] In another possible implementation, after a pair of interconnected sockets is created through a socketpair system call, one end is held inside the container and one end is held outside the container, so that bidirectional communication can be achieved.
[0071] It should be noted that the main content of the communication between the container and the outside is the return result of the direct call of the client application code by REE when there is no container. Since the client application code is placed in the container, the main caller cannot directly call and get the result and can only complete it through anonymous communication. In addition, the main caller passes parameters to the client application code through anonymous communication.
[0072] It should be noted that the characteristic of containers is that they can achieve many isolation effects, such as file system isolation, network isolation, etc.
[0073] The above solution places the client application main code into a container created inside the client application, which can play a role in strengthening the security of the client application and prevent the client application from being attacked in an unsafe environment, thereby reducing the risk of breaking into TA.
[0074] Step 203: Map the operating environment of the first container to the operating environment of the main calling program of the client application.
[0075] The embodiment of the present invention creates a file system environment that is the same as that outside the container before running the client application main code.
[0076] Specifically, create a temporary private directory;
[0077] Map the file system environment outside the first container into the temporary private directory.
[0078] In the embodiment of the present invention, the essence of mapping is binding. The purpose of mapping is to solve the dependency of the client application main code in the container on the original file system, for example, the support of some system libraries is required.
[0079] The above solution maps the container's operating environment to the operating environment of the client application's main calling program by creating a temporary private directory, thereby solving the problem of the client application's main code's dependence on the outside world and the problem of returning results to the outside world, and realizing the client application's independent operation in a closed environment.
[0080] Step 204: Run the client application main code through the first container.
[0081] Step 205: After the execution is completed, the execution result is returned to the main calling program of the client application.
[0082] In the embodiment of the present invention, after the main code of the client application is finished running, the process returns the execution result to the main calling program of the client application and exits, and the container is automatically destroyed.
[0083] The above solution, by creating a container inside the client application so that the main code of the client application runs under the container, isolates the outside world from observing the client application, which can effectively reduce the attack surface of CA and TA and play a role in strengthening CA security.
[0084] Furthermore, if the internal container is not used in the development of the client application, the client application can also be called by creating an external container of the client application. Figure 3 A schematic diagram of a process flow corresponding to a method for strengthening security on a client application side provided by an embodiment of the present invention, such as Figure 3 As shown, the method includes:
[0085] Step 301: Create a second container outside the main calling program of the client application.
[0086] Step 302: Call the client application main code through the second container.
[0087] Step 303: Return the calling result to the calling program outside the second container.
[0088] In the embodiment of the present invention, if the client application needs to be called multiple times, the second container is created multiple times.
[0089] It should be noted that the reason for the above method of using an integrated container for integrated calling is that the client application main code cannot be modified, so it is impossible to create a container inside the client application.
[0090] In the above solution, the main code of the client application does not need to be modified. The main calling program of the client application creates the container creation environment, and then calls the main code of the client application inside the container. After obtaining the return value, the main calling program transmits the result to the calling program outside the container through anonymous communication.
[0091] Based on the same inventive concept, Figure 4A security reinforcement device on a client application side provided by an embodiment of the present invention is exemplarily shown. The device may be a process of a method for security reinforcement on a client application side.
[0092] The device comprises:
[0093] A creation module 401 is used to create a private communication between the main caller of the client application and the main code of the client application; and to create a first container for running the main code of the client application;
[0094] The processing module 402 is used to map the operating environment of the first container to the operating environment of the main calling program of the client application; run the main code of the client application through the first container; and return the execution result to the main calling program of the client application after the running is completed.
[0095] Furthermore, the creation module 401 is specifically used for:
[0096] Creating an anonymous pipe between the main caller of the client application and the main code of the client application; and / or,
[0097] Create an anonymous socket pair between the main caller of the client application and the main code of the client application.
[0098] Furthermore, the creation module 401 is specifically used for:
[0099] An anonymous pipe is created between the main calling program of the client application and the main code of the client application through the pipe system call.
[0100] Furthermore, the processing module 402 is specifically used for:
[0101] Create a temporary private directory;
[0102] The file system environment outside the first container is mapped to the temporary private directory.
[0103] Furthermore, the processing module 402 is also used for:
[0104] Creating a second container outside the main calling program of the client application;
[0105] Calling the client application main code through the second container;
[0106] The calling result is returned to the calling program outside the second container.
[0107] Based on the same inventive concept, another embodiment of the present invention provides an electronic device, see Figure 5, the electronic device specifically includes the following contents: a processor 501, a memory 502, a communication interface 503 and a communication bus 504;
[0108] The processor 501, the memory 502, and the communication interface 503 communicate with each other through the communication bus 504; the communication interface 503 is used to realize information transmission between various devices;
[0109] The processor 501 is used to call the computer program in the memory 502. When the processor executes the computer program, all steps of the method for security reinforcement on the client application side are implemented. For example, when the processor executes the computer program, the following steps are implemented: creating private communication between the main calling program of the client application and the main code of the client application; creating a first container for running the main code of the client application; mapping the operating environment of the first container to the operating environment of the main calling program of the client application; running the main code of the client application through the first container;
[0110] After the execution is completed, the execution result is returned to the main calling program of the client application.
[0111] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the security reinforcement method on the client application side provided by the above-mentioned methods, and the method includes: creating private communication between the main calling program of the client application and the main code of the client application; creating a first container for running the main code of the client application; mapping the operating environment of the first container to the operating environment of the main calling program of the client application; running the main code of the client application through the first container; and returning the execution result to the main calling program of the client application after the running is completed.
[0112] Based on the same inventive concept, another embodiment of the present invention provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, all steps of the above-mentioned method for security reinforcement on the client application side are implemented. For example, when the processor executes the computer program, the following steps are implemented: creating a private communication between a main calling program of a client application and a main code of the client application; creating a first container for running the main code of the client application; mapping the operating environment of the first container to the operating environment of the main calling program of the client application; running the main code of the client application through the first container;
[0113] After the execution is completed, the execution result is returned to the main calling program of the client application.
[0114] In addition, the logic instructions in the above-mentioned memory can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a security reinforcement device on the client application side, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.
[0115] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the embodiments of the present invention. Those of ordinary skill in the art may understand and implement them without creative effort.
[0116] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a security reinforcement device on the client application side, or a network device, etc.) to execute the security reinforcement method on the client application side described in each embodiment or some parts of the embodiment.
[0117] In addition, in the present invention, terms such as "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0118] In addition, in the present invention, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0119] In addition, in the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. 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 representations of the above terms do 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. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0120] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A security reinforcement method for client application side, It is characterized in that include: Establishing private communication between a main calling program of a client application and a main body code of the client application, wherein both the main calling program of the client application and the main body code of the client application are in an untrusted execution environment; Creating a first container to run the client application main code; Mapping the operating environment of the first container to the operating environment of the main calling program of the client application; Run the client application main code through the first container; After the execution is completed, the execution result is returned to the main calling program of the client application.
2. The method for strengthening the security of the client application side according to claim 1, It is characterized in that The step of establishing private communication between the main calling program of the client application and the main code of the client application includes: Creating an anonymous pipe between the main caller of the client application and the main code of the client application; and / or, Create an anonymous socket pair between the main caller of the client application and the main code of the client application.
3. The method for strengthening the security of the client application side according to claim 2, It is characterized in that The step of creating an anonymous pipeline between the main calling program of the client application and the main code of the client application includes: An anonymous pipe is created between the main calling program of the client application and the main code of the client application through the pipe system call.
4. The method for strengthening the security of the client application side according to claim 1, It is characterized in that Mapping the operating environment of the first container to the operating environment of the main calling program of the client application includes: Create a temporary private directory; The file system environment outside the first container is mapped to the temporary private directory.
5. The method for strengthening the security of the client application side according to claim 1, It is characterized in that The method further comprises: Creating a second container outside the main calling program of the client application; Calling the client application main code through the second container; The calling result is returned to the calling program outside the second container.
6. A security reinforcement device on the client application side, It is characterized in that include: A creation module is used to establish private communication between a main calling program of a client application and a main code of the client application, wherein both the main calling program of the client application and the main code of the client application are in an untrusted execution environment; and a first container is created to run the main code of the client application; A processing module is used to map the operating environment of the first container into the operating environment of the main calling program of the client application; run the main code of the client application through the first container; and return the execution result to the main calling program of the client application after the running is completed.
7. The security reinforcement device on the client application side according to claim 6, It is characterized in that The creation module is specifically used for: Creating an anonymous pipe between the main caller of the client application and the main code of the client application; and / or, Create an anonymous socket pair between the main caller of the client application and the main code of the client application.
8. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the steps of the method according to any one of claims 1 to 5 are implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
