Conditional competition vulnerability detection method and device

By detecting concurrent operations in the target program, building business instructions and controlling program execution, and extracting execution information to detect conditional competition vulnerabilities, the problem of low detection efficiency in existing technologies is solved and efficient vulnerability detection is achieved.

CN119167368BActive Publication Date: 2025-10-03INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411195337.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-28
Publication Date
2025-10-03
Estimated Expiration
2044-08-28

AI Technical Summary

Technical Problem

The detection efficiency of conditional race vulnerabilities in existing technologies is low, especially in large systems and complex programs, where the coverage is low and it consumes a lot of time.

Method used

By receiving target detection requests, the target program is detected, the target code related to concurrent operations is extracted, the target business instructions are constructed, the control program runs according to the business instructions, and the running information is extracted to detect conditional competition vulnerabilities.

Benefits of technology

It achieves accurate and efficient detection of conditional competition vulnerabilities, improves detection efficiency, and ensures that vulnerabilities in the program are fully exposed in a specific test environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119167368B_ABST
    Figure CN119167368B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a method for detecting a conditional competition vulnerability, wherein the method includes: receiving a target detection request, wherein the target detection request is used to request detection of a conditional competition vulnerability in a target program; responding to the target detection request, detecting the program code of the target program to obtain the target code in the target program; constructing a target business instruction for the target program based on the code information of the target code; controlling the target program to run in accordance with the business handling method indicated by the target business instruction, and extracting the target operation information of the target code; detecting the conditional competition vulnerability in the target program based on the target operation information. Through this application, the problem of low detection efficiency of conditional competition vulnerabilities in the related art is solved, thereby achieving the effect of improving the detection efficiency of conditional competition vulnerabilities.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computers, and more specifically, to a method and apparatus for detecting race conditions vulnerabilities. Background Art

[0002] With the rapid development of computer technology and the increasing complexity of applications, race conditions have gradually become a common and serious security issue. A race condition vulnerability refers to when two or more threads or processes fail to properly synchronize the order of operations when accessing shared resources, resulting in uncertainty in program behavior and data inconsistency. Race conditions may lead to security issues such as system crashes and data corruption. Therefore, detecting race conditions is crucial to protecting system security. In related technologies, the method of detecting race conditions is usually through manual testing, that is, developers or security experts manually check the code and test the application to identify possible race conditions. Although this method can detect vulnerabilities to a certain extent, the detection coverage is low when facing large systems and complex programs, and it requires a lot of time and cost, resulting in low efficiency in detecting race conditions. Summary of the Invention

[0003] The embodiments of the present application provide a method and apparatus for detecting a race condition vulnerability, so as to at least solve the problem of low detection efficiency of the race condition vulnerability in the related art.

[0004] According to one embodiment of the present application, a method for detecting a race condition vulnerability is provided, comprising:

[0005] Receive a target detection request, wherein the target detection request is used to request detection of a conditional race vulnerability in a target program;

[0006] In response to the target detection request, detecting the program code of the target program to obtain the target code in the target program, wherein the target code is the code in the target program that is associated with the concurrent operation;

[0007] Constructing a target business instruction for the target program according to the code information of the target code, wherein the code information is used to represent the operation status of the operation instructed by the target code, and the target business instruction is used to indicate the business handling method of the business to be handled on the target program;

[0008] Controlling the target program to run in accordance with the business processing mode indicated by the target business instruction, and extracting target operation information of the target code, wherein the target operation information is used to indicate the running timing of the target code during the running of the target program;

[0009] A conditional competition vulnerability in the target program is detected according to the target operation information.

[0010] Optionally, controlling the target program to run according to the business processing method indicated by the target business instruction includes:

[0011] generating a corresponding target monitoring program for each target code, wherein the target monitoring program is used to monitor the running status of the target code in the target program;

[0012] Inserting the target monitoring program into the position corresponding to the target code in the target program;

[0013] The target program into which the target monitoring program is inserted is run according to the business handling method indicated by the target business instruction.

[0014] Optionally, generating a corresponding target monitoring program for each target code includes:

[0015] generating a timestamp recording program for detecting the running time of the target code, wherein the timestamp recording program is used to record the running time of the target code;

[0016] In a case where the operation indicated by the target code is an access operation to a shared resource, an operation identification program is generated for the target code, wherein the operation identification program is used to identify the operation indicated by the target code, and the target monitoring program includes the timestamp recording program and the operation identification program.

[0017] Optionally, extracting target operation information of the target code includes:

[0018] Obtaining a target operation identifier output by an operation identifier program, and obtaining a target timestamp output by a timestamp recording program carried in the target program, wherein the operation identifier program is used to identify the shared resource access operation corresponding to the target code, and the timestamp recording program is used to record the running time of the target code;

[0019] Searching for log data corresponding to the target timestamp and the target operation identifier from the operation log of the target program;

[0020] querying the target shared resource accessed by the shared resource access operation executed by the target code from the log data;

[0021] The target operation identifier, target timestamp and target shared resource having a corresponding relationship are constructed as the target operation information.

[0022] Optionally, detecting a conditional race vulnerability in the target program according to the target running information includes:

[0023] sorting target operation identifiers corresponding to the plurality of target codes according to a target timestamp to obtain a target identifier sequence, wherein the target timestamp is used to indicate the running time of the target code in the target program, and the target operation identifier is used to identify the operation indicated by the target code;

[0024] Filtering a plurality of reference operation identifiers from the target identifier sequence, wherein the difference between the target timestamps corresponding to the plurality of reference operation identifiers is less than or equal to a target threshold;

[0025] determining an operation type for the operation identified by each reference operation identifier;

[0026] In a case where the operations identified by the multiple reference operation identifiers are operations of the same operation type, matching the target shared resource corresponding to each of the multiple reference operation identifiers, wherein the target shared resource is a resource accessed when the operation identified by the reference operation identifier is executed, and the target operation information includes the target operation identifier of the operation indicated by the target code, the target timestamp of the execution of the target code in the target program, and the target shared resource accessed when the operation indicated by the target code is executed;

[0027] In a case where the configurations of the plurality of target shared resources are consistent, it is determined that a conditional race vulnerability exists between the target codes corresponding to the reference operation identifiers in the target program.

