Method for securely protecting execution of a software code against physical attacks
The method dynamically activates security countermeasures during the execution of attacked functions, addressing the inefficiencies of existing methods by providing adaptive protection with minimal overhead and code impact.
Patent Information
- Application Number
- PCT/EP2024/075699
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-09-13
- Filing Date
- 2024-09-13
- Publication Date
- 2025-03-20
AI Technical Summary
Existing methods for securing software execution on electronic devices against physical attacks, such as fault injection attacks, are cumbersome, costly, and inefficient, as they require permanent activation of countermeasures and do not adaptively protect all code portions.
A method that dynamically activates security countermeasures only during the execution of functions that have previously been attacked, by detecting attacks, storing relevant addresses, and updating the software code to include wrapper functions that activate and deactivate countermeasures as needed.
This method provides adaptive, finely-tuned protection for specific code parts that have been attacked, minimizing code footprint and execution time overhead, while ensuring that countermeasures are only activated when necessary.
Smart Images

Figure EP2024075699_20032025_PF_FP_ABST
Abstract
Description
[0001] METHOD FOR SECURELY PROTECTING EXECUTION OF A SOFTWARE CODE AGAINST PHYSICAL ATTACKS
[0002] FIELD OF THE INVENTION
[0003] The present invention relates to the field of securing software execution on an electronic device against physical attacks, especially fault injection attacks, and more particularly to a method for a dynamic activation of countermeasures.
[0004] BACKGROUND OF THE INVENTION
[0005] Software execution on an electronic device may be subject to various attacks that enable an attacker to modify maliciously the software code execution on the electronic device or to gain knowledge of sensitive data stored on the secure device, such as secret cryptographic keys or banking information.
[0006] Various countermeasures have been designed in order to prevent or resist such attacks. One major drawback of such countermeasure is usually their heavy cost that slows down the execution code on a protected electronic device when such countermeasures are activated.
[0007] In order to avoid a permanent activation of multiple countermeasures, each designed against different type of attacks, at a very high cost to performance, methods have been proposed in order to activate such countermeasures only when specific code parts, which require a high level of protection, are executed. Such methods usually require to manually modify the software code to be protected in order to add activation and deactivation commands of each needed countermeasure, at the beginning and the end of each code part to be protected by some countermeasure.
[0008] Such methods are very cumbersome for the code designers. They may also have a noticeable impact on the code size. In addition, even though their cost in terms of execution time is less than the one of methods implying a permanent activation of the countermeasure, they still induce an overhead that does not take into account the execution environment of the protected electronic device and will remain the same even when the device is not the target of any attack.
[0009] Such methods also have the drawback of not being adaptative in terms of coverage: they only secure predetermined portions of the code in which a countermeasure activation command has been added. Portions of the code which are outside of the range of countermeasure activation will always remain unprotected unless the code is manually modified in order to permanently change the code portion protected by the countermeasure.
[0010] Consequently, there is a need for a software secure execution method on an electronic device which enables to dynamically activate a finely tuned protection of only limited code parts that have suffered from attacks, with a minimal code footprint and execution time overhead.
[0011] SUMMARY OF THE INVENTION
[0012] For this purpose and according to a first aspect, this invention therefore relates to a method for securely protecting execution of a software code against physical attacks, said software code comprising calls to a plurality of functions and, before a call to a first function among said plurality of functions, an instruction storing the address of said first function into a global variable, said method being performed by an electronic system comprising a hardware processor, a non-volatile memory and a detection system configured to detect an attack on said electronic system during an execution of a function among said plurality of functions, and comprising:
[0013] - detecting, by said detection system, during an execution of said first function, an attack on said electronic system, - after said detection of an attack, retrieving the address from where the first function was called, storing said retrieved address in said non-volatile memory and stopping the execution of said first function,
[0014] - on the next startup of the electronic system: o determining if an attack has occurred during a previous execution of said first function by checking if an address of a call to said first function is stored in said nonvolatile memory, o when it is determined that an attack has occurred during a previous execution of said first function, updating the software code in said non-volatile memory by replacing at said address stored in said non-volatile memory the call to the first function by a call to a function which: activates security countermeasures, calls said first function using the address saved in said global variable and deactivates said activated security countermeasures after the execution of said first function.
[0015] Such a method enables to activate countermeasures dynamically, only during the execution of function which have already undergone an attack, and with a minimal footprint on the executed code.
[0016] Said activated security countermeasures may comprise software countermeasures deactivated by default.
[0017] Said activated security countermeasures may comprise hardware security countermeasures deactivated by default.
[0018] Activation or deactivation of said security countermeasures may comprise a change of the software or hardware parameters or security configurations of the electronic system.
[0019] The method according to the first aspect may comprise previously, updating the software code by inserting in the software code before each call to a function an instruction storing the address of said function into a global variable, said update being performed during the compilation of the software code or after the compilation before linking the software code. According to a second aspect, this invention relates to a method for executing a software code protected by the method according to the first aspect and comprising calls to a plurality of functions and, before a call to a first function among said plurality of functions, an instruction storing the address of said first function into a global variable, said method comprising calling a function which: o activates security countermeasures, o calls said first function using the address saved in said global variable and, o deactivates said activated security countermeasures after the execution of said first function.
[0020] According to a third aspect, this invention relates to a computer program product directly loadable into the memory of at least one computer, comprising software code instructions for performing the steps of the methods according to the first and second aspect of the invention when said product is run on the computer.
[0021] According to a fourth aspect, this invention relates to an electronic system comprising a hardware processor, a non-volatile memory and a detection system configured for performing the steps of the methods according to the first and second aspect of the invention.
[0022] To the accomplishment of the foregoing and related ends, one or more embodiments comprise the features hereinafter fully described and particularly pointed out in the claims.
[0023] BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The following description and the annexed drawings set forth in detail certain illustrative aspects and are indicative of but a few of the various ways in which the principles of the embodiments may be employed. Other advantages and novel features will become apparent from the following detailed description when considered in conjunction with the drawings and the disclosed embodiments are intended to include all such aspects and their equivalents.
[0025] • Figure 1 is a schematic illustration of an electronic system according to the present invention;
[0026] • Figure 2 is a schematic illustration of a method for securely protecting execution of a software code against physical attacks according to an embodiment of the present invention;
[0027] • Figure 3 is a schematic illustration of a method for executing a software code protected by the method illustrated on figure 1 according to the present invention.
[0028] DETAILED DESCRIPTION OF EMBODIMENTS OF THE INVENTION
[0029] According to a first aspect, the invention relates to a method for protecting the execution by an electronic system 1 of a software code, comprising calls to a plurality of functions, against attacks. In order to protect the execution of such functions against attacks, this method enables the electronic system to detect the occurrence of an attack during the execution of a function and to apply dynamically, only during the next execution of the attacked function, one or more security countermeasures protecting it against attacks.
[0030] In the following paragraphs, the expression “function” is used as a generic term for any programmed set of operations, covering functions of any imperative programming language, methods of object-programming languages, routines...
[0031] Such an electronic system comprises, as depicted on Figure 1 , a hardware processor 101 for the execution of the software code to be protected, and at least one memory 102, such as a Non-Volatile memory (NVM), a RAM memory and / or a ROM memory in which the software code is stored. Such an electronic system may for example be a tamperproof smartcard, a smartphone, a personal computer or a server. The electronic system may also include an input / output interface 103 providing interfaces to an administrator of the device, such as one or more screens, loudspeakers, a mouse, tactile surfaces, a keyboard etc...
[0032] The main idea of the invention is to activate countermeasures during the execution of functions that have undergone attacks during a previous execution. In order to do so, attacks are detected during operation of the electronic system. To this end, the electronic system comprises a detection system 104 configured to detect an attack on the electronic system during an execution of a function among the plurality of functions called in the code to be protected.
[0033] In order to dynamically activate countermeasures, a first idea of the invention is to replace, in the software code, the call to the function to be protected by a call to another function, that we can call hereafter a wrapper function, which not only executes the function to be protected but also activates adequate countermeasures before this execution and deactivates the countermeasures at the end of the execution of the function.
[0034] A challenge of such a solution is to make sure that the wrapper function calls the right function without requiring any manual verification by a programmer. Therefore, another idea of the method according to the invention is to modify the software code by adding before each call to a function an instruction storing the address of this function into a global variable. By doing so, the wrapper function replacing a call to a function can find the address of the function it should call in this global variable.
[0035] The following paragraphs describe in detail the steps, shown on Figure 2, of the method for protecting the execution of a software code by the electronic system according to the invention. In the following, the assumption is made, for illustration purposes, that an attack will occur during the execution of a function to be protected of the software code, hereafter called the “first function”.
[0036] As described earlier, a prerequisite of the method according to the invention is that the address of the first function is stored into global variable before it is called, such that the wrapper function replacing this call can read in the global variable the address of the first function for calling it. In order to do so, in a prior step SO, the software code may be updated by inserting in the software code, before each call to a function, an instruction storing the address of said function into a global variable. In order to make things easier for the wrapper function, all such instructions may use the same unique global variable for storing the address to be saved.
[0037] Such an update may be performed by a compiler itself during the compilation of the software code. Alternatively, it can be done by the compiler, or by an external tool, at the end of the compilation, or after the end of the compilation and before linking the compiled software code. Alternatively, such an update is performed in the source code of the software code before it is compiled.
[0038] Then the method according to the invention described here is supposed to be performed during the execution by the electronic system of the software code updated in the prior step SO as described above.
[0039] In a first step S1 , the detection system of the electronic system detects an attack on the electronic system during the execution of the first function. Such a detection may be performed continuously during the operation of the electronic system until an attack is detected. Since the first function is the last function that has been called, the global variable used for storing addresses of called functions stores, at that time, the address of the first function. Such a detection may be performed at the hardware level by sensors. Thus, no extra software may be required to detect the attacks. Such a detection may be also performed at the software level, for example when a redundancy check fails.
[0040] In a second step S2, after the detection of an attack at the first step S2, the electronic system retrieves the address from where the first function was called and stores the retrieved address in the non-volatile memory of the electronic system. This is the address of the call to the first function which has to be replaced by a call to the wrapper function described above in order to have it activate countermeasures before calling the first function. It can be retrieved from the address of the next instruction, which may correspond to the Program Counter, for processors using it, after the end of the execution of the first function. This address of the next instruction may for example be stored in the LR register or the C-stack of the hardware processor. For other types of processors, other registers may be of interest to retrieve the address of the next instruction. Then, at the end of the second step, the electronic system stops the execution of the first function in order to prevent the detected attack from going further. The electronic system may even restart.
[0041] Then, the following steps are performed at the next startup of the electronic system.
[0042] In a third step S3, the electronic system may determine if an attack has occurred during a previous execution of the first function by checking if an address of a call to the first function is stored in the non-volatile memory.
[0043] When it is, the electronic system may update the software code in the non-volatile memory by replacing in the code, at the address stored in the non-volatile memory, the call to the first function by a call to a function, here before called wrapper function, which activates security countermeasures, calls the first function using the address saved in the global variable, and deactivates the activated security countermeasures after the execution of the first function.
[0044] Such countermeasures may be hardware or software countermeasures, which may be deactivated by default and only activated by the wrapper function for the time of the execution of specific functions to be protected such as the first function described above. Such countermeasures may for example comprise timing de-synchronization as clock jitter, power smoothing, activating code anti rerouting mechanism, and memory access redundancy.
[0045] After the end of the third step, the updated software code, comprising calls to a plurality of functions, including a call to the first function by the wrapper function inserted in the software code in the third step, may be eventually executed as illustrated on Figure 3. During its execution, just before executing the call to the wrapper function, the electronic system executes the instruction storing the address of the first function into a global variable. Then it calls the wrapper function which activates the security countermeasures in a first execution step E11 , calls the first function using the address saved in said global variable in a second execution step E12 and, finally deactivates the activated security countermeasures after the execution of the first function has ended in a third execution step E13. Therefore, the execution of the first function is protected by the countermeasures which remain activated only during the execution of the first function, which minimizes the load of the system generated by their activation. Activation or deactivation of said security countermeasures may comprise a change of both software and hardware parameters or security configuration, such as security level, of the electronic system.
[0046] According to a second aspect, the invention relates to a computer program product directly loadable into the memory of at least one computer, comprising software code instructions for performing, when said product is run on the computer, the steps of the methods described here before.
[0047] According to a third aspect, this invention relates to an electronic system 1 comprising a hardware processor 101 , a non-volatile memory 102 and a detection system 104 configured for performing the steps of the methods described here before.
[0048] In addition to these features, the computer program and the electronic system according to the second and third aspects of the invention may be configured for performing or may comprise any other features described here before.
[0049] The electronic system and method presented here therefore enable to efficiently trigger the execution of additional countermeasures on specific parts of the code to be protected, with a very limited footprint on this code and with a limited impact on the execution time since no countermeasure is activated during the execution of functions for which no protection is needed.
Claims
CLAIMS1. A method for securely protecting execution of a software code against physical attacks, said software code comprising calls to a plurality of functions and, before a call to a first function among said plurality of functions, an instruction storing the address of said first function into a global variable, said method being performed by an electronic system comprising a hardware processor (101 ), a non-volatile memory (102) and a detection system (104) configured to detect an attack on said electronic system during an execution of a function among said plurality of functions, and comprising:- detecting (S1 ), by said detection system, during an execution of said first function, an attack on said electronic system,- after said detection of an attack, retrieving the address from where the first function was called, storing said retrieved address in said non-volatile memory and stopping the execution of said first function (S2),- on the next startup of the electronic system (S3): o determining if an attack has occurred during a previous execution of said first function by checking if an address of a call to said first function is stored in said nonvolatile memory, o when it is determined that an attack has occurred during a previous execution of said first function, updating the software code in said non-volatile memory by replacing at said address stored in said non-volatile memory the call to the first function by a call to a function which: activates security countermeasures, calls said first function using the address saved in said global variable and deactivates said activated security countermeasures after the execution of said first function.
2. The method of claim 1 wherein, said activated security countermeasures comprise software countermeasures deactivated by default.
3. The method of claim 1 or 2 wherein, said activated security countermeasures comprise hardware security countermeasures deactivated by default.
4. The method of any one of claims 1 to 3, wherein activation or deactivation of said security countermeasures comprises a change of the software or hardware parameters or security configurations of the electronic system.
5. The method of any one of claims 1 to 4, comprising previously, updating (SO) the software code by inserting in the software code before each call to a function an instruction storing the address of said function into a global variable, said update being performed during the compilation of the software code or after the compilation before linking the software code.
6. A method for executing a software code protected by the method of any of claims 1 to 5 and comprising calls to a plurality of functions and, before a call to a first function among said plurality of functions, an instruction storing the address of said first function into a global variable, said method comprising calling a function (E1 ) which: o activates security countermeasures (E11 ), o calls said first function using the address saved in said global variable (E12) and, o deactivates said activated security countermeasures after the execution of said first function (E13).
7. A computer program product directly loadable into the memory of at least one computer, comprising software code instructions for performing the steps of any one of claims 1 to 6 when said product is run on the computer.
8. An electronic system comprising a hardware processor (101 ), a non-volatile memory (102) and a detection system (104) configured for performing the steps of any one of claims 1 to 6.
Citation Information
Patent Citations
Self-adaptive countermeasures
EP3376423A1
Electronic system and methods for a dynamic activation of countermeasures
EP3839779A1
A computation device with increased resistance against address probing
US20220027461A1