How to securely protect software code execution from physical attacks

JP2026531607APending Publication Date: 2026-09-17THALES DIS FRANCE SA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
JP2026514902
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-09-13
Filing Date
2024-09-13
Publication Date
2026-09-17

Smart Images

  • Figure 2026531607000001_ABST
    Figure 2026531607000001_ABST
Patent Text Reader

Abstract

The present invention relates to a method for securely protecting the execution of software code from physical attacks, wherein the software code includes calls to a plurality of functions and an instruction to store the address of a first function in a global variable before calling the first of the plurality of functions, and the method is executed by an electronic system comprising a hardware processor, non-volatile memory, and a detection system configured to detect attacks against the electronic system during the execution of a function among the plurality of functions, wherein the detection system detects an attack against the electronic system during the execution of the first function (S1), and after the detection of the attack, retrieves the address from which the first function was called, stores the retrieved address in the non-volatile memory, and the execution of the first function The method includes stopping the line (S2), and at the next startup of the electronic system (S3), determining whether an attack occurred during a previous execution of the first function by checking whether the address of the call to the first function is stored in the non-volatile memory, and if it is determined that an attack occurred during a previous execution of the first function, updating the software code in the non-volatile memory by replacing the call to the first function at the address stored in the non-volatile memory with a call to a function that activates a security measure, calls the first function using the address stored in the global variable, and deactivates the activated security measure after the execution of the first function.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] The present invention relates to the field of protecting software execution on electronic devices against physical attacks, particularly fault injection attacks, and more specifically to a method for dynamic activation of countermeasures. [Background Art]

[0002] Software execution on electronic devices may be subject to various attacks that allow an attacker to maliciously modify the execution of software code on an electronic device, or obtain knowledge of confidential data stored on a secure device such as a secret encryption key or banking information.

[0003] Various countermeasures have been devised to prevent such attacks. One major disadvantage of such countermeasures is their high cost, which typically slows down the execution code on the protected electronic device when such countermeasures are activated.

[0004] In order to avoid that multiple countermeasures designed for different types of attacks are continuously activated with very high performance cost, methods have been proposed to activate such countermeasures only when specific code portions requiring a high level of protection are executed. Such methods usually require manually modifying the software code to be protected, in order to add activation commands and deactivation commands for each required countermeasure at the beginning and the end of each code portion that is to be protected by a certain countermeasure.

[0005] Such methods are very cumbersome for code designers. They may also have a notable impact on the code size. Furthermore, although the cost in terms of execution time is lower than that of methods implying permanent activation of countermeasures, they still cause overhead that does not take into account the execution context of the protected electronic device, and remains the same even when the device is not the target of any attack.

[0006] Such methods also have the disadvantage of being inflexible in terms of scope, as the countermeasure activation command only protects the specified portion of the code to which it is added. The portion of the code outside the scope of the countermeasure activation will always remain unprotected unless the code is manually modified to permanently change the code portion protected by the countermeasure.

[0007] Therefore, there is a need for software-secure execution methods on electronic devices that allow for the dynamic activation of finely tuned protection for only the limited code portions that have been attacked, with minimal code footprint and execution time overhead. [Overview of the Initiative]

[0008] For this purpose, according to a first aspect, the present invention relates to a method for securely protecting the execution of software code against physical attacks. The software code includes calls to multiple functions and instructions that store the address of the first of those functions in a global variable before calling the first of those functions. The method is performed by an electronic system comprising a hardware processor, non-volatile memory, and a detection system configured to detect an attack on the electronic system during the execution of one of the multiple functions, and - The detection system detects an attack on the electronic system during the execution of the first function, - After the detection of the attack, the address from which the first function was called is retrieved, the retrieved address is stored in the non-volatile memory, and the execution of the first function is stopped. -At the next startup of the electronic system, ○By checking whether the address of the call to the first function is stored in the non-volatile memory, it is determined whether the attack occurred during a previous execution of the first function. ○If it is determined that an attack occurred during a previous execution of the first function, the software code in the non-volatile memory is updated in the non-volatile memory by replacing the call to the first function at the address stored in the non-volatile memory with a call to a function that activates security measures, calls the first function using the address stored in the global variable, and deactivates the activated security measures after the execution of the first function.

[0009] Such a method allows for the dynamic activation of countermeasures with minimal footprint on the executed code, but only while the already attacked function is running.

[0010] The activated security measures may include software countermeasures that are deactivated by default.

[0011] The activated security measures may include hardware security measures that are deactivated by default.

[0012] Activating or deactivating such security measures may involve changing software or hardware parameters or security configurations of the electronic system.

[0013] The method according to the first embodiment may include pre-updating the software code by inserting an instruction into the software code that stores the address of the function in a global variable before each call to the function, the update being performed during compilation of the software code or after compilation but before linking the software code.