[0028] Optionally, constructing a target business instruction for the target program according to the code information of the target code includes:

[0029] Determining a target business type of a business to be handled by the target program and a target number of businesses of each target business type according to the operation type of the operation to be performed indicated by each target code, wherein the code information includes the operation type of the operation to be performed indicated by each target code;

[0030] configuring a plurality of target services to be handled by the target program according to the target service type and the target quantity of each target service type;

[0031] Sort the target services according to the target service type to obtain a target service sequence;

[0032] A target service instruction corresponding to the target service sequence is generated, wherein the target service instruction is used to instruct the target program to handle the target service in a service handling order indicated by the target service sequence.

[0033] Optionally, after detecting a race condition vulnerability in the target program according to the target running information, the method further includes:

[0034] Obtaining a target number of conditional race vulnerabilities in the target program monitored and stored according to the target operation information;

[0035] Determine the candidate number of services of each target service type corresponding to the target number of vulnerabilities and the target service type from the corresponding relationship among the number of vulnerabilities, the service type, and the number of services of each service type;

[0036] configuring a plurality of candidate services to be handled by the target program according to the target service type and the number of candidates for each target service type;

[0037] Sort the plurality of candidate services according to the target service type to obtain a candidate service sequence;

[0038] A candidate service instruction corresponding to the candidate service sequence is generated, wherein the candidate service instruction is used to instruct the target program to handle the candidate service in a service handling order indicated by the candidate service sequence.

[0039] According to another embodiment of the present application, a device for detecting a race condition vulnerability is provided, comprising:

[0040] A receiving module, configured to receive a target detection request, wherein the target detection request is used to request detection of a conditional race vulnerability in a target program;

[0041] a response module, configured to respond to the target detection request, detect the program code of the target program, and obtain the target code in the target program, wherein the target code is the code in the target program that is associated with the concurrent operation;

[0042] a construction module, configured to construct a target business instruction for the target program based on code information of the target code, wherein the code information is used to represent an operation status of the operation instructed by the target code, and the target business instruction is used to indicate a business handling method for the business to be handled on the target program;

[0043] a control module, configured to control the target program to run in accordance with the business processing mode indicated by the target business instruction, and to extract target operation information of the target code, wherein the target operation information is used to indicate the running timing of the target code during the running of the target program;

[0044] The detection module is used to detect a conditional competition vulnerability in the target program according to the target operation information.

[0045] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the steps of any one of the above method embodiments when run.

[0046] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0047] Through the present application, by detecting the program code in the target program, the target code related to the concurrent operation is extracted from the target program, and then the operation status of the operation performed by the target code is obtained according to the code information of the target code, and then the target business instruction is constructed for the target program according to the code information representing the execution operation status of the target code, so that the business instruction can be constructed for the target program according to the concurrent operation status included in the target program, so that the conditional competition vulnerability in the target program can be effectively exposed, and then the target program is controlled to run according to the business handling method indicated by the target business instruction, and then the running information of the target code when it is running is extracted in this targeted test environment, and the target running information indicating the running sequence of the target code during the running process of the target program is obtained. The conditional competition vulnerability in the target program is detected by the target running information, thereby accurately and efficiently detecting the conditional competition vulnerability existing in the program. Therefore, the problem of low detection efficiency of conditional competition vulnerability in the related art can be solved, and the effect of improving the detection efficiency of conditional competition vulnerability is achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 This is a hardware structure block diagram of a server device for a method for detecting a conditional race vulnerability according to an embodiment of the present application;

[0049] Figure 2 This is a flow chart of a method for detecting a conditional race vulnerability according to an embodiment of the present application;

[0050] Figure 3 This is a flow chart for detecting a conditional race vulnerability according to an embodiment of the present application;

[0051] Figure 4 This is a structural block diagram of a device for detecting a race condition vulnerability according to an embodiment of the present application. DETAILED DESCRIPTION

[0052] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0053] It should be noted that the terms "first", "second", etc. in the description and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0054] The method embodiments provided in the embodiments of the present application can be executed in a server device or a similar computing device. Taking running on a server device as an example, Figure 1 This is a hardware structure diagram of a server device for detecting a conditional competition vulnerability in an embodiment of the present application. Figure 1 As shown, the server device may include one or more ( Figure 1 Only one is shown) a processor 102 (the processor 102 may include but is not limited to a microprocessor MCU or a programmable logic device FPGA and other processing devices) and a memory 104 for storing data, wherein the above-mentioned server device may also include a transmission device 106 for communication functions and an input and output device 108. It will 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 server device. Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.

[0055] 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 method for detecting conditional competition vulnerabilities in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implementing 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 located relative to the processor 102, and these remote memories can be connected to the server device via a network. Examples of the above-mentioned network include but are not limited to the Internet, corporate intranet, local area network, mobile communication network and combinations thereof.

[0056] The transmission device 106 is used to receive or send data via a network. A specific example of the aforementioned network may include a wireless network provided by a communication provider of the server device. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0057] In this embodiment, a method for detecting a conditional competition vulnerability is provided. Figure 2 : is a flow chart of a method for detecting a conditional competition vulnerability according to an embodiment of the present application, such as Figure 2 As shown, the process includes the following steps:

[0058] Step S202: receiving a target detection request, wherein the target detection request is used to request detection of a conditional race vulnerability in a target program;

[0059] Step S204: In response to the target detection request, the program code of the target program is detected to obtain the target code in the target program, wherein the target code is the code in the target program that is associated with the concurrent operation;

[0060] Step S206: constructing a target business instruction for the target program based on the code information of the target code, wherein the code information is used to represent the operation status of the operation instructed by the target code, and the target business instruction is used to indicate the business handling method of the business to be handled on the target program;

[0061] Step S208, controlling the target program to run in accordance with the business processing mode indicated by the target business instruction, and extracting target running information of the target code, wherein the target running information is used to indicate the running timing of the target code during the running of the target program;

[0062] Step S210: detecting a race condition vulnerability in the target program according to the target operation information.

