Tainted data tracking method, device, electronic device and storage medium
By instrumenting all methods and functions in the application, obtaining data flow direction, and recording information about unknown functions, the problem of link interruption in taint tracking technology is solved, achieving stable tracking and high-coverage taint data propagation.
Patent Information
- Application Number
- CN202210460917.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-28
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2042-04-28
AI Technical Summary
Existing taint tracking technologies are prone to tracing link interruptions when dealing with methods and basic data types that do not collect propagation rules, making it impossible to effectively track the propagation path of taint data.
By instrumenting the method functions in the application being tested, including both collected and uncollected function rules, the data flow direction of tainted data is obtained. Data flow direction information is recorded by instrumenting in uncollected functions. The propagation rules of unknown functions are automatically collected, and the location of unknown functions in the propagation chain is determined using the marking information.
It achieves stable tracking of tainted data, improves the coverage of tainted tracking, can automatically collect the propagation rules of unknown functions, and solves the problem of tracking link interruption.
Smart Images

Figure CN114896589B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a method, device, electronic device and storage medium for tainted data tracking. Background Art
[0002] In the past two years, taint tracking technology has been widely used in the field of application security testing. With its advantages of fast detection speed, low false alarm rate and high coverage, taint tracking technology has won high recognition from security practitioners.
[0003] In the existing conventional taint tracking technology, the tracking mainly relies on the propagation rules in the method function, so it is necessary to collect the propagation rules of each method function in the application. However, the current taint tracking technology can only collect the propagation rules manually, that is, it can only manually collect the propagation rules of the method functions initially preset in the application, and it is not possible to collect the propagation rules of the newly added method functions in the subsequent use optimization of the program. In this case, when the taint data passes through the method function for which the propagation rules are not collected during the propagation process, the tracking link will be interrupted, and the propagation path of the taint data cannot be effectively tracked.
[0004] At the same time, the basic data types in the method function cannot be tracked. That is to say, when the tainted data passes through the method function with basic data types during the propagation process, and the operation of the basic data type causes the tainted data to change, the tracking link will be interrupted.
[0005] There is no effective solution to the problem of easy interruption of tracking links in existing taint tracking technologies. Summary of the invention
[0006] In this embodiment, a tainted data tracking method, device, system, electronic device and storage medium are provided to solve the problem of easy interruption of tracking links in the existing taint tracking technology.
[0007] In a first aspect, a method for tracking tainted data is provided in this embodiment, and the method includes:
[0008] Performing instrumentation processing on method functions in the detected application, the method functions including a first method function whose function rules have been collected and a second method function whose function rules have not been collected;
[0009] Obtain the data flow of the tainted data in the method function;
[0010] According to the data flow direction, a propagation link of the tainted data in the detected application is determined.
[0011] In some of the embodiments, the tainted data tracking method further includes:
[0012] When the tainted data passes through the second method function, obtaining corresponding data processing information of the second method function;
[0013] When the tainted data reaches the vulnerability trigger point, determining whether the second method function exists in the propagation link of the tainted data;
[0014] If the second method function exists in the propagation link, the function rule of the corresponding second method function is obtained according to the data processing information of the corresponding second method function and the data flow direction of the tainted data in the corresponding second method function.
[0015] In some embodiments, when the tainted data reaches a vulnerability trigger point, determining whether the second method function exists in a propagation link of the tainted data includes:
[0016] Adding marking information to the tainted data passing through the second method function, when the tainted data reaches the vulnerability trigger point, determining whether the tainted data has the marking information; if the tainted data has the marking information, the second method function exists in the propagation link.
[0017] In some of the embodiments, when the tainted data reaches the vulnerability trigger point, determining whether there is a second method function in the propagation link of the tainted data further includes:
[0018] The position of the second method function in the propagation link is determined according to the appearance position of the mark information in the propagation link.
[0019] In some embodiments, determining the position of the second method function in the propagation link according to the position of occurrence of the tag information in the propagation link includes:
[0020] Step A, determining the position of the first second method function in the propagation link according to the first appearance position of the marking information;
[0021] Step B, after the position of the first second method function in the propagation link is determined, marking the first second method function as the first method function;
[0022] The step A and the step B are repeatedly performed until the positions of all second method functions in the propagation link are determined.
[0023] In some embodiments, the data processing information of the second method function includes: the method, line number, and call stack of the second method function outputting the tainted data.
[0024] In a second aspect, a tainted data tracking device is provided in this embodiment, and the device includes:
[0025] A program instrumentation module, used for instrumenting method functions in the detected application, wherein the method functions include a first method function whose function rules have been collected and a second method function whose function rules have not been collected;
[0026] A flow direction acquisition module, used to obtain the data flow direction of the tainted data in the method function;
[0027] The link determination module is used to determine the propagation link of the tainted data in the detected application according to the data flow direction.
[0028] In some of the embodiments, the tainted data tracking device further includes: an information acquisition module, configured to acquire corresponding data processing information of the second method function when the tainted data passes through the second method function;
[0029] A link judgment module, used for judging whether the second method function exists in the propagation link of the tainted data when the tainted data reaches the vulnerability trigger point;
[0030] A rule acquisition module is used to acquire the function rule of the corresponding second method function according to the data processing information of the corresponding second method function and the data flow direction of the tainted data in the corresponding second method function if the second method function exists in the propagation link.
[0031] In a third aspect, an electronic device is provided in this embodiment, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the taint data tracking method described in the first aspect when executing the computer program.
[0032] In a fourth aspect, a storage medium is provided in this embodiment, on which a computer program is stored, and when the program is executed by a processor, the tainted data tracking method described in the first aspect is implemented.
[0033] Compared with the related technology, the taint data tracking method provided in this embodiment solves the problem of easy interruption of tracking links in the existing taint tracking technology by performing instrumentation processing in functions whose function rules are not collected, and uses the instrumentation code to record its data flow information, thereby achieving the effect of stable tracking of taint data and improving the coverage of taint tracking.
[0034] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0036] Figure 1 It is a hardware structure block diagram of a terminal of the tainted data tracking method of this embodiment.
[0037] Figure 2 This is a flow chart of a tainted data tracking method of this embodiment.
[0038] Figure 3 It is a flowchart of another tainted data tracking method in this embodiment.
[0039] Figure 4 It is a flow chart of the tainted data tracking method of this preferred embodiment.
[0040] Figure 5 It is a structural block diagram of a tainted data tracking device of this embodiment.
[0041] Figure 6 It is a structural block diagram of another tainted data tracking device of this embodiment. DETAILED DESCRIPTION
[0042] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.
[0043] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the", "these" and the like in this application do not represent quantitative restrictions, and they can be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether directly or indirectly. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. Usually, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0044] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1 FIG. 1 is a hardware structure diagram of a terminal of the tainted data tracking method of this embodiment. Figure 1 As shown, the terminal may include one or more ( Figure 1 Only one is shown in the figure) processor 102 and memory 104 for storing data, wherein processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0045] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the tainted data tracking method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0046] The transmission device 106 is used to receive or send data via a network. The above network includes a wireless network provided by the communication provider of the terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.
[0047] In this embodiment, a tainted data tracking method is provided. Figure 2 is a flow chart of a tainted data tracking method of this embodiment. Figure 2 As shown, the process includes the following steps:
[0048] Step S210 , instrumenting the method functions in the detected application, where the method functions include a first method function whose function rules have been collected and a second method function whose function rules have not been collected.
[0049] Specifically in this step, the detection terminal performs instrumentation processing on all the first method functions and the second method functions in the detected application, wherein the first method function refers to the function whose function rules have been collected, and the second method function refers to the function whose function rules have not been collected. Generally, the first method function refers to the function initially used to construct the program, and the function rules of such method functions have been manually collected and obtained in the process of constructing the program. The second method function refers to the function added or replaced in the subsequent use and optimization process of the program, and the function rules of such method functions are unknown and need to be collected and obtained twice. Therefore, in the process of tracking tainted data, if the tainted data passes through such functions, since the function rules of such functions are unknown, it is easy to cause the problem of interruption of the tracking link. Function rules refer to the processing rules of method functions for data, and function rules have different meanings in different method functions; in the propagation link of propagating tainted data, the function rules of tainted input functions can be called input point rules; the function rules of conventional string operation functions are called propagation rules, wherein the propagation rules specifically refer to one or more tainted data flows generated after the tainted data passes through the propagation method function, such as: {parameter→return value, parameter→object itself, object itself→return value...}. This step is to perform a plugging operation in each method function in the detected application, that is, to put a preset code in a certain position in the method function, so as to monitor the running status of the method function; in particular, the plugging operation is also performed in the function whose function rules are not collected. Specifically, for the first method function, the appropriate plugging position can be determined according to the corresponding function rule; and for the second method function, the plugging can be performed according to a specific rule template. The rule template of each second method function is: all its M inputs are regarded as the source of tainted data, and all its N outputs are regarded as the flow direction of tainted data. Then this method function generates a total of M*N different data flows, and the appropriate plugging position is determined based on these data flows.
[0050] Step S220, obtaining the data flow of the tainted data in the method function.
[0051] Specifically in this step, the detection terminal obtains the data flow direction of the tainted data in the first method function and / or the second method function. Since the plugging operation is performed in both the first method function and the second method function, the data flow direction of the tainted data in each method function can be obtained through the plugging code, and the data flow direction of the tainted data is used to determine the propagation link of the tainted data. In particular, when the tainted data passes through the second method function, the detection terminal obtains the data flow direction of the tainted data in the second method function through the plugging code, avoiding the problem of tracking the link terminal. In the prior art, the flow direction of the tainted data in the method function needs to be determined by the function rule. Therefore, when the tainted data passes through the method function where the function rule is not collected, the data flow direction of the tainted data in the method function cannot be determined, which will cause the tracking link of the tainted data to be interrupted, and the subsequent propagation path of the tainted data cannot be tracked. In the present invention, by also performing the plugging operation in the second method function where the function rule is not collected, when the tainted data passes through the second method function, the data flow direction of the tainted data in the corresponding second method function can be obtained through the plugging code, so that the tainted data can be stably tracked.
[0052] Step S230: Determine the propagation link of the tainted data in the detected application according to the data flow direction.
[0053] Specifically, in this step, the detection terminal determines the propagation link of the tainted data in the detected application according to the data flow direction of the tainted data in the first method function and / or the second method function. Since the data flow direction of the tainted data in each method function is obtained, the propagation link of the corresponding tainted function can be obtained by integrating all the data flows. When the tainted data reaches the vulnerability trigger point, the propagation link of the tainted data can be traced back to determine the method function through which the tainted data passes.
[0054] Through the above steps, firstly, the instrumentation operation is performed in all method functions, and the data flow of the tainted data in each method function is obtained through the instrumentation code. In particular, the data flow of the tainted data in the method function that is not collected by the function rule can be obtained, so when the tainted data propagates in the method function that is not collected by the function rule, it can also be tracked, thereby improving the coverage of taint tracking.
[0055] At the same time, in the prior art, some method functions use basic data type operations to change the original data, but the basic data type cannot be tracked, so this situation will also cause the interruption of the tainted data tracking link. In the present invention, since the method functions with basic data type operations are also plugged, the basic data type modification can be tracked from the side.
[0056] Figure 3is a flow chart of another tainted data tracking method in this embodiment. In some of the embodiments, such as Figure 3 As shown, the process includes Figure 2 All the steps shown, plus the steps:
[0057] Step S240: when the tainted data passes through the second method function, the corresponding data processing information of the second method function is obtained.
[0058] Specifically in this step, when the tainted data passes through the second method function, the detection terminal obtains data processing information of the second method function through the plugging code, wherein the data processing information specifically includes: the method, line number, and call stack used by the second method function to output the tainted data.
[0059] Step S250: When the tainted data reaches the vulnerability trigger point, it is determined whether there is a second method function in the propagation link of the tainted data.
[0060] Specifically in this step, when the tainted data reaches the vulnerability trigger point, the detection terminal determines whether there is a second method function in the propagation link of the tainted data. When the tainted data reaches the vulnerability trigger point, it means that among the method functions that the tainted data passes through, there may be at least one method function that causes the vulnerability. At this time, it is necessary to analyze the propagation rules of each method function and the tainted data information to determine the specific vulnerability information. Therefore, it is necessary to obtain the function rules of each method function in the propagation link of the tainted data. Among them, the propagation rules of the first method function are known, and at this time it is necessary to collect the propagation of the second method function, so first determine whether there is a second method function in the propagation link of the tainted data.
[0061] Step S260: If there is a second method function in the propagation link, the function rule of the corresponding second method function is obtained according to the data processing information of the corresponding second method function and the data flow direction of the tainted data in the corresponding second method function.
[0062] Specifically in this step, when the second method function exists in the transmission link of the tainted data, the detection terminal determines the function rule of the second method function according to the second data processing information and the data flow direction and other information. Specifically, the function rule of the second method function can be determined according to the input / output information when the tainted data passes through the second method function, the method information, line number, call stack of the second method function outputting the tainted data, and the data flow direction of the tainted data in the second method function and other information.
[0063] Through the above steps, the effect of automatically collecting function rules is achieved, which facilitates the subsequent determination of vulnerability information in the propagation link.
[0064] It should be noted that the steps shown in the above process or the flowchart of the attached figure can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here. For example, step S240 can be executed before step S230, or after step S230, or can be executed simultaneously with step S220, such as obtaining the data flow of the tainted data in the method function according to the plug-in code, and obtaining the data processing information of the second method function according to the plug-in code.
[0065] In some embodiments, when the tainted data reaches the vulnerability trigger point, the step of determining whether there is a second method function in the propagation link of the tainted data specifically includes:
[0066] Tag information is added to the tainted data that passes through the second method function. When the tainted data reaches the vulnerability trigger point, it is determined whether the tainted data has the tag information; if the tainted data has the tag information, the second method function exists in the propagation link.
[0067] Specifically in this step, when the tainted data passes through the second method function, tag information is added to the tainted data, and the tag information is propagated along with the tainted data. Therefore, when the tainted data reaches the vulnerability trigger point, it is possible to determine whether the tainted data passes through the second method function during the propagation process by judging whether the tainted data carries the tag information. Further preferably, the position of the second method function in the propagation link can be determined based on the position where the tag information appears in the propagation link. Since the tag information is added to the tainted data only when it passes through the second method function, the position where the tag information appears corresponds to the position of the second method function, and the position of the second method function can be determined by the position where the tag information appears.
[0068] In some of the embodiments, the step of determining the position of the second method function in the propagation link according to the position of the marker information in the propagation link comprises:
[0069] Step A, determining the position of the first second method function in the propagation link according to the first appearance position of the marking information;
[0070] Step B, after the position of the first second method function in the propagation link is determined, marking the first second method function as the first method function;
[0071] Repeat step A and step B until the positions of all second method functions in the propagation link are determined.
[0072] In the specific embodiment, a mark is added to the tainted data when it passes through the second method function. Since the added mark is the same, when the tainted function passes through the second method function for the first time, the mark information on the tainted data will change, so the position of the first second method function can be determined according to the position where the mark information first appears. For example, when the tainted data has the mark information when it propagates to the fifth method function, it can be determined that the fifth method function is the second method function. However, since the tainted function with the mark information will not change when it passes through the second method function again. For example, after the tainted data is added with the mark information a, whether it passes through the first method function or the second method function, the attached mark information is a, so the position of the subsequent second method function cannot be determined according to the mark information. Based on this, when the first second method function is determined, it is marked as the first method function. At this time, the mark information attached to the tainted data by the method function disappears, so the position of the mark information a changes, and its updated position corresponds to the position of the second second method function in the propagation link. Therefore, steps A and B can be repeated until the positions of all second method functions in the propagation link are determined.
[0073] In some other embodiments, different marking information may be added to the tainted data when it passes through the second method function. For example, marking information a may be added to the tainted data that passes through the second method function for the first time, and marking information b may be added to the tainted data that passes through the second method function and has marking information a, and so on. The positions of different second method functions can be determined by different marking information.
[0074] The present embodiment is described and illustrated below through preferred embodiments.
[0075] Figure 4 FIG. 1 is a flow chart of the tainted data tracking method of the preferred embodiment. Figure 4 As shown, the process includes the following steps:
[0076] Step S310 , instrumenting method functions in the detected application, wherein the method functions include method functions with instrumentation rules and method functions without instrumentation rules.
[0077] Specifically, in this step, the method functions with and without the instrumentation rules in the detected application are instrumented. The instrumented functions with the rules can be instrumented according to the instrumentation rules, and the instrumented functions without the instrumentation rules can be instrumented according to the relationship between each input and each output of the function. The instrumentation rules have different terms in different types of method functions; in the propagation link of tainted data, the function rules of the tainted input function can be called the input point rules; the function rules of the conventional string operation function are called the propagation rules. By also instrumenting the method functions without the instrumentation rules, the data flow of the tainted data in the method functions without the instrumentation rules can be obtained, so that the propagation link of the tainted data can be determined. At the same time, the method functions with basic data type operations are instrumented to track the modification of the basic data types from the side.
[0078] Step S320 , marking differently the tainted data that passes through the method functions with and without the instrumentation rules.
[0079] Specifically, in this embodiment, different marks are made for the tainted data that pass through different method functions in order to better determine the method functions that the tainted data passes through. Specifically, the method function with the plug-in rule can be called Ps, and the method function without the plug-in rule can be called Px; the externally input tainted data is recorded as Ts, and the tainted data generated by Ts through the Ps method function is also marked as Ts, the tainted data generated by Ts through the Px method function is marked as Tx, and the tainted data generated by Tx through the Px method function is marked as Ty. There are four data marking situations: Ps(Ts)->Ts, Px(Ts)->Tx, Ps(Tx)->Ts, and Px(Tx)->Ty. In the process of tracking tainted data, the same tracking strategy as Ts is adopted for Tx and Ty, but the specific data is not collected.
[0080] Step S330, when the tainted data passes through the method function without the plug-in rule, the data processing information and the data flow are collected, wherein the data processing information includes: the method, line number, call stack, etc., which generate the Tx data.
[0081] Specifically in this step, the data flow and data processing information of the tainted data in the corresponding function are obtained through the instrumentation program. The data flow is used to determine the propagation link of the tainted data, and the data flow and data processing information are both used to determine the instrumentation rules of the corresponding method function.
[0082] Step S340, determining the propagation link of the tainted data according to the data flow direction of the tainted data in the method function.
[0083] Specifically, in this step, after marking the tainted data differently, a propagation link of Ts->Tx...->Ty can be generated, and the propagation link can be denoted as L.
[0084] Step S350, judging the tainted data of the arriving risk function, if the propagation link of the tainted data passes through a method function without an instrumentation rule, proceeding to the next step.
[0085] Specifically in this step, the tainted data reaching the risk function is judged, that is, the tainted data reaching the vulnerability trigger point is judged. If there is no method function without plug-in rules in the propagation link of the tainted data, it means that the plug-in rules of the method function through which the tainted data passes are all known, and then the process ends. If there is a method function without plug-in rules in the propagation link of the tainted data, proceed to the next step. Further specifically judge whether the tainted data entering the risk function point is Tx or Ty, if so, execute the next step; if the tainted data is Ts, the process ends.
[0086] Step S360: treat the method function without the instrumentation rule in the tainted data propagation link as a pseudo propagation point, and collect its propagation rules.
[0087] Specifically, in this step, the method functions without plug-in rules that exist in the tainted data propagation link are first determined, and the plug-in rules of the method functions without plug-in rules are obtained through the corresponding data processing information and data flow. Specifically, the first Tx data is found in the propagation link L, and the vulnerability triggered by the Tx data is regarded as a suspected vulnerability, and reported to the user together with the corresponding data processing information and data flow information. According to the first Tx data, the first Px in the propagation link is determined, and after obtaining the plug-in rules of the method function, it is marked as Py, and then the same measures as Ps are taken for Py. Taking the same measure is to directly regard Py as Ps, and the data Ts is still output as Ts after being processed by Py. At this time, the mark of the tainted data changes accordingly, and according to the changed mark information, step S360 is continuously repeated until the plug-in rules of all Px in the propagation link L are collected.
[0088] In this preferred embodiment, the method function func whose propagation rules are not collected is used as an example for explanation. Its input and output can be obtained through the instrumentation program. The program calls the input() method to accept an external input and obtains a tainted data s1, which is marked as Ts. Then the func method function is called. In this method function, if its input s1 is tainted data, an output is generated after data operation inside the method function, and its output is marked as Tx, and this method function is marked as Px. If its output Tx eventually reaches the dangerous function point, this method function func is marked as Py as an automatically discovered propagation rule.
[0089] The present invention also inserts method functions other than existing insertion rules between applications, records their data flow information, and improves the coverage of taint tracking; at the same time, the present invention expands its capabilities based on taint tracking technology, so that it can track some methods that perform basic data type operations, thereby improving the tracking capability.
[0090] In this embodiment, a tainted data tracking device is also provided, which is used to implement the above embodiments and preferred implementation modes, and will not be repeated hereafter. The terms "module", "unit", "subunit", etc. used below may be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and conceivable.
[0091] Figure 5 is a structural block diagram of a tainted data tracking device of this embodiment, such as Figure 5 As shown, the device includes: a program instrumentation module 410 , a flow direction acquisition module 420 and a link determination module 430 .
[0092] The program instrumentation module 410 is used to perform instrumentation processing on method functions in the detected application, where the method functions include a first method function whose function rules have been collected and a second method function whose function rules have not been collected.
[0093] Specifically in this module, function rules refer to the rules for method functions to process data. Function rules have different definitions in different types of method functions. In the propagation link of tainted data, the function rules of tainted input functions can be called input point rules. The function rules of conventional string operation functions are called propagation rules. This step is to perform instrumentation operations in each method function in the detected application, that is, to place preset code in a certain position in the method function to monitor the running status of the method function. In particular, instrumentation operations are also performed in functions whose function rules are not collected. Specifically, for the first method function, the appropriate instrumentation position can be determined based on the corresponding function rules; and for the second method function, the appropriate instrumentation position can be determined based on the relationship between each input and each output of the method function.
[0094] The flow direction acquisition module 420 is used to obtain the data flow direction of the tainted data in the method function.
[0095] Specifically in this module, since the instrumentation operation is performed in the method function, the data flow direction of the tainted data in the method function can be obtained through the instrumentation code, and the data flow direction of the tainted data is used to determine the propagation link of the tainted data. In the prior art, the flow direction of the tainted data in the method function needs to be determined by the function rules. Therefore, when the tainted data passes through the method function whose propagation rules are not collected, the data flow direction of the tainted data in the method function cannot be determined, which will cause the tracking link of the tainted data to be interrupted, and it is impossible to continue to track the subsequent propagation path of the tainted data. In the present invention, by also performing the instrumentation operation in the second function whose function rules are not collected, when the tainted data passes through the second method function, the data flow direction of the tainted data in the corresponding second method function can be obtained through the instrumentation code, so that the tainted data can be stably tracked.
[0096] The link determination module 430 is used to determine the propagation link of the tainted data in the detected application according to the data flow direction.
[0097] Specifically, in this module, since the data flow of the tainted function in each method function is obtained, all data flows can be integrated to obtain the propagation link of the corresponding tainted function. When the tainted data reaches the vulnerability trigger point, the propagation link of the tainted data can be traced back to determine the method function that the tainted data passes through.
[0098] Through the above modules, we first perform instrumentation operations on all method functions, and obtain the data flow of tainted data in each method function through the instrumentation code. In particular, we can obtain the data flow of tainted data in method functions that are not collected by function rules, so when tainted data propagates in method functions that are not collected by function rules, we can also track it, thereby improving the coverage of taint tracking.
[0099] At the same time, in the prior art, some method functions use basic data type operations to change the original data, but the basic data type cannot be tracked, so this situation will also cause the interruption of the tainted data tracking link. In the present invention, since the method functions with basic data type operations are also plugged, the basic data type modification can be tracked from the side.
[0100] Figure 6 FIG. 1 is a structural block diagram of another tainted data tracking device of this embodiment. Figure 6 As shown, the device comprises Figure 5 All modules shown in the figure further include: an information acquisition module 440 , a link determination module 450 and a rule acquisition module 460 .
[0101] The information acquisition module 440 is used to acquire data processing information of the corresponding second method function when the tainted data passes through the second method function.
[0102] Specifically in this module, when the tainted data passes through the second method function, the data processing information of the second method function is obtained through the plugging code, wherein the data processing information specifically includes: the method, line number, and call stack used by the second method function to output the tainted data.
[0103] The link determination module 450 is used to determine whether there is a second method function in the propagation link of the tainted data when the tainted data reaches the vulnerability trigger point.
[0104] Specifically in this module, when the tainted data reaches the vulnerability trigger point, it means that among the method functions that the tainted data passes through, there may be at least one method function that causes the vulnerability. At this time, it is necessary to analyze the propagation rules of each method function and the tainted data information to determine the specific vulnerability information. Therefore, it is necessary to obtain the function rules of each method function in the propagation link of the tainted data. Among them, the propagation rules of the first method function are known, and at this time it is necessary to collect the propagation of the second method function, so first determine whether there is a second method function in the propagation link of the tainted data.
[0105] The rule acquisition module 460 is used to acquire the function rule of the corresponding second method function according to the data processing information of the corresponding second method function and the data flow direction of the tainted data in the corresponding second method function if there is a second method function in the propagation link.
[0106] Specifically in this module, when there is a second method function in the propagation link of the tainted data, the function rule of the second method function is determined according to the second data processing information and the data flow direction and other information. Specifically, the function rule of the second method function is determined according to the input / output information when the tainted data passes through the second method function, the method information, line number, call stack of the second method function outputting the tainted data, and the data flow direction of the tainted data in the second method function and other information.
[0107] Through the above modules, the effect of automatically collecting function rules is achieved, which facilitates the subsequent determination of vulnerability information in the propagation link.
[0108] In some embodiments, the link judgment module 450 is used to add tag information to the tainted data that passes through the second method function, and when the tainted data reaches the vulnerability trigger point, it is judged whether the tainted data has the tag information; if the tainted data has the tag information, the second method function exists in the propagation link. Specifically, the link judgment module 450 is used to determine the position of the second method function in the propagation link according to the position where the tag information appears in the propagation link.
[0109] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0110] In this embodiment, an electronic device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0111] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0112] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0113] Step S210 , instrumenting the method functions in the detected application, where the method functions include a first method function whose function rules have been collected and a second method function whose function rules have not been collected.
[0114] Step S220, obtaining the data flow of the tainted data in the method function.
[0115] Step S230: Determine the propagation link of the tainted data in the detected application according to the data flow direction.
[0116] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and will not be repeated in this embodiment.
[0117] In addition, in combination with the tainted data tracking method provided in the above embodiments, a storage medium may be provided in this embodiment to implement the tainted data tracking method. The storage medium stores a computer program, and when the computer program is executed by a processor, any tainted data tracking method in the above embodiments is implemented.
[0118] It should be understood that the specific embodiments described herein are only used to explain the application, rather than to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of this application.
[0119] Obviously, the drawings are only some examples or embodiments of the present application. For ordinary technicians in the field, the present application can also be applied to other similar situations based on these drawings without creative work. In addition, it is understandable that although the work done in this development process may be complicated and lengthy, for ordinary technicians in the field, certain changes in design, manufacturing or production based on the technical content disclosed in this application are only conventional technical means and should not be regarded as insufficient content disclosed in this application.
[0120] The term "embodiment" in this application refers to a specific feature, structure or characteristic described in conjunction with the embodiment that can be included in at least one embodiment of the present application. The appearance of this phrase in various locations in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is clearly or implicitly understood by those of ordinary skill in the art that the embodiments described in this application can be combined with other embodiments without conflict.
[0121] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the attached claims.
Claims
1. A tainted data tracking method, characterized in that: The method comprises: Performing instrumentation processing on the method functions in the detected application, the method functions include a first method function whose function rules have been collected and a second method function whose function rules have not been collected; the function rules refer to the processing rules of the method functions on data, and the function rules have different meanings in different method functions; in the propagation link of the tainted data, the function rules of the tainted input function are called input point rules; the function rules of the conventional string operation function are called propagation rules; the propagation rules refer to one or more tainted data flows generated after the tainted data passes through the propagation method function; Obtain the data flow of the tainted data in the method function; Determining, according to the data flow direction, a propagation link of the tainted data in the detected application; When the tainted data passes through the second method function, the corresponding data processing information of the second method function is obtained; the data processing information includes: the method, line number, and call stack of the second method function outputting the tainted data; Adding marking information to the tainted data that has passed through the second method function, and when the tainted data reaches the vulnerability trigger point, determining whether the tainted data has the marking information; if the tainted data has the marking information, then the second method function exists in the propagation link; If the second method function exists in the propagation link, acquiring a function rule of the corresponding second method function according to data processing information of the corresponding second method function and a data flow direction of the tainted data in the corresponding second method function; The method function in the detected application is instrumented, including: for the second method function, instrumenting according to a specific rule template, the rule template of each second method function is: all M inputs of the second method function are regarded as tainted data sources, and all N outputs of the second method function are regarded as tainted data flows, then this method function generates a total of M*N different data flows, and a suitable instrumentation position is determined based on these data flows.
2. The tainted data tracking method according to claim 1, characterized in that: When the tainted data reaches the vulnerability trigger point, determining whether there is a second method function in the propagation link of the tainted data further includes: The position of the second method function in the propagation link is determined according to the appearance position of the mark information in the propagation link.
3. The tainted data tracking method according to claim 2, characterized in that: Determining the position of the second method function in the propagation link according to the appearance position of the tag information in the propagation link includes: Step A, determining the position of the first second method function in the propagation link according to the first appearance position of the marking information; Step B, after the position of the first second method function in the propagation link is determined, marking the first second method function as the first method function; The step A and the step B are repeatedly performed until the positions of all second method functions in the propagation link are determined.
4. A tainted data tracking device, characterized in that: The device comprises: A program instrumentation module is used to perform instrumentation processing on method functions in the detected application, wherein the method functions include a first method function whose function rules have been collected and a second method function whose function rules have not been collected; the function rules refer to the processing rules of the method function on data, and the function rules have different meanings in different method functions; in the propagation link of the tainted data, the function rules of the tainted input function are called input point rules; the function rules of the conventional string operation function are called propagation rules; the propagation rules refer to one or more tainted data flows generated after the tainted data passes through the propagation method function; A flow direction acquisition module, used to obtain the data flow direction of the tainted data in the method function; A link determination module, used to determine a propagation link of the tainted data in the detected application according to the data flow direction; An information acquisition module, used for acquiring corresponding data processing information of the second method function when the tainted data passes through the second method function; the data processing information includes: the method, line number, and call stack of the second method function outputting the tainted data; a link judgment module, used for adding marking information to the tainted data passing through the second method function, and when the tainted data reaches the vulnerability trigger point, judging whether the tainted data has the marking information; if the tainted data has the marking information, the second method function exists in the propagation link; A rule acquisition module is used to acquire the function rule of the corresponding second method function according to the data processing information of the corresponding second method function and the data flow direction of the tainted data in the corresponding second method function if the second method function exists in the propagation link; wherein, The method function in the detected application is instrumented, including: for the second method function, instrumenting according to a specific rule template, the rule template of each second method function is: all M inputs of the second method function are regarded as tainted data sources, and all N outputs of the second method function are regarded as tainted data flows, then this method function generates a total of M*N different data flows, and a suitable instrumentation position is determined based on these data flows.
5. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the stain data tracking method according to any one of claims 1 to 3.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the taint data tracking method according to any one of claims 1 to 3 are implemented.