[0014] According to a second aspect, the present invention is a method for executing software code protected by the method according to the first aspect, comprising: calls to a plurality of functions; and instructions to store the address of the first of the plurality of functions in a global variable before calling the first of the plurality of functions; The method includes calling a function, and the function is ○Activate security measures, ○The first function is called using the address stored in the global variable, and, ○ After the execution of the first function, the activated security measure is deactivated.

[0015] According to a third aspect, the present invention relates to a computer program product that can be directly loaded into the memory of at least one computer, and which includes software code instructions for performing steps of the methods according to the first and second aspects of the present invention when the product is executed on the computer.

[0016] According to a fourth aspect, the present invention relates to an electronic system comprising a hardware processor, a non-volatile memory, and a detection system configured to perform steps of the methods according to the first and second aspects of the present invention.

[0017] To achieve the aforementioned and related objectives, one or more embodiments may have features that are fully described below and are particularly pointed out in the claims. [Brief explanation of the drawing]

[0018] The following description and accompanying drawings detail a particular illustrative embodiment and illustrate only a few of the various ways in which the principles of the embodiment 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 embodiments and their equivalents. [Figure 1]It is a schematic diagram of an electronic system according to the present invention. [Figure 2] It is a schematic diagram of a method for securely protecting execution of software code against physical attacks according to an embodiment of the present invention. [Figure 3] It is a schematic diagram of a method for executing software code protected by the method shown in Fig. 1 according to the present invention. MODE FOR CARRYING OUT THE INVENTION

[0019] According to a first aspect, the present invention relates to a method for protecting, from attacks, execution of software code including calls to a plurality of functions by an electronic system 1. In order to protect execution of such a function from attacks, the method enables the electronic system to detect occurrence of an attack during execution of the function, and dynamically apply one or more security measures that protect from the attack only during the next execution of the attacked function.

[0020] In the following paragraphs, the expression "function" is used as a generic term for any programmed set of operations, including functions in any imperative programming language, methods in object-oriented programming languages, routines, and the like.

[0021] Such an electronic system comprises, as shown in Fig. 1, a hardware processor 101 for executing 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 be, for example, a tamper-proof smart card, a smartphone, a personal computer, or a server. The electronic system may also include an input / output interface 103 that provides an interface to an administrator of the device, such as one or more screens, loudspeakers, a mouse, a touch surface, a keyboard, and the like.

[0022] The main idea of the present invention is to activate a countermeasure during the execution of a function that was attacked during a previous execution. To this end, an attack is detected during the operation of an electronic system. For this purpose, the electronic system comprises a detection system 104 configured to detect an attack on the electronic system during execution of one function among a plurality of functions called in the code to be protected.

[0023] For dynamically activating countermeasures, a first idea of the present invention is to replace, in software code, a call to a function to be protected with a call to another function that can be hereinafter referred to as a wrapper function, which not only executes the function to be protected, but also activates an appropriate countermeasure before the execution of the function, and deactivates the countermeasure at the end of the execution of the function.

[0024] The challenge of such a solution is to ensure that the wrapper function calls the correct function without requiring manual verification by a programmer. Therefore, another idea of the method according to the present invention is to modify the software code by adding, before each call to a function, an instruction that stores the address of the function in a global variable. By doing so, the wrapper function replacing the call to the function can obtain the address of the function to be called from the global variable.

[0025] In the following paragraphs, the steps shown in Figure 2 of the method for protecting the execution of software code by an electronic system according to the present invention will be described in detail. For the purpose of explanation, it is hereinafter assumed that an attack occurs during the execution of a function to be protected (hereinafter referred to as the "first function") in the software code.

[0026] As described above, a prerequisite for the method according to the present invention is that the address of the first function is stored in a global variable before it is called, and as a result, a wrapper function that replaces this call can read the address of the first function to call it from the global variable. To do this, in the previous step S0, the software code may be updated by inserting an instruction into the software code before each call to the function that stores the address of the function in a global variable. To make processing easier for the wrapper function, all such instructions may use the same unique global variable to store the address to be saved.

[0027] Such updates may be performed by the compiler itself during the compilation of the software code. Alternatively, they may be performed by the compiler or an external tool at the end of compilation, or after compilation is complete but before linking the compiled software code. Alternatively, such updates may be performed in the source code of the software code before compilation.

[0028] Next, the method according to the present invention described herein is assumed to be performed while the software code updated in the previous step S0 is being executed by an electronic system, as described above.

[0029] In the first step S1, the detection system of the electronic system detects an attack on the electronic system during the execution of a first function. Such 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 called, the global variable used to store the address of the called function will at that point store the address of the first function. Such detection may be performed at the hardware level by a sensor. Therefore, no extra software may be required to detect an attack. Such detection may be performed at the software level, for example, if a redundancy check fails.