[0063] Through the above steps, by detecting the program code in the target program, the target code related to the concurrent operation is extracted from the target program, and then the operation status of the operation performed by the target code is obtained according to the code information of the target code, and then the target business instruction is constructed for the target program according to the code information representing the execution operation status of the target code, so that the business instruction can be constructed for the target program according to the concurrent operation status included in the target program, so that the conditional competition vulnerability in the target program can be effectively exposed, and then the target program is controlled to run according to the business handling method indicated by the target business instruction, and then the running information of the target code is extracted in this targeted test environment, and the target running information indicating the running sequence of the target code in the target program running process is obtained, and the conditional competition vulnerability in the target program is detected by the target running information, thereby accurately and efficiently detecting the conditional competition vulnerability existing in the program. Therefore, the problem of low detection efficiency of conditional competition vulnerability in the related technology can be solved, and the effect of improving the detection efficiency of conditional competition vulnerability can be achieved.

[0064] In the embodiment provided in the above step S202, the conditional race vulnerability is a security vulnerability that occurs in a concurrent execution environment.

[0065] In the embodiment provided in the above step S204, the purpose of detecting the program code in the target program is to pre-identify the code that may have concurrent operations from the target program, and then perform targeted detection on the conditional competition vulnerability that may appear in the concurrent operation code block. The method of detecting the program code in the target program can be: obtaining the concurrency keyword in the target program, wherein the concurrency keyword is used to indicate the keyword in the code block related to the concurrent operation in the target program, traversing the program code in the target program according to the concurrency keyword, inserting the start marker code at the starting position of the program code block containing the concurrent keyword, inserting the end marker code at the end position of the program code block containing the concurrent keyword, and determining the program code block between the start marker code and the end marker code as the target code, wherein the start marker code is located before the end marker code. Among them, the method of obtaining concurrent keywords in the target program includes: using static analysis tools to scan the entire code base, analyzing thread creation and management codes, and identifying concurrent code segments that are executed concurrently; analyzing lock operations and semaphore usage, marking possible resource contention point codes; analyzing access to variables and data structures, and identifying access operation codes for shared resources, wherein the concurrent keywords include the concurrent code segments, the resource contention point codes, and access operation codes for shared resources. Through the above content, by identifying the concurrent keywords in the code base, all possible codes for storing concurrent operations included in the target program are identified, and then the concurrent keywords in the target program are marked, thereby marking the concurrent operations that may exist in the target program and avoiding omissions in monitoring concurrent operations in the target program.

[0066] Optionally, in an embodiment of the present application, concurrent operations are operations performed simultaneously by multiple threads or processes in a target program. Concurrent operations may include, but are not limited to, synchronous business operations and synchronous access operations. Synchronous business operations are used to indicate operations performed simultaneously by multiple threads or processes in a target program. Synchronous business operations may include, but are not limited to, thread creation, lock operations, semaphores, etc.; synchronous access operations are used to indicate synchronous access to shared resources by multiple threads or processes in a target program, where shared resources may include, but are not limited to, code, variables, files, etc., and this solution does not limit this.

[0067] In the embodiment provided in the above step S206, the code information may include, but is not limited to, information used to characterize the operation execution status, such as the operation type, the number of operations, the operation logic, etc., and this solution does not impose any limitation on this.

[0068] Optionally, in an embodiment of the present application, the target business instruction may be, but is not limited to, instructing the target program to handle the business type, the number of businesses of each business type, the concurrent volume of business handling, etc. This solution does not limit this.

[0069] Optionally, in an embodiment of the present application, since the execution operation indicated by the target code is an operation related to parallel operation, that is, running the target code may cause a conditional competition vulnerability, a test environment can be built for the target program in a targeted manner according to the operation situation indicated by the target code. Therefore, a target business instruction can be constructed for the target program based on the code information of the target code, which is equivalent to building a test environment in which a large number of parallel operations may occur in each program module, thereby enabling the target program to fully expose possible conditional competition vulnerabilities in the program when running according to the target business instructions, thereby improving the coverage rate of detecting conditional competition vulnerabilities. The method of constructing target business instructions for the target program based on the code information of the target code can be: a method of randomly constructing the program, and randomly constructing target business instructions for the target program can be: obtaining multiple target business types corresponding to the code information of the current target code, and the target number of businesses required for each of the target business types from the code information, business types and business quantities of the businesses of the business type with corresponding relationships, and randomly screening out a target number of target businesses from a business library of the target business type, wherein the business library is used to store businesses of the target business type; randomly arranging the target number of target businesses corresponding to each target business type in the multiple target business types to obtain a target business sequence, and then generating a target business instruction corresponding to the target business sequence.

[0070] In the embodiment provided in the above step S208, the purpose of controlling the target program to run in the business processing mode indicated by the target business instruction is to enable the target program to fully expose the possible conditional competition vulnerabilities of the program in a specific test environment. The target operation information may include but is not limited to the running timing, running times, number of running vulnerabilities, etc. during the running of the target program. This solution does not limit this.

[0071] Optionally, in an embodiment of the present application, the target operation information of the target code can be obtained by, but is not limited to, analyzing the business processing log of the target program in response to the target business instruction to handle the business output, such as identifying the target code in the business processing log, and identifying and analyzing the log data including the target code, thereby obtaining the target operation information for indicating the running timing of the target code during the running process of the target program. This solution does not limit this.

[0072] Optionally, in an embodiment of the present application, the target running information of the target code can also be collected by an running information collection program inserted in the target program. For example, the target code to be targeted is searched in the target program, and the dynamic insertion tool is called to insert the running information collection program at the corresponding position of the target code in the target program. Then, during the running of the target program, when the target code is called, the running information collection program inserted at the target code position will collect the running information of the target code and output it.

[0073] In the embodiment provided in the above step S210, the method for detecting the conditional race vulnerability in the target program based on the target operation information can be to use a conditional race detection algorithm. The specific method can be: before performing the conditional race detection, the collected target operation information is preprocessed, and the concurrent operation and shared resource access data recorded in the target operation information are extracted from the target operation information, and irrelevant information is eliminated, and only the records related to the conditional race detection are retained; initialize the data structure: use a dictionary to store the access record of each shared resource, with the key being the resource ID and the value being the access record list (including timestamp, thread ID and operation type). Traverse the log records: traverse the sorted log records and process each operation one by one. For each operation, add it to the corresponding access record list according to its resource ID; sort the access record list of each resource according to the timestamp to ensure that the order of the access records is consistent with the actual order; traverse the sorted access records, and for each pair of adjacent operations, check their thread IDs. If the two adjacent operations come from different threads or requests, further check their operation types; if one of the two operations is a write operation, it is determined that a conditional race exists and the pair of operations is recorded.

