Method and apparatus for determining data flow path, device, and product
By identifying the association between variables and operations of neighboring classes in the application code, the scope of analysis is narrowed, solving the problems of high computational resource consumption and long analysis time in existing technologies, and achieving efficient data flow path identification.
Patent Information
- Application Number
- PCT/SG2025/050308
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2025-05-08
- Publication Date
- 2026-11-12
AI Technical Summary
Existing technologies suffer from high computational resource consumption and excessively long analysis time when dealing with data flow paths in complex systems. In particular, pointer analysis algorithms consume too many resources when dealing with transitional variables, while global scan algorithms increase the analysis time.
By identifying variables in the application code that are stored and loaded across functions, and by associating variables with operations of neighboring classes, the analysis scope is narrowed down to the vicinity of transitional variables, reducing the need for global scans and pointer analysis.
It reduces computational resource consumption and analysis time, improves the availability and accuracy of taint analysis, and enhances the efficiency of data flow path identification.
Smart Images

Figure SG2025050308_12112026_PF_FP_ABST
Abstract
Description
[0001] Methods, apparatus, equipment, and products for determining data flow paths
[0002] Technical Field
[0003] This disclosure relates to the field of data security, and more specifically to methods, apparatus, devices and products for determining data flow paths.
[0004] Background Technology
[0005] In actual enterprise development, rapid code iteration can introduce potential security risks. These risks may stem from vulnerabilities in the code itself or defects in the business logic. Changes to business code not only directly impact business processes but can also have a ripple effect on upstream and downstream systems. In privacy-protection scenarios, how to handle and protect target data is particularly important. For example, how target data is passed between different variables or functions, and how this data is encrypted or stored, are all issues closely related to data security.
[0006] In this context, leveraging program analysis techniques to conduct in-depth code analysis can help developers better understand and track the flow of data. Especially in complex systems, program analysis techniques can automatically identify potential security vulnerabilities and data breach risks, helping to improve the security of target data.
[0007] Summary of the Invention
[0008] In a first aspect of the embodiments of this disclosure, a method for determining a data flow path is provided. The method includes determining that variables in application code are stored and loaded across functions, the variables being associated with a first operation in a first function of a first class. The method further includes determining a second class in the application code associated with the first class, the location of the second class being within a predetermined range from the location of the first class. The method also includes determining that the variables are associated with a second operation in a second function of the second class, the second operation being a store or load operation corresponding to the first operation. Furthermore, the method includes determining a data flow path associated with the variables based on the second operation.
[0009] In a second aspect of the embodiments of this disclosure, an apparatus for determining a data flow path is provided. The apparatus includes a variable determination module configured to determine that a variable in application code is stored and loaded across functions, and the variable is associated with a first operation in a first function of a first class. The apparatus also includes a class determination module configured to determine a second class in the application code associated with the first class, the position of the second class being within a predetermined range from the position of the first class. The apparatus further includes an operation determination module configured to determine that the variable is associated with a second operation in a second function of the second class, the second operation being a store or load operation corresponding to the first operation. Furthermore, the apparatus includes a path determination module configured to determine the data flow path associated with the variable based on the second operation.
[0010] In a third aspect of embodiments of this disclosure, an electronic device is provided. The electronic device includes one or more processors; and a storage device for storing one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement a method for determining a data flow path. The method includes determining that variables in application code are stored and loaded across functions, the variables being associated with a first operation in a first function of a first class. The method further includes determining a second class in the application code associated with the first class, the location of the second class being within a predetermined range from the location of the first class. The method also includes determining that the variables are associated with a second operation in a second function of the second class, the second operation being a store or load operation corresponding to the first operation. Furthermore, the method includes determining a data flow path associated with the variables based on the second operation.
[0011] In a fourth aspect of embodiments of this disclosure, a computer program product is provided. The computer program product is tangibly stored on a non-transitory computer-readable medium and includes machine-executable instructions that, when executed, cause a machine to implement a method for determining a data flow path. The method includes determining that variables in application code are stored and loaded across functions, the variables being associated with a first operation in a first function of a first class. The method also includes determining a second class in the application code associated with the first class, the location of the second class being within a predetermined range from the location of the first class. The method further includes determining that the variables are associated with a second operation in a second function of the second class, the second operation being a store or load operation corresponding to the first operation. Furthermore, the method includes determining a data flow path associated with the variables based on the second operation.
[0012] The summary section is provided to present the chosen concepts in a simplified form, which will be further described in the detailed description below. The summary section is not intended to identify key or principal features of the claimed subject matter, nor is it intended to limit the scope of the claimed subject matter.
[0013] Attached Figure Description
[0014] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. In the drawings, the same or similar reference numerals denote the same or similar elements, wherein: FIG1 is a schematic diagram of an example environment in which various embodiments of this disclosure may be implemented; FIG2 is a flowchart of a method for determining a data flow path according to some embodiments of this disclosure; FIG3 is a schematic diagram of an example static taint analysis system according to some embodiments of this disclosure; FIG4 is a schematic diagram of an example of forward taint analysis according to some embodiments of this disclosure; FIG5 is a schematic diagram of an example of backward taint analysis according to some embodiments of this disclosure; FIG6 is a schematic diagram of an example of processing equipment interacting with a client according to some embodiments of this disclosure;
[0015] Figure 7 shows a block diagram of an apparatus for determining a data flow path according to some embodiments of the present disclosure; and
[0016] Figure 8 shows a block diagram of a device capable of implementing several embodiments of the present disclosure.
[0017] Detailed Implementation
[0018] It is understood that all user-related data involved in this technical solution should be obtained and used only after authorization from the user. This means that if it is necessary to use the user's personal information in this technical solution, the user's explicit consent and authorization are required before obtaining this data; otherwise, no related data collection and use will be carried out. It should also be understood that when implementing this technical solution, relevant laws and regulations should be strictly followed in the process of data collection, use, and storage, and necessary technical measures should be taken to protect user data security and ensure the secure use of data.
[0019] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0020] In the description of embodiments of this disclosure, the term "comprising" and similar terms should be understood as open-ended inclusion, i.e., "including but not limited to". The term "based on" should be understood as "at least partially based on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc., may refer to different or the same objects unless explicitly stated. Other explicit and implicit definitions may also be included below.
[0021] As mentioned above, by leveraging program analysis techniques to conduct in-depth code analysis, developers can better understand and track the flow of data. Especially in complex systems, program analysis techniques can automatically identify potential security vulnerabilities and data breach risks, helping to improve the security of target data.
[0022] Static taint analysis is a key technique in static program analysis, widely used in data security, especially in detecting software vulnerabilities. The core of static taint analysis is to determine whether tainted data flows into the desired exit function by tainting the initial data of interest, simulating the execution of the target program, and continuously executing taint propagation logic, without actually executing the program code. This allows for the identification of potential security risks. Specifically, static taint analysis can begin with a predefined "taint source," representing the target data of interest. During simulated program execution, the system tracks the propagation path of the taint source through operations such as assignments and function calls, ultimately determining whether the tainted data flows to the desired "taint sink."
[0023] (taint sink), that is, an exit point with potential security risks. For example, consider the following code snippet: public float func(float var){
[0024] return var * 2;
[0025] }
[0026] a = source * c;
[0027] d = func(a);
[0028] Sink(d);
[0029] In this example, `source` is the initial data of interest and is contaminated. Since variable `a` is calculated using `source`, it is also considered a contaminated variable. Then, `a` is passed as an argument to the function `func`, and the function's return value is assigned to the variable `d`. Based on the function body of `func`, it can be determined that the function will propagate parameter taints to the return value; therefore, `d` will also be contaminated. Finally, `d` is passed to the function `Sink`, which represents the exit function of interest in this specific taint analysis task.
[0030] During static taint analysis, the analysis program may encounter transition variables. Transition variables are variables that are detached from the current context and pass through the path of taint propagation. In other words, transition variables are variables that are stored and loaded across functions. For example, when performing taint analysis within a function body, once taint data passes through variables such as global variables, static variables, object member variables, or intermediate storage variables, it is necessary to exit the current context (i.e., the current function body) and search globally for the next potential tainted node.
[0031] In some related techniques, pointer analysis algorithms can be used to determine the next tainted node when the tainted node being processed by the taint analysis program is a transitional variable. However, pointer analysis algorithms significantly increase computational resource consumption. In other related techniques, a global scan can be performed in the target application's code to filter out all possible subsequent tainted nodes before continuing with the taint propagation logic. However, global scan algorithms significantly increase computational time. Especially when analyzing the code of large applications, the significant increase in time consumption reduces the usability of static taint analysis.
[0032] To address this, embodiments of this disclosure provide a scheme for determining data flow paths. This scheme is based on the observation that transition variables are often stored and loaded (or used) in adjacent locations. In this scheme, the processing device can determine that variables in application code are stored and loaded across functions, and that the variables are associated with a first operation in a first function of a first class. The processing device can then determine a second class in the application code associated with the first class, the location of which is within a predetermined range from the location of the first class. The processing device can then determine that the variable is associated with a second operation in a second function of the second class, the second operation being a store or load operation corresponding to the first operation. The processing device can then determine the data flow path associated with the variable based on the second operation. In this way, the processing device can narrow down the scope of code that needs to be analyzed to determine subsequent contaminated nodes to the vicinity of the transition variables, even when a contaminated node involves a transition variable. Compared to pointer analysis algorithms, this scheme reduces computational resource consumption. Compared to global scan algorithms, this scheme reduces the amount of code that needs to be analyzed without sacrificing accuracy, thereby reducing the time spent locating subsequent contaminated nodes and improving the usability of contamination analysis.
[0033] Figure 1 illustrates a schematic diagram of an example environment 100 in which various embodiments of the present disclosure may be implemented. As shown in Figure 1, environment 100 includes a processing device 102. The processing device 102 can be any device with processing or computing capabilities. For example, the processing device 102 can be a cloud server, a local server, a virtual server, a desktop computer, or a laptop computer, etc. Processing device 102 can obtain the application's source code 104. Source code 104 is the code and logic implementation used to build the software application, which can be written by developers using programming languages (e.g., Java, Python, Go, C++, etc.). Source code 104 can define the application's functionality, data processing logic, and user interaction methods, and can be compiled or interpreted into a computer-executable program. Source code 104 includes code for class 106, which in turn includes code for function (also called method) 108. The function body of function 108 can include operation 112 performed on variable 110. Variable 110 can be a node identified as tainted in taint analysis, meaning the value of variable 110 is associated with the initial data of interest. Operation 112 can be a field access operation on variable 110. For example, operation 112 can be a store operation assigning a value to variable 110, or a load operation reading the value of variable 110.
[0034] In environment 100, processing device 102 can determine that variable 110 in source code 104 is stored and loaded across functions. In other words, processing device 102 can determine whether variable 110 is a transitional variable. For example, when variable 110 is stored (i.e., assigned a value) in the body of one function and loaded (i.e., read or used the value of the variable) in the body of another function, processing device 102 can determine that variable 110 is stored and loaded across functions, and therefore processing device 102 can determine that variable 110 is a transitional variable. For example, variable 110 can be a global variable, a static variable, an object member variable, or an intermediate storage variable, etc.
[0035] In related technologies, after determining that variable 110 is stored and loaded across functions, processing device 102 will globally scan source code 104 to identify subsequent contaminated nodes. This approach significantly increases the time consumption of contamination analysis. However, the inventors of this disclosure have discovered that developers have specific coding patterns when writing code, which include the storage and use of transitional variables often being located in adjacent positions. Taking object member variables as an example, when writing code, developers often use loading operations (e.g., calling the get function) and storage operations (e.g., calling the set function) in adjacent positions within the object's member variable, thus facilitating the standardized storage and use of the object's member variable. Furthermore, transitional variables such as intermediate storage variables, global variables, and static variables also adopt a coding pattern where storage and use occur in adjacent positions.
[0036] Therefore, in environment 100, processing device 102 can determine class 114 in source code 104 that is associated with class 106, wherein the position of class 114 is within a predetermined range as the position of class 106. In other words, the position of class 114 is adjacent to the position of class 106. For example, classes adjacent to class 106 may include inner classes, outer classes, subclasses, parent classes, or classes with the same package name as class 106 (i.e., the two classes belong to the same package name).
[0037] In environment 100, processing device 102 can scan the code of class 114 to determine that variable 110 is associated with operation 118 in function 116 of class 114, where operation 118 is a store or load operation corresponding to operation 112. For example, if operation 112 is a store operation for variable 110, then operation 118 is a load operation for variable 110. Processing device 102 can determine that variable 110 is loaded in function 116 of class 114 by scanning the code of class 114. If operation 112 is a load operation for variable 110, then operation 118 is a store operation for variable 110. Processing device 102 can determine that variable 110 is stored in function 116 of class 114 by scanning the code of class 114. Thus, processing device 102 can determine that operation 118 is associated with subsequently contaminated nodes.
[0038] In environment 100, after determining that operation 118 is related to subsequent contaminated nodes, processing device 102 can execute subsequent contamination analysis logic based on operation 118 to determine the data flow path 122 associated with variable 110, i.e., the flow path of the initial data of interest. For example, when the initial data of interest is user data to be protected, the flow path can indicate whether the data flows to a specified exit function. When the flow path indicates that the exit function is associated with the initial data of interest, processing device 102 can generate a notification indicating that there is a data security risk in the exit function for display to the user.
[0039] In environment 100, the positions of class 120 and class 106 are outside the predetermined range. Therefore, when determining subsequent contaminated nodes of variable 110, processing device 102 can avoid scanning the code of class 120, thereby reducing the amount of code scanned and thus reducing the time consumption of taint analysis.
[0040] In this way, processing device 102 can narrow down the range of code that needs to be analyzed to determine subsequent contaminated nodes, when the contaminated node involves transition variables (e.g., including class 114 but excluding class 120), to the vicinity of the transition variables. Compared to pointer analysis algorithms, this approach reduces computational resource consumption. Compared to global scan algorithms, this approach reduces the amount of code that needs to be analyzed without sacrificing accuracy, thereby reducing the time spent locating subsequent contaminated nodes and improving the usability of contamination analysis.
[0041] Figure 2 illustrates a flowchart of a method 200 for determining a data flow path according to some embodiments of the present disclosure. Method 200 can be performed by a processing device. For example, method 200 can be performed by processing device 102 in Figure 1. As shown in Figure 2, at block 202, the processing device can determine that a variable in application code is stored and loaded across functions, the variable being associated with a first operation in a first function of a first class. For example, in the environment 100 shown in Figure 1, processing device 102 can determine that variable 110 in source code 104 is stored and loaded across functions. In other words, processing device 102 can determine whether variable 110 is a transitional variable. For example, when variable 110 is stored (i.e., assigned a value) in the function body of one function and loaded (i.e., read or used the value of the variable) in the function body of another function, processing device 102 can determine that variable 110 is stored and loaded across functions, and therefore processing device 102 can determine that variable 110 is a transitional variable. For example, variable 110 can be a global variable, a static variable, an object member variable, or an intermediate storage variable.
[0042] In box 204, the processing device can determine a second class in the application code that is associated with the first class, the location of the second class being within a predetermined range of the location of the first class. For example, in environment 100 as shown in FIG. 1, processing device 102 can determine a class 114 in source code 104 that is associated with class 106, wherein the location of class 114 is within a predetermined range of the location of class 106. In other words, the location of class 114 is adjacent to the location of class 106. For example, classes adjacent to class 106 may include inner classes, outer classes, subclasses, parent classes, or classes with the same package name (i.e., the two classes belong to the same package name).
[0043] In box 206, the processing device can determine that a variable is associated with a second operation in a second function of a second class, the second operation being a store or load operation corresponding to the first operation. For example, in environment 100 as shown in FIG1, processing device 102 can scan the code of class 114 to determine that variable 110 is associated with operation 118 in function 116 of class 114, where operation 118 is a store or load operation corresponding to operation 112. For example, when operation 112 is a store operation for variable 110, operation 118 is a load operation for variable 110. Processing device 102 can determine that variable 110 is loaded in function 116 of class 114 by scanning the code of class 114. When operation 112 is a load operation for variable 110, operation 118 is a store operation for variable 110. Processing device 102 can determine that variable 110 is stored in function 116 of class 114 by scanning the code of class 114. Therefore, processing device 102 can determine that operation 118 is related to subsequently contaminated nodes.
[0044] In box 208, the processing device can determine the data flow path associated with the variable based on the second operation. For example, in environment 100 as shown in FIG1, after determining that operation 118 is associated with a subsequent contaminated node, processing device 102 can execute subsequent contamination analysis logic based on operation 118 to determine the data flow path 122 associated with variable 110, i.e., the flow path of the initial data of interest. For example, when the initial data of interest is user data to be protected, the flow path can indicate whether the data flows to a specified exit function. When the flow path indicates that the exit function is associated with the initial data of interest, processing device 102 can generate a notification indicating that there is a data security risk in the exit function for display to the user.
[0045] In this way, the processing device can narrow down the range of code that needs to be analyzed to determine subsequent contaminated nodes to the vicinity of the transition variables, even when the contaminated node involves a transition variable. Compared to pointer analysis algorithms, this approach reduces computational resource consumption. Compared to global scanning algorithms, this approach reduces the amount of code that needs to be analyzed without sacrificing accuracy, thereby reducing the time spent locating subsequent contaminated nodes and improving the usability of contamination analysis.
[0046] In some embodiments, when determining that a variable in the application code is stored and loaded across functions, the processing device may determine that the variable is stored and loaded across functions in response to determining that the variable is a global variable, a static variable, an object member variable, or an intermediate storage variable. In some embodiments, when determining a second type associated with a first type in the application code, the processing device may determine that the inner class, outer class, parent class, child class, or class with the same package name of the first type in the application code is the second type. In this way, subsequent contaminated nodes of transition variables can be analyzed within an appropriate scope, thereby ensuring that accuracy is not reduced while reducing time consumption.
[0047] In some embodiments, the processing device can determine the operation type of the first operation. Then, the processing device can trigger the storage and loading of variables across functions based on the operation type. In this way, the identification of transition variables can be triggered at appropriate times, thereby reducing the number of times the logic for identifying transition variables is triggered and reducing the time consumption of taint analysis.
[0048] In some embodiments, the processing device may, in response to determining that a variable is associated with a second operation in a second function of a second class, store the variable and information associated with the second operation. In this way, the processing device can directly read the previously stored information when querying subsequent contaminated nodes of the transition variable, thereby improving the efficiency of taint analysis.
[0049] In some embodiments, when determining that variables in application code are stored and loaded across functions, the processing device can generate an intermediate representation of the application code based on the application code. The processing device can then determine the storage and loading of variables across functions based on this intermediate representation. In some embodiments, when determining that a variable is associated with a second operation in a second function of a second type, the processing device can determine the association of the variable with the second operation in the second function of the second type based on the intermediate representation of the application code. In this way, various assignment statements and variable usage statements can be transformed into a unified intermediate representation (e.g., store statements and load statements), thereby simplifying the complexity of taint analysis and improving analysis efficiency.
[0050] Figure 3 illustrates a schematic diagram of an example static taint analysis system 300 according to some embodiments of the present disclosure. As shown in Figure 3, the static taint analysis system 300 includes a transition variable identification module 302 and a subsequent taint identification module 304. The transition variable identification module 302 can determine in real time whether a taint has been passed to a node with the property of a transition variable during the execution of the taint propagation analysis algorithm. Once it is determined that a taint has been passed to a node with the property of a transition variable, the transition variable identification module 302 can pass the information of the transition variable to the subsequent taint identification module 304 to identify the subsequent tainted node of the transition variable.
[0051] In mobile application code, the storage and use of transition variables typically conform to the "class:field" format. For example, in a forward taint analysis task, when a taint of interest is propagated to a transition variable, the program first uses a store operation to store the data into the transition variable. Then, within the code of another function, a load operation is used to load the value of the transition variable to read the data from it. The static taint analysis system 300 can generate an intermediate representation of the application code based on the application code. In this intermediate representation, various store and load operations on variables can be converted into unified store statements (e.g., storef statements) and load statements (e.g., loadf statements). This simplifies the complexity of taint analysis and improves analysis efficiency.
[0052] The transition variable identification module 302 can scan application code and trigger transition variable identification logic based on whether the scanned operation is a store operation or a load operation. For example, if the transition variable identification module 302 scans the current operation and determines that the current operation is not a store operation or a load operation, the transition variable identification module 302 may not execute the transition variable identification logic. If the current operation is a store operation or a load operation, the transition variable identification module 302 can trigger the transition variable identification logic to determine whether the variables involved in the current operation are transition variables. For example, after determining that the current operation is a store operation or a load operation, the transition variable identification module 302 can identify whether the variables involved in the current operation are one of the following: global variables, static variables, object member variables, or intermediate storage variables. If it is determined that the variables involved in the current operation are one of these variable types, the transition variable identification module 302 can determine that the variable is a transition variable.
[0053] After determining that a taint has propagated to a transition variable, the subsequent taint identification module 304 can search for subsequent contaminated nodes corresponding to that transition variable in real time, ensuring that taint propagation is not interrupted by the flow to the transition variable. Due to the proximity of the transition variable's storage and retrieval code, the subsequent taint identification module 304 can filter for potential subsequent contaminated nodes in the vicinity of the contaminated transition variable. Selecting different proximity ranges will cause variations in the accuracy and time consumption of the taint analysis. In some embodiments, the subsequent taint identification module 304 can define the proximity range as the parent class, subclass, inner class, outer class, and class with the same package name of the beauty class to which the transition variable belongs. The subsequent taint identification module 304 can then filter the code of all functions declared in these classes to identify the corresponding operation node of the contaminated transition variable as a subsequent contaminated node. For example, in forward taint analysis, the corresponding operation node could be a load operation on the transition variable. Then, the static taint analysis system 300 can continue to execute the taint analysis propagation logic based on this operation node, thereby enabling rapid and efficient identification of subsequent contaminated nodes.
[0054] After the taint identification module 304 filters out subsequent tainted nodes of the tainted transition variable, the static taint analysis system 300 can cache the transition variable and the information associated with the corresponding operation node. For example, the static taint analysis system 300 can cache the transition variable and the subsequent tainted nodes identified by analyzing the corresponding operation node for use in the next query for the subsequent tainted nodes of the transition variable. In this way, the static taint analysis system 300 can trade space for time, thereby improving the execution efficiency of taint analysis.
[0055] In some embodiments, taint analysis is forward taint analysis. When determining whether a variable is stored and loaded across functions based on operation type, the processing device can trigger the storage and loading of the variable across functions in response to the operation type being a storage operation. In some embodiments, when a variable is associated with a second operation in a second function of a second class, the processing device can determine the association between the variable and the second operation in the second function of the second class by determining that the variable is loaded in the second function. In this way, in forward taint analysis, the processing device can look up the corresponding loading operation in the neighboring class based on the storage operation of the transition variable, thereby improving the accuracy and efficiency of taint analysis.
[0056] Figure 4 illustrates a schematic diagram of example 400 of forward taint analysis according to some embodiments of the present disclosure. In example 400, taint propagates to variable 406 in function 404 of class 402; that is, variable 406 is the tainted variable. A transition variable identification module (e.g., transition variable identification module 302 in Figure 3) can then determine the type of operation on variable 406. If the type of operation is a storage operation, the transition variable identification module can trigger transition variable identification logic to determine whether variable 406 is a transition variable. For example, in example 400, the transition variable identification module can determine that the operation on variable 406 is a storage operation 408, and then the transition variable identification module can determine whether variable 406 is a global variable, a static variable, an object member variable, or an intermediate storage variable. After determining that variable 406 is a global variable, a static variable, an object member variable, or an intermediate storage variable, the transition variable identification module can determine that variable 406 is a transition variable that is stored and read across functions.
[0057] After determining that variable 406 is a transitional variable, the subsequent taint detection module (e.g., subsequent taint detection module 304 in Figure 3) can obtain the code of all inner classes, outer classes, subclasses, parent classes, and classes with the same package name of class 402 in the application code, and search for loading operations for variable 406 in the code of these classes. In example 400, the subsequent taint detection module can obtain the code of inner class 412 of class 402, the code of outer class 422 of class 402, the code of subclass 432 of class 402, the code of parent class 442 of class 402, and the code of class 452 with the same package name of class 402.
[0058] In inner class 412, the subsequent taint detection module finds a load operation 418 for variable 406 in the code of function 414. Therefore, the subsequent taint detection module can determine the subsequent tainted node of variable 406 based on load operation 418. In outer class 422, the subsequent taint detection module finds a load operation 428 for variable 406 in the code of function 424. Therefore, the subsequent taint detection module can determine another subsequent tainted node of variable 406 based on load operation 428. In subclass 432, the subsequent taint detection module finds a load operation 438 for variable 406 in the code of function 434. Therefore, the subsequent taint detection module can determine yet another subsequent tainted node of variable 406 based on load operation 438. In parent class 442, the subsequent taint detection module finds a load operation 448 for variable 406 in the code of function 444. Therefore, the subsequent taint detection module can determine another subsequently tainted node of variable 406 based on load operation 448. In class 452 with the same package name, the subsequent taint detection module finds load operation 458 for variable 406 in the code of function 454. Therefore, the subsequent taint detection module can determine another subsequently tainted node of variable 406 based on load operation 458.
[0059] In Example 400, the static contamination analysis system can perform subsequent contamination analysis based on these identified subsequently contaminated nodes to determine the data flow path associated with variable 406. In this way, in forward contamination analysis, the processing device can look up corresponding load operations in neighboring classes based on storage operations of transition variables, thereby improving the accuracy and efficiency of taint analysis.
[0060] In some embodiments, taint analysis is backward taint analysis. When determining whether a variable is stored and loaded across functions based on operation type, the processing device can trigger the storage and loading of the variable across functions in response to the operation type being a load operation. In some embodiments, when a variable is associated with a second operation in a second function of a second class, the processing device can determine the association between the variable and the second operation in the second function of the second class by determining that the variable is stored in the second function. In this way, in backward taint analysis, the processing device can find the corresponding storage operation in the neighboring class based on the load operation of the transition variable, thereby improving the accuracy and efficiency of taint analysis.
[0061] Figure 5 illustrates a schematic diagram of example 500 of backward taint analysis according to some embodiments of the present disclosure. In example 500, taint propagates to variable 506 in function 504 of class 502; that is, variable 506 is a tainted variable. A transition variable identification module (e.g., transition variable identification module 302 in Figure 3) can then determine the type of operation on variable 506. If the type of operation is a load operation, the transition variable identification module can trigger transition variable identification logic to determine whether variable 506 is a transition variable. For example, in example 500, the transition variable identification module can determine that the operation on variable 506 is a load operation 508, and then the transition variable identification module can determine whether variable 506 is a global variable, a static variable, an object member variable, or an intermediate storage variable. After determining that variable 506 is a global variable, a static variable, an object member variable, or an intermediate storage variable, the transition variable identification module can determine that variable 506 is a transition variable that is stored and read across functions.
[0062] After determining that variable 506 is a transitional variable, the subsequent taint detection module (e.g., subsequent taint detection module 304 in Figure 3) can obtain the code of all inner classes, outer classes, subclasses, parent classes, and classes with the same package name of class 502 in the application code, and search for storage operations on variable 506 in the code of these classes. In example 500, the subsequent taint detection module can obtain the code of inner class 512 of class 502, the code of outer class 522 of class 502, the code of subclass 532 of class 502, the code of parent class 542 of class 502, and the code of class 552 with the same package name of class 502.
[0063] In inner class 512, the subsequent taint detection module finds a store operation 518 for variable 506 in the code of function 514. Therefore, the subsequent taint detection module can determine the subsequent tainted node of variable 506 based on store operation 518. In outer class 522, the subsequent taint detection module finds a store operation 528 for variable 506 in the code of function 524. Therefore, the subsequent taint detection module can determine another subsequent tainted node of variable 506 based on store operation 528. In subclass 532, the subsequent taint detection module finds a store operation 538 for variable 506 in the code of function 534. Therefore, the subsequent taint detection module can determine yet another subsequent tainted node of variable 506 based on store operation 538. In parent class 542, the subsequent taint detection module finds a store operation 548 for variable 506 in the code of function 544. Therefore, the subsequent taint detection module can determine another subsequent tainted node of variable 506 based on storage operation 548. In class 552 with the same package name, the subsequent taint detection module finds storage operation 558 for variable 506 in the code of function 554. Therefore, the subsequent taint detection module can determine another subsequent tainted node of variable 506 based on storage operation 558.
[0064] In Example 500, the static contamination analysis system can perform subsequent contamination analysis based on these identified subsequently contaminated nodes to determine the data flow path associated with variable 506. In this way, in backward contamination analysis, the processing device can look up corresponding storage operations in neighboring variables based on the loading operations of transition variables, thereby improving the accuracy and efficiency of contamination analysis.
[0065] Figure 6 illustrates a schematic diagram of an example 600 of a processing device interacting with a client according to some embodiments of the present disclosure. As shown in Figure 6, example 600 includes a processing device 602 (e.g., processing device 102 in Figure 1) and a client 604. A user (e.g., a developer, program analysis engineer, etc.) wants to know whether target data of interest flows to a specific exit function in the code. Therefore, the user can send an analysis request 608 to the processing device 602 through the client 604. The analysis request 608 may include, for example, the target data of interest and the specified exit function. After receiving the analysis request 608, the processing device can obtain the application's source code 610 and perform taint analysis (e.g., forward taint analysis or backward taint analysis) on the source code 610.
[0066] During taint analysis, processing device 602 can identify whether a tainted variable is a transition variable. After determining that a tainted variable is a transition variable, processing device 602 can filter subsequent tainted nodes in the classes adjacent to the class described by the transition variable. After identifying all tainted nodes, processing device 602 can determine the flow path of the target data of interest in the source code 610 and generate analysis result 612 based on the flow path. Analysis result 612 can indicate whether the target data of interest flows to a specified exit function or whether the target data of interest does not flow to the specified exit function. Then, processing device 602 can send analysis result 612 to client 604. After receiving analysis result 612, client 604 can present analysis result 612 to the user through display 606. In this way, the time consumption of taint analysis can be reduced and the user experience improved.
[0067] Figure 7 shows a block diagram of an apparatus 700 for determining a data flow path according to some embodiments of the present disclosure. The apparatus 700 includes a variable determination module 702 configured to determine that variables in application code are stored and loaded across functions, and that the variables are associated with a first operation in a first function of a first class. The apparatus 700 also includes a class determination module 704 configured to determine a second class in the application code associated with the first class, the position of the second class being within a predetermined range from the position of the first class. The apparatus 700 also includes an operation determination module 706 configured to determine that the variables are associated with a second operation in a second function of the second class, the second operation being a store or load operation corresponding to the first operation. Furthermore, the apparatus 700 includes a path determination module configured to determine the data flow path associated with the variables based on the second operation.
[0068] In some embodiments, the variable determination module 702 includes: a first variable determination module configured to determine whether a variable is a global variable, a static variable, an object member variable, or an intermediate storage variable, and to determine whether the variable is stored and loaded across functions.
[0069] In some embodiments, the class determination module 704 includes: a first class determination module configured to determine an inner class, outer class, parent class, child class, or class with the same package name of the first class in the application code as a second class.
[0070] In some embodiments, the apparatus 700 further includes: a first operation type determination module configured to determine the operation type of a first operation; and a first operation type usage module configured to trigger the storage and loading of a determination variable across functions based on the operation type.
[0071] In some embodiments, the first operation type using the module includes: a first triggering module configured to, in forward taint analysis, trigger a determination variable to be stored and loaded across a function in response to the operation type being a storage operation.
[0072] In some embodiments, the first operation type using module includes: a second triggering module configured to, in backward taint analysis, trigger the determination of variables to be stored and loaded across functions in response to the operation type being a load operation.
[0073] In some embodiments, the operation determination module 706 includes: a first operation determination module configured to determine, in a liner stain analysis, associate a variable with a second operation in a second function of a second class by determining that the variable is loaded in a second function.
[0074] In some embodiments, the operation determination module 706 includes a second operation determination module configured to determine, in backward taint analysis, the association of a variable with a second operation in a second function of a second class by determining that the variable is stored in a second function.
[0075] In some embodiments, the apparatus 700 further includes an information storage module configured to store the variable and information associated with the second operation in response to determining that the variable is associated with a second operation in a second function of the second class.
[0076] In some embodiments, the variable determination module 702 includes: an intermediate representation generation module configured to generate an intermediate representation of application code based on application code; and a first intermediate representation usage module configured to determine whether variables are stored and loaded across functions based on the intermediate representation.
[0077] In some embodiments, the operation determination module 708 includes a second intermediate representation usage module configured to determine the association of a variable with a second operation in a second function of a second class based on an intermediate representation of the application code. It is understood that, utilizing the apparatus 700 of this disclosure, at least one of the many advantages achievable by the methods or processes described above can be realized. For example, the processing device can narrow down the range of code to be analyzed to determine subsequent contaminated nodes to the vicinity of the transition variable when the contaminated node involves a transition variable. Compared to pointer analysis algorithms, this approach reduces computational resource consumption. Compared to global scan algorithms, this approach reduces the amount of code to be analyzed without compromising accuracy, thereby reducing the time spent locating subsequent contaminated nodes and improving the availability of contamination analysis.
[0078] Figure 8 shows a block diagram of a device 800 capable of implementing various embodiments of the present disclosure. Device 800 may, for example, be a processing device 102 as shown in Figure 1. As shown in Figure 8, device 800 includes a central processing unit (CPU) and / or a graphics processing unit (GPU) 801, which can perform various appropriate actions and processes according to computer program instructions stored in read-only memory (ROM) 802 or loaded from storage unit 808 into random access memory (RAM) 803. Various programs and data required for the operation of device 800 may also be stored in RAM 803. The CPU / GPU 801, ROM 802, and RAM 803 are interconnected via bus 804. Input / output (I / O) interface 805 is also connected to bus 804. Although not shown in Figure 8, device 800 may also include a coprocessor.
[0079] Multiple components in device 800 are connected to I / O interface 805, including: input unit 806, such as keyboard, mouse, etc.; output unit 807, such as various types of monitors, speakers, etc.; storage unit 808, such as disk, optical disk, etc.; and communication unit 809, such as network card, modem, wireless transceiver, etc. Communication unit 809 allows device 800 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0080] The various methods or processes described above can be executed by CPU / GPU 801. For example, in some embodiments, the methods can be implemented as computer software programs tangibly contained in a machine-readable medium, such as storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed on device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by CPU / GPU 801, one or more steps or actions in the methods or processes described above can be performed.
[0081] In some embodiments, the methods and processes described above can be implemented as a computer program product. The computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for performing various aspects of this disclosure.
[0082] Computer-readable storage media can be tangible devices capable of holding and storing instructions for use by an instruction execution device. Computer-readable storage media can be, for example, but not limited to, electrical storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination of the foregoing. The computer-readable storage media used herein are not to be construed as transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waves or other transmission media (e.g., light pulses through fiber optic cables), or electrical signals transmitted through wires.
[0083] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, a local area network (LAN), a wide area network (WAN), and / or a wireless network, to an external computer or external storage device. The network may include copper cables, fiber optic cables, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them for storage.
[0084] In computer-readable storage media in various computing / processing devices.
[0085] Computer program instructions used to perform the operations of this disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages and conventional procedural programming languages. The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing the status information of the computer-readable program instructions. This electronic circuitry can execute the computer-readable program instructions to implement various aspects of this disclosure.
[0086] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processing unit of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of a flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of a flowchart and / or block diagram.
[0087] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.
[0088] The flowcharts and block diagrams in the accompanying drawings illustrate possible architectures, functions, and operations of devices, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0089] The various embodiments of this disclosure have been described above. These descriptions are exemplary and not exhaustive, and are not limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical applications, or technical improvements to the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.
Claims
Claims 1. A method for determining data flow paths, comprising: Determine that variables in the application code are stored and loaded across functions, and that the variables are associated with a first operation in a first function of a first class; Identify a second category in the application code that is associated with the first category, wherein the position of the second category is within a predetermined range from the position of the first category; The variable is determined to be associated with a second operation in a second function of the second class, the second operation being a store or load operation corresponding to the first operation; as well as The second operation is used to determine the data flow path associated with the variable.
2. The method of claim 1, wherein determining that the variable in the application code is stored and loaded across functions comprises: In response to determining that the variable is a global variable, a static variable, an object member variable, or an intermediate storage variable, it is determined that the variable is stored and loaded across functions.
3. The method of claim 1, wherein determining the second class associated with the first class in the application code comprises: In the application code, the inner class, outer class, parent class, child class, or class with the same package name of the first class are identified as the second class.
4. The method according to claim 1, further comprising: Determine the operation type of the first operation; as well as The operation type is used to trigger the determination that the variable is stored and loaded across functions.
5. The method of claim 4, wherein triggering the determination that the variable is stored and loaded across functions based on the operation type comprises: In forward taint analysis, in response to the operation type being a storage operation, a determination is triggered that the variable is stored and loaded across functions.
6. The method of claim 4, wherein triggering the determination that the variable is stored and loaded across functions based on the operation type comprises: In backward taint analysis, in response to the operation type being a load operation, a determination is triggered that the variable is stored and loaded across functions.
7. The method of claim 1, wherein determining that the variable is associated with the second operation in the second function of the second class comprises: In forward taint analysis, the variable is determined to be associated with the second operation in the second function of the second class by determining that the variable is loaded in the second function.
8. The method of claim 1, wherein determining that the variable is associated with the second operation in the second function of the second class comprises: In backward taint analysis, the variable is associated with the second operation in the second function of the second class by determining that the variable is stored in the second function.
9. The method according to claim 1, further comprising: In response to determining that the variable is associated with the second operation in the second function of the second class, the variable and the information associated with the second operation are stored.
10. The method of claim 1, wherein determining that the variable in the application code is stored and loaded across functions comprises: An intermediate representation of the application code is generated based on the application code; as well as The intermediate representation is used to determine whether the variable is stored and loaded across functions.
11. The method of claim 10, wherein determining that the variable is associated with the second operation in the second function of the second class comprises: The intermediate representation of the application code is used to determine the association between the variable and the second operation in the second function of the second class.
12. An apparatus for determining a data flow path, comprising: A variable determination module is configured to determine variables in application code that are stored and loaded across functions, the variables being associated with a first operation in a first function of a first class; A class determination module is configured to determine a second class in the application code that is associated with the first class, wherein the position of the second class is within a predetermined range from the position of the first class; The operation determination module is configured to determine that the variable is associated with a second operation in a second function of the second type, wherein the second operation is a store or load operation corresponding to the first operation; as well as The path determination module is configured to determine the data flow path associated with the variable based on the second operation.
13. An electronic device, comprising: processor; as well as A memory coupled to the processor, the memory having instructions stored therein, which, when executed by the processor, cause the electronic device to perform the method according to any one of claims 1 to 11.
14. A computer program product tangibly stored on a non-transitory computer-readable medium and comprising machine-executable instructions that, when executed, cause a machine to perform the method according to any one of claims 1 to 11.
