Side channel detection method and apparatus

By marking the attribute information of sensitive data in the source code and performing side channel detection, it solves the problems of small detection range and high false alarm rate in the existing technology, and achieves accurate identification of side channel risks and user data security during the compilation process. sexual enhancement.

WO2024174622A1PCT designated stage expired Publication Date: 2024-08-29HUAWEI TECH CO LTD

Patent Information

Application Number
PCT/CN2023/133202
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-02-24
Filing Date
2023-11-22
Publication Date
2024-08-29

AI Technical Summary

Technical Problem

Existing side channel detection methods have problems such as small detection range, high false alarm rate, and poor ease of use, making it difficult to comprehensively identify side channel risks in the compilation process.

Method used

By marking the attribute information of sensitive data in the source code, accurate side channel detection is performed based on these attribute information, including detection of branch execution time, variable time function, cache time and variable time instructions, improving the completeness of detection and reducing False positives and false negatives.

Benefits of technology

It achieves accurate detection of multiple side channel risks during the compilation process, improves the accuracy and completeness of detection, reduces false positives and false negatives, and improves the security of user sensitive data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023133202_29082024_PF_FP_ABST
    Figure CN2023133202_29082024_PF_FP_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a side channel detection method and apparatus. The method comprises: acquiring attribute information of first sensitive data, wherein the first sensitive data is marked with the attribute information; on the basis of the attribute information of the first sensitive data, determining whether the first sensitive data satisfies a side channel security constraint, wherein a side channel comprises one or more of a branch execution time side channel, a variable time function side channel, a buffer time side channel, and a variable-time instruction side channel; and if the first sensitive data does not satisfy the side channel security constraint, recording error information in a compilation log. According to the method, sensitive data in a source code is marked with attribute information, and on the basis of the attribute information, a plurality of side channels in a compilation process can be accurately and comprehensively detected, so that the side channel risk in the compilation process can be quickly and accurately identified, thereby improving the detection completeness, and solving the problems of false reporting and missing reporting of the side channel risk to a great extent.
Need to check novelty before this filing date? Find Prior Art

Description

Side channel detection method and device

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on February 24, 2023, with application number 202310209869.6 and application name “Method and Device for Side Channel Detection”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] Embodiments of the present application relate to the field of side channel detection, and more specifically, to a method and apparatus for side channel detection. Background Art

[0003] As users pay more and more attention to their personal sensitive information, the side-channel security of products becomes increasingly important.

[0004] Therefore, it is particularly important to conduct side-channel detection more accurately and completely to ensure the security of sensitive information and thus improve product security.

[0005] Summary of the Invention

[0006] The present application provides a method and apparatus for side channel detection. In this method, sensitive data in source code is marked with attribute information. Based on this attribute information, multiple side channels in the compilation process can be accurately and comprehensively detected, thereby enabling rapid and accurate identification of side channel risks in the compilation process. This improves the completeness of detection and largely solves the problem of misreporting and omission of side channel risks.

[0007] In a first aspect, a method for side channel detection is provided, the method comprising: obtaining attribute information of first sensitive data, the first sensitive data being marked with the attribute information; determining whether the first sensitive data satisfies a side channel security constraint based on the attribute information of the first sensitive data, the side channel comprising one or more of a branch execution time side channel, a variable time function side channel, a cache time side channel, and a variable time instruction side channel; if the first sensitive data does not satisfy the side channel security constraint, recording an error message in a compilation log.

[0008] Optionally, the error information includes error location and / or constraint violation details.

[0009] Optionally, when it is determined that the first sensitive data does not satisfy the branch execution time side channel security constraint, first error information is recorded in the compilation log.

[0010] Optionally, the first error information includes error location information: the code line where the marked sensitive data is located in the conditional statement information, and may also include constraint violation details: there is a security risk in the branch execution time side channel.

[0011] Optionally, when it is determined that the first sensitive data does not satisfy the variable time function side channel security constraint, second error information is recorded in the compilation log.

[0012] Optionally, the second error information includes error location information: the code line where the marked sensitive data is located in the parameter list of the called function, and may also include constraint violation details: there is a security risk in the variable time function side channel.

[0013] Optionally, when it is determined that the first sensitive data does not satisfy the cache time side channel security constraint, third error information is recorded in the compilation log.

[0014] Optionally, the third error information includes error location information: the code line where the marked sensitive data is located as the pointer offset in the pointer calculation address offset expression to access the data, and may also include constraint violation details: there is a security risk in the cache time side channel.

[0015] Optionally, when it is determined that the first sensitive data does not satisfy the variable-time instruction side channel security constraint, fourth error information is recorded in the compilation log.

[0016] Optionally, the fourth error information includes error location information: the code line where the marked sensitive data is located in the operand of the operation corresponding to the variable time instruction, and may also include constraint violation details: there is a security risk in the variable time instruction side channel.

[0017] Optionally, sensitive data may also be understood as non-public data or private data, such as personal data of a user, internal data of an organization, keys, etc.

[0018] In an embodiment of the present application, sensitive data in the source code is marked with attribute information. Based on this attribute information, multiple side channels of the compilation process can be accurately and comprehensively detected, and side channel risks in the compilation process can be quickly and accurately identified, thereby improving the completeness of the detection and largely solving the problem of misreporting and omission of side channel risks.

[0019] In combination with the first aspect, in a possible implementation, before obtaining the attribute information of the first sensitive data, the method further includes: marking the attribute information of the first sensitive data in the source code.

[0020] Optionally, before marking the attribute information of the first sensitive data, the method may further include the step of registering the attributes of the first sensitive data.

[0021] In an embodiment of the present application, sensitive data is attribute-marked in the source code to provide an execution basis for subsequent steps (for example, security constraint detection based on the attribute information, desensitization mechanism judgment based on the attribute information, or type reasoning based on the attribute information, etc.).

[0022] In combination with the first aspect, in one possible implementation method, based on the attribute information of the first sensitive data, determining whether the first sensitive data satisfies the side-channel security constraints includes: determining whether the first sensitive data satisfies the desensitization conditions; if the first sensitive data does not satisfy the desensitization conditions, determining whether the first sensitive data satisfies the side-channel security constraints based on the attribute information of the first sensitive data.

[0023] In an embodiment of the present application, before performing side-channel security constraint detection, it is first determined whether the sensitive data meets the desensitization conditions. Side-channel security constraint detection will only be performed if the sensitive data does not meet the desensitization conditions. This can effectively avoid false reporting of side-channel risks.

[0024] In combination with the first aspect, in a possible implementation, the method further includes: performing type inference on the first sensitive data.

[0025] It can be understood that the above type inference refers to the impact transmission of the first sensitive data during the compilation process.

[0026] In an embodiment of the present application, by utilizing the transferability of the tag attributes of sensitive data, it is possible to automatically infer the type of sensitive data, thereby transferring the impact of sensitive data throughout the compilation process, thereby improving the completeness of side channel detection and the ease of use of tools during the detection process.

[0027] In combination with the first aspect, in one possible implementation, determining whether the first sensitive data satisfies the side channel security constraint based on the attribute information of the first sensitive data includes: obtaining conditional statement information stored in the compiled intermediate representation; determining whether the first sensitive data exists in the conditional statement information based on the attribute information of the first sensitive data; if the first sensitive data exists in the conditional statement information, determining that the first sensitive data does not satisfy the branch execution time side channel security constraint.

[0028] In an embodiment of the present application, a method for detecting branch execution time side channel risks is provided. The method determines whether there is a branch execution time side channel risk during the compilation process based on the attribute information of sensitive data. The method can accurately and comprehensively detect the branch execution time side channel of the compilation process, and thus can quickly and accurately identify the branch execution time side channel risk in the compilation process, thereby improving the security of user sensitive data or keys, etc.

[0029] In combination with the first aspect, in a possible implementation method, based on the attribute information of the first sensitive data, determining whether the first sensitive data satisfies the side channel security constraint includes: obtaining calling information of the calling function during the compilation process, the calling information of the calling function includes the name of the calling function and the parameter list of the calling function; determining whether the calling function is a variable time function according to the name of the calling function; if the calling function is a variable time function, determining whether the first sensitive data exists in the parameter list of the calling function based on the attribute information of the first sensitive data; if the first sensitive data exists in the parameter list of the calling function, determining that the first sensitive data does not satisfy the side channel security constraint of the variable time function.

[0030] In an embodiment of the present application, a method for detecting variable time function side channel risks is provided. The method determines whether there is a variable time function side channel risk during the compilation process based on the attribute information of sensitive data. The method can accurately and comprehensively detect the variable time function side channel of the compilation process, and thus can quickly and accurately identify the variable time function side channel risk in the compilation process, thereby improving the security of user sensitive data or keys, etc.

[0031] In combination with the first aspect, in a possible implementation method, based on the attribute information of the first sensitive data, determining whether the first sensitive data satisfies the side channel security constraint includes: obtaining dereference statement information stored in the compiled intermediate representation, the dereference statement information including a pointer calculation address offset expression; based on the attribute information of the first sensitive data, determining whether the first sensitive data is used as a pointer offset in the pointer calculation address offset expression to access data; if it is determined that the first sensitive data is used as a pointer offset in the pointer calculation address offset expression to access data, then determining that the first sensitive data does not satisfy the cache time side channel security constraint.

[0032] In an embodiment of the present application, a method for detecting cache time side channel risks is provided. The method determines whether there is a cache time side channel risk during the compilation process based on the attribute information of sensitive data. The method can accurately and comprehensively detect the cache time side channel of the compilation process, and thus can quickly and accurately identify the cache time side channel risk in the compilation process, thereby improving the security of user sensitive data or keys, etc.

[0033] In combination with the first aspect, in a possible implementation method, the first sensitive data is determined based on the attribute information of the first sensitive data to satisfy the side-channel security constraints, including: determining the central processing unit CPU architecture when the program is compiled; determining the variable time instruction corresponding to the CPU architecture; based on the attribute information of the first sensitive data, determining whether the first sensitive data exists in the operand of the operation corresponding to the variable time instruction; if it is determined that the first sensitive data exists in the operand of the operation corresponding to the variable time instruction, determining that the first sensitive data does not satisfy the variable time instruction side-channel security constraints.

[0034] In an embodiment of the present application, a method for detecting variable-time instruction side channel risks is provided. The method determines whether there is a variable-time instruction side channel risk during the compilation process based on the attribute information of sensitive data. The method can accurately and comprehensively detect the variable-time instruction side channel of the compilation process, and can quickly and accurately identify the variable-time instruction side channel risk in the compilation process, thereby improving the security of user sensitive data or keys, etc.

[0035] In combination with the first aspect, in one possible implementation method, determining whether the first sensitive data meets the desensitization conditions includes: constructing a control flow graph consisting of nodes of each branch of the program; when the execution depth of each branch is consistent and each step operation of each branch is equivalent, determining that the first sensitive data meets the desensitization conditions; or, when the execution depth of each branch is inconsistent, and / or each step operation of each branch is not equivalent, determining that the first sensitive data does not meet the desensitization conditions.

[0036] In an embodiment of the present application, a method for determining whether sensitive data meets the desensitization conditions is provided. In this method, when the compiler meets the equivalence conditions, it is determined that the sensitive data meets the desensitization conditions, providing a basis for subsequently determining whether security constraint detection is required.

[0037] In combination with the first aspect, in one possible implementation, determining whether the first sensitive data meets the desensitization condition includes: obtaining a first list in a program configuration file, the first list including one or more obfuscation operations; when the first sensitive data is processed by the obfuscation operation in the first list, determining that the first sensitive data meets the desensitization condition; or, when the first sensitive data is not processed by the obfuscation operation in the first list, determining that the first sensitive data does not meet the desensitization condition.

[0038] In an embodiment of the present application, another method for determining whether sensitive data meets the desensitization conditions is provided. In this method, when sensitive data is processed by the obfuscation operation in the program configuration file, it indicates that the sensitive data is confused with other data and is treated equally, thereby determining that the sensitive data meets the desensitization conditions, providing a basis for subsequently determining whether security constraint detection is required.

[0039] In combination with the first aspect, in one possible implementation, type inference is performed on the first sensitive data, including: based on the attribute information of the first sensitive data, determining whether a first variable in the program is sensitive according to the type rules of the expression and the subtype inference rules of the variable, the first variable refers to a variable in the program other than the first sensitive data; when it is determined that the first variable is sensitive, the attribute tag of the first sensitive data is passed to the first variable.

[0040] Optionally, if the first variable has an operation relationship with the sensitive data, such as an assignment operation, it can be determined that the first variable is affected by the sensitive data, and the attribute tag of the sensitive data is further transferred to the first variable.

[0041] In an embodiment of the present application, a method for performing type inference on sensitive data is provided. The method determines whether other variables are sensitive based on the attribute information of the sensitive data and the relationship between other variables and the sensitive data. When it is determined that other variables are affected by the sensitive data, the attributes of the sensitive data are passed to the other variables. In this way, when performing security constraint detection, it is possible to detect other variables affected by the sensitive data while detecting the sensitive data, thereby making the detection process more complete and further improving the security of user sensitive data or keys.

[0042] In a second aspect, a method for data processing is provided, the method comprising: obtaining attribute information of first data; determining whether the attribute information exists in an information library, the information library comprising at least one of the following: conditional statement information stored in a compiled intermediate representation, a parameter list of a called function, dereference statement information stored in a compiled intermediate representation, or operands corresponding to operations of variable-time instructions; and issuing an alarm when the attribute information exists in the first information library.

[0043] In an embodiment of the present application, sensitive data in the source code is marked with attribute information. Based on this attribute information, multiple side channels of the compilation process can be accurately and comprehensively detected, and side channel risks in the compilation process can be quickly and accurately identified, thereby improving the completeness of the detection and largely solving the problem of misreporting and omission of side channel risks.

[0044] In combination with the first aspect, in a possible implementation, before obtaining the attribute information of the first sensitive data, the method further includes: marking the attribute information of the first sensitive data in the source code.

[0045] In conjunction with the second aspect, in a possible implementation, before obtaining the attribute information of the first data, the method further includes: marking the attribute information of the first data in the source code.

[0046] Optionally, before marking the attribute information of the first sensitive data, the method may further include the step of registering the attributes of the first sensitive data.

[0047] In an embodiment of the present application, sensitive data is attribute-marked in the source code to provide an execution basis for subsequent steps (for example, security constraint detection based on the attribute information, desensitization mechanism judgment based on the attribute information, or type reasoning based on the attribute information, etc.).

[0048] In combination with the second aspect, in one possible implementation method, determining whether the attribute information exists in the information database includes: determining whether the first data meets the desensitization conditions; if the first data does not meet the desensitization conditions, determining whether the attribute information exists in the information database.

[0049] In an embodiment of the present application, before performing side-channel security constraint detection, it is first determined whether the sensitive data meets the desensitization conditions. Side-channel security constraint detection will only be performed if the sensitive data does not meet the desensitization conditions. This can effectively avoid false reporting of side-channel risks.

[0050] In combination with the second aspect, in a possible implementation, the method further includes: performing type inference on the first data.

[0051] It can be understood that the above type inference refers to the impact transmission of the first sensitive data during the compilation process.

[0052] In an embodiment of the present application, by utilizing the transferability of the tag attributes of sensitive data, it is possible to automatically infer the type of sensitive data, thereby transferring the impact of sensitive data throughout the compilation process, thereby improving the completeness of side channel detection and the ease of use of tools during the detection process.

[0053] In conjunction with the second aspect, in a possible implementation, determining whether the attribute information exists in the information library includes: obtaining conditional statement information stored in the compiled intermediate representation; and determining whether the attribute information exists in the conditional statement information.

[0054] In an embodiment of the present application, a method for detecting branch execution time side channel risks is provided. The method determines whether there is a branch execution time side channel risk during the compilation process based on the attribute information of sensitive data. The method can accurately and comprehensively detect the branch execution time side channel of the compilation process, and thus can quickly and accurately identify the branch execution time side channel risk in the compilation process, thereby improving the security of user sensitive data or keys, etc.

[0055] In combination with the second aspect, in a possible implementation method, determining whether the attribute information exists in the information library includes: obtaining the calling information of the calling function during the compilation process, the calling information of the calling function includes the name of the calling function and the parameter list of the calling function; determining whether the calling function is a variable time function based on the name of the calling function; if the calling function is a variable time function, determining whether the attribute information exists in the parameter list of the calling function.

[0056] In an embodiment of the present application, a method for detecting variable time function side channel risks is provided. The method determines whether there is a variable time function side channel risk during the compilation process based on the attribute information of sensitive data. The method can accurately and comprehensively detect the variable time function side channel of the compilation process, and thus can quickly and accurately identify the variable time function side channel risk in the compilation process, thereby improving the security of user sensitive data or keys, etc.

[0057] In combination with the second aspect, in a possible implementation method, determining whether the attribute information exists in the information library includes: obtaining dereference statement information stored in the compiled intermediate representation, the dereference statement information including a pointer calculation address offset expression; and determining whether the attribute information exists in the pointer offset access data in the pointer calculation address offset expression.

[0058] In an embodiment of the present application, a method for detecting cache time side channel risks is provided. The method determines whether there is a cache time side channel risk during the compilation process based on the attribute information of sensitive data. The method can accurately and comprehensively detect the cache time side channel of the compilation process, and thus can quickly and accurately identify the cache time side channel risk in the compilation process, thereby improving the security of user sensitive data or keys, etc.

[0059] In combination with the second aspect, in a possible implementation method, determining whether the attribute information exists in the information library includes: determining the central processing unit CPU architecture when the program is compiled; determining the variable time instruction corresponding to the CPU architecture; and determining whether the attribute information exists in the operand of the operation corresponding to the variable time instruction.

[0060] In an embodiment of the present application, a method for detecting variable-time instruction side channel risks is provided. The method determines whether there is a variable-time instruction side channel risk during the compilation process based on the attribute information of sensitive data. The method can accurately and comprehensively detect the variable-time instruction side channel of the compilation process, and can quickly and accurately identify the variable-time instruction side channel risk in the compilation process, thereby improving the security of user sensitive data or keys, etc.

[0061] In combination with the second aspect, in one possible implementation method, determining whether the first data meets the desensitization condition includes: constructing a control flow graph consisting of nodes of each branch of the program; when the execution depth of each branch is consistent and each step operation of each branch is equivalent, determining that the first data meets the desensitization condition; or, when the execution depth of each branch is inconsistent, and / or each step operation of each branch is not equivalent, determining that the first data does not meet the desensitization condition.

[0062] In an embodiment of the present application, a method for determining whether sensitive data meets the desensitization conditions is provided. In this method, when the compiler meets the equivalence conditions, it is determined that the sensitive data meets the desensitization conditions, providing a basis for subsequently determining whether security constraint detection is required.

[0063] In combination with the second aspect, in one possible implementation, determining whether the first data meets the desensitization condition includes: obtaining a first list in a program configuration file, the first list including one or more obfuscation operations; when the first data is processed by the obfuscation operation in the first list, determining that the first data meets the desensitization condition; or, when the first sensitive data is not processed by the obfuscation operation in the first list, determining that the first data does not meet the desensitization condition.

[0064] In an embodiment of the present application, another method for determining whether sensitive data meets the desensitization conditions is provided. In this method, when sensitive data is processed by the obfuscation operation in the program configuration file, it indicates that the sensitive data is confused with other data and is treated equally, thereby determining that the sensitive data meets the desensitization conditions, providing a basis for subsequently determining whether security constraint detection is required.

[0065] In combination with the second aspect, in one possible implementation, type inference is performed on the first data, including: based on the attribute information of the first data, determining whether a first variable in the program is sensitive according to the type rule of the expression and the subtype inference rule of the variable, the first variable refers to a variable in the program other than the first data; when it is determined that the first variable is sensitive, the attribute tag of the first data is passed to the first variable.

[0066] Optionally, if the first variable has an operation relationship with the sensitive data, such as an assignment operation, it can be determined that the first variable is affected by the sensitive data, and the attribute tag of the sensitive data is further transferred to the first variable.

[0067] In an embodiment of the present application, a method for performing type inference on sensitive data is provided. The method determines whether other variables are sensitive based on the attribute information of the sensitive data and the relationship between other variables and the sensitive data. When it is determined that other variables are affected by the sensitive data, the attributes of the sensitive data are passed to the other variables. In this way, when performing security constraint detection, it is possible to detect other variables affected by the sensitive data while detecting the sensitive data, thereby making the detection process more complete and further improving the security of user sensitive data or keys.

[0068] In a third aspect, a side channel detection device is provided, which includes: an acquisition module for acquiring attribute information of first sensitive data, where the first sensitive data is marked with the attribute information; a constraint detection module for determining whether the first sensitive data satisfies a side channel security constraint based on the attribute information of the first sensitive data, where the side channel includes one or more of a branch execution time side channel, a variable time function side channel, a cache time side channel, and a variable time instruction side channel; and a recording module for recording error information in a compilation log when the first sensitive data does not satisfy the side channel security constraint.

[0069] Optionally, the error information includes error location and / or constraint violation details.

[0070] Optionally, when the constraint detection module determines that the first sensitive data does not satisfy the branch execution time side channel security constraint, the recording module records the first error information in the compilation log.

[0071] Optionally, the first error information includes error location information: the code line where the marked sensitive data is located in the conditional statement information, and may also include constraint violation details: there is a security risk in the branch execution time side channel.

[0072] Optionally, when the constraint detection module determines that the first sensitive data does not satisfy the variable time function side channel security constraint, the recording module records second error information in the compilation log.

[0073] Optionally, the second error information includes error location information: the code line where the marked sensitive data is located in the parameter list of the called function, and may also include constraint violation details: there is a security risk in the variable time function side channel.

[0074] Optionally, when the constraint detection module determines that the first sensitive data does not satisfy the cache time side channel security constraint, the recording module records third error information in the compilation log.

[0075] Optionally, the third error information includes error location information: the code line where the marked sensitive data is located as the pointer offset in the pointer calculation address offset expression to access the data, and may also include constraint violation details: there is a security risk in the cache time side channel.

[0076] Optionally, when the constraint detection module determines that the first sensitive data does not satisfy the variable time instruction side channel security constraint, the recording module records fourth error information in the compilation log.

[0077] Optionally, the fourth error information includes error location information: the code line where the marked sensitive data is located in the operand of the operation corresponding to the variable time instruction, and may also include constraint violation details: there is a security risk in the variable time instruction side channel.

[0078] In an embodiment of the present application, sensitive data in the source code is marked with attribute information. Based on this attribute information, multiple side channels of the compilation process can be accurately and comprehensively detected, and side channel risks in the compilation process can be quickly and accurately identified, thereby improving the completeness of the detection and largely solving the problem of misreporting and omission of side channel risks.

[0079] In combination with the third aspect, in a possible implementation, the device further includes: a registration module, configured to mark the attribute information of the first sensitive data in the source code.

[0080] Optionally, the registration module may also be used to: register the attributes of the first sensitive data before marking the attribute information of the first sensitive data.

[0081] In an embodiment of the present application, the registration module attributes the sensitive data in the source code to provide an execution basis for the work of subsequent modules (for example, security constraint detection based on the attribute information, desensitization mechanism judgment based on the attribute information, or type reasoning based on the attribute information, etc.).

[0082] In combination with the third aspect, in a possible implementation method, the device also includes: a desensitization module, used to determine whether the first sensitive data meets the desensitization conditions; the constraint detection module is specifically used to: when the first sensitive data does not meet the desensitization conditions, determine whether the first sensitive data meets the side channel security constraints based on the attribute information of the first sensitive data.

[0083] In an embodiment of the present application, before performing side channel security constraint detection, the desensitizing module first determines whether the sensitive data meets the desensitizing conditions. Side channel security constraint detection will only be performed if the sensitive data does not meet the desensitizing conditions. This can effectively avoid false reporting of side channel risks.

[0084] In combination with the third aspect, in a possible implementation, the device further includes: a type inference module, configured to perform type inference on the first sensitive data.

[0085] It can be understood that the above type inference refers to the impact transmission of the first sensitive data during the compilation process.

[0086] In an embodiment of the present application, by utilizing the transferability of the tag attributes of sensitive data, the type inference module can realize automatic type inference of sensitive data, and then transfer the influence of sensitive data throughout the compilation process, which can improve the completeness of side channel detection and the usability of tools in the detection process.

[0087] In combination with the third aspect, in a possible implementation method, the constraint detection module is specifically used to: obtain conditional statement information stored in the compiled intermediate representation; determine whether the first sensitive data exists in the conditional statement information based on the attribute information of the first sensitive data; when the first sensitive data exists in the conditional statement information, determine that the first sensitive data does not meet the branch execution time side channel security constraint.

[0088] In an embodiment of the present application, a device for detecting branch execution time side channel risks is provided. The constraint detection module determines whether there is a branch execution time side channel risk during the compilation process based on the attribute information of the sensitive data, so that the device can accurately and comprehensively detect the branch execution time side channel of the compilation process, and thus can quickly and accurately identify the branch execution time side channel risk in the compilation process, thereby improving the security of user sensitive data or keys, etc.

[0089] In combination with the third aspect, in a possible implementation method, the constraint detection module is specifically used to: obtain calling information of the calling function during the compilation process, the calling information of the calling function includes the name of the calling function and the parameter list of the calling function; determine whether the calling function is a variable time function based on the name of the calling function; when the calling function is a variable time function, determine whether the first sensitive data exists in the parameter list of the calling function based on the attribute information of the first sensitive data; when the first sensitive data exists in the parameter list of the calling function, determine that the first sensitive data does not meet the variable time function side channel security constraint.

[0090] In an embodiment of the present application, a device for detecting variable time function side channel risks is provided. The constraint detection module determines whether there is a variable time function side channel risk during the compilation process based on the attribute information of the sensitive data, so that the device can accurately and comprehensively detect the variable time function side channel of the compilation process, and then can quickly and accurately identify the variable time function side channel risk in the compilation process, thereby improving the security of user sensitive data or keys, etc.

[0091] In combination with the third aspect, in a possible implementation method, the constraint detection module is specifically used to: obtain dereference statement information stored in the compiled intermediate representation, the dereference statement information including a pointer calculation address offset expression; based on the attribute information of the first sensitive data, determine whether the first sensitive data is used as a pointer offset in the pointer calculation address offset expression to access data; when determining that the first sensitive data is used as a pointer offset in the pointer calculation address offset expression to access data, determine that the first sensitive data does not meet the cache time side channel security constraint.

[0092] In an embodiment of the present application, a device for detecting cache time side channel risks is provided. The constraint detection module determines whether there is a cache time side channel risk during the compilation process based on the attribute information of the sensitive data, so that the device can accurately and comprehensively detect the cache time side channel of the compilation process, and then can quickly and accurately identify the cache time side channel risk in the compilation process, thereby improving the security of user sensitive data or keys, etc.

[0093] In combination with the third aspect, in one possible implementation, the constraint detection module is specifically used to: determine the central processing unit CPU architecture when the program is compiled; determine the variable time instruction corresponding to the CPU architecture; based on the attribute information of the first sensitive data, determine whether the first sensitive data exists in the operand of the operation corresponding to the variable time instruction; when it is determined that the first sensitive data exists in the operand of the operation corresponding to the variable time instruction, determine that the first sensitive data does not meet the variable time instruction side channel security constraint.

[0094] In an embodiment of the present application, a device for detecting variable-time instruction side channel risks is provided. The constraint detection module determines whether there is a variable-time instruction side channel risk during the compilation process based on the attribute information of the sensitive data, so that the device can accurately and comprehensively detect the variable-time instruction side channel of the compilation process, and thus can quickly and accurately identify the variable-time instruction side channel risk in the compilation process, thereby improving the security of user sensitive data or keys, etc.

[0095] In combination with the third aspect, in one possible implementation method, the desensitizing module is specifically used to: construct a control flow graph consisting of nodes of each branch of the program; when the execution depth of each branch is consistent and each step operation of each branch is equivalent, it is determined that the first sensitive data meets the desensitizing condition; or, when the execution depth of each branch is inconsistent, and / or each step operation of each branch is not equivalent, it is determined that the first sensitive data does not meet the desensitizing condition.

[0096] In an embodiment of the present application, a device is provided for determining whether sensitive data meets the desensitization conditions. When the compiler meets the equivalence conditions, the desensitization module determines that the sensitive data meets the desensitization conditions, providing a basis for subsequently determining whether security constraint detection is required.

[0097] In combination with the third aspect, in a possible implementation method, the desensitization module is further specifically used to: obtain a first list in a program configuration file, the first list including one or more obfuscation operations; when the first sensitive data is processed by the obfuscation operation in the first list, determine that the first sensitive data meets the desensitization condition; or, when the first sensitive data is not processed by the obfuscation operation in the first list, determine that the first sensitive data does not meet the desensitization condition.

[0098] In an embodiment of the present application, another device is provided for determining whether sensitive data meets the desensitization conditions. When sensitive data is processed by the obfuscation operation in the program configuration file, it means that the sensitive data is confused with other data and is treated equally. Therefore, the desensitization module determines that the sensitive data meets the desensitization conditions, providing a basis for subsequently determining whether security constraint detection is required.

[0099] In combination with the third aspect, in one possible implementation, the type inference module is specifically used to: determine whether a first variable in the program is sensitive based on the attribute information of the first sensitive data, according to the type rules of the expression and the subtype inference rules of the variable, where the first variable refers to the variable in the program other than the first sensitive data; when it is determined that the first variable is sensitive, pass the attribute tag of the first sensitive data to the first variable.

[0100] Optionally, if the first variable has an operation relationship with the sensitive data, such as an assignment operation, the type inference module may determine that the first variable is affected by the sensitive data, and further pass the attribute tag of the sensitive data to the first variable.

[0101] In an embodiment of the present application, a device for performing type inference on sensitive data is provided. In the device, a type inference module determines whether other variables are sensitive based on attribute information of the sensitive data and the relationship between other variables and the sensitive data. When it is determined that other variables are affected by the sensitive data, the attributes of the sensitive data are passed to the other variables. In this way, when performing security constraint detection, it is possible to detect other variables affected by the sensitive data while detecting the sensitive data, thereby making the detection process more complete and further improving the security of user sensitive data or keys.

[0102] In combination with the third aspect, in a possible implementation, the desensitizing module is further used to: perform a desensitizing operation on the first sensitive data when the first sensitive data meets the desensitizing condition.

[0103] In a fourth aspect, a data processing device is provided, which includes: an acquisition module for acquiring attribute information of first data; a determination module for determining whether the attribute information exists in an information library, the information library including at least one of the following: conditional statement information stored in a compiled intermediate representation, a parameter list for calling a function, dereference statement information stored in a compiled intermediate representation, or an operand corresponding to an operation of a variable-time instruction; and an alarm module for issuing an alarm when the attribute information exists in the information library.

[0104] In an embodiment of the present application, sensitive data in the source code is marked with attribute information. Based on this attribute information, multiple side channels of the compilation process can be accurately and comprehensively detected, and side channel risks in the compilation process can be quickly and accurately identified, thereby improving the completeness of the detection and largely solving the problem of misreporting and omission of side channel risks.

[0105] In combination with the fourth aspect, in a possible implementation, the device further includes: a registration module, configured to mark the attribute information of the first data in the source code.

[0106] Optionally, the registration module may also be used to: register the attributes of the first sensitive data before marking the attribute information of the first sensitive data.

[0107] In an embodiment of the present application, the registration module attributes the sensitive data in the source code to provide an execution basis for the work of subsequent modules (for example, security constraint detection based on the attribute information, desensitization mechanism judgment based on the attribute information, or type reasoning based on the attribute information, etc.).

[0108] In combination with the fourth aspect, in a possible implementation method, the device also includes a desensitization module for determining whether the first data meets the desensitization conditions; the determination module is specifically used to: if the first data does not meet the desensitization conditions, further determine whether the attribute information exists in the information database.

[0109] In an embodiment of the present application, before performing side channel security constraint detection, the desensitizing module first determines whether the sensitive data meets the desensitizing conditions. Side channel security constraint detection will only be performed if the sensitive data does not meet the desensitizing conditions. This can effectively avoid false reporting of side channel risks.

[0110] In combination with the fourth aspect, in a possible implementation, the device further includes: a type inference module, configured to perform type inference on the first data.

[0111] It can be understood that the above type inference refers to the impact transmission of the first sensitive data during the compilation process.

[0112] In an embodiment of the present application, by utilizing the transferability of the tag attributes of sensitive data, the type inference module can realize automatic type inference of sensitive data, and then transfer the influence of sensitive data throughout the compilation process, which can improve the completeness of side channel detection and the usability of tools in the detection process.

[0113] In conjunction with the fourth aspect, in a possible implementation, the determination module is specifically used to: obtain conditional statement information stored in the compiled intermediate representation; and determine whether the attribute information exists in the conditional statement information.

[0114] In an embodiment of the present application, a device for detecting branch execution time side channel risks is provided. The constraint detection module determines whether there is a branch execution time side channel risk during the compilation process based on the attribute information of the sensitive data, so that the device can accurately and comprehensively detect the branch execution time side channel of the compilation process, and thus can quickly and accurately identify the branch execution time side channel risk in the compilation process, thereby improving the security of user sensitive data or keys, etc.

[0115] In combination with the fourth aspect, in a possible implementation method, the determination module is specifically used to: obtain the calling information of the calling function during the compilation process, the calling information of the calling function includes the name of the calling function and the parameter list of the calling function; determine whether the calling function is a variable time function based on the name of the calling function; if the calling function is a variable time function, determine whether the attribute information exists in the parameter list of the calling function.

[0116] In an embodiment of the present application, a device for detecting variable time function side channel risks is provided. The constraint detection module determines whether there is a variable time function side channel risk during the compilation process based on the attribute information of the sensitive data, so that the device can accurately and comprehensively detect the variable time function side channel of the compilation process, and then can quickly and accurately identify the variable time function side channel risk in the compilation process, thereby improving the security of user sensitive data or keys, etc.

[0117] In combination with the fourth aspect, in a possible implementation method, the determination module is specifically used to: obtain the dereference statement information stored in the compiled intermediate representation, the dereference statement information including the pointer calculation address offset expression; determine whether the attribute information exists in the pointer offset access data in the pointer calculation address offset expression.

[0118] In an embodiment of the present application, a device for detecting cache time side channel risks is provided. The constraint detection module determines whether there is a cache time side channel risk during the compilation process based on the attribute information of the sensitive data, so that the device can accurately and comprehensively detect the cache time side channel of the compilation process, and then can quickly and accurately identify the cache time side channel risk in the compilation process, thereby improving the security of user sensitive data or keys, etc.

[0119] In combination with the fourth aspect, in one possible implementation, the determination module is specifically used to: determine the central processing unit CPU architecture when the program is compiled; determine the variable time instruction corresponding to the CPU architecture; and determine whether the attribute information exists in the operand of the operation corresponding to the variable time instruction.

[0120] In an embodiment of the present application, a device for detecting variable-time instruction side channel risks is provided. The constraint detection module determines whether there is a variable-time instruction side channel risk during the compilation process based on the attribute information of the sensitive data, so that the device can accurately and comprehensively detect the variable-time instruction side channel of the compilation process, and thus can quickly and accurately identify the variable-time instruction side channel risk in the compilation process, thereby improving the security of user sensitive data or keys, etc.

[0121] In combination with the fourth aspect, in a possible implementation method, the desensitizing module is specifically used to: construct a control flow graph consisting of nodes of each branch of the program; when the execution depth of the branches is consistent and each step operation of the branches is equivalent, determine that the first data meets the desensitizing condition; or, when the execution depth of the branches is inconsistent, and / or, each step operation of the branches is not equivalent, determine that the first data does not meet the desensitizing condition.

[0122] In an embodiment of the present application, a device is provided for determining whether sensitive data meets the desensitization conditions. When the compiler meets the equivalence conditions, the desensitization module determines that the sensitive data meets the desensitization conditions, providing a basis for subsequently determining whether security constraint detection is required.

[0123] In combination with the fourth aspect, in one possible implementation, the desensitization module is specifically used to: obtain a first list in a program configuration file, the first list including one or more obfuscation operations; when the first data is processed by the obfuscation operation in the first list, determine that the first data meets the desensitization condition; or, when the first data is not processed by the obfuscation operation in the first list, determine that the first data does not meet the desensitization condition.

[0124] In an embodiment of the present application, another device is provided for determining whether sensitive data meets the desensitization conditions. When sensitive data is processed by the obfuscation operation in the program configuration file, it means that the sensitive data is confused with other data and is treated equally. Therefore, the desensitization module determines that the sensitive data meets the desensitization conditions, providing a basis for subsequently determining whether security constraint detection is required.

[0125] In combination with the fourth aspect, in a possible implementation method, the type inference module is specifically used to: determine whether a first variable in the program is sensitive based on the attribute information of the first data, according to the type rule of the expression and the subtype inference rule of the variable, where the first variable refers to the variable in the program other than the first data; when it is determined that the first variable is sensitive, pass the attribute tag of the first data to the first variable.

[0126] Optionally, if the first variable has an operation relationship with the sensitive data, such as an assignment operation, the type inference module may determine that the first variable is affected by the sensitive data, and further pass the attribute tag of the sensitive data to the first variable.

[0127] In an embodiment of the present application, a device for performing type inference on sensitive data is provided. In the device, a type inference module determines whether other variables are sensitive based on attribute information of the sensitive data and the relationship between other variables and the sensitive data. When it is determined that other variables are affected by the sensitive data, the attributes of the sensitive data are passed to the other variables. In this way, when performing security constraint detection, it is possible to detect other variables affected by the sensitive data while detecting the sensitive data, thereby making the detection process more complete and further improving the security of user sensitive data or keys.

[0128] In a fifth aspect, an electronic device is provided, comprising a memory and a processor, wherein the memory is used to store computer program code, and the processor is used to execute the computer program code stored in the memory to implement the method in the above-mentioned first aspect or any possible implementation of the first aspect, or to implement the method in the above-mentioned second aspect or any possible implementation of the second aspect.

[0129] In a sixth aspect, a chip is provided, in which instructions are stored. When the chip is run on a device, the chip executes the method in the above-mentioned first aspect or any possible implementation of the first aspect, or executes the method in the above-mentioned second aspect or any possible implementation of the second aspect.

[0130] In the seventh aspect, a computer-readable storage medium is provided, which stores a computer program or instruction. When the computer program or instruction is executed, it implements the method in the above-mentioned first aspect or any possible implementation of the first aspect, or implements the method in the above-mentioned second aspect or any possible implementation of the second aspect.

[0131] In an eighth aspect, a computer program product is provided, which includes a computer program code. When the computer program code runs on a computer, it implements the method in the above-mentioned first aspect or any possible implementation of the first aspect, or implements the method in the above-mentioned second aspect or any possible implementation of the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0132] FIG1 is a flow chart of an existing side channel detection method;

[0133] FIG2 is a schematic diagram of another existing side channel detection method;

[0134] FIG3 is a schematic diagram of functional modules of a side channel detection device provided in an embodiment of the present application;

[0135] FIG4 is a schematic diagram of functional modules of another side channel detection device provided in an embodiment of the present application;

[0136] FIG5 is a schematic diagram of a side channel detection method provided in an embodiment of the present application implemented in software;

[0137] FIG6 is a schematic flowchart of a side channel detection method provided in an embodiment of the present application;

[0138] FIG7 is a schematic flowchart of another side channel detection method provided in an embodiment of the present application;

[0139] FIG8 is a schematic flowchart of a method for obtaining attributes of sensitive data provided in an embodiment of the present application;

[0140] FIG9 is a schematic flow chart of a method for security constraint detection based on sensitive data provided in an embodiment of the present application;

[0141] FIG10 is a schematic flowchart of a method for determining whether there is a branch execution time side channel security risk provided by an embodiment of the present application;

[0142] FIG11 is a schematic flowchart of a method for determining whether there is a variable time function side channel security risk provided by an embodiment of the present application;

[0143] FIG12 is a schematic flowchart of a method for determining whether there is a cache time side channel security risk provided by an embodiment of the present application;

[0144] FIG13 is a schematic flowchart of a method for determining whether there is a variable-time instruction side channel security risk provided by an embodiment of the present application;

[0145] FIG14 is a schematic flowchart of a method for determining whether first sensitive data meets a desensitization condition provided in an embodiment of the present application;

[0146] FIG15 is a schematic flowchart of another method for determining whether first sensitive data meets the desensitization condition provided in an embodiment of the present application;

[0147] FIG16 is a schematic flowchart of another side channel detection method provided in an embodiment of the present application;

[0148] Figure 17 is a schematic flowchart of a method for performing type reasoning based on first sensitive data provided in an embodiment of the present application. DETAILED DESCRIPTION

[0149] The technical solutions of this application will be described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only part of the embodiments of this application, rather than all the embodiments.

[0150] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "plurality" or "multiple" refers to two or more than two.

[0151] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of the technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.

[0152] The method provided in the embodiments of the present application can be applied to electronic devices such as mobile phones, tablet computers, wearable devices, in-vehicle devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPCs), netbooks, and personal digital assistants (PDAs). The embodiments of the present application do not impose any restrictions on the specific types of electronic devices.

[0153] Below, some terms involved in the embodiments of this application are first introduced in detail.

[0154] 1. Sensitive Data

[0155] Sensitive data refers to data that, if leaked, could pose a serious threat to society or individuals. This includes private personal data such as name, ID number, address, phone number, bank account number, email address, password, medical information, and educational background. It also includes data that businesses or social organizations should not disclose, such as business performance, network structure, and IP address lists. In cryptographic algorithms, sensitive data generally refers to secret keys or private keys.

[0156] 2. Side Channel Attacks

[0157] A side-channel attack refers to a method of attacking cryptographic implementations (including cryptographic chips, cryptographic modules, cryptographic systems, etc.) in order to ultimately analyze the key.

[0158] 3. Static detection technology

[0159] Static detection technology refers to scanning the source program or binary code of the software being tested, understanding the behavior of the program from a grammatical and semantic perspective, directly analyzing the characteristics of the program being tested, and looking for anomalies that may cause errors.

[0160] 4. Dynamic detection technology

[0161] Dynamic detection technology refers to the analysis of the running behavior of the software system, which includes formally running the program with specific inputs in a controlled environment and comparing it with the expected results to check whether the system is running correctly or incorrectly.

[0162] 5. Key Recovery

[0163] Key recovery refers to the process by which an attacker guesses the key or even directly obtains the key based on leaked information.

[0164] 6. Branch Execution Time Side Channel

[0165] The branch execution time side channel refers to the situation where sensitive data affects the branch execution of the program, causing the program to have different execution times when different inputs are given. Therefore, attackers can guess the sensitive data through the execution time difference.

[0166] 7. Cache Time Side Channel

[0167] The cache time side channel, also known as the cache time side channel, refers to the situation where sensitive data determines memory data access. There is a large time difference between memory access hits and misses, and attackers can use this time difference to infer the content of sensitive data.

[0168] 8. Variable time instructions

[0169] Variable-time instructions refer to central processing unit (CPU) instructions that have different operands and different execution times.

[0170] 9. Compiler

[0171] A compiler is a program that translates high-level computer languages ​​that are easy for people to write, read, and maintain into low-level machine languages ​​that computers can recognize and run. Commonly used compilers for C language include GCC, clang, etc.

[0172] 10. Compile plugin

[0173] A compilation plug-in allows users to intervene in the compilation process of the compiler through the plug-in, obtain various data in the compilation process, and even modify the intermediate data generated during the compilation process, thereby achieving the purpose of modifying the behavior of the final binary file.

[0174] 11. Compile Intermediate Representation

[0175] Compiled intermediate representation is a universal code that is independent of the programming language and target machine during the compilation process. As an intermediate representation, it contains information such as the program's functions and execution flow. Users can modify, customize, and optimize the intermediate representation.

[0176] 12. Compile-time instrumentation

[0177] Compile-time instrumentation refers to modifying existing code or generating new code and inserting it into the original code during code compilation.

[0178] 13. Attribute Marking

[0179] Attribute tagging means adding some attributes to the variable type to be used for problem detection.

[0180] 14. Subtype system

[0181] A subtype system refers to a partial order relationship between types, that is, S<:T means that any value type of type S can also be T, that is, the element set of S is a subset of the element set of T, and type S is a subclass of type T.

[0182] 15. Plugin Type System

[0183] A plug-in type system refers to a system that adds some new types that do not affect the original system on the basis of the original type system.

[0184] 16. Type Inference

[0185] Type inference refers to the ability of a programming language to automatically infer the data type of a value at compile time. It is a feature of some strongly statically typed languages. Generally speaking, functional programming languages ​​have this feature. The ability to automatically infer types makes many programming tasks easier, allowing programmers to omit type annotations while still allowing type checking.

[0186] 17. Taint Analysis

[0187] Taint analysis is a technique for tracking and analyzing the flow of tainted information within a program. In vulnerability analysis, taint analysis techniques are used to mark data of interest (usually from external program input) as tainted data. By tracking the flow of information related to the tainted data, it is possible to determine whether it affects certain critical program operations, thereby uncovering program vulnerabilities.

[0188] 18. Desensitization mechanism

[0189] Desensitization refers to obfuscating sensitive data during product or program execution, preventing attackers from guessing the original sensitive data during calculation or processing, even in the presence of side-channel vulnerabilities. Furthermore, constant-time implementation or obfuscation operations also prevent attackers from guessing the sensitive data. Therefore, constant-time implementation or obfuscation operations are considered data desensitization mechanisms.

[0190] 19.PASS

[0191] PASS refers to the general term for operations such as obtaining and processing intermediate representation (IR) information during the intermediate stage of compilation.

[0192] 20. Branch condition judgment

[0193] Branch condition judgment refers to the satisfaction judgment of variables in the program. When the judgment results are different, the executed branch process will also be different.

[0194] 21. Pointer offset

[0195] Pointer offset means that when accessing memory space in a program, the pointer address content needs to be read. The pointer is the first address, so when reading other addresses, the corresponding address offset needs to be added.

[0196] 22. Variable time function

[0197] A variable time function is a function whose execution time is related to the parameters entered when the function is called.

[0198] 23. Program Control Flow Graph

[0199] A control flow graph (CFD) is an abstract representation of a process or program. It is an abstract data structure used by compilers and maintained internally. It represents all the paths traversed during program execution. It graphically depicts the possible jumps between all basic blocks within a process and can also reflect the real-time execution of a process.

[0200] 24.GIMPLE

[0201] GIMPLE is a generic code that is independent of the programming language and target machine during the compilation process of the GNU compiler collection (GCC). As an intermediate representation, it contains information such as the program's functions and execution flow. Users can modify, customize, and optimize GIMPLE.

[0202] 25.gimple_cond

[0203] Gimple_cond is a keyword in the gimple intermediate representation, which stores the conditional judgment content of the program.

[0204] 26.gimple_call

[0205] Gimple_call is a keyword in the gimple intermediate representation, which stores information about program call functions.

[0206] 27.indirect_ref

[0207] indirect_ref is a keyword in the gimple intermediate representation, which stores the expression of address offset calculation. The function of this keyword is to dereference and read the address content.

[0208] 28.pointer_plus_expr

[0209] pointer_plus_expr is a keyword in the gimple intermediate representation that stores the expression for pointer addition, and similarly, pointer_sub_expr represents pointer subtraction, both of which are used to calculate pointer offsets.

[0210] 29.cache hit

[0211] A cache hit is also called a cache hit. When a program requests data, it first searches the cache for the data. If the required data is found, it is considered a cache hit.

[0212] 30.cache miss

[0213] A cache miss, also known as a cache miss, means that when a program requests data, it first searches the cache level by level for the data. If the data is not found, it has to read the data from the disk, which is a cache miss.

[0214] 31. Floating point numbers

[0215] Due to resource limitations, decimals in mathematics cannot be accurately represented directly in computers. To better represent these decimals, computer scientists invented floating-point numbers, which approximate decimal representations. Therefore, floating-point numbers are decimals represented using four components: a sign, a mantissa, a base, and an exponent. This involves certain errors, and because of the complexity of the representation, computer operations are relatively slow.

[0216] 32. Operands

[0217] Operands refer to the participants in instruction execution and are the objects of various operations, that is, the data that needs to participate in the calculation.

[0218] 33. Equivalence Operations

[0219] Equivalence operation means that the type of operation in each step of the program in different execution branches is the same, so that the execution cost of the operation is also the same. This operation can be called an equivalence operation.

[0220] 34. Obfuscation Operation

[0221] Obfuscation refers to a method of hiding specific information so that attackers cannot obtain the original data. There is usually a corresponding deobfuscation operation to restore the data.

[0222] 35. Dominator Tree Algorithm

[0223] The dominator tree algorithm, given a directed graph with a starting point S and an end point T, asks which points must be passed through all paths from S to T (i.e., the intersection of the points on each path). These points are called dominator points (must-pass points). In short, if a certain point (the dominator point) is deleted, there will be no path that can lead from S to T. The tree formed by the dominator points is called a dominator tree, and the process of finding the dominator points and constructing the dominator tree is the dominator tree algorithm.

[0224] 36.RSA

[0225] RSA is an asymmetric encryption algorithm. The so-called asymmetric means that the algorithm uses different keys for encryption and decryption, that is, it uses an encryption key for encryption and a decryption key for decryption.

[0226] 37.Signature Algorithm

[0227] A signature algorithm refers to a method of signing information using the private key in a public-private key pair, which serves as a non-repudiation and identity verification function.

[0228] 38. Blinding

[0229] Blinding refers to transforming the message m before RSA signing. With the help of another parameter r, which must satisfy the condition that the greatest common factor of r and n is 1, m is converted to m' using m'=mr^e(mod n).

[0230] 39. Type Rules

[0231] Type rules are inference rules that describe how a type system assigns types to syntactic constructs. A type system can apply these rules to determine whether a program is well-typed and what type a type expression has.

[0232] 40. Subtype Inference Rules

[0233] The subtype inference rule refers to the process of transferring type attributes from the source variable to the target variable when the variable is assigned, calculated, or otherwise operated in an expression. This is the process of grouping subtypes into larger types, i.e., multiple source variable types <: target variable type.

[0234] 41. Cryptographic Algorithm Protocol

[0235] A cryptographic algorithm protocol is a protocol that uses cryptographic algorithms as the basis, runs in a network or distributed system, and provides a series of steps for parties with security needs with the help of cryptographic algorithms to achieve the purposes of identity authentication, key distribution, information transmission protection, etc. These communication processes constitute the protocol.

[0236] 42.Data-sensitive products

[0237] Data-sensitive products refer to products that are sensitive to data and need to ensure the security of data such as user personal information.

[0238] It should be understood that the technical solutions in the embodiments of the present application can be used in Android, IOS, Hongmeng and other systems.

[0239] The technical solutions of the embodiments of the present application can be applied to side channel detection scenarios, specifically, can be applied to programming devices, or to electronic devices that can be used for programming.

[0240] The electronic device in the embodiment of the present application may be a television, a desktop computer, a laptop computer, or a portable electronic device such as a mobile phone, a tablet computer, a camera, a video camera, a video recorder, or other electronic devices with storage functions, electronic devices in a 5G network, or electronic devices in a future evolved public land mobile communication network (PLMN), etc. This application does not limit this.

[0241] Currently, the industry has proposed many methods for detecting side channel problems, but there are few methods currently available in the industry, and their usability is poor, and they do not cover many side channel problems.

[0242] FIG1 shows a flow chart of an existing side channel detection method 100. As shown in FIG1 , the method 100 includes:

[0243] S101: Preprocessing source code to extract network protocol-related codes from the source code to perform static taint analysis.

[0244] S102: Based on the code related to the network protocol, determine the contamination variables in the network protocol through the static taint analysis.

[0245] S103: Based on the shared variables obtained from the code related to the network protocol, determine the pollution propagation path of the shared variables by reversely traversing the pollution variables.

[0246] Among them, the contamination propagation path of the shared variable can be used to exploit vulnerabilities in the side channels of network protocols.

[0247] This method uses static taint analysis detection. Although it can find side channel vulnerabilities in the protocol, since this method uses instrumentation technology or code rewriting technology, modifying the program often brings huge overhead to the analysis system, which makes this method have problems such as long detection cycle for complex programs, inability to complete analysis, and high false alarm rate. In addition, this detection method only analyzes branch paths and can only discover side channel problems during branch execution, and the detection range is small.

[0248] FIG2 shows a schematic diagram of another existing side channel detection method 200. As shown in FIG2 , the method 200 includes:

[0249] S201: Calling a rule parsing module to parse a rule file based on a predefined rule base and user-defined rules.

[0250] S202: Construct a regular expression based on the parsed rule file.

[0251] S203: Perform rule matching on the program.

[0252] S204: Generate structural information based on the file under test and obtain the control flow and data flow of the program.

[0253] S205: Perform path alias analysis of the program to obtain path alias information of the program.

[0254] S206: Perform static detection based on the control flow, data flow information, and path alias information of the program.

[0255] S207: Encapsulate the static detection result and output the static detection result.

[0256] This method uses rule matching technology, which can to a certain extent solve the shortcomings of existing static detection technology such as slow speed. However, since the rule files detected in this method are completely customized by the user, different users make different rule configurations, which makes it easy for the rule configuration of the detection problem to be missed, and then there will be missed reports, which greatly affects the quality of the detection rules and thus seriously affects the detection effect. In addition, the rules in this method are effective for the entire program, and no variables or data are tracked, which can easily lead to false positives.

[0257] Therefore, most existing side-channel detection methods use dynamic detection. Since detection is strongly correlated with coverage, there may be omissions. Although a small number of static detection methods are used, these methods have high overhead and a small detection range, making it difficult to fully discover time side-channel problems in software. In addition, existing side-channel detection tools have usability issues and require detection configuration and test code writing, which results in a large detection workload.

[0258] Based on this, the present application provides a method and device for side channel detection. This method expands the functionality of the native compiler, adopts static side channel detection, and combines security constraint judgment with consideration of the transmission of sensitive data. It can improve the efficiency, accuracy, and completeness of side channel detection, thereby better improving the security of program products and ensuring that users' personal sensitive data can be well protected.

[0259] The terms used in the following embodiments are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the specification of this application and the appended claims, the singular expressions "a", "an", "said", "above", "the" and "this" are intended to also include expressions such as "one or more", unless there is a clear contrary indication in the context. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" refer to one, two or more. The term "and / or" is used to describe the association relationship of associated objects, indicating that three relationships can exist; for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship.

[0260] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "one embodiment," "some embodiments," "another embodiment," and "other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically stated. The terms "including," "comprising," "having," and variations thereof mean "including but not limited to," unless otherwise specifically stated.

[0261] For example, Figure 3 shows a functional module diagram of a side channel detection device 300 provided by an embodiment of the present application. As shown in Figure 3, the device 300 includes a native compiler 310 and a compilation plug-in 320, wherein the compilation plug-in 320 includes a registration module 321 and an encapsulation module 322, and the encapsulation module 322 further includes a constraint detection module 3221, a desensitization module 3222, and a type inference module 3223, wherein:

[0262] The native compiler 310 is a compiler that supports secondary development (ie, supports expansion), and may be, for example, a C / C++ native compiler (eg, a GNU compiler collection (GCC) compiler, a clang compiler, etc.).

[0263] The compiler plug-in 320 is used to expand the functionality of the native compiler 310 .

[0264] The registration module 321 is used to mark sensitive data in the source code.

[0265] Optionally, the registration module 321 is used to register the side channel attribute and mark the side channel attribute on the sensitive data.

[0266] Among them, the registration module 321 marks the sensitive data, which can support the subsequent constraint detection and desensitization mechanism execution for the marked sensitive data, and the marked sensitive data can be used as the source point of type reasoning. The type reasoning process can be regarded as the process of transmitting the influence of sensitive data.

[0267] The encapsulation module 322 is used to implement the overall encapsulation of the constraint detection module 3221 , the desensitization module 3222 and the type inference module 3223 .

[0268] Optionally, the encapsulation module 322 may also be referred to as a type checking process (TypeCheckingPass) module.

[0269] The constraint detection module 3221 is used to determine whether the marked sensitive data meets the side channel security constraint conditions. When the marked sensitive data does not meet the side channel security constraint conditions, a side channel problem alarm will be triggered and an error message will be recorded in the compilation log; when the marked sensitive data meets the side channel security constraint conditions, other subsequent steps will be executed.

[0270] Optionally, the error information includes information such as the error location and constraint violation details.

[0271] Optionally, when the constraint detection module 3221 determines that the marked sensitive data does not meet the side channel security constraint, it records the error information in the compilation log and continues to execute subsequent steps. For example, when the constraint detection module 3221 determines that the marked sensitive data does not meet the branch execution time side channel security constraint, it records the first error information in the compilation log and continues to execute the steps of determining whether the marked sensitive data meets the variable time function side channel security constraint, or determining whether the marked sensitive data meets the cache time side channel security constraint, or determining whether the marked sensitive data meets the variable time instruction side channel security constraint, etc.

[0272] The desensitization module 3222 is used to desensitize the marked sensitive data when the marked sensitive data meets the desensitization conditions, and in this case does not detect whether the marked sensitive data meets the security constraint conditions.

[0273] Optionally, the desensitization condition includes that the marked sensitive data satisfies an equivalence operation condition and / or the marked sensitive data is in an obfuscated state.

[0274] The type inference module 3223 is used to influence the marked sensitive data.

[0275] In one example, if the marked sensitive data is assigned to another variable, the other variable will also carry the attribute tag, that is, the influence of the marked sensitive data is transferred to the other variable. When performing the above-mentioned security constraint judgment, the other variable is also the object of judgment.

[0276] Optionally, the device 300 may not include the native compiler 310 , that is, the device and the native compiler may exist independently of each other.

[0277] It should be understood that the above-mentioned desensitization module 3222 and type inference module 3223 are optional modules of the device 300.

[0278] Optionally, the apparatus 300 may further include an acquisition module for acquiring attribute information of the marked sensitive data.

[0279] Optionally, the apparatus 300 may further include a recording module configured to record error information in a compilation log when a side channel risk is detected.

[0280] In an embodiment of the present application, a compilation plug-in is used to expand the functionality of the native compiler, so that sensitive data in the source code can be attributed and marked. On this basis, multiple side channels of the compilation process (for example, branch execution time side channel, variable time function side channel, cache time side channel, variable time instruction side channel, etc.) can be further accurately and comprehensively detected, and various side channel risks can be quickly and accurately identified, which largely solves the problem of missed risks. In addition, through the judgment of the desensitization mechanism, when the sensitive data meets the requirements of the desensitization mechanism, side channel risk detection is not performed, which can reduce overhead and also largely solve the problem of misreporting of risks. Moreover, the device also transmits the impact of sensitive data through type reasoning, which can significantly improve the usability of the device and save a lot of workload.

[0281] For example, Figure 4 shows a functional module diagram of another side channel detection device 400 provided by an embodiment of the present application. As shown in Figure 4, the device 400 includes a native compiler 410 and a compilation plug-in 420, wherein the compilation plug-in 420 includes a registration module 421 and an encapsulation module 422, and the encapsulation module 422 further includes a constraint detection module 4221, a desensitization module 4222, and a type inference module 4223. The constraint detection module 4221 further includes a branch execution time side channel module 42211, a variable time function detection module 42212, a cache time side channel detection module 42213, and a variable time instruction side channel detection module 42214, wherein:

[0282] The native compiler 410 is a compiler that supports secondary development (ie, supports expansion), and may be, for example, a C / C++ native compiler (eg, a GNU compiler collection (GCC) compiler, a clang compiler, etc.).

[0283] The compiler plug-in 420 is used to expand the functionality of the native compiler 410 .

[0284] The registration module 421 is used to mark sensitive data in the source code.

[0285] Optionally, the registration module 421 is used to register the side channel attribute and mark the side channel attribute on the sensitive data.

[0286] Among them, the registration module 421 marks the sensitive data, which can support the subsequent constraint detection and desensitization mechanism execution for the marked sensitive data, and the marked sensitive data can be used as the source point of type reasoning. The type reasoning process can be regarded as the process of transmitting the influence of sensitive data.

[0287] The encapsulation module 422 is used to implement the overall encapsulation of the constraint detection module 4221 , the desensitization module 4222 and the type inference module 4223 .

[0288] Optionally, the encapsulation module 422 may also be referred to as a type checking process (TypeCheckingPass) module.

[0289] The constraint detection module 4221 is used to determine whether the marked sensitive data meets the side channel security constraint conditions. When the marked sensitive data does not meet the side channel security constraint conditions, a side channel problem alarm will be triggered and an error message will be recorded in the compilation log; when the marked sensitive data meets the side channel security constraint conditions, other subsequent steps will be executed.

[0290] Optionally, the error information includes information such as the error location and constraint violation details.

[0291] The branch execution time side channel module 42211 is used to detect whether the branch execution time side channel meets the side channel security constraints. If the marked sensitive data does not meet the side channel security constraints, it will trigger a side channel problem alarm and record the first error information in the compilation log; when the marked sensitive data meets the side channel security constraints, other subsequent steps will continue to be executed (for example: steps executed by the variable time function detection module 42212, steps executed by the cache time side channel detection module 42213, steps executed by the variable time instruction side channel detection module 42214, etc.).

[0292] Optionally, the branch execution time side channel module 42211 detects the impact of the marked sensitive data on the program control flow to detect whether the program meets the side channel security constraint (i.e., whether there is a branch execution time side channel risk). The specific steps may be:

[0293] The branch execution time side channel module 42211 obtains the conditional statement information stored in the compiled intermediate representation. When the marked sensitive data exists in the conditional statement information (for example, the judgment condition), it is determined that the side channel security constraint condition is not met, further triggering the side channel problem alarm and recording the first error information in the compilation log.

[0294] The first error information may include error location information: the code line where the marked sensitive data is located in the conditional statement information, and may also include constraint violation details: there is a security risk in the branch execution time side channel.

[0295] It can be understood that when the marked sensitive data exists in the conditional statement information (for example, the judgment condition), it may cause the execution time of the program to be variable. Therefore, in this case, it is determined that the side channel security constraint condition is not satisfied.

[0296] The variable time function detection module 42212 is used to detect whether the variable time function side channel meets the side channel security constraints. If the marked sensitive data does not meet the side channel security constraints, it will trigger a side channel problem alarm and record a second error message in the compilation log; when the marked sensitive data meets the side channel security constraints, other subsequent steps will continue to be executed (for example: the steps executed by the cache time side channel detection module 42213, the steps executed by the variable time instruction side channel detection module 42214, etc.).

[0297] Optionally, the variable time function detection module 42212 detects whether the program meets the side channel security constraint (i.e., whether there is a variable time function side channel risk) by detecting whether the marked sensitive data is used as a call parameter of the variable time function. The specific steps may be:

[0298] The variable time function detection module 42212 obtains function call information during the compilation process, and the function call information includes the name of the called function and the parameter list of the called function. It first determines whether the called function is a variable time function based on the name of the called function. If so, it further determines whether there is marked sensitive data in the parameter list of the called function. If so, it is determined that the side channel security constraint conditions are not met, further triggering a side channel problem alarm, and recording a second error message in the compilation log.

[0299] The second error information may include error location information: the code line where the marked sensitive data is located in the parameter list of the calling function, and may also include constraint violation details: there is a security risk in the variable time function side channel.

[0300] The cache time side channel detection module 42213 is used to detect whether the cache time side channel meets the side channel security constraints. If the marked sensitive data does not meet the side channel security constraints, it will trigger a side channel problem alarm and record a third error message in the compilation log; when the marked sensitive data meets the side channel security constraints, other subsequent steps will continue to be executed (for example: the steps executed by the variable time instruction side channel detection module 42214, etc.).

[0301] The cache time side channel detection module 42213 detects whether the program meets the side channel security constraint (i.e., whether there is a cache time side channel risk) by detecting the impact of the marked sensitive data on data access. The specific steps may be:

[0302] The cache time side channel detection module 42213 obtains the dereference statement information stored in the compiled intermediate representation, which includes a pointer calculation address offset expression, and then further determines whether the marked sensitive data is used as a pointer offset in the pointer calculation address offset expression to access the data. If so, it is determined that the side channel security constraint conditions are not met, further triggering a side channel problem alarm, and recording a third error message in the compilation log.

[0303] Among them, the third error information may include error location information: the code line where the marked sensitive data is located as the pointer offset in the pointer calculation address offset expression to access data, and may also include constraint violation details: there is a security risk in the cache time side channel.

[0304] The variable time instruction side channel detection module 42214 is used to detect whether the variable time instruction side channel meets the side channel security constraints. If the marked sensitive data does not meet the side channel security constraints, it will trigger a side channel problem alarm and record the fourth error message in the compilation log; when the marked sensitive data meets the side channel security constraints, other subsequent steps will continue to be executed (for example: the steps executed by the type inference module 4223, etc.).

[0305] Optionally, the variable time instruction side channel detection module 42214 detects whether the program satisfies the side channel security constraint (i.e., whether there is a variable time instruction side channel risk) by detecting whether the marked sensitive data is an operand of a variable time instruction. The specific steps may be:

[0306] The variable time instruction side channel detection module 42214 determines the CPU architecture when the program is compiled, and then determines the variable time instruction corresponding to the CPU architecture based on the CPU architecture, and then determines the operands of the variable time instruction corresponding to the CPU architecture, and further determines whether the marked sensitive data appears in the operands of the variable time instruction corresponding to the operation. If so, it is determined that the side channel security constraint conditions are not met, further triggering the side channel problem alarm, and recording the fourth error message in the compilation log.

[0307] Among them, the fourth error information may include error location information: the code line where the marked sensitive data is located in the operand of the operation corresponding to the variable time instruction, and may also include constraint violation details: there is a security risk in the variable time instruction side channel.

[0308] It can be understood that there is a corresponding relationship between the CPU architecture during program compilation and the variable time instructions. That is, different CPU architectures during program compilation result in different variable time instructions.

[0309] The desensitization module 4222 is used to desensitize the marked sensitive data when the marked sensitive data meets the desensitization conditions, and in this case does not detect whether the marked sensitive data meets the security constraint conditions.

[0310] Optionally, the desensitization condition includes that the marked sensitive data satisfies an equivalence operation condition and / or the marked sensitive data is in an obfuscated state.

[0311] The type inference module 4223 is used to influence the marked sensitive data.

[0312] In one example, if the marked sensitive data is assigned to another variable, the other variable will also carry the attribute tag, that is, the influence of the marked sensitive data is transferred to the other variable. When performing the above-mentioned security constraint judgment, the other variable is also the object of judgment.

[0313] Optionally, the apparatus 400 may not include the native compiler 410 , that is, the apparatus 400 and the native compiler 410 may exist independently of each other.

[0314] In one example, the native compiler 410 is a GCC compiler, and the step of the constraint detection module 4221 determining whether the side channel security constraint is satisfied may be:

[0315] During the intermediate compilation phase, the compiler first checks whether the conditional expression contained in the gimple_cond keyword in the GIMPLE intermediate representation contains marked sensitive data. It then determines whether the function called by the gimple_call keyword is a variable-time function and whether the call parameters contain sensitive data. Next, it checks whether the address offset expression in the indirect reference (indirect_ref) dereference contains sensitive data. Finally, it checks whether the operation involves a variable-time instruction with sensitive data as an operand. Note that the order of these steps is not crucial.

[0316] For example, Figure 5 shows a schematic diagram of a software implementation of a side channel detection method provided in an embodiment of the present application. As shown in Figure 5, the implementation includes the following steps:

[0317] S501: Input the source code into the native compiler.

[0318] S502: Add the compilation plug-in to the native compiler as an extension plug-in of the native compiler and deploy it in the compilation process of the software.

[0319] The function of the compilation plug-in has been described in detail in the embodiments shown in FIG3 and FIG4 , and will not be repeated here for the sake of brevity.

[0320] S503: Configure the plug-in usage in the compilation script or configuration.

[0321] As can be seen, the compilation plug-in provided in the embodiments of this application can deeply participate in the software compilation process and can determine whether the program implementation semantics has side channel risks. However, this compilation plug-in does not affect the original implementation of the program at all, but is intended to detect side channel issues. The implementation form of the compilation plug-in in software compilation shown in the embodiments of this application is completely independent of the native compiler.

[0322] For example, FIG6 shows a schematic flow chart of a side channel detection method 600 provided in an embodiment of the present application. As shown in FIG6 , the method 600 includes:

[0323] S601: Mark sensitive data.

[0324] Specifically, sensitive data is marked in the source code.

[0325] In one example, marking sensitive data in source code may specifically include:

[0326] Among them, a is sensitive data.

[0327] S602: During the compilation process, side channel detection is performed based on the marked sensitive data.

[0328] Optionally, marked sensitive data is identified (or obtained) during the compilation process.

[0329] Optionally, security constraint detection is performed based on the marked sensitive data (for example, processing (PASS) and detection of the intermediate representation (IR) of the code during the compilation phase), that is, branch execution time side channel detection, variable time function side channel detection, cache time side channel detection and variable time instruction side channel detection are performed respectively.

[0330] Optionally, when the marked sensitive data meets the desensitization conditions, the marked sensitive data is temporarily desensitized and the above-mentioned security constraint detection is not performed.

[0331] Optionally, type inference is performed based on the marked sensitive data to achieve impact transfer of the marked sensitive data.

[0332] S603: Output compilation results.

[0333] If the compilation result is successful, it means there is no side channel risk.

[0334] When the compilation result is compilation failure, it indicates that there is a side channel risk.

[0335] Optionally, during the compilation process, when compilation errors (side channel risks) are detected, these compilation errors will be automatically recorded, and the recorded compilation error information can be uniformly output after the compilation of the entire program is completed. Then, the source code can be further uniformly modified according to the output compilation error information, and then the compilation process can be returned for detection.

[0336] In an embodiment of the present application, an innovative method for statically detecting time side channel problems is proposed. The method utilizes the feature of the compilation plug-in that supports assigning attributes to variables. By marking sensitive data with attributes, type comparisons between nodes are performed in the intermediate (IR) stage of compilation, or the position of the marked sensitive data in the program is determined to detect time side channel problems. At the same time, a desensitization mechanism and type reasoning of the plug-in type system are implemented, which can effectively improve the accuracy and completeness of side channel detection.

[0337] For example, FIG7 shows a schematic flow chart of another side channel detection method 700 provided in an embodiment of the present application. As shown in FIG7 , the method 700 includes:

[0338] S701: Obtain attribute information of first sensitive data.

[0339] Optionally, the first sensitive data is attribute-registered in the source code, and the first sensitive data is attribute-tagged to obtain the first sensitive data with the attribute tag, and the attribute information of the first sensitive data is obtained in the compilation stage.

[0340] The first sensitive data may refer to all sensitive data in the source code; may refer to part of the sensitive data in the source code; or may refer to a specific type of sensitive data in the source code.

[0341] Optionally, sensitive data attributes are registered in the source code using C language macro definitions. The registered attributes can then be appended between the variable type and variable name in the source code, and the variable type and variable name in the source code can serve as an additional type or attribute. Next, in the middle stage of the compilation process, the compilation plug-in will obtain the attributes of these variables for subsequent security constraint judgment.

[0342] Optionally, the attributes of the sensitive data may be configured through an additional configuration file, and then the attribute information of the first sensitive data may be read during compilation.

[0343] S702: Determine whether the first sensitive data meets the desensitization condition.

[0344] Among them, the desensitization conditions of the first sensitive data include equivalence conditions and obfuscation conditions. The equivalence condition specifically means that the number of instructions in each branch of the program is equal and they are the same type of operations; the obfuscation condition means that the first sensitive data has been obfuscated.

[0345] When the first sensitive data meets the desensitization condition, step S703 is executed; when the first sensitive data does not meet the desensitization condition, step S704 is executed.

[0346] S703: Temporarily desensitize the first sensitive data.

[0347] Optionally, in this case, step S706 may be further performed.

[0348] S704: Determine whether the first sensitive data satisfies the side-channel security constraint.

[0349] Specifically, a security constraint check is performed based on the first sensitive data to determine whether the first sensitive data satisfies the side channel security constraint. This includes performing branch execution time side channel checks, variable time function side channel checks, cache time side channel checks, and variable time instruction side channel checks. The order in which these four checks are performed is irrelevant. If the side channel security constraint is not satisfied, step S705 is executed. If the side channel security constraint is satisfied, step S706 is executed.

[0350] S705: Record error information in the compilation log.

[0351] The error information may include error location, constraint violation details, and other information.

[0352] S706: Perform type inference based on the first sensitive data.

[0353] This step actually realizes the influence transfer of the first sensitive data. For example, if the first sensitive data is assigned to the second data, then the second data will also be marked with the attribute of the first sensitive data, that is, the second data will also be regarded as sensitive data.

[0354] Optionally, after executing this step, return to step S702 to continue compiling and checking, and execute step S707 synchronously or asynchronously.

[0355] S707: Output compilation results.

[0356] In an embodiment of the present application, a compilation plug-in is used to expand the functionality of the native compiler, so that sensitive data in the source code can be attributed and marked. On this basis, multiple side channels of the compilation process (for example, branch execution time side channel, variable time function side channel, cache time side channel, variable time instruction side channel, etc.) can be further accurately and comprehensively detected, and various side channel risks can be quickly and accurately identified, which largely solves the problem of missed risks. In addition, through the judgment of the desensitization mechanism, when the sensitive data meets the requirements of the desensitization mechanism, side channel risk detection is not performed, which can reduce overhead and also largely solve the problem of misreporting of risks. Moreover, the method also transmits the influence of sensitive data through type reasoning, which can significantly improve the ease of use of the method and save a lot of workload.

[0357] To more clearly understand the process of obtaining attributes of sensitive data, FIG8 shows, for example, a schematic flow chart of a method 800 for obtaining attributes of sensitive data provided by an embodiment of the present application. As shown in FIG8 , the method 800 includes:

[0358] S801: Register attributes of first sensitive data in source code.

[0359] Optionally, the attributes of the first sensitive data are registered in the source code by means of C language macro definition.

[0360] S802: Attribute marking is performed on the first sensitive data in the source code to obtain first sensitive data with the attribute marking.

[0361] Among them, the first sensitive data can refer to all sensitive data in the source code; it can also refer to part of the sensitive data in the source code; it can also refer to a specific type of sensitive data in the source code. The attributes of the first sensitive data can be appended between the variable type and variable name of the source code as an additional type or attribute.

[0362] S803: Obtain attribute information of the first sensitive data.

[0363] Specifically, in the middle stage of the compilation process, the compilation plug-in obtains attribute information of the first sensitive data for subsequent security constraint judgment.

[0364] In an embodiment of the present application, sensitive data is attribute-tagged, and in the middle stage of the compilation process, the compilation plug-in obtains the attribute information of the sensitive data, which can provide a basis for subsequent detection of side channel risks.

[0365] To more clearly understand the security constraint detection process based on sensitive data, FIG9 shows, for example, a schematic flow chart of a method 900 for security constraint detection based on sensitive data provided by an embodiment of the present application. As shown in FIG9 , the method 900 includes:

[0366] S901: Determine whether there is a branch execution time side channel security risk. If yes, go to step S902; if not, go to step S903.

[0367] S902: Record the first error information in the compilation log, and proceed to step S903.

[0368] The first error information may include error location information: the code line where the marked sensitive data is located in the conditional statement information, and may also include constraint violation details: there is a security risk in the branch execution time side channel.

[0369] Optionally, after the error code is corrected according to the first error information, step S903 is continued.

[0370] S903: Determine whether the first sensitive data is used as a call parameter of a variable time function (ie, determine whether there is a side channel security risk of the variable time function). If so, execute step S904; if not, execute step S905.

[0371] S904: Record the second error information in the compilation log, and continue to execute step S905.

[0372] Optionally, after the error code is corrected according to the second error information, step S905 is continued.

[0373] The second error information may include error location information: the code line where the marked sensitive data is located in the parameter list of the calling function, and may also include constraint violation details: there is a security risk in the variable time function side channel.

[0374] S905: Determine whether there is a buffer time side channel security risk. If yes, go to step S906; if not, go to step S907.

[0375] S906: Record the third error information in the compilation log, and continue to execute step S907.

[0376] Optionally, after the error code is corrected according to the third error information, step S907 is continued.

[0377] Among them, the third error information may include error location information: the code line where the marked sensitive data is located as the pointer offset in the pointer calculation address offset expression to access data, and may also include constraint violation details: there is a security risk in the cache time side channel.

[0378] S907: Determine whether the first sensitive data is used as an operand of a variable time instruction (i.e., determine whether there is a variable time instruction side channel security risk). If so, execute step S908; if not, the compilation ends and the compilation result is successful.

[0379] S908: Record the fourth error information in the compilation log.

[0380] Optionally, the error code is corrected according to the fourth error information.

[0381] Among them, the fourth error information may include error location information: the code line where the marked sensitive data is located in the operand of the operation corresponding to the variable time instruction, and may also include constraint violation details: there is a security risk in the variable time instruction side channel.

[0382] Hereinafter, illustratively, based on the embodiment shown in FIG. 9 and in combination with FIG. 10 to FIG. 13 , the process of safety constraint detection will be described in detail.

[0383] For example, FIG10 shows a schematic flow chart of a method 1000 for determining whether there is a branch execution time side channel security risk (which can also be understood as detecting the impact of sensitive data on program control flow) provided by an embodiment of the present application. As shown in FIG10 , the method 1000 includes:

[0384] S1001: Obtain conditional statement information.

[0385] Specifically, the conditional statement information stored in the compiled intermediate representation is obtained.

[0386] Optionally, the conditional statement information is obtained based on the loop exit condition and / or if statement in the source code.

[0387] S1002: Determine whether the first sensitive data exists in the acquired conditional statement information. If so, execute step S1003; if not, execute step S1004.

[0388] Specifically, it is determined whether the first sensitive data exists in the acquired conditional statement information according to the attribute information of the first sensitive data.

[0389] Optionally, the conditional statement information may include a left variable (lhs) and a right variable (rhs), for example, in the conditional statement information 2>1, 2 is the left variable and 1 is the right variable.

[0390] S1003: Record the first error information in the compilation log, and continue to execute step S1004.

[0391] Among them, the first error information may include error location information: the code line where the first sensitive data is located in the conditional statement information, and may also include constraint violation details: there is a security risk in the branch execution time side channel.

[0392] Optionally, code repair is performed according to the first error information, and step S1004 is continued.

[0393] It is understandable that if the first sensitive data exists in the conditional statement information, the execution time of the program may be variable. Therefore, when it is detected that the first sensitive data appears in the conditional statement information, the first error information needs to be recorded in the compilation log.

[0394] S1004: Continue compiling and testing.

[0395] For example, FIG11 shows a schematic flow chart of a method 1100 for determining whether a variable time function side channel security risk exists, provided by an embodiment of the present application. As shown in FIG11 , the method 1100 includes:

[0396] S1101: Obtain function call information.

[0397] The function call information includes the name of the called function and a parameter list of the called function.

[0398] Specifically, the function call information is obtained during the compilation process.

[0399] S1102: Determine whether the called function is a variable time function based on the name of the called function. If so, execute step S1103.

[0400] S1103: Determine whether the first sensitive data exists in the parameter list of the calling function. If so, execute step S1104.

[0401] Optionally, if the first sensitive data is passed in as a pointer parameter, or the first sensitive data length is passed in as the pointer address space length, it can be determined that the first sensitive data exists in the parameter list of the calling function.

[0402] S1104: Record the second error information in the compilation log, and continue to execute step S1105.

[0403] Among them, the second error information may include error location information: the code line where the first sensitive data is located in the parameter list of the calling function, and may also include constraint violation details: there is a security risk in the variable time function side channel.

[0404] Optionally, code repair is performed according to the first error information, and step S1105 is continued.

[0405] S1105: Continue compiling and testing.

[0406] For example, FIG12 shows a schematic flow chart of a method 1200 for determining whether there is a cache time side channel security risk (which can also be understood as detecting the impact of sensitive data on data access) provided by an embodiment of the present application. As shown in FIG12 , the method 1200 includes:

[0407] S1201: Obtain dereference statement information, where the dereference statement information includes a pointer calculation address offset expression.

[0408] Specifically, the dereference statement information stored in the compiled intermediate representation is obtained.

[0409] S1202: Determine whether the first sensitive data is used as the pointer offset access data of the pointer calculation address offset expression. If so, execute step S1203; if not, execute step S1204.

[0410] Specifically, first determine whether the pointer offset access data of the pointer calculation address offset expression is used, and then determine whether the first sensitive data is used as the pointer offset access data of the pointer calculation address offset expression.

[0411] S1203: Record the third error information in the compilation log, and continue to execute step S1204.

[0412] Optionally, after correcting the error code according to the third error information, continue to step S1204.

[0413] Among them, the third error information may include error location information: the code line where the first sensitive data accessed by the pointer offset in the pointer calculation address offset expression is located, and may also include constraint violation details: there is a security risk in the cache time side channel.

[0414] S1204: Continue compiling and testing.

[0415] For example, FIG13 shows a schematic flow chart of a method 1300 for determining whether a variable time instruction side channel security risk exists, provided by an embodiment of the present application. As shown in FIG13 , the method 1300 includes:

[0416] S1301: Determine the CPU architecture when compiling the program.

[0417] S1302: Determine the variable time instruction corresponding to the CPU architecture.

[0418] There is a corresponding relationship between the CPU architecture and the variable time instructions, that is, different CPU architectures correspond to different variable time instructions.

[0419] S1303: Determine whether the first sensitive data appears in the operand of the operation corresponding to the variable time instruction. If so, execute step S1304; if not, execute step S1305.

[0420] S1304: Record the fourth error information in the compilation log, and continue to execute step S1305.

[0421] Optionally, after correcting the error code according to the fourth error information, continue to step S1305.

[0422] Among them, the fourth error information may include error location information: the code line where the first sensitive data is located in the operand of the operation corresponding to the variable time instruction, and may also include constraint violation details: there is a security risk in the variable time instruction side channel.

[0423] S1305: Continue compiling and testing.

[0424] In order to more clearly understand the process of determining whether the first sensitive data meets the desensitization conditions provided in the embodiment of the present application, the following, by way of example, with reference to Figures 14 and 15, provides a detailed introduction to the method for determining whether the first sensitive data meets the desensitization conditions provided in the embodiment of the present application.

[0425] For example, FIG14 shows a schematic flow chart of a method 1400 for determining whether first sensitive data meets a desensitization condition provided by an embodiment of the present application. As shown in FIG14 , the method 1400 includes:

[0426] S1401: Construct a control flow graph consisting of nodes from the beginning to the end of each branch of the program.

[0427] Specifically, the conditional judgment statement (or conditional statement information) stored in the intermediate representation of the function is used as the starting point, the dominator tree algorithm is used to determine the end point, and then a control flow graph consisting of each node from the beginning to the end of each branch of the program is constructed.

[0428] Optionally, the control flow graph may be specifically constructed by obtaining the basic block partitioning based on the IR intermediate representation of the function, and then constructing the control flow graph according to the jump relationship between these basic blocks.

[0429] S1402: Determine whether the execution depths of the various program branches are consistent. If so, execute step S1403; if not, execute step S1404.

[0430] In other words, this step is to determine whether the length of each path in the control flow graph is equal.

[0431] S1403: Determine whether each step of each branch of the program is equivalent. If so, execute step S1405; if not, execute step S1404.

[0432] Optionally, by comparing the operations within the basic blocks on each path in the control flow graph at the instruction level, it is determined whether each step of the operation of each branch of the program is equivalent.

[0433] S1404: Continue safety restraint detection.

[0434] Optionally, the security constraint detection may include the above-mentioned branch execution time side channel detection, and may also include one or more of variable time function side channel detection, cache time side channel detection or variable time instruction side channel detection.

[0435] S1405: Temporarily desensitize the first sensitive data in the conditional judgment statement (or conditional statement information) stored in the intermediate representation of the function.

[0436] It can be understood that when the first sensitive data is in a temporarily desensitized state, side channel detection during branch execution time will not be performed.

[0437] For example, FIG15 shows a schematic flow chart of another method 1500 for determining whether first sensitive data meets the desensitization condition provided by an embodiment of the present application. As shown in FIG15 , the method 1500 includes:

[0438] S1501: Read the list of obfuscation operations defined in the program configuration file.

[0439] S1502: Determine whether the first sensitive data has been processed by the obfuscation operation in the above list. If so, execute step S1503; if not, execute step S1504.

[0440] S1503: Desensitize the first sensitive data and continue to perform subsequent operations.

[0441] Specifically, the attribute of the first sensitive data is converted into an intermediate special desensitized state. In this desensitized state, the first sensitive data is the same as other unlabeled variables, and any operation thereof does not pose a side channel risk.

[0442] The subsequent operations do not include the operation in step S1504.

[0443] The step S1503 can be understood as: after the first sensitive data is desensitized, step S1504 (security constraint detection) will be skipped and subsequent operations will be executed directly.

[0444] S1504: Perform a safety constraint check, and continue to perform subsequent operations after the safety constraint check is completed.

[0445] Optionally, the security constraint detection may include the above-mentioned variable time function side channel detection, and may also include one or more of branch execution time side channel detection, cache time side channel detection or variable time instruction side channel detection.

[0446] Optionally, the method 1500 may further include the steps of:

[0447] S1505: Perform a deobfuscation operation on the first sensitive data. After performing the deobfuscation operation, return to the above step S1504.

[0448] For example, based on the embodiments shown in Figures 10 to 15, Figure 16 shows a schematic flow chart of another side channel detection method 1600 provided in an embodiment of the present application. As shown in Figure 16, the method 1600 includes:

[0449] S1601: Determine whether the conditional judgment statement meets the equivalence condition. If so, execute step S1604; if not, execute step S1602.

[0450] Specifically, the case where the conditional judgment statement satisfies the equivalence condition may include: the control flow graph of the conditional judgment statement satisfies that each branch has equal depth and equal operations.

[0451] The explanation of this step is the same as that in the embodiment shown in FIG14 , and will not be repeated here for the sake of brevity.

[0452] S1602: Determine whether there is a branch execution time side channel security risk. If so, execute step S1603; if not, execute step S1604.

[0453] S1603: Record the first error information in the compilation log, and further execute step S1604.

[0454] The explanation of step S1602 and step S1603 is the same as the explanation of step S901 and step S902 in the embodiment shown in FIG9 , and will not be repeated here for the sake of brevity.

[0455] S1604: Determine whether the calling function is an obfuscation operation. If so, temporarily desensitize the first sensitive data (convert it to an intermediate special state) and further execute step S1607; if not, execute step S1605.

[0456] The explanation of this step is the same as that in the embodiment shown in FIG15 , and will not be repeated here for the sake of brevity.

[0457] S1605: Determine whether the first sensitive data is used as a calling parameter of the variable time function. If so, execute step S1606; if not, execute step S1607.

[0458] S1606: Record the second error information in the compilation log, and further execute step S1607.

[0459] The explanation of step S1606 and step S1607 is the same as the explanation of step S903 and step S904 in the embodiment shown in FIG9 , and will not be repeated here for the sake of brevity.

[0460] S1607: Determine whether there is a cache time side channel security risk. If yes, execute step S1608; if no, execute step S1609.

[0461] S1608: Record the third error information in the compilation log, and continue to execute step S1609.

[0462] The explanations of step S1607 and step S1608 are the same as those of step S905 and step S906 in the embodiment shown in FIG9 , and are not repeated here for the sake of brevity.

[0463] S1609: Determine whether the first sensitive data is used as an operand of a variable time instruction (i.e., determine whether there is a variable time instruction side channel security risk). If so, execute step S1610; if not, the compilation ends and the compilation result is successful.

[0464] S1610: Record the fourth error information in the compilation log.

[0465] Optionally, the error code is corrected according to the fourth error information, and detection is continued.

[0466] The explanation of step S1609 and step S1610 is the same as the explanation of step S907 and step S908 in the embodiment shown in FIG9 , and will not be repeated here for the sake of brevity.

[0467] To more clearly understand the process of performing type reasoning based on the first sensitive data provided in the embodiment of the present application, FIG17 shows, for example, a schematic flow chart of a method 1700 for performing type reasoning based on the first sensitive data provided in the embodiment of the present application. As shown in FIG17 , the method 1700 includes:

[0468] It is understandable that the method 1700 will be performed throughout the entire compilation process.

[0469] S1701: Determine whether the typing rules of the expression and the subtyping rules of the variable are satisfied. If so, execute step S1702.

[0470] Optionally, the expression includes an assignment statement, an operation statement, or a function return value.

[0471] Specifically, this step tracks the data flow and automatically infers the additional types of each variable through the type rules of expressions and the subtype inference rules of variables. That is, based on a small amount of type annotations (first sensitive data) in the program, type inference automatically marks whether other variables in the program are sensitive.

[0472] S1702: Attribute transfer is performed.

[0473] Specifically, the tag attribute of the first sensitive data is passed to other variables. For example, in the expression "b=a", a is the first sensitive data, and the tag attribute of a will be passed to b.

[0474] For example, on top of the native type system of C language (e.g., Bool, Integer, Char, etc.), a custom system (Secret, Uncomparable, Other Tags, etc.) is added to expand and reason about the types of sensitive data. In a specific example:

[0475] For the above formula (1), when the type of the left variable e1 is T1, the type of the right variable e2 is T2, and T1 is a subtype of T2, the result after the binocular operation is of type T2;

[0476] Similarly, for the above formula (2), when the return value type of the function is T, the type of the variable assigned by calling the function will also be passed as type T.

[0477] In an embodiment of the present application, by utilizing the transferability of the tag attributes of sensitive data, it is possible to automatically infer the type of sensitive data, thereby transferring the impact of sensitive data throughout the compilation process, thereby improving the completeness of side channel detection and the ease of use of tools during the detection process.

[0478] An embodiment of the present application further provides a computer-readable medium storing a program code. When the computer program code runs on a computer, the computer executes any one of the methods in FIG. 6 to FIG. 17 .

[0479] An embodiment of the present application also provides a chip, comprising: at least one processor and a memory, wherein the at least one processor is coupled to the memory and is used to read and execute instructions in the memory to execute any one of the methods in Figures 6 to 17 above.

[0480] An embodiment of the present application also provides an electronic device, comprising: at least one processor and a memory, wherein the at least one processor is coupled to the memory and is used to read and execute instructions in the memory to execute any one of the methods in Figures 6 to 17 above.

[0481] The above embodiments can be used alone or in combination with each other to achieve different technical effects.

[0482] One or more of the modules or units described herein can be implemented in software, hardware, or a combination of the two. When any of the above modules or units is implemented in software, the software exists in the form of computer program instructions and is stored in a memory, and a processor can be used to execute the program instructions and implement the above method flow. The processor may include, but is not limited to, at least one of the following: a central processing unit (CPU), a microprocessor, a digital signal processor (DSP), a microcontroller (MCU), or an artificial intelligence processor, etc., a computing device that runs software, each computing device may include one or more cores for executing software instructions to perform operations or processing. The processor may be built into an SoC (system on chip) or an application specific integrated circuit (ASIC), or it may be an independent semiconductor chip. In addition to the core for executing software instructions to perform operations or processing within the processor, it may further include necessary hardware accelerators, such as a field programmable gate array (FPGA), a PLD (programmable logic device), or a logic circuit that implements dedicated logic operations.

[0483] When the modules or units described in this document are implemented in hardware, the hardware can be any one or any combination of a CPU, a microprocessor, a DSP, an MCU, an artificial intelligence processor, an ASIC, a SoC, an FPGA, a PLD, a dedicated digital circuit, a hardware accelerator, or a non-integrated discrete device, which can run the necessary software or not rely on the software to execute the above method flow.

[0484] When the modules or units described herein are implemented using software, they can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).

[0485] Those skilled in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0486] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0487] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0488] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0489] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0490] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, 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. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0491] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A side channel detection method, characterized in that: The method comprises: Acquire attribute information of first sensitive data, where the first sensitive data is marked with the attribute information; Based on the attribute information of the first sensitive data, determining whether the first sensitive data satisfies a side channel security constraint, wherein the side channel includes one or more of a branch execution time side channel, a variable time function side channel, a cache time side channel, and a variable time instruction side channel; If the first sensitive data does not satisfy the side channel security constraint, an error message is recorded in the compilation log.

2. The method according to claim 1, characterized in that Before obtaining the attribute information of the first sensitive data, the method further includes: The first sensitive data is marked with the attribute information in the source code.

3. The method according to claim 1 or 2, characterized in that: The determining, based on the attribute information of the first sensitive data, whether the first sensitive data satisfies the side channel security constraint includes: Determining whether the first sensitive data meets the desensitization condition; If the first sensitive data does not meet the desensitization conditions, determine whether the first sensitive data meets the side channel security constraints based on the attribute information of the first sensitive data.

4. The method according to any one of claims 1 to 3, characterized in that The method further comprises: Type inference is performed on the first sensitive data.

5. The method according to any one of claims 1 to 4, characterized in that The determining, based on the attribute information of the first sensitive data, whether the first sensitive data satisfies the side channel security constraint includes: Get the conditional statement information stored in the compiled intermediate representation; Based on the attribute information of the first sensitive data, determining whether the first sensitive data exists in the conditional statement information; If the first sensitive data exists in the conditional statement information, it is determined that the first sensitive data does not satisfy the branch execution time side channel security constraint.

6. The method according to any one of claims 1 to 5, characterized in that The determining, based on the attribute information of the first sensitive data, whether the first sensitive data satisfies the side channel security constraint includes: Acquire calling information of a calling function during the compiling process, wherein the calling information of the calling function includes a name of the calling function and a parameter list of the calling function; Determine whether the calling function is a variable time function according to the name of the calling function; If the calling function is a variable time function, determining whether the first sensitive data exists in a parameter list of the calling function based on the attribute information of the first sensitive data; If the first sensitive data exists in the parameter list of the calling function, it is determined that the first sensitive data does not satisfy the variable time function side channel security constraint.

7. The method according to any one of claims 1 to 6, characterized in that The determining, based on the attribute information of the first sensitive data, whether the first sensitive data satisfies the side channel security constraint includes: Obtaining dereference statement information stored in the compiled intermediate representation, wherein the dereference statement information includes a pointer calculation address offset expression; Based on the attribute information of the first sensitive data, determining whether the first sensitive data is used as pointer offset access data in the pointer calculation address offset expression; If it is determined that the first sensitive data is accessed as data by the pointer offset in the pointer calculation address offset expression, it is determined that the first sensitive data does not satisfy the cache time side channel security constraint.

8. The method according to any one of claims 1 to 7, characterized in that The determining, based on the attribute information of the first sensitive data, whether the first sensitive data satisfies the side channel security constraint includes: Determine the CPU architecture of the central processing unit when the program is compiled; Determine the variable time instruction corresponding to the CPU architecture; Based on the attribute information of the first sensitive data, determining whether the first sensitive data exists in an operand of an operation corresponding to the variable time instruction; If it is determined that the first sensitive data exists in the operand of the operation corresponding to the variable time instruction, it is determined that the first sensitive data does not exist. Satisfying variable-time instruction side-channel security constraints.

9. The method according to claim 3, characterized in that: The determining whether the first sensitive data meets the desensitization condition includes: Construct a control flow graph consisting of nodes in each branch of the program; When the execution depths of the branches are consistent and each step of the operations of the branches is equivalent, it is determined that the first sensitive data meets the desensitization condition; or, When the execution depths of the branches are inconsistent and / or each operation of the branches is not equivalent, it is determined that the first sensitive data does not meet the desensitization condition.

10. The method according to claim 3 or 9, characterized in that: The determining whether the first sensitive data meets the desensitization condition includes: Obtaining a first list in a program configuration file, wherein the first list includes one or more obfuscation operations; When the first sensitive data is processed by the obfuscation operation in the first list, it is determined that the first sensitive data meets the desensitization condition; or, When the first sensitive data is not processed by the obfuscation operation in the first list, it is determined that the first sensitive data does not meet the desensitization condition.

11. The method according to claim 4, characterized in that The performing type reasoning on the first sensitive data includes: Based on the attribute information of the first sensitive data, determining whether a first variable in the program is sensitive according to a type rule of an expression and a subtype inference rule of a variable, the first variable refers to a variable in the program other than the first sensitive data; When it is determined that the first variable is sensitive, an attribute tag of the first sensitive data is passed to the first variable.

12. The method according to any one of claims 1 to 11, characterized in that The error information includes error location and / or constraint violation details.

13. A side channel detection device, characterized in that: The device comprises: An acquisition module, configured to acquire attribute information of first sensitive data, wherein the first sensitive data is marked with the attribute information; a constraint detection module, configured to determine whether the first sensitive data satisfies a side channel security constraint based on the attribute information of the first sensitive data, wherein the side channel includes one or more of a branch execution time side channel, a variable time function side channel, a cache time side channel, and a variable time instruction side channel; A recording module is used to record error information in a compilation log when the first sensitive data does not satisfy the side channel security constraint.

14. The device according to claim 13, characterized in that The device also includes: A registration module is used to mark the attribute information of the first sensitive data in the source code.

15. The device according to claim 13 or 14, characterized in that The device also includes: A desensitization module, used to determine whether the first sensitive data meets the desensitization condition; The constraint detection module is specifically used for: When the first sensitive data does not meet the desensitization conditions, it is determined whether the first sensitive data meets the side channel security constraints based on the attribute information of the first sensitive data.

16. The device according to any one of claims 13 to 15, characterized in that The device also includes: A type inference module is used to perform type inference on the first sensitive data.

17. The device according to any one of claims 13 to 16, characterized in that The constraint detection module is specifically used for: Get the conditional statement information stored in the compiled intermediate representation; Based on the attribute information of the first sensitive data, determining whether the first sensitive data exists in the conditional statement information; When the first sensitive data exists in the conditional statement information, it is determined that the first sensitive data does not satisfy the branch execution time side channel security constraint.

18. The device according to any one of claims 13 to 17, characterized in that The constraint detection module is specifically used for: Acquire calling information of a calling function during the compiling process, wherein the calling information of the calling function includes a name of the calling function and a parameter list of the calling function; Determine whether the calling function is a variable time function according to the name of the calling function; When the calling function is a variable time function, determining whether the first sensitive data exists in a parameter list of the calling function based on the attribute information of the first sensitive data; When the first sensitive data exists in the parameter list of the calling function, it is determined that the first sensitive data does not satisfy the variable time function side channel security constraint.

19. The device according to any one of claims 13 to 18, characterized in that The constraint detection module is specifically used for: Obtaining dereference statement information stored in the compiled intermediate representation, wherein the dereference statement information includes a pointer calculation address offset expression; Based on the attribute information of the first sensitive data, determining whether the first sensitive data is used as pointer offset access data in the pointer calculation address offset expression; When determining that the first sensitive data is used as the pointer offset in the pointer calculation address offset expression to access data, it is determined that the first sensitive data does not satisfy the cache time side channel security constraint.

20. The device according to any one of claims 13 to 19, characterized in that The constraint detection module is specifically used for: Determine the CPU architecture of the central processing unit when the program is compiled; Determine the variable time instruction corresponding to the CPU architecture; Based on the attribute information of the first sensitive data, determining whether the first sensitive data exists in an operand of an operation corresponding to the variable time instruction; When it is determined that the first sensitive data exists in the operand of the operation corresponding to the variable time instruction, it is determined that the first sensitive data does not satisfy the variable time instruction side channel security constraint.

21. The device according to claim 15, characterized in that The desensitization module is specifically used for: Construct a control flow graph consisting of nodes in each branch of the program; When the execution depths of the branches are consistent and each step of the operation of the branches is equivalent, it is determined that the first sensitive data meets the desensitization condition; or, When the execution depths of the branches are inconsistent and / or each operation of the branches is not equivalent, it is determined that the first sensitive data does not meet the desensitization condition.

22. The device according to claim 15 or 21, characterized in that The desensitization module is also specifically used for: Obtaining a first list in a program configuration file, wherein the first list includes one or more obfuscation operations; When the first sensitive data is processed by the obfuscation operation in the first list, determining that the first sensitive data meets the desensitization condition; or, When the first sensitive data is not processed by the obfuscation operation in the first list, it is determined that the first sensitive data does not meet the desensitization condition.

23. The device according to claim 16, characterized in that The type inference module is specifically used for: Based on the attribute information of the first sensitive data, determining whether a first variable in the program is sensitive according to a type rule of an expression and a subtype inference rule of a variable, the first variable refers to a variable in the program other than the first sensitive data; When it is determined that the first variable is sensitive, an attribute tag of the first sensitive data is passed to the first variable.

24. The device according to claim 15, characterized in that The desensitization module is also used for: When the first sensitive data meets the desensitization condition, a desensitization operation is performed on the first sensitive data.

25. The device according to any one of claims 13 to 24, characterized in that The error information includes error location and / or constraint violation details.

26. An electronic device, characterized in that: include: one or more processors; one or more memories; and one or more computer programs, wherein the one or more computer programs are stored in the one or more memories, and the one or more computer programs include instructions that, when executed by the one or more processors, cause the electronic device to perform the method as described in any one of claims 1 to 12.

27. A computer-readable storage medium, characterized in that: The storage medium stores a program or an instruction, and when the program or the instruction is executed, the method according to any one of claims 1 to 12 is implemented.

28. A chip, characterized in that: include: one or more processors; One or more memories, the one or more processors are coupled to the one or more memories, and are configured to read and execute instructions in the one or more memories to perform the method according to any one of claims 1 to 12.

29. A computer program product, characterized in that The computer program product includes computer program codes, and when the computer program codes are executed on a computer, the method according to any one of claims 1 to 12 is implemented.

Citation Information

Patent Citations

  • Sensitive user data processing system and method

    CN106302328A

  • SGX side channel attack defense method and system, medium, program and application

    CN111865909A

  • Method and device for detecting side channel vulnerability

    CN115292723A

  • Method and device for detecting side channel vulnerability

    CN115329346A

  • Secure Cache Memory Architecture

    US20110153944A1

Cited By

  • Side channel analysis method based on firmware instrumentation

    CN119739637A

  • A Side-Channel Analysis Method Based on Firmware Instrumentation

    CN119739637B