[0074] As an optional embodiment, controlling the target program to run according to the business processing method indicated by the target business instruction includes:

[0075] generating a corresponding target monitoring program for each target code, wherein the target monitoring program is used to monitor the running status of the target code in the target program;

[0076] Inserting the target monitoring program into the position corresponding to the target code in the target program;

[0077] The target program into which the target monitoring program is inserted is run according to the business handling method indicated by the target business instruction.

[0078] Optionally, in an embodiment of the present application, the target monitoring program is a program that detects the running status of the target code in the target program. The target monitoring program may include, but is not limited to, a timestamp recording program, an operation identification program, a business recording program, etc., wherein the timestamp recording program is used to record the running timestamp of the target code, the operation identification program is used for the operations performed by the target code, and the business recording program is used to record the business handled by the target code (such as the resources accessed). This solution does not limit this.

[0079] Optionally, in an embodiment of the present application, the running status of the target code in the target program may include but is not limited to running timing, running times, running business conditions, etc., and this solution does not limit this.

[0080] Optionally, in an embodiment of the present application, generating a target monitoring program for the target code may be: configuring a debugger in the target program to detect the running time of the target code, wherein the debugger is used to calculate the running time of the target code; configuring a monitor to monitor the running status of the target code, wherein the monitor is used to monitor the business involved in the execution operation of the target code and the business processing results of the business handled by the execution operation of the target code, etc. This solution does not limit this.

[0081] Through the above content, by inserting the target monitoring program at the position corresponding to each target code in the target program, the target monitoring program can be used to monitor the running status of the target code in the target program during the running of the target program, thereby improving the monitoring efficiency of the running status of the target code in the target program.

[0082] As an optional embodiment, generating a corresponding target monitoring program for each target code includes:

[0083] generating a timestamp recording program for detecting the running time of the target code, wherein the timestamp recording program is used to record the running time of the target code;

[0084] In a case where the operation indicated by the target code is an access operation to a shared resource, an operation identification program is generated for the target code, wherein the operation identification program is used to identify the operation indicated by the target code, and the target monitoring program includes the timestamp recording program and the operation identification program.

[0085] Optionally, in an embodiment of the present application, the purpose of recording the running time of the target code is to detect whether the execution operations of the target code will occur at the same time. If the running time of the target code is the same, it may be a parallel operation, which may lead to a conditional competition vulnerability. The running time of the target code can be recorded as follows: set breakpoints at the beginning and end positions of the target code block; run the program, and when the program stops at the first breakpoint, record the current time t1; continue running the program until it stops at the second breakpoint, and record the current time t2 again; calculate the execution time of the target code block: t2-t1.

[0086] Optionally, in an embodiment of the present application, the purpose of generating an operation identification program for the target code is to identify the code segment in the target code whose operation type is accessing shared resources. The specific method may be: obtaining the operation identification word generated by the operation identification program, wherein the operation identification word is used to indicate the identification word in the target code that indicates the operation of accessing shared resources; traversing the target code to match the reference code segment containing the operation identification word, wherein the reference code segment is used to indicate the code segment that the target code executes the operation of accessing shared resources; inserting thread ID recording code before and after the reference code segment, wherein the thread ID recording code is used to record the reference code segment execution operation ID, and the execution operation ID is used to distinguish the access operations of different requests.

[0087] In the above manner, by generating a timestamp recording program and an operation identification program for the target code, the running time of the target code and the operation type indicated by the target code can be obtained. Therefore, it is possible to judge whether there are operations executed simultaneously in the target program based on the running time of the target code, and to judge whether there are operations to access shared resources based on the operation type indicated by the target code, thereby improving the accuracy of identifying parallel operations.

[0088] As an optional embodiment, extracting target operation information of the target code includes:

[0089] Obtaining a target operation identifier output by an operation identifier program, and obtaining a target timestamp output by a timestamp recording program carried in the target program, wherein the operation identifier program is used to identify the shared resource access operation corresponding to the target code, and the timestamp recording program is used to record the running time of the target code;

[0090] Searching for log data corresponding to the target timestamp and the target operation identifier from the operation log of the target program;

[0091] querying the target shared resource accessed by the shared resource access operation executed by the target code from the log data;

[0092] The target operation identifier, target timestamp and target shared resource having a corresponding relationship are constructed as the target operation information.

[0093] Optionally, in an embodiment of the present application, the target operation identifier is used to indicate that the type of operation executed by the target code is accessing shared resources. The target operation identifier can be, but is not limited to, identifying the resource type, resource quantity, etc. of the shared resources accessed by the target code. This solution does not limit this.

[0094] Optionally, in an embodiment of the present application, the running time of the target code may include, but is not limited to, the time point when the target code starts running, the time point when the target code ends running, and the length of the time period during which the target code runs. This solution does not limit this.

[0095] Optionally, in an embodiment of the present application, the operation log of the target program is used to record the operation information during the program operation process. The operation log may include but is not limited to the timestamp of the code execution, log level, program or module identification, user information, exception and error information, etc. This solution does not limit this.

[0096] Optionally, in an embodiment of the present application, the log data corresponding to the target timestamp in the operation log may include, but is not limited to, the thread ID, operation ID, request ID, etc. corresponding to each timestamp; the log data corresponding to the target operation identifier in the operation log may include, but is not limited to, the access type, number of accesses, frequency of access, etc. of the target shared resource executed by the target code; the target shared resource may include, but is not limited to, the resource type and quantity of the shared resource, etc. This solution does not impose any restrictions on this.

[0097] Through the above content, by inserting an operation identification program and a timestamp recording program into the target code of the target program, it is possible to output the target operation identification of the shared resource access operation corresponding to the target code and the target timestamp representing the running time of the target code during the running of the target program. Then, based on the target timestamp and the target operation identification, the target shared resource accessed by the shared resource access operation to be executed by the target code can be found in the log data, thereby improving the efficiency of collecting target operation information and avoiding the complex operation of directly performing keyword analysis on the log data in the related technology.