[0030] In the second step S2, after detecting the attack in the first step S2, the electronic system retrieves the address from which the first function was called and stores the retrieved address in the electronic system's non-volatile memory. This is the address of the call to the first function that must be replaced by a call to the wrapper function described above in order to activate the countermeasure before calling the first function. This can be retrieved from the address of the next instruction that can correspond to the program counter for the processor using it after the execution of the first function has finished. This address of the next instruction may be stored, for example, in the LR register or C stack of a hardware processor. For other types of processors, other registers may be targeted 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 to prevent the detected attack from progressing further. The electronic system may even be restarted.

[0031] Next, the following steps will be performed the next time the electronic system is started up.

[0032] In the third step S3, the electronic system may determine whether the attack occurred during a previous execution of the first function by checking whether the address of the call to the first function is stored in non-volatile memory.

[0033] If so, the electronic system may update the software code in non-volatile memory by replacing a call to a first function in the code at an address stored in non-volatile memory with a call to a function referred to as the aforementioned wrapper function, which activates security measures, calls the first function using an address stored in a global variable, and deactivates the activated security measures after the execution of the first function.

[0034] Such measures may be hardware or software measures, and may be deactivated by default and activated by a wrapper function only when a specific function to be protected, such as the first function described above, is executed. Such measures may include, for example, timing asynchronous measures such as clock jitter, power smoothing, activation of code rerouting prevention mechanisms, and memory access redundancy.

[0035] After the completion of the third step, the updated software code, which includes calls to multiple functions, including a call to the first function by a wrapper function inserted into the software code in the third step, may finally be executed as shown in Figure 3. During this execution, immediately before executing the call to the wrapper function, the electronic system executes an instruction to store the address of the first function in a global variable. Then, in the first execution step E11, the wrapper function that activates the security measures is called; in the second execution step E12, the first function is called using the address stored in the global variable; and finally, in the third execution step E13, after the execution of the first function has finished, the activated security measures are deactivated. Thus, the execution of the first function is protected only by measures that remain activated during the execution of the first function, thereby minimizing the system load generated by their activation.

[0036] Activating or deactivating such security measures may involve changing both the software and hardware parameters of the electronic system, or the security configuration, such as the security level.

[0037] According to a second aspect, the present invention relates to a computer program product that can be directly loaded into the memory of at least one computer, and which includes software code instructions for performing the steps of the methods described herein when the product is executed on the computer.

[0038] According to a third aspect, the present invention relates to an electronic system 1 comprising a hardware processor 101, a non-volatile memory 102, and a detection system 104 configured to perform the steps of the method described herein.

[0039] In addition to these features, the computer programs and electronic systems according to the second and third aspects of the present invention may be configured to perform or include any other features described herein.

[0040] Therefore, the electronic systems and methods presented herein enable the efficient triggering of additional measures against specific parts of the code to be protected, with a very limited footprint on the code and limited impact on execution time, since the measures are not activated during the execution of functions that do not require protection.

Claims

1. A method for securely protecting the execution of software code from physical attacks, The software code includes calls to a plurality of functions, and an instruction to store the address of the first function in a global variable before calling the first of the plurality of functions, The method is 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 the electronic system during the execution of one of the plurality of functions, and - The detection system detects an attack on the electronic system during the execution of the first function (S1), - After the detection of the attack, the first function is retrieved from the address where it was called, the retrieved address is stored in the non-volatile memory, and the execution of the first function is stopped (S2). - During the next startup of the electronic system (S3), ○By checking whether the address of the call to the first function is stored in the non-volatile memory, it is determined whether an attack occurred during a previous execution of the first function, A method comprising: if it is determined that an attack occurred during a previous execution of the first function, updating the software code in the non-volatile memory by replacing the call to the first function at the address stored in the non-volatile memory with a call to a function that activates security measures, calls the first function using the address stored in the global variable, and deactivates the activated security measures after the execution of the first function.

2. The method according to claim 1, wherein the activated security measures include software measures that are deactivated by default.

3. The method according to claim 1 or 2, wherein the activated security measures include hardware security measures that are deactivated by default.

4. The method according to any one of claims 1 to 3, wherein the activation or deactivation of the security measures includes changing the parameters or security configuration of the software or hardware of the electronic system.

5. The method according to any one of claims 1 to 4, comprising updating the software code in advance (S0) by inserting an instruction into the software code to store the address of the function in a global variable before each call to the function, wherein the update is performed during compilation of the software code or after compilation before linking the software code.

6. The function includes calls to multiple functions, and an instruction to store the address of the first function in a global variable before calling the first function among the multiple functions, The method includes calling a function (E1), and the function (E1) is ○Activate security measures (E11), ○The first function is called using the address stored in the global variable (E12), and ○ A method for executing software code protected by the method of any one of claims 1 to 5, wherein the activated security measures are deactivated (E13) after the execution of the first function.

7. A computer program product that can be directly loaded into the memory of at least one computer, and which includes software code instructions for performing the steps described in any one of claims 1 to 6 when the product is executed on the computer.

8. An electronic system comprising a hardware processor (101), a non-volatile memory (102), and a detection system (104) configured to perform the steps described in any one of claims 1 to 6.