A software backdoor determination method based on static code analysis
Through static code analysis, distinguishing software backdoors and security vulnerabilities is solved, distinguishing difficulties are provided, quantitative indicators and processing solutions are provided, and processing accuracy and efficiency are improved.
Patent Information
- Application Number
- CN202410341887.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-25
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-03-25
AI Technical Summary
The prior art is difficult to effectively distinguish and handle software backdoors and security vulnerabilities, resulting in differences in the formulation of processing solutions, and the harshness and severity of the backdoors complicate the processing methods.
Using a method based on static code analysis, we use program models to construct a program model, analyze project relevance and operational sensitivity indicators, calculate quantitative indicators and set thresholds, distinguish software backdoors and security vulnerabilities, and guide subsequent processing plans.
It provides code-level quantitative indicators, which can effectively distinguish software backdoors and security vulnerabilities, help formulate targeted processing plans, and reduce the misjudgment rate and processing complexity.
Smart Images

Figure CN118349997B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of software security, and in particular relates to a software backdoor determination method based on static code analysis. Background Art
[0002] A software backdoor is a piece of code maliciously implanted by an attacker as a hidden access point so that normal security measures and authorization authentication can be bypassed when necessary to directly access the core parts of the system. A security vulnerability refers to a design flaw in the software that can be exploited by an attacker to perform malicious operations or obtain unauthorized information. Both are issues of concern in the field of software security, and both can result in serious consequences such as information leakage and system manipulation, but they are quite different in their causes and treatment methods, and deserve the attention of researchers.
[0003] In terms of the causes, software backdoors are actively implanted by attackers, are intentional acts of destruction, and are independent of the original business logic; security vulnerabilities are system defects caused by design problems or coding errors made by R&D personnel during the software development process. They are unintentional additional products and are related to the original business logic.
[0004] In terms of handling methods, repairing software backdoors not only requires removing malicious code logic, because there are cases of human intention, but also involves investigating and handling the saboteurs to reduce similar risks in subsequent production; repairing security vulnerabilities can focus more on the vulnerabilities themselves, which requires fixing the vulnerabilities and conducting relevant security training.
[0005] However, at the code logic level, software backdoors and security vulnerabilities have great similarities. For example, it is difficult to distinguish whether a program that allows remote command execution is an intentionally implanted backdoor or an unintentional vulnerability. This will also cause differences in the formulation of subsequent treatment plans. Software backdoors often mean worse behavior and more serious treatment methods. Summary of the invention
[0006] 1. Technical issues to be resolved
[0007] The technical problem to be solved by the present invention is to provide a software backdoor determination method for effectively distinguishing software backdoors from security vulnerabilities and guiding relevant personnel to formulate subsequent processing plans for security issues.
[0008] (II) Technical solution
[0009] In order to solve the above technical problems, the present invention provides a software backdoor determination method based on static code analysis, comprising the following steps:
[0010] Step 1: For the source code of the software project, construct the program model required for static analysis;
[0011] Step 2: Based on the first step, analyze the correlation index between the target problem code and the overall software project as the analysis result of project correlation;
[0012] Step 3: Analyze the sensitivity indicators of relevant operations in the target problem code as the analysis results of operation sensitivity;
[0013] Step 4: Calculate the overall quantitative index based on the analysis results of project relevance and operational sensitivity;
[0014] Step 5: Compare the overall quantitative indicator value with the set threshold and make a backdoor judgment.
[0015] Preferably, the program model required for static analysis constructed in the first step includes an abstract syntax tree AST, a function call graph CG, a control flow graph CFG and a data flow graph VFG.
[0016] Preferably, in the second step, after analyzing multiple open source project samples containing backdoors, the following correlation indicators are summarized:
[0017] (1) Independence of data branches. The independence of data branches is determined by checking whether the relevant code is in an independent data branch and has no data interaction with other modules. Here, the program model VFG is used to analyze the data transfer relationship of the problem code. If it is in an independent branch in VFG, that is, there is no data interaction with other modules, it is considered to be in an independent data branch.
[0018] (2) Whether the process is independent. This correlation indicator is determined by checking whether the relevant code belongs to an independent process and whether it can run in parallel with other codes. Here, the program models CG and CFG are used. CG is used to analyze whether the problem code has a separate execution entry and is in a separate call chain. CFG is used to analyze whether the problem code is in a separate process or thread.
[0019] (3) The specificity of the relevant code. The specificity of the relevant code is determined by checking whether the relevant code is an individual case of behavior in the overall program. This correlation is determined based on statistical operations on some grammatical structures in the AST, including statistics on operations to establish http connections. If the problem code is the only http connection location in the program, it is considered an individual case. On the contrary, if the program uses more http connections than the preset value, the operation of the problem code is considered normal.
[0020] Preferably, in the third step, after analyzing multiple open source project samples containing backdoors, the following sensitivity indicators are summarized:
[0021] (1) Network data transmission. This sensitivity indicator is determined by checking whether the relevant code is associated with network information transmission. If it involves monitoring of network addresses, receiving or transmitting data, or sending emails, then it is considered to be associated;
[0022] (2) Operations on system and environment variables. The sensitivity indicator of operations on system and environment variables is determined by checking whether the relevant code is associated with the system and environment variables. If it involves operations to obtain the current system and hardware information, obtain process information, and obtain environment variables, it can be determined that there is an association;
[0023] (3) Whether system instructions are executed. This sensitivity indicator is determined by checking whether the relevant code is associated with the execution of system instructions. If it involves calling the exec or system function in C++ or using JNI to call local system instruction operations in Java, it is considered to be related.
[0024] Preferably, the calculation of the overall quantitative index in the fourth step follows the following principles: the lower the correlation between the problem code and normal business, the higher the sensitivity of its behavior pattern, and the greater the possibility that it is a software backdoor; each correlation index and sensitivity index is assigned a weight score of 1 / 3, that is, each correlation index is scored 1 / 3 or 0 points, and 1 / 3 points if there is no correlation, otherwise 0 points; each sensitivity index is scored 1 / 3 or 0 points, and 1 / 3 points if there is a correlation, otherwise 0 points; finally, the "sum of each correlation index" multiplied by the "sum of each sensitivity index" is used as the final score, that is, the overall quantitative index value. The score ranges from 0 to 1, and the possibility of being a software backdoor increases with the value.
[0025] Preferably, in the fifth step, the calculated overall quantitative index value is compared with a threshold value. If the overall quantitative index value is greater than or equal to the threshold value, the corresponding problem code is determined to be a software backdoor. If it is less than the threshold value, it is determined not to be a software backdoor.
[0026] Preferably, the threshold is set according to the actual usage scenario. If the threshold is set to a higher value in a stricter determination environment, the threshold is set to a lower value. Otherwise, the threshold is set to a lower value.
[0027] Preferably, the threshold is set to 0.5. If the overall quantitative index value is greater than or equal to 0.5, the corresponding problem code is determined to be a software backdoor. If it is less than 0.5, it is determined not to be a software backdoor.
[0028] The present invention also provides a system for implementing the method.
[0029] The invention also provides a network security analysis method implemented based on the method.
[0030] (III) Beneficial effects
[0031] The present invention provides a code-level quantitative indicator by analyzing the project relevance and operation sensitivity of the problem code, which can effectively distinguish software backdoors and security vulnerabilities, and can set thresholds to adjust the scale of judgment according to actual conditions, and guide relevant personnel to formulate subsequent processing plans for security issues. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 It is a technical solution flow chart of the software backdoor determination method based on static code analysis, which is divided into 5 stages, namely, building a program model, project correlation analysis, behavior sensitivity analysis, quantitative index calculation and software backdoor determination;
[0033] Figure 2 Take a screenshot of a piece of code in a local data processing software;
[0034] Figure 3 This is a screenshot of code in a network service system. DETAILED DESCRIPTION
[0035] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.
[0036] The present invention conducts an in-depth study on two types of security issues, software backdoors and security vulnerabilities, and proposes a software backdoor determination method based on static code analysis, which can distinguish the two in a quantitative way. The present invention generates quantitative indicators for the rationality of the problem code by analyzing the syntax and semantic information in the source code, and determines whether the problem is a software backdoor or a security vulnerability based on the calculated quantitative value, thereby assisting in formulating subsequent solutions.
[0037] refer to Figure 1 , the technical solution of the present invention comprises the following steps:
[0038] Step 1: For the source code of the project, construct the program model required for static analysis;
[0039] Step 2: Analyze the correlation index between the target problem code and the overall software project as the analysis result of project correlation;
[0040] Step 3: Analyze the sensitivity indicators of relevant operations in the target problem code as the analysis results of operation sensitivity;
[0041] Step 4: Calculate the overall quantitative index based on the analysis results of project relevance and operational sensitivity;
[0042] Step 5: Compare the overall quantitative indicator value with the set threshold and make a backdoor judgment.
[0043] The program model required for static analysis constructed in the first step includes the abstract syntax tree AST (Abstract SyntaxTree), function call graph CG (Call Graph), control flow graph CFG (Control Flow Graph) and data flow graph VFG (Value Flow Graph).
[0044] In the second step, after analyzing more than 100 open source project samples containing backdoors, the following correlation indicators were summarized:
[0045] (1) Most backdoor codes have independent data processing logic and no data interaction with normal business codes, so the independence of data branches can be used as one of the correlation indicators. The correlation indicator of whether the data branch is independent is determined in the following way: check whether the relevant code is in an independent data branch and has no data interaction with other modules. Here, the program model VFG is needed to analyze the data transfer relationship of the problem code. If it is in an independent branch in VFG, that is, there is no data interaction with other modules, it is considered to be in an independent data branch.
[0046] (2) Most backdoor codes are running in parallel with normal business codes. That is, when normal business logic is running, the backdoor codes are also in their own independent processes, waiting to be triggered. Therefore, whether the process is independent can be used as one of the correlation indicators. Whether the process is independent is determined by checking whether the relevant code belongs to an independent process and whether it can run in parallel with other codes. Here, the program models CG and CFG are needed. CG can be used to analyze whether the problem code has a separate execution entry and whether it is in a separate call chain. CFG can be used to analyze whether the problem code is in a separate process or thread.
[0047] (3) Backdoor code often has the particularity of instruction behavior in the overall project, that is, it will perform operations that normal business code will not perform, so the particularity of the relevant code can be used as one of the indicators. The particularity of the relevant code is determined by the following method: Check whether the relevant code belongs to the behavior of the overall program, such as a few or only network monitoring or data transmission. This indicator is mainly based on the statistical operation of some grammatical structures in AST, such as the statistics of the operation of establishing http connection. If the problem code is the only http connection location in the program, it can be considered as an exception; on the contrary, if a large number of http connections are used in the program, the operation of the problem code can be considered normal.
[0048] With the help of the above correlation indicators, it is possible to quantitatively calculate the differences between backdoor codes and normal business codes.
[0049] In the third step, after analyzing more than 100 open source project samples containing backdoors, the following sensitivity indicators were summarized:
[0050] (1) Backdoor codes often require specific instructions to be transmitted remotely to be triggered, or to steal sensitive data through the network, so network data transmission can be used as one of the sensitivity indicators. The sensitivity indicator of network data transmission is determined in the following way: Check whether the relevant code is associated with network information transmission, such as monitoring network addresses, receiving or transmitting data, sending emails, etc., to determine whether there is a connection.
[0051] (2) Backdoor codes often have the behavior of obtaining target system information, so the operation of system and environment variables can be used as one of the sensitivity indicators. The sensitivity indicator of the operation of system and environment variables is determined by checking whether the relevant code is associated with the system and environment variables, such as obtaining the current system and hardware information, obtaining process information, obtaining environment variables, etc., and it can be determined that there is a connection.
[0052] (3) Backdoor code often executes specific system instructions in the target system to steal information or destabilize the system, so whether or not system instructions are executed can be used as one of the sensitivity indicators. Whether or not system instructions are executed is determined by checking whether the relevant code is associated with the execution of system instructions, such as calling functions such as exec or system in C++, and using JNI to call local system instructions in Java.
[0053] With the help of the above sensitivity indicators, it is possible to quantitatively calculate the danger of the operations performed by the backdoor code.
[0054] In the fourth step, the calculation of the overall quantitative index needs to follow the following principles: the lower the correlation between the problem code and normal business, the higher the sensitivity of its behavior pattern, and the greater the possibility that it is a software backdoor. Each correlation index and sensitivity index is assigned a weight score of 1 / 3, that is, each correlation index is scored 1 / 3 or 0 points, if there is no correlation, it is scored 1 / 3 points, otherwise it is scored 0 points, each sensitivity index is scored 1 / 3 or 0 points, if there is a correlation, it is scored 1 / 3 points, otherwise it is scored 0 points, and finally the "sum of each correlation index" multiplied by the "sum of each sensitivity index" is used as the final score, that is, the overall quantitative index value, and the score range is 0 to 1. The possibility of being a software backdoor increases with the value.
[0055] In the fifth step, the calculated overall quantitative index value is compared with the threshold value. The threshold value here can be set according to the actual usage scenario. For example, in a more stringent judgment environment, the threshold value can be set to a higher value, otherwise it can be set to a lower value. Assuming that the threshold value is set to 0.5, if the overall quantitative index value is greater than or equal to 0.5, the corresponding problem code can be determined to be a software backdoor. If it is less than 0.5, it is determined not to be a software backdoor. Example 1
[0056] This embodiment is used to illustrate a method for determining a software backdoor based on static code analysis and demonstrate a situation where a software backdoor is determined.
[0057] Figure 2 It is a piece of code in local data processing software that has been found to have security risks, which will cause remotely transmitted instructions to be executed by the local system. The following will determine whether it is a software backdoor. The determination process will follow the process described above:
[0058] Step 1: Build the required program model, including AST, CFG, CG, and VFG.
[0059] Step 2: Analyze the correlation indicators between the target code and the overall project:
[0060] (1) The problem code is in an independent data branch and does not interact with other modules, which is scored 1 / 3 points;
[0061] (2) The problem code has an independent running entry and is in an independent process, which is worth 1 / 3 points;
[0062] (3) There are no other network connection operations in the local data processing software. The network operation used by the problematic code is an individual case and is worth 1 / 3 points.
[0063] Step 3: Analyze the sensitivity indicators of the target code behavior pattern:
[0064] (1) The relevant code uses URL.openConnection to create a network connection, reads and parses the data content returned by the remote server, which is related to network information transmission and is worth 1 / 3 points;
[0065] (2) The relevant code does not read system and hardware information, does not obtain process information, does not obtain environment variable information, and is irrelevant to the system and environment variables, and is scored 0 points;
[0066] (3) The relevant code made a system call through the exec function in the Runtime package and executed the remotely transmitted content, which is related to the execution of system instructions and is worth 1 / 3 points.
[0067] Step 4: Calculate the quantitative indicators. A score of 1 / 3 is assigned to each project relevance indicator. Since all three items are met, the total score of the relevance indicator is 1. A score of 1 / 3 is assigned to each operational sensitivity indicator. Since two of the items are met, the total score of the operational sensitivity indicator is 2 / 3. The final quantitative indicator calculation result is the relevance indicator multiplied by the sensitivity operational indicator, which is 2 / 3 ≈ 0.67.
[0068] Step 5: Here we assume that the preset threshold is 0.5. Since the calculated quantization result is greater than the threshold, the relevant problematic code can be determined as a software backdoor. Example 2
[0069] This embodiment is used to illustrate a method for determining a software backdoor based on static code analysis, and demonstrates a situation where a software backdoor is determined not to be a backdoor.
[0070] Figure 3 It is a piece of code in a network service system that has been found to have security risks, which can cause remotely transmitted instructions to be executed by the local system. The following is a determination of whether it is a software backdoor. The determination process will follow the process described above:
[0071] Step 1: Build the required program model, including AST, CFG, CG, and VFG.
[0072] Step 2: Analyze the correlation indicators between the target code and the overall project:
[0073] (1) The problematic code uses the variables key and root defined in other modules, and passes the parameter info to other modules, which is associated with other data branches, and is scored 0 points;
[0074] (2) Because the problematic code belongs to a network interface function, after the application service is started, the interface has an independent access process, which is worth 1 / 3 points;
[0075] (3) In this network service system, the use of HttpServletResponse for network information transmission is a common pattern and is not an isolated case in this system, so 0 points are awarded.
[0076] Step 3: Analyze the sensitivity indicators of the target code behavior pattern:
[0077] (1) The relevant code uses HttpServletResponse to obtain the parameters transmitted remotely, and uses the relevant data in the subsequent logic. It is related to network transmission and is worth 1 / 3 points;
[0078] (2) The relevant code does not read system and hardware information, does not obtain process information, does not obtain environment variable information, and is irrelevant to the system and environment variables, and is scored 0 points;
[0079] (3) The relevant code made a system call through the exec function in the Runtime package and executed the remotely transmitted content, which is related to the execution of system instructions and is worth 1 / 3 points.
[0080] Step 4: Calculate the quantitative indicators. A score of 1 / 3 is assigned to each project relevance indicator. Since one of the three items is met, the total score of the relevance indicator is 1 / 3. A score of 1 / 3 is assigned to each operational sensitivity indicator. Since two of the three items are met, the total score of the operational sensitivity indicator is 2 / 3. The final quantitative indicator calculation result is the relevance indicator multiplied by the sensitivity operational indicator, which is 2 / 9 ≈ 0.22.
[0081] Step 5: Here we assume that the preset threshold is 0.5. Since the calculated quantization result is less than the threshold, the relevant problematic code can be determined as not a software backdoor but a security vulnerability.
[0082] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A software backdoor determination method based on static code analysis, characterized in that: The following steps are involved: Step 1: For the source code of the software project, construct the program model required for static analysis; Step 2: Based on the first step, analyze the correlation index between the target problem code and the overall software project as the analysis result of project correlation; Step 3: Analyze the sensitivity indicators of relevant operations in the target problem code as the analysis results of operation sensitivity; Step 4: Calculate the overall quantitative index based on the analysis results of project relevance and operational sensitivity; Step 5: Compare the overall quantitative index value with the set threshold and make a backdoor determination; The program model required for static analysis constructed in the first step includes the abstract syntax tree AST, function call graph CG, control flow graph CFG and data flow graph VFG; In the second step, after analyzing multiple open source project samples containing backdoors, the following correlation indicators were summarized: (1) Independence of data branches. The independence of data branches is determined by checking whether the relevant code is in an independent data branch and has no data interaction with other modules. Here, the program model VFG is used to analyze the data transfer relationship of the problem code. If it is in an independent branch in VFG, that is, there is no data interaction with other modules, it is considered to be in an independent data branch. (2) Whether the process is independent. This correlation indicator is determined by checking whether the relevant code belongs to an independent process and whether it can run in parallel with other codes. Here, the program models CG and CFG are used. CG is used to analyze whether the problem code has a separate execution entry and is in a separate call chain. CFG is used to analyze whether the problem code is in a separate process or thread. (3) The specificity of the relevant code. The specificity of the relevant code is determined by checking whether the relevant code is an individual case of the behavior in the overall program. This correlation is determined based on statistical operations on some grammatical structures in the AST, including statistics on operations to establish http connections. If the problematic code is the only http connection location in the program, it is considered an individual case. On the contrary, if the program uses more than a preset number of http connections, the operation of the problematic code is considered normal. In the third step, after analyzing multiple open source project samples containing backdoors, the following sensitivity indicators were summarized: (1) Network data transmission. This sensitivity indicator is determined by checking whether the relevant code is associated with network information transmission. If it involves monitoring of network addresses, receiving or transmitting data, or sending emails, then it is considered to be associated; (2) Operations on system and environment variables. The sensitivity indicator of operations on system and environment variables is determined by checking whether the relevant code is associated with the system and environment variables. If it involves operations to obtain the current system and hardware information, obtain process information, and obtain environment variables, it can be determined that there is an association; (3) Whether system instructions are executed. This sensitivity indicator is determined by checking whether the relevant code is associated with the execution of system instructions. If it involves calling the exec or system function in C++ or using JNI to call local system instruction operations in Java, it is considered to be related.
2. The method according to claim 1, characterized in that The calculation of the overall quantitative index in the fourth step follows the following principles: the lower the correlation between the problem code and normal business, the higher the sensitivity of its behavior pattern, and the greater the possibility that it is a software backdoor; each correlation index and sensitivity index is assigned a weight score of 1 / 3, that is, each correlation index is scored 1 / 3 or 0 points, and 1 / 3 points if there is no correlation, otherwise 0 points; each sensitivity index is scored 1 / 3 or 0 points, and 1 / 3 points if there is a correlation, otherwise 0 points; finally, the "sum of each correlation index" multiplied by the "sum of each sensitivity index" is used as the final score, that is, the overall quantitative index value. The score ranges from 0 to 1, and the possibility of being a software backdoor increases with the value.
3. The method according to claim 2, characterized in that In the fifth step, the calculated overall quantitative index value is compared with the threshold. If the overall quantitative index value is greater than or equal to the threshold, the corresponding problem code is determined to be a software backdoor. If it is less than the threshold, it is determined not to be a software backdoor.
4. The method according to claim 3, characterized in that The threshold is set according to the actual usage scenario. If the threshold is set to a higher value in a stricter judgment environment, it is set to a lower value.
5. The method according to claim 4, characterized in that The threshold is set to 0.
5. If the overall quantitative index value is greater than or equal to 0.5, the corresponding problem code is determined to be a software backdoor. If it is less than 0.5, it is determined not to be a software backdoor.
Citation Information
Patent Citations
Backdoor inspection device, backdoor inspection method, and non-transitory computer-readable medium
WO2021038780A1
KR1016404790000B1