[0098] As an optional embodiment, detecting a conditional race vulnerability in the target program according to the target running information includes:

[0099] sorting target operation identifiers corresponding to the plurality of target codes according to a target timestamp to obtain a target identifier sequence, wherein the target timestamp is used to indicate the running time of the target code in the target program, and the target operation identifier is used to identify the operation indicated by the target code;

[0100] Filtering a plurality of reference operation identifiers from the target identifier sequence, wherein the difference between the target timestamps corresponding to the plurality of reference operation identifiers is less than or equal to a target threshold;

[0101] determining an operation type for the operation identified by each reference operation identifier;

[0102] In a case where the operations identified by the multiple reference operation identifiers are operations of the same operation type, matching the target shared resource corresponding to each of the multiple reference operation identifiers, wherein the target shared resource is a resource accessed when the operation identified by the reference operation identifier is executed, and the target operation information includes the target operation identifier of the operation indicated by the target code, the target timestamp of the execution of the target code in the target program, and the target shared resource accessed when the operation indicated by the target code is executed;

[0103] In a case where the configurations of the plurality of target shared resources are consistent, it is determined that a conditional race vulnerability exists between the target codes corresponding to the reference operation identifiers in the target program.

[0104] Optionally, in an embodiment of the present application, sorting target operation identifiers corresponding to multiple target codes according to the target timestamp can be: converting the target timestamp into a directly comparable numerical type to obtain a reference timestamp; creating a data set corresponding to the reference timestamp and the target operation identifier, and passing the data set as input to a sorting function (such as the sorted() function in Python); specifying a key parameter, which is a function for extracting a timestamp for comparison from each data element, and if the timestamp has been processed (such as converted to a datetime object), the function should return the processed timestamp; executing the sorting algorithm to sort the data elements according to the timestamp value returned by the key function.

[0105] Optionally, in an embodiment of the present application, the purpose of matching the target shared resource corresponding to each reference operation identifier in multiple reference operation identifiers is to determine whether the operation type of the operation indicated by multiple target codes is to access the same shared resource. If the operation type of the operation indicated by multiple target codes is to access the same shared resource, it is determined that there is a conditional competition vulnerability between the target codes corresponding to the reference operation identifiers in the target program.

[0106] Through the above content, by analyzing the running time indicated by the timestamp and matching the target shared resources corresponding to each reference operation identifier in multiple reference operation identifiers, it is possible to avoid judging different operations in the same time and the same operation at different times as conditional competition vulnerabilities, thereby improving the accuracy of conditional competition vulnerability detection.

[0107] As an optional embodiment, constructing a target business instruction for the target program according to the code information of the target code includes:

[0108] Determining a target business type of a business to be handled by the target program and a target number of businesses of each target business type according to the operation type of the operation to be performed indicated by each target code, wherein the code information includes the operation type of the operation to be performed indicated by each target code;

[0109] configuring a plurality of target services to be handled by the target program according to the target service type and the target quantity of each target service type;

[0110] Sort the target services according to the target service type to obtain a target service sequence;

[0111] A target service instruction corresponding to the target service sequence is generated, wherein the target service instruction is used to instruct the target program to handle the target service in a service handling order indicated by the target service sequence.

[0112] Optionally, in an embodiment of the present application, the target business type of the target program's to-be-processed business can be determined from a mapping table with corresponding target codes indicating the execution operation type and the to-be-processed business type, and the target number of businesses of each target business type can be determined from a mapping table with corresponding business types and business quantities. This solution does not limit this.

[0113] Optionally, in an embodiment of the present application, the method of configuring multiple target businesses for the target program can be to create a to-be-done business template for the target program, add the target business type and target business quantity of the to-be-done business of the target program to the to-be-done business template deployed in the target program, and generate a target configuration process for the target program according to the to-be-done business template, wherein the target configuration process is used to indicate the configuration of the target business for the target program according to the to-be-done business template.

[0114] Optionally, in an embodiment of the present application, sorting multiple target businesses according to target business types can be: determining a target priority corresponding to the target business type indicated by the target code to perform the operation from business types and priorities with corresponding relationships, wherein the target priority is used to indicate the order in which the operations indicated by the current target code are run in the target program.

[0115] Through the above content, by determining the target business type that the target program needs to handle and the target quantity required for each business type according to the operation type of the operation indicated by the target code, it is possible to classify the business to be handled by the target program according to the operation type of the concurrent operation involved, and then sort multiple target businesses according to the business type to obtain a target business sequence, and then by handling the business in the business handling order indicated by the target business sequence, as many conditional competition vulnerabilities in the target program as possible can be exposed.

[0116] As an optional embodiment, after detecting a conditional race vulnerability in the target program according to the target running information, the method further includes:

[0117] Obtaining a target number of conditional race vulnerabilities in the target program monitored and stored according to the target operation information;

[0118] Determine the candidate number of services of each target service type corresponding to the target number of vulnerabilities and the target service type from the corresponding relationship among the number of vulnerabilities, the service type, and the number of services of each service type;

[0119] configuring a plurality of candidate services to be handled by the target program according to the target service type and the number of candidates for each target service type;

[0120] Sort the plurality of candidate services according to the target service type to obtain a candidate service sequence;

[0121] A candidate service instruction corresponding to the candidate service sequence is generated, wherein the candidate service instruction is used to instruct the target program to handle the candidate service in a service handling order indicated by the candidate service sequence.

[0122] Optionally, in an embodiment of the present application, after a conditional race vulnerability is detected, the business volume configured for the target code in the program can be optimized based on the detection results. The specific method can be: using the corresponding number of vulnerabilities, business types, and the number of businesses of each business type as multiple groups of input values, randomly generating training sets and test sets, and performing data normalization on the input data, and then constructing a neural network model, setting appropriate training parameters (such as learning rate, maximum number of training times, etc.) for model training, and after outputting the final result, selecting the type and number of candidate businesses corresponding to the predicted value with the smallest number of vulnerabilities, and then configuring corresponding business operations for the target program based on the predicted optimal candidate business information.

[0123] Optionally, in an embodiment of the present application, a locking mechanism, such as a mutex lock or a read-write lock, can be created for the target program based on the specific location information of each vulnerability, such as the line number of code, operation type, and thread ID, to ensure the correct order of access to concurrent operations and shared resources. The execution order of the code can also be reconstructed based on the timestamp to reduce conflicts in concurrent operations and shared resource access.

[0124] Through the above content, by obtaining the number of conditional competition vulnerabilities detected by running the target program according to the target business instructions, and then optimizing the number of business candidates for each target business type according to the number of detected conditional competition vulnerabilities, it is possible to optimize the business instructions according to the conditional competition vulnerability detection results, so that after the program runs according to the business instructions, the conditional competition vulnerabilities in the target program are exposed as much as possible, thereby improving the detection efficiency of the conditional competition vulnerabilities of the target program and shortening the time required for conditional competition vulnerability testing of the program.

[0125] Figure 3 This is a flow chart of detecting a conditional competition vulnerability according to an embodiment of the present application. Figure 3 As shown in the figure, the specific process of detecting conditional competition vulnerabilities is as follows:

[0126] (1) Static analysis:

[0127] The specific process of the static analysis phase is as follows:

[0128] 1. Use static analysis tools to scan the entire code base and identify all possible concurrent operations (such as thread creation, lock operations, semaphores, etc.) and access operations to shared resources.

[0129] 2. Analyze thread creation and management code to identify concurrently executed code segments.

[0130] 3. Analyze lock operations and semaphore usage to mark possible resource contention points.

[0131] 4. Analyze access to variables and data structures, and identify access operations to shared resources.

[0132] (2) Dynamic instrumentation:

[0133] The specific process of the dynamic instrumentation stage is as follows:

[0134] 1. Insert timestamp recording code before and after each concurrent operation (such as thread creation, lock acquisition and release) to accurately record the time when the operation occurred.

[0135] 2. Insert thread ID or request ID recording code before and after the code segment that accesses shared resources to record the ID of the current operation to ensure that access operations of different threads or requests can be distinguished.

[0136] 3. Compile and build the instrumented code to ensure that detailed log information can be generated at runtime.

[0137] (3) Execution monitoring:

[0138] The specific process of executing the monitoring phase is as follows:

[0139] 1. Set up the test environment to ensure that typical user operations and concurrent requests can be simulated.

[0140] 2. Run the instrumented application to simulate user operations and concurrent requests, covering all possible concurrent operations and shared resource access paths.

[0141] 3. Dynamically monitor the running process of the application and record the timestamp, thread ID and operation type (read or write) of each concurrent operation and shared resource access.

[0142] 4. Store the generated log data in a log file or database for subsequent analysis.

[0143] (4) Data collection and processing:

[0144] The specific process of data collection and processing is as follows:

[0145] 1. Data extraction: Extract recorded concurrent operations and shared resource access data from log files or databases, mainly including timestamps, thread IDs (or request IDs), and operation types (read or write).

[0146] 2. Data filtering: Eliminate irrelevant information and retain only records related to conditional competition detection.

[0147] 3. Data sorting: Sort records by timestamp to ensure that operations can be processed in chronological order during analysis.

[0148] (5) Conditional competition detection algorithm:

[0149] The race condition detection algorithm analyzes the collected log data based on timestamps and thread IDs to identify and report race condition vulnerabilities. The following are the specific implementation steps and details:

[0150] 1. Data preprocessing: Before performing conditional race detection, the collected log data needs to be preprocessed to facilitate subsequent analysis.

[0151] 2. Race Detection Algorithm: This algorithm analyzes preprocessed log data to identify race conditions. The main steps are as follows: Initialize the data structure: Use a dictionary to store access records for each shared resource, with the key being the resource ID and the value being a list of access records (including timestamp, thread ID, and operation type).

[0152] Traverse the log records: Traverse the sorted log records and process each operation one by one. For each operation, add it to the corresponding access record list according to its resource ID.

[0153] Analyze access records: Sort access records for each resource by timestamp to ensure that the order of access records matches the order in which they actually occurred. Check for interleaved accesses: Traverse the sorted access records and, for each pair of adjacent operations, check their thread IDs. If the two adjacent operations come from different threads or requests, further check their operation types. If one of the two operations is a write operation, a race condition exists. Record the pair of operations.

[0154] 3. Report detection results: Record the detected conditional race vulnerability, including detailed operation information (timestamp, thread ID, operation type and resource ID).

[0155] (6) Result report and repair suggestions:

[0156] The specific process of the result report and repair suggestion stage is as follows:

[0157] 1. Generate a test result report, which includes:

[0158] Details of all detected race conditions.

[0159] Specific location information for each vulnerability, such as line number, operation type, and thread ID.

[0160] 2. Make repair suggestions:

[0161] Use locking mechanisms or other synchronization control methods to ensure the correct order of access to concurrent operations and shared resources.

[0162] Refactor code to reduce conflicts in concurrent operations and access to shared resources.

[0163] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0164] In this embodiment, a detection device for a conditional race vulnerability is also provided. The device is used to implement the above-mentioned embodiments and preferred implementation methods. The details that have been described will not be repeated here. As used below, the term "module" can 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.

[0165] Figure 4 This is a structural block diagram of a detection device for a conditional competition vulnerability according to an embodiment of the present application. Figure 4 As shown, the device includes: a receiving module for receiving a target detection request, wherein the target detection request is used to request the detection of a conditional competition vulnerability in a target program; a response module for responding to the target detection request, detecting the program code of the target program, and obtaining the target code in the target program, wherein the target code is the code in the target program that has an associated relationship with concurrent operations; a construction module for constructing a target business instruction for the target program according to the code information of the target code, wherein the code information is used to characterize the operation status of the operation indicated by the target code, and the target business instruction is used to indicate the business handling method of the business to be handled on the target program; a control module for controlling the target program to run in accordance with the business handling method indicated by the target business instruction, and extracting the target operation information of the target code, wherein the target operation information is used to indicate the running sequence of the target code during the operation of the target program; a detection module for detecting a conditional competition vulnerability in the target program according to the target operation information.

[0166] Through the above content, through this application, by detecting the program code in the target program, and then extracting the target code related to the concurrent operation from the target program, and then deriving the operation status of the operation performed by the target code according to the code information of the target code, and then constructing the target business instruction for the target program according to the code information representing the execution operation status of the target code, it is possible to realize constructing the business instruction for the target program according to the concurrent operation status included in the target program, so that the conditional competition vulnerability in the target program can be effectively exposed, and then the target program is controlled to run according to the business handling method indicated by the target business instruction, and then in this targeted test environment, the running information of the target code is extracted when it is running, and the target running information indicating the running sequence of the target code during the running process of the target program is obtained, and the conditional competition vulnerability in the target program is detected by the target running information, thereby accurately and efficiently detecting the conditional competition vulnerability existing in the program. Therefore, the problem of low detection efficiency of conditional competition vulnerability in the related art can be solved, and the effect of improving the detection efficiency of conditional competition vulnerability can be achieved.

[0167] Optionally, the control module includes:

[0168] A first generating unit is configured to generate a corresponding target monitoring program for each target code, wherein the target monitoring program is configured to monitor the running status of the target code in the target program;

[0169] An inserting unit, configured to insert the target monitoring program into a position corresponding to the target code in the target program;

[0170] An operating unit is configured to operate the target program into which the target monitoring program is inserted according to a business handling method indicated by the target business instruction.

[0171] Optionally, the first generating unit is further configured to:

[0172] generating a timestamp recording program for detecting the running time of the target code, wherein the timestamp recording program is used to record the running time of the target code;

[0173] In a case where the operation indicated by the target code is an access operation to a shared resource, an operation identification program is generated for the target code, wherein the operation identification program is used to identify the operation indicated by the target code, and the target monitoring program includes the timestamp recording program and the operation identification program.

[0174] Optionally, the control module further includes:

[0175] an acquisition unit, configured to acquire a target operation identifier output by an operation identifier program, and to acquire a target timestamp output by a timestamp recording program carried in the target program, wherein the operation identifier program is used to identify a shared resource access operation corresponding to the target code, and the timestamp recording program is used to record the running time of the target code;

[0176] a search unit, configured to search the target program's running log for log data corresponding to the target timestamp and the target operation identifier;

[0177] a query unit, configured to query the target shared resource accessed by the shared resource access operation executed by the target code from the log data;

[0178] The construction unit is configured to construct the target operation identifier, the target timestamp, and the target shared resource that have a corresponding relationship into the target operation information.

[0179] Optionally, the detection module includes:

[0180] a first sorting unit, configured to sort target operation identifiers corresponding to the plurality of target codes according to a target timestamp to obtain a target identifier sequence, wherein the target timestamp is used to indicate a running time of the target code in the target program, and the target operation identifier is used to identify an operation indicated by the target code;

[0181] a screening unit, configured to screen out a plurality of reference operation identifiers from the target identifier sequence, wherein a difference between the target timestamps corresponding to the plurality of reference operation identifiers is less than or equal to a target threshold;

[0182] a first determining unit, configured to determine an operation type of the operation identified by each reference operation identifier;

[0183] a matching unit, configured to match a target shared resource corresponding to each of the reference operation identifiers in a case where the operations identified by the multiple reference operation identifiers are operations of the same operation type, wherein the target shared resource is a resource accessed when the operation identified by the reference operation identifier is executed, and the target operation information includes the target operation identifier of the operation indicated by the target code, the target timestamp of the execution of the target code in the target program, and the target shared resource accessed when the operation indicated by the target code is executed;

[0184] The second determining unit is configured to determine whether a conditional race vulnerability exists between the target codes corresponding to the reference operation identifier in the target program when the configurations of the plurality of target shared resources are consistent.

[0185] Optionally, the building block includes:

[0186] a third determining unit, configured to determine a target business type of a business to be handled by the target program and a target number of businesses of each target business type according to the operation type of the operation to be performed indicated by each target code, wherein the code information includes the operation type of the operation to be performed indicated by each target code;

[0187] a configuration unit, configured to configure a plurality of target services to be handled by the target program according to the target service type and the target quantity of each target service type;

[0188] A second sorting unit is configured to sort the plurality of target services according to the target service type to obtain a target service sequence;

[0189] The second generating unit is configured to generate a target business instruction corresponding to the target business sequence, wherein the target business instruction is configured to instruct the target program to handle the target business in a business handling order indicated by the target business sequence.

[0190] Optionally, the device further includes:

[0191] an acquisition module, configured to acquire, after detecting a conditional competition vulnerability in the target program according to the target operation information, a target vulnerability number of the conditional competition vulnerability in the target program monitored and stored according to the target operation information;

[0192] a determination module, configured to determine, from a correspondence between the number of vulnerabilities, the business type, and the number of businesses of each business type, a candidate number of businesses of each target business type corresponding to the target number of vulnerabilities and the target business type;

[0193] a configuration module, configured to configure a plurality of candidate services to be handled by the target program according to the target service type and the number of candidates for each target service type;

[0194] A sorting module, configured to sort the plurality of candidate services according to the target service type to obtain a candidate service sequence;

[0195] A generating module is used to generate candidate business instructions corresponding to the candidate business sequence, wherein the candidate business instructions are used to instruct the target program to handle the candidate business in the business handling order indicated by the candidate business sequence.

[0196] It should be noted that the above modules can be implemented through software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.

[0197] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps of any of the above method embodiments when run.

[0198] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.

[0199] An embodiment of the present application further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0200] In an exemplary embodiment, 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.

[0201] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.

[0202] An embodiment of the present application further provides another computer program product, comprising a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above method embodiments are implemented.

[0203] An embodiment of the present application also provides a computer program, which includes computer instructions, which are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps of any of the above method embodiments.

[0204] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail here.

[0205] Obviously, those skilled in the art should understand that the modules or steps of the present application described above can be implemented using a general-purpose computing device, they can be concentrated on a single computing device, or distributed across a network composed of multiple computing devices, they can be implemented using program code executable by the computing device, and thus, they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be performed in a different order than herein, or they can be fabricated into separate integrated circuit modules, or multiple modules or steps can be fabricated into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.

[0206] The above description is merely a preferred embodiment of the present application and is not intended to limit the present application. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present application shall be included within the scope of protection of the present application.

Claims

1. A method for detecting a conditional competition vulnerability, characterized in that: include: Receive a target detection request, wherein the target detection request is used to request detection of a conditional race vulnerability in a target program; In response to the target detection request, detecting the program code of the target program to obtain the target code in the target program, wherein the target code is the code in the target program that is associated with the concurrent operation; Constructing a target business instruction for the target program according to the code information of the target code, wherein the code information is used to represent the operation status of the operation instructed by the target code, and the target business instruction is used to indicate the business handling method of the business to be handled on the target program; Controlling the target program to run in accordance with the business processing mode indicated by the target business instruction, and extracting target operation information of the target code, wherein the target operation information is used to indicate the running timing of the target code during the running of the target program; Detecting a conditional competition vulnerability in the target program according to the target operation information; The controlling the target program to run in accordance with the business handling method indicated by the target business instruction includes: generating a corresponding target monitoring program for each target code, wherein the target monitoring program is used to monitor the running status of the target code in the target program; inserting the target monitoring program into the position corresponding to the target code in the target program; and running the target program into which the target monitoring program is inserted in accordance with the business handling method indicated by the target business instruction; The generating of a corresponding target monitoring program for each target code includes: generating a timestamp recording program for detecting the running time of the target code, wherein the timestamp recording program is used to record the running time of the target code; when the operation indicated by the target code is an access operation to a shared resource, generating an operation identification program for the target code, wherein the operation identification program is used to identify the operation indicated by the target code, and the target monitoring program includes the timestamp recording program and the operation identification program.

2. The method according to claim 1, characterized in that The step of extracting target operation information of the target code includes: Obtaining a target operation identifier output by an operation identifier program, and obtaining a target timestamp output by a timestamp recording program carried in the target program, wherein the operation identifier program is used to identify the shared resource access operation corresponding to the target code, and the timestamp recording program is used to record the running time of the target code; Searching for log data corresponding to the target timestamp and the target operation identifier from the operation log of the target program; querying the target shared resource accessed by the shared resource access operation executed by the target code from the log data; The target operation identifier, target timestamp and target shared resource having a corresponding relationship are constructed as the target operation information.

3. The method according to claim 1, characterized in that The detecting a conditional race vulnerability in the target program according to the target operation information includes: sorting target operation identifiers corresponding to the plurality of target codes according to a target timestamp to obtain a target identifier sequence, wherein the target timestamp is used to indicate the running time of the target code in the target program, and the target operation identifier is used to identify the operation indicated by the target code; Filtering a plurality of reference operation identifiers from the target identifier sequence, wherein the difference between the target timestamps corresponding to the plurality of reference operation identifiers is less than or equal to a target threshold; determining an operation type for the operation identified by each reference operation identifier; In a case where the operations identified by the multiple reference operation identifiers are operations of the same operation type, matching the target shared resource corresponding to each of the multiple reference operation identifiers, wherein the target shared resource is a resource accessed when the operation identified by the reference operation identifier is executed, and the target operation information includes the target operation identifier of the operation indicated by the target code, the target timestamp of the execution of the target code in the target program, and the target shared resource accessed when the operation indicated by the target code is executed; In a case where the configurations of the plurality of target shared resources are consistent, it is determined that a conditional race vulnerability exists between the target codes corresponding to the reference operation identifiers in the target program.

4. The method according to claim 1, wherein The step of constructing a target business instruction for the target program according to the code information of the target code includes: Determining a target business type of a business to be handled by the target program and a target number of businesses of each target business type according to the operation type of the operation to be performed indicated by each target code, wherein the code information includes the operation type of the operation to be performed indicated by each target code; configuring a plurality of target services to be handled by the target program according to the target service type and the target quantity of each target service type; Sort the target services according to the target service type to obtain a target service sequence; A target service instruction corresponding to the target service sequence is generated, wherein the target service instruction is used to instruct the target program to handle the target service in a service handling order indicated by the target service sequence.

5. The method according to claim 4, characterized in that After detecting a conditional race vulnerability in the target program according to the target running information, the method further includes: Obtaining a target number of conditional race vulnerabilities in the target program monitored and stored according to the target operation information; Determine the candidate number of services of each target service type corresponding to the target number of vulnerabilities and the target service type from the corresponding relationship among the number of vulnerabilities, the service type, and the number of services of each service type; configuring a plurality of candidate services to be handled by the target program according to the target service type and the number of candidates for each target service type; Sort the plurality of candidate services according to the target service type to obtain a candidate service sequence; A candidate service instruction corresponding to the candidate service sequence is generated, wherein the candidate service instruction is used to instruct the target program to handle the candidate service in a service handling order indicated by the candidate service sequence.

6. A detection device for a conditional competition vulnerability, characterized in that: include: A receiving module, configured to receive a target detection request, wherein the target detection request is used to request detection of a conditional race vulnerability in a target program; a response module, configured to respond to the target detection request, detect the program code of the target program, and obtain the target code in the target program, wherein the target code is the code in the target program that is associated with the concurrent operation; a construction module, configured to construct a target business instruction for the target program based on code information of the target code, wherein the code information is used to represent an operation status of the operation instructed by the target code, and the target business instruction is used to indicate a business handling method for the business to be handled on the target program; a control module, configured to control the target program to run in accordance with the business processing mode indicated by the target business instruction, and to extract target operation information of the target code, wherein the target operation information is used to indicate the running timing of the target code during the running of the target program; A detection module, configured to detect a conditional race vulnerability in the target program based on the target operation information; The control module includes: a first generation unit for generating a corresponding target monitoring program for each target code, wherein the target monitoring program is used to monitor the running status of the target code in the target program; an insertion unit for inserting the target monitoring program into the position corresponding to the target code in the target program; and an operation unit for operating the target program into which the target monitoring program is inserted according to the business processing method indicated by the target business instruction; The first generation unit is further used to: generate a timestamp recording program for detecting the running time of the target code, wherein the timestamp recording program is used to record the running time of the target code; when the operation indicated by the target code is an access operation to a shared resource, generate an operation identification program for the target code, wherein the operation identification program is used to identify the operation indicated by the target code, and the target monitoring program includes the timestamp recording program and the operation identification program.

7. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 5 when executed by a processor.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Logic vulnerability detection method and device, equipment and storage medium

    CN116108453A

  • LLM-driven industrial network intrusion detection method and response system

    CN118381627A