Adversarial sample generation method based on vulnerability codes

By obtaining the vulnerability detection model to be attacked and the initial countermeasure code, generating candidate countermeasures codes based on preset code conversion rules, and using the Monte Carlo tree search algorithm to conduct iterative statement perturbation attacks, the code mutation method solves the problem of semantic changes and compatibility in the vulnerable code. This problem improves the quality and generation efficiency of adversarial samples.

CN118862072APending Publication Date: 2024-10-29CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410984577.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-22
Publication Date
2024-10-29

AI Technical Summary

Technical Problem

When the existing technology uses the code mutation method, the semantic changes to the vulnerable code may cause the vulnerability to disappear or the compilation to fail, and it is difficult to be compatible with multiple vulnerability detection models.

Method used

By obtaining the vulnerability detection model to be attacked and the initial adversarial code, candidate adversarial codes are generated according to the preset code conversion rules, and the Monte Carlo tree search algorithm is used to conduct iterative statement perturbation attacks to ensure that the semantic and grammatical features of the adversarial samples are retained and are compatible with a variety of Vulnerability detection model.

Benefits of technology

It effectively avoids semantic changes and grammatical errors, improves the quality and generation efficiency of adversarial samples, and ensures that adversarial samples are compatible with multiple vulnerability detection models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118862072A_ABST
    Figure CN118862072A_ABST
Patent Text Reader

Abstract

The invention discloses an adversarial sample generation method and device based on a vulnerability code, a storage medium and electronic equipment, and relates to the technical field of computers.The method comprises the steps that firstly, a to-be-attacked vulnerability detection model and an initial adversarial code corresponding to the to-be-attacked vulnerability detection model are obtained; code statement conversion is conducted on the initial adversarial code according to first preset code conversion rules, first candidate adversarial codes corresponding to the initial adversarial code are generated, and the initial adversarial code comprises at least one first preset code conversion rule; performing iterative statement disturbance attack on the to-be-attacked vulnerability detection model by using the first candidate adversarial code according to a Monte Carlo tree search algorithm; and determining the target first candidate adversarial code as an adversarial sample of the to-be-attacked vulnerability detection model in response to judging that the target first candidate adversarial code in the first candidate adversarial codes is successfully attacked. Compared with the prior art, the quality of the generated adversarial sample and the generation efficiency of the adversarial sample are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, device, storage medium and electronic device for generating adversarial samples based on vulnerability codes. Background Art

[0002] Adversarial sample generation refers to a security research method for machine learning and deep learning models. Its purpose is to impose tiny, often imperceptible perturbations on the original input data, causing the model to make incorrect predictions or classifications, thereby "deceiving" the model and demonstrating the model's vulnerability and potential security risks.

[0003] At present, the main method based on code mutation uses deep learning to fill in the missing codes, so that the original code can mutate into a variety of codes with different or similar semantics. From an intuitive point of view, it is difficult to distinguish the changes in the code, which provides a more reliable guarantee for the generation of adversarial samples of source code.

[0004] However, in the case of vulnerable code, vulnerability preservation is a necessary prerequisite. If the code mutation method is used, it will change the original semantics of the code, affect the correctness of the syntax, and even cause the vulnerability to disappear and the mutated vulnerable code to fail to compile. Summary of the invention

[0005] In view of this, the present application provides a method, device, storage medium and electronic device for generating adversarial samples based on vulnerability codes. The main purpose is to improve the current existing technology. In the case of vulnerability codes, if the code mutation method is used, it will lead to changes in the original semantics of the code, affect the correctness of the syntax, and even cause the vulnerability to disappear and the mutated vulnerability code to fail to compile. Technical problems.

[0006] In a first aspect, the present application provides a method for generating adversarial samples based on vulnerability codes, comprising:

[0007] Obtaining a vulnerability detection model to be attacked and an initial adversarial code corresponding to the vulnerability detection model to be attacked;

[0008] Performing code statement conversion on the initial confrontation code according to a first preset code conversion rule to generate a first candidate confrontation code corresponding to the initial confrontation code;

[0009] Performing an iterative statement perturbation attack on the vulnerability detection model to be attacked using the first candidate adversarial code according to a Monte Carlo tree search algorithm;

[0010] In response to determining that the attack on a target first candidate adversarial code in the first candidate adversarial code is successful, the target first candidate adversarial code is determined as an adversarial sample of the vulnerability detection model to be attacked.

[0011] In a second aspect, the present application provides an adversarial sample generation device based on vulnerability code, comprising:

[0012] An acquisition module is configured to acquire a vulnerability detection model to be attacked and an initial confrontation code corresponding to the vulnerability detection model to be attacked;

[0013] A generating module is configured to convert the initial confrontation code into a code statement according to a first preset code conversion rule, and generate a first candidate confrontation code corresponding to the initial confrontation code;

[0014] An attack module is configured to perform an iterative statement perturbation attack on the vulnerability detection model to be attacked using the first candidate adversarial code according to a Monte Carlo tree search algorithm;

[0015] The determination module is configured to determine the target first candidate adversarial code as an adversarial sample of the vulnerability detection model to be attacked in response to determining that the attack on the target first candidate adversarial code in the first candidate adversarial code is successful.

[0016] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the vulnerability code-based adversarial sample generation method of the first aspect.

[0017] In a fourth aspect, the present application provides an electronic device comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein when the processor executes the computer program, the vulnerability code-based adversarial sample generation method of the first aspect is implemented.

[0018] In a fifth aspect, the present application provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the vulnerability code-based adversarial sample generation method of the first aspect.

[0019] By means of the above technical scheme, the present application provides a vulnerability code-based adversarial sample generation method, device, storage medium and electronic device, which first obtain a vulnerability detection model to be attacked and an initial adversarial code corresponding to the vulnerability detection model to be attacked; perform code statement conversion on the initial adversarial code according to a first preset code conversion rule to generate a first candidate adversarial code corresponding to the initial adversarial code, wherein the initial adversarial code contains at least one of the first preset code conversion rules; use the first candidate adversarial code to perform an iterative statement perturbation attack on the vulnerability detection model to be attacked according to a Monte Carlo tree search algorithm; in response to judging that the attack on a target first candidate adversarial code in the first candidate adversarial code is successful, determine the target first candidate adversarial code as an adversarial sample of the vulnerability detection model to be attacked. Compared with the current existing technology, the present application converts the initial adversarial code according to the first preset code rule to obtain the first candidate adversarial code. In the conversion process, multiple conversion methods are taken into consideration, the semantic features and grammatical features of the code are effectively retained, and the flexibility of code transformation is improved. The first candidate adversarial code is generated based on the code conversion method, which can avoid modifying the vulnerability location information of the code, changing the original semantics of the code, and affecting the correctness of the grammar; based on the first candidate code, the code statements of the vulnerability detection model to be attacked are disturbed, so that the adversarial sample generation method of the embodiment of the present application can be compatible with multiple vulnerability detection models, and the Monte Carlo tree search algorithm is used to guide the generation of adversarial samples, thereby improving the quality of the generated adversarial samples and the efficiency of generating adversarial samples.

[0020] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0022] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0023] Figure 1 A schematic diagram of a process for generating an adversarial sample based on a vulnerability code provided in an embodiment of the present application is shown;

[0024] Figure 2A schematic diagram of a process for generating an adversarial sample based on a vulnerability code provided in an embodiment of the present application is shown;

[0025] Figure 3 A schematic diagram showing an example provided by an embodiment of the present application;

[0026] Figure 4 A schematic diagram of an example process provided by an embodiment of the present application is shown;

[0027] Figure 5 A schematic diagram of the structure of an adversarial sample generation device based on vulnerability code provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0028] The embodiments of the present application will be described in more detail below with reference to the accompanying drawings. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.

[0029] In order to improve the current existing technology based on vulnerability code, if the code mutation method is used, it will change the original semantics of the code, affect the correctness of the syntax, and even cause the vulnerability to disappear and the mutated vulnerability code to fail to compile. This embodiment provides a method for generating adversarial samples based on vulnerability code, such as Figure 1 As shown, the method includes:

[0030] Step 101: Obtain a vulnerability detection model to be attacked and an initial adversarial code corresponding to the vulnerability detection model to be attacked.

[0031] In the embodiment of the present application, the vulnerability detection model to be attacked is a vulnerability detection model that needs to be model-checked. Specifically, the vulnerability detection model is an algorithm or framework used to identify and evaluate potential security weaknesses in computer systems, networks, and applications. These models use a variety of technologies and methods to automate the detection process and ensure the security of the system.

[0032] In some examples, the initial adversarial code corresponding to the vulnerability detection model to be attacked is a code that can perform vulnerability detection through the vulnerability detection model to be attacked. Specifically, adversarial code usually refers to carefully constructed input data in the security field, especially in security testing of machine learning models, which is intended to deceive or bypass the detection mechanism of the model. This type of code is not directly used in production environments or for positive purposes, but is used as a means for security researchers to evaluate the robustness and defense mechanisms of the model. For example, if code A can perform vulnerability detection through vulnerability detection model 1 to be attacked, then code A can be the initial adversarial code of vulnerability detection model 1 to be attacked.

[0033] Step 102: convert the initial adversarial code into code statements according to a first preset code conversion rule to generate a first candidate adversarial code corresponding to the initial adversarial code.

[0034] In the embodiment of the present application, the first preset code conversion rule is a pre-set rule for converting the initial adversarial code. Correspondingly, code statement conversion refers to the process of rewriting the code from one form or language to another form or language, aiming to achieve code optimization, compatibility enhancement, readability improvement or functional equivalent conversion. This process may involve grammatical structure adjustment, algorithm logic rewriting, conversion between programming languages, etc.

[0035] In this embodiment, the first candidate confrontation code is obtained by performing sentence conversion on the initial confrontation code based on one or more of the first preset code conversion rules.

[0036] Step 103: Perform an iterative statement perturbation attack on the vulnerability detection model to be attacked using the first candidate adversarial code according to the Monte Carlo tree search algorithm.

[0037] In some examples, the Monte Carlo Tree Search (MCTS) algorithm is a probabilistic search algorithm used to find the optimal path in the decision-making process. It is particularly suitable for dealing with decision problems with high branching factors and incomplete information, such as board games, game tree searches, etc. MCTS combines random sampling and tree search techniques to gradually approach the optimal solution by iteratively building and updating a search tree. The basic steps of the MCTS algorithm can include selection: starting from the current tree root node, select a path to go deeper into the tree according to a certain strategy (usually the UCB formula, i.e., the upper confidence bound). The UCB formula balances "exploration" and "exploitation", encouraging the algorithm to explore nodes that have not been fully examined and to utilize nodes with known higher benefits; Expansion: When the selection process reaches a leaf node and the node has not been fully expanded (that is, there are still legal actions that have not been explored), the algorithm will generate a new child node under the node; Simulation: Starting from the newly expanded child node, the algorithm performs a random simulation (playout), that is, randomly selects actions from the current state until the end of the game, thereby simulating the result of a game. This process does not depend on any specific strategy and usually uses random moves; Backpropagation: After the simulation is completed, according to the results of the simulation, the algorithm will reversely update the statistical information of all nodes on this path, such as the number of visits, winning rate, etc. These updated information will guide future node selection. The MCTS algorithm gradually builds and optimizes the search tree by repeating the above four steps, so that the paths corresponding to actions that often lead to good results are frequently visited and strengthened. As the number of iterations increases, the search tree tends to reflect the optimal strategy more and more, thus helping the algorithm find the best action choice in a given state. The MCTS algorithm is effective because it can efficiently explore a huge search space with limited computing resources by focusing on the most promising paths while avoiding exhaustive exploration of all possible states.

[0038] It should be noted that the search tree constructed in the Monte Carlo tree search algorithm needs to be depth-limited to avoid the situation where the search time is too long.

[0039] In some examples, embodiments of the present application determine the next code among multiple first candidate adversarial codes to perform a statement perturbation attack through a Monte Carlo tree search algorithm.

[0040] Step 104: In response to determining that the target first candidate adversarial code in the first candidate adversarial code is successfully attacked, determine the target first candidate adversarial code as an adversarial sample of the vulnerability detection model to be attacked.

[0041] Optionally, a successful attack on the target first candidate adversarial code may be that vulnerability information of the target first candidate code will not be detected by the vulnerability detection model to be attacked, or the vulnerability detection model to be attacked incorrectly detects the vulnerability information of the target first candidate code, thereby determining the target first candidate code as an adversarial sample of the vulnerability detection model to be attacked.

[0042] Specifically, adversarial examples are created by carefully constructing almost imperceptible modifications to the original input data, causing the model to produce incorrect predictions or classification results. The generation of adversarial examples is based on perturbing the model's input. This perturbation can be targeted at a specific model (white-box attack), in which the attacker knows the model's structure and parameters; or it can be performed without knowing the specific details of the model (black-box attack), and the attack is designed only by observing the model's response to the input. Common methods for generating adversarial examples include the Fast Gradient Sign Method (FGSM), DeepFool, and Projected Gradient Descent (PGD). The existence of adversarial examples highlights the potential security risks of machine learning models, especially in security-sensitive application scenarios such as autonomous driving and medical diagnosis. Therefore, studying adversarial examples is not only to understand the model's vulnerability, but also to develop more powerful defense mechanisms and improve the model's robustness and security. Adversarial training is a common method that adds adversarial examples to the training data so that the model can also make correct predictions on perturbed data, thereby improving the model's resistance to adversarial attacks.

[0043] Compared with the current existing technology, this embodiment converts the initial adversarial code according to the first preset code rule to obtain the first candidate adversarial code. In the conversion process, multiple conversion methods are taken into account, the semantic characteristics and grammatical characteristics of the code are effectively retained, and the flexibility of code transformation is improved. The first candidate adversarial code is generated based on the code conversion method, which can avoid modifying the vulnerability location information of the code, changing the original semantics of the code, and affecting the correctness of the grammar; based on the first candidate code, the code statements of the vulnerability detection model to be attacked are disturbed, so that the adversarial sample generation method of the embodiment of the present application can be compatible with multiple vulnerability detection models, and the Monte Carlo tree search algorithm is used to guide the generation of adversarial samples, thereby improving the quality of the generated adversarial samples and the efficiency of generating adversarial samples.

[0044] In order to further illustrate the specific implementation process of the method of this embodiment, this embodiment provides the following Figure 2 The specific method shown includes:

[0045] Step 201: Obtain the vulnerability detection model to be attacked and the vulnerability test code corresponding to the vulnerability detection model to be attacked.

[0046] Optionally, after step 201, the method of this embodiment further includes: determining the vulnerability line file information corresponding to the vulnerability test code.

[0047] In the embodiments of the present application, the vulnerability test code is code that can perform vulnerability detection through the vulnerability detection model to be attacked, where the vulnerability test code includes initial adversarial code.

[0048] Exemplarily, as Figure 3 shown, for the entire vulnerability detection process, the vulnerability test code in the embodiments of the present application is Figure 3 the training set in. Regardless of the differences between vulnerability detection models, they all need to go through a preprocessing step and be input into the model for training or prediction. The generation of adversarial samples in the embodiments of the present application is completed before preprocessing.

[0049] Step 202: Determine the vulnerability test code containing the first preset code conversion rule and / or the second preset code conversion rule in the vulnerability test code as the initial adversarial code.

[0050] In the embodiments of the present application, the specific contents of the first preset code conversion rule and the second preset code conversion rule can be shown in Table 1 below:

[0051] Table 1

[0052]

[0053] Specifically, the first preset code conversion rule may include: equivalent replacement markers, relational operator conversion, array reference conversion, equivalent calculation, increment and decrement operator conversion, pointer reference conversion, array definition, typeof expression conversion, forced type conversion, integer variable conversion, character constant conversion, adding useless multipliers, and adding useless expressions. Among them, the equivalent replacement markers are some replaceable operators provided by the library in the C++ language. For example, the logical AND operator && and and, the logical OR operator || and or, etc., a total of 11 pairs of replaceable markers; the relational operator mainly converts the judgment conditions in conditional statements. For example, a>b can be equivalent to b<a, and can also be negatively converted. In addition, the exchange and negative conversion can be combined; the array reference conversion uses the fact that the array name is also a pointer variable pointing to the first address of the array to convert the reference to the array. For example, a[1]=0 can be equivalent to *(a + 1)=0.

[0054] Correspondingly, equivalent calculation is to replace the original statement by changing the arithmetic operator. For example, in addition and subtraction operations, a+b can be converted to the form of a-(-b); the conversion of increment and decrement operators requires independence judgment of the expression. If the statement exists independently, multiple types can be replaced. For example, i++, ++i, i=i+1, i+=1, etc. are equivalent, while increment and decrement nested in the expression cannot be replaced, such as a=b++; after the statement is replaced, it is not equivalent to the original statement; pointer reference conversion uses the characteristics of pointer variables to convert instantiation calls and pointer accesses to each other. For example, ab can be expressed as &a->b.

[0055] Correspondingly, array definition is only a conversion between array space applications, changing the array definition into an application of the malloc method; typeof expression conversion uses the typeof function to return the variable type of the input parameter, and this return value can be directly used as the type to declare other variables; forced type conversion is to perform a forced conversion on the same type of assignment, for example, the integer variable a is assigned a=int(b); integer variable conversion refers to changing the expression of the variable, for example, int a=8 can be equivalent to a=2*4 or a=0x8.

[0056] Furthermore, character constant conversion converts characters into ASCII values; adding a useless multiplier means multiplying any variable in an operation expression by a random number and then dividing it by the random number so that the operation result does not change; adding a useless expression means adding a useless expression expr in the operation expression, where the operation result of the expression is 0.

[0057] In some examples, the second preset code conversion rule may be identifier replacement, where identifier replacement refers to modifying the identifier to a random or uniform identifier format.

[0058] It should be noted that the vulnerability test code needs to be matched with the first preset code conversion rule and the second preset code conversion rule, and a code containing at least one of the first preset code conversion rule and / or the second preset code conversion rule is screened out as the initial confrontation code.

[0059] Optionally, after step 202, the method of this embodiment further includes: locating the vulnerability line included in the initial confrontation code according to the vulnerability line file information, and obtaining the vulnerability line position information corresponding to the initial confrontation code.

[0060] It should be noted that the vulnerability line location information may be a standard result of the initial vulnerability detection of the adversarial code, and may be used in subsequent steps to determine whether the vulnerability detection result is accurate.

[0061] Exemplarily, the vulnerability line file information may be a diff file of the vulnerability code, and the vulnerability line may be located by obtaining the position information of the vulnerability line from the diff file.

[0062] Step 203: convert the initial confrontation code into a code statement according to a first preset code conversion rule to generate a first candidate confrontation code corresponding to the initial confrontation code.

[0063] Step 204: Perform an iterative statement perturbation attack on the vulnerability detection model to be attacked using the first candidate adversarial code according to the Monte Carlo tree search algorithm.

[0064] Optionally, before step 204, the method of this embodiment also includes: performing vulnerability detection on the initial adversarial code based on the vulnerability detection model to be attacked, and obtaining an initial vulnerability detection result corresponding to the initial adversarial code; accordingly, step 204 may specifically include: when it is determined that the initial vulnerability detection result is the same as the vulnerability row location information, using the first candidate adversarial code according to the Monte Carlo tree search algorithm to perform an iterative statement perturbation attack on the vulnerability detection model to be attacked.

[0065] Exemplarily, if the initial adversarial code obtained by matching the vulnerability test code is code A, code A needs to be subjected to vulnerability detection through the vulnerability detection model to be attacked to obtain the vulnerability detection result of code A, and the vulnerability detection result of code A is compared with the vulnerability row position information obtained in step 202. If the detection result is the same as the vulnerability row position information, it means that the vulnerability detection model to be attacked can successfully predict the vulnerability row position information of code A. Code A can then be converted according to the preset first code conversion rule and the second preset code conversion rule to start attacking the vulnerability detection model to be attacked.

[0066] Correspondingly, if the detection result is different from the vulnerability row position information, it means that the vulnerability detection model to be attacked cannot accurately predict the vulnerability row position information of code A. In this case, code A can be used as an adversarial sample of the vulnerability detection model to be attacked, and the vulnerability detection model to be attacked can be optimized based on code A.

[0067] As a preferred method, step 204 specifically also includes: for each statement perturbation attack process, when it is determined that the last statement perturbation attack failed, determining the first candidate adversarial code used in the current statement perturbation attack according to the Monte Carlo tree search algorithm; inputting the first candidate adversarial code used in the current statement perturbation attack into the vulnerability detection model to be attacked for vulnerability detection, and obtaining the current vulnerability detection result.

[0068] Exemplarily, there may be multiple candidate codes B corresponding to code A. In each statement perturbation attack process, it is necessary to determine the candidate code B used for the current statement perturbation attack based on the Monte Carlo tree search algorithm, input the candidate code B into the vulnerability detection model to be attacked for vulnerability detection, and obtain the vulnerability detection result of the candidate code B. The vulnerability detection result of the candidate code B is compared with the vulnerability row position information obtained in step 202. If the detection result is the same as the vulnerability row position information, it means that the vulnerability detection model to be attacked can successfully predict the vulnerability row position information of the candidate code B.

[0069] For this embodiment, step 204 specifically also includes: if the current vulnerability detection result is different from the vulnerability row position information, it is determined that the current statement perturbation attack is successful, and the first candidate adversarial code used in the current statement perturbation attack is determined as the adversarial sample of the vulnerability detection model to be attacked; if the current vulnerability detection result is the same as the vulnerability row position information, it is determined that the current statement perturbation attack has failed, and it is judged whether the number of attacks corresponding to the current statement perturbation attack reaches the preset attack threshold.

[0070] Exemplarily, the vulnerability detection result of candidate code B is compared with the vulnerability row position information obtained in step 202. If the detection result is different from the vulnerability row position information, it means that the vulnerability detection model to be attacked cannot accurately predict the vulnerability row position information of candidate code B. Then, candidate code B can be determined as an adversarial sample of the vulnerability detection model to be attacked.

[0071] Optionally, step 204 specifically also includes: when the number of attacks corresponding to the current statement perturbation attack reaches a preset attack threshold, analyzing the vulnerability detection model to be attacked; when the number of attacks corresponding to the current statement perturbation attack does not reach the preset attack threshold, determining the first candidate adversarial code to be used for the next statement perturbation attack according to the Monte Carlo tree search algorithm.

[0072] In some examples, the preset attack threshold is set according to demand, and there is no limitation on the specific value of the preset attack threshold.

[0073] Exemplarily, if the vulnerability detection model to be attacked can successfully predict the vulnerability line location information of the candidate code B, it is necessary to determine the current number of attacks. If the number of attacks does not reach the preset attack threshold, the next attack is performed.

[0074] It should be noted that if the preset attack threshold is 5 times and there are 6 candidate codes B, then if the first 5 attacks fail, the candidate code B used in the 5th attack will be used as the adversarial sample; if the preset attack threshold is 5 times and there are 4 candidate codes B, then if the first 4 attacks fail, the candidate code B used in the 4th attack will be used as the adversarial sample, and the 5th attack will not be performed.

[0075] In an embodiment of the present application, step 204 specifically also includes: if the analysis of the vulnerability detection model to be attacked satisfies the identifier mapping condition, the initial adversarial code is converted into a code identifier according to a second preset code conversion rule to generate a second candidate adversarial code corresponding to the initial adversarial code; if the analysis of the vulnerability detection model to be attacked does not satisfy the identifier mapping condition, the candidate adversarial code currently undergoing a statement perturbation attack is determined as an adversarial sample of the vulnerability detection model to be attacked.

[0076] Correspondingly, if the number of attacks reaches the preset attack threshold, it is necessary to determine whether the vulnerability detection model to be attacked includes an identifier mapping function. If it does not include the identifier mapping function, the candidate code B used for the last time that reaches the preset attack threshold will be used as the adversarial sample of the vulnerability detection model to be attacked.

[0077] Optionally, step 204 specifically also includes: using the second candidate adversarial code to perform an iterative identifier perturbation attack on the vulnerability detection model to be attacked according to the Monte Carlo tree search algorithm; in response to determining that the attack on the target second candidate adversarial code in the second candidate adversarial code is successful, determining the target second candidate adversarial code as an adversarial sample of the vulnerability detection model to be attacked.

[0078] Exemplarily, if an identifier mapping function is included, the initial adversarial code is identifier-converted to obtain multiple candidate adversarial codes C, and a Monte Carlo tree search algorithm is used to perform an iterative identifier perturbation attack on the vulnerability detection model to be attacked using the candidate adversarial code C.

[0079] In some examples, step 204 specifically also includes: when it is determined that the initial vulnerability detection result is the same as the vulnerability row location information, determining the initial adversarial code as an adversarial sample of the vulnerability detection model to be attacked.

[0080] Furthermore, in the process of each identifier perturbation attack, the candidate adversarial code C used in the current identifier perturbation attack is determined by the Monte Carlo tree search algorithm, and the candidate adversarial code C is input into the vulnerability detection model to be attacked for detection to obtain the vulnerability detection result of the candidate adversarial code C, and the vulnerability detection result of the candidate adversarial code C is compared with the vulnerability row position information obtained in step 202. If the detection result is the same as the vulnerability row position information, it means that the vulnerability detection model to be attacked can successfully predict the vulnerability row position information of the candidate adversarial code C, and the next attack can be carried out.

[0081] Correspondingly, if the detection result is different from the vulnerability row position information, it means that the vulnerability detection model to be attacked cannot accurately predict the vulnerability row position information of the candidate adversarial code C, and the candidate adversarial code C is used as the adversarial sample of the vulnerability detection model to be attacked.

[0082] Step 205: In response to determining that the target first candidate adversarial code in the first candidate adversarial code is successfully attacked, determine the target first candidate adversarial code as an adversarial sample of the vulnerability detection model to be attacked.

[0083] In the embodiments of the present application, adversarial sample generation has always been a hot topic. Many related researchers have conducted a lot of research work in the field of source code processing and achieved certain research results. In the field of source code processing, common adversarial sample generation methods include: code mutation-based methods and code conversion-based methods. Among them, in the code conversion-based methods, according to the conversion characteristics, they can be divided into three types: dead code insertion, identifier name transformation, and code structure transformation. Related adversarial sample generation methods in source code processing can include code mutation-based methods and code conversion-based methods.

[0084] Among them, the code mutation-based method mainly uses machine learning to automatically fill in the missing code. This method can make the original code mutate into a variety of codes with different or similar semantics. From an intuitive point of view, it is difficult to distinguish the changes in the code, which provides a more reliable guarantee for the generation of adversarial samples of the source code; the code transformation-based method will not change the semantics of the code. This method can be divided into three types of transformations in the characteristics of code transformation. Among them, dead code insertion mainly uses the absence of any dependency on the code context to insert a meaningless code statement so as not to affect the semantics of the code, such as declaring a variable that has not appeared. Identifier transformation is to replace the identifier names in the code, including function names, variable names, etc. Code structure transformation is to replace the structural statements of the code, such as loop statements and judgment statements.

[0085] Furthermore, the above two methods are two commonly used adversarial sample generation methods in the field of source code. However, in the generation of adversarial samples applied to vulnerable code, there are still the following problems: The first method based on code mutation leaves the code blank and uses deep learning to complete the blank code. Although this code completion technology can express similar semantics, it still has errors and produces a large number of code statements whose semantics and syntax are different from the original code. This method is more applicable to tasks such as code translation and code description generation. In vulnerable code, vulnerability preservation is a necessary prerequisite. When code mutation changes the semantics, the vulnerability may disappear. Secondly, code mutation cannot guarantee the correctness of syntax, and the mutated vulnerable code may cause compilation failure.

[0086] Correspondingly, the second method based on code transformation can ensure the grammatical correctness and semantic features of the code, but in the vulnerability detection task, it is not compatible with all vulnerability detection models. For the vulnerability detection model that slices the code, the code statements will be split by slicing the code, so this can also ignore the code transformation of dead code insertion. For the vulnerability detection model that maps the code identifier, all identifiers will be mapped to a unified identifier name, so this can ignore the code transformation of identifier transformation. For the vulnerability code, the vulnerable line of the code is often given in the patch file, and the code structure transformation can easily lead to the failure to locate the vulnerability information in the vulnerability code.

[0087] Nowadays, with the explosive growth of software scale, the number of vulnerabilities is also increasing, and higher requirements are placed on vulnerability detection capabilities. Among them, vulnerability detection models based on deep learning are becoming more and more important. Vulnerability detection models based on deep learning can automatically identify vulnerability features in the code to detect vulnerabilities, and the current risk is the lack of model robustness. Improving model robustness mainly lies in using high-quality adversarial sample models for adversarial training. Deep learning vulnerability detection models have differences in the process of processing vulnerable codes, such as slicing and preprocessing the code by statement, mapping code identifiers, etc.

[0088] In vulnerability detection, the requirements for vulnerability codes are often more stringent than those in other source code processing tasks, and the existing adversarial sample generation methods cannot be well applied to vulnerability detection. In the embodiment of the present application, a vulnerability detection model that does not use the identifier mapping function is considered. In terms of the disturbance range, it can be changed more flexibly by modifying a single statement, which reduces the disturbance degree of the code to a certain extent. At the same time, it is different from the traditional dead code insertion. The dead code of the present invention acts on the inside of the statement, rather than being divided as an independent statement. In this way, the vulnerability detection model that avoids slicing processing can filter out the disturbance of dead code insertion, and can also avoid modifying the vulnerability location information of the code, and improve the compatibility of the code disturbance with the vulnerability detection model, improve the quality of the generated adversarial samples, and also provide some guarantees for the robustness problem in vulnerability detection.

[0089] Compared with the current existing technology, this embodiment converts the initial adversarial code according to the first preset code rule and / or the second preset code rule to obtain the first candidate adversarial code and the second candidate adversarial code. In the conversion process, multiple conversion methods are taken into account, the semantic characteristics and grammatical characteristics of the code are effectively retained, and the flexibility of code transformation is improved. The initial adversarial code is converted into an identifier separately to avoid modifying the vulnerability location information of the code, changing the original semantics of the code, and affecting the correctness of the grammar; based on the first candidate adversarial code, the code statement of the vulnerability detection model to be attacked is disturbed, and the code statement perturbation attack and the code identifier perturbation attack are combined, so that the adversarial sample generation method of the embodiment of the present application can be compatible with multiple vulnerability detection models, and the Monte Carlo tree search algorithm is used to guide the generation of adversarial samples, thereby improving the quality of the generated adversarial samples and the efficiency of generating adversarial samples.

[0090] In order to illustrate the specific implementation process of this embodiment, the following specific application examples are given: Figure 4 As shown, but not limited to:

[0091] Initialize the vulnerability code program, including the code language, vulnerability line information, and parameter information (search iteration number) of the Monte Carlo tree search algorithm that guides the generation of adversarial samples; extract the statements containing these rules according to the code rule information provided above and mark them as target statements; generate a candidate code statement replacement list for each target code statement, each target code statement may have multiple rules, and these rules can be converted individually and in combination to obtain multiple equivalent replacement statements; mark the vulnerability line and filter the code statement. Marking the code vulnerability line requires the diff file of the vulnerability code, obtain the location information of the vulnerability line from the diff file, and locate the vulnerability line; make the first judgment on the original code to determine whether the model itself predicts correctly. If yes, the next step of replacement perturbation attack can be carried out; if not, the attack process is directly terminated to save the code information; during the iterative attack process, the Monte Carlo tree search algorithm is used to simulate the selection of the next replacement rule and replace the code statement. The algorithm can select the optimal child node as the parent node of the next conversion through random simulation, and determine whether the number of adversarial sample search iterations reaches the critical value. If yes, it means that the attack is unsuccessful and the sample is discarded. If yes, continue the attack to determine whether the model uses the identifier mapping function. If yes, save the attack results and end the attack. If there is no mapping and the attack is not successful, use the perturbation of identifier conversion to attack the model, use the Monte Carlo number search algorithm to select the identifier replacement, and finally determine whether the attack is successful.

[0092] Compared with the current existing technology, this embodiment converts the initial adversarial code according to the first preset code rule and / or the second preset code rule to obtain the first candidate adversarial code and the second candidate adversarial code. In the conversion process, multiple conversion methods are taken into account, the semantic characteristics and grammatical characteristics of the code are effectively retained, and the flexibility of code transformation is improved. The initial adversarial code is converted into an identifier separately to avoid modifying the vulnerability location information of the code, changing the original semantics of the code, and affecting the correctness of the grammar; based on the first candidate adversarial code, the code statement of the vulnerability detection model to be attacked is disturbed, and the code statement perturbation attack and the code identifier perturbation attack are combined, so that the adversarial sample generation method of the embodiment of the present application can be compatible with multiple vulnerability detection models, and the Monte Carlo tree search algorithm is used to guide the generation of adversarial samples, thereby improving the quality of the generated adversarial samples and the efficiency of generating adversarial samples.

[0093] Further, as Figure 1 and Figure 2 The specific implementation of the method shown in the embodiment provides an adversarial sample generation device based on vulnerability code, such as Figure 5 As shown, the device includes: an acquisition module 31, a generation module 32, an attack module 33, and a determination module 34.

[0094] An acquisition module 31 is configured to acquire a vulnerability detection model to be attacked and an initial confrontation code corresponding to the vulnerability detection model to be attacked;

[0095] A generating module 32 is configured to convert the initial confrontation code into a code statement according to a first preset code conversion rule, and generate a first candidate confrontation code corresponding to the initial confrontation code;

[0096] An attack module 33 is configured to perform an iterative statement perturbation attack on the vulnerability detection model to be attacked using the first candidate adversarial code according to a Monte Carlo tree search algorithm;

[0097] The determination module 34 is configured to, in response to determining that the target first candidate adversarial code in the first candidate adversarial code is successfully attacked, determine the target first candidate adversarial code as an adversarial sample of the vulnerability detection model to be attacked.

[0098] In some examples of this embodiment, the acquisition module 31 is specifically configured to obtain the vulnerability detection model to be attacked and the vulnerability test code corresponding to the vulnerability detection model to be attacked; and determine the vulnerability test code containing the first preset code conversion rule and / or the second preset code conversion rule in the vulnerability test code as the initial adversarial code.

[0099] In some examples of this embodiment, the acquisition module 31 is further specifically configured to determine the vulnerability line file information corresponding to the vulnerability test code; accordingly, the acquisition module 31 is further specifically configured to locate the vulnerability line contained in the initial confrontation code based on the vulnerability line file information, and obtain the vulnerability line position information corresponding to the initial confrontation code.

[0100] In some examples of the present embodiment, the attack module 33 is further configured to perform vulnerability detection on the initial adversarial code based on the vulnerability detection model to be attacked, and obtain an initial vulnerability detection result corresponding to the initial adversarial code; accordingly, the attack module 33 is specifically configured to, when it is determined that the initial vulnerability detection result is the same as the vulnerability row position information, use the first candidate adversarial code to perform an iterative statement perturbation attack on the vulnerability detection model to be attacked according to the Monte Carlo tree search algorithm; when it is determined that the initial vulnerability detection result is the same as the vulnerability row position information, determine the initial adversarial code as an adversarial sample of the vulnerability detection model to be attacked.

[0101] In some examples of this embodiment, the attack module 33 is further configured to determine, for each statement perturbation attack, if it is determined that the last statement perturbation attack failed, the first candidate adversarial code for the current statement perturbation attack according to the Monte Carlo tree search algorithm.

[0102] In some examples of this embodiment, the attack module 33 is further configured to input the first candidate adversarial code currently used in the statement perturbation attack into the vulnerability detection model to be attacked to perform vulnerability detection and obtain a current vulnerability detection result.

[0103] In some examples of the present embodiment, the attack module 33 is further specifically configured to determine, for each statement perturbation attack, a first candidate adversarial code for the current statement perturbation attack according to the Monte Carlo tree search algorithm when it is determined that the last statement perturbation attack failed; input the first candidate adversarial code for the current statement perturbation attack into the vulnerability detection model to be attacked for vulnerability detection, and obtain the current vulnerability detection result.

[0104] In some examples of the present embodiment, the attack module 33 is further specifically configured to determine that the current statement perturbation attack is successful if the current vulnerability detection result is different from the vulnerability row position information, and determine the first candidate adversarial code used in the current statement perturbation attack as the adversarial sample of the vulnerability detection model to be attacked; if the current vulnerability detection result is the same as the vulnerability row position information, then determine that the current statement perturbation attack has failed, and judge whether the number of attacks corresponding to the current statement perturbation attack reaches a preset attack threshold.

[0105] In some examples of the present embodiment, the attack module 33 is further specifically configured to analyze the vulnerability detection model to be attacked when the number of attacks corresponding to the current statement perturbation attack reaches a preset attack threshold; and to determine the first candidate adversarial code to be used for the next statement perturbation attack according to the Monte Carlo tree search algorithm when the number of attacks corresponding to the current statement perturbation attack does not reach the preset attack threshold.

[0106] In some examples of the present embodiment, the attack module 33 is further configured to, if the analysis of the vulnerability detection model to be attacked satisfies the identifier mapping condition, perform code identifier conversion on the initial adversarial code according to a second preset code conversion rule to generate a second candidate adversarial code corresponding to the initial adversarial code; if the analysis of the vulnerability detection model to be attacked does not satisfy the identifier mapping condition, determine the candidate adversarial code currently undergoing statement perturbation attack as the adversarial sample of the vulnerability detection model to be attacked.

[0107] In some examples of this embodiment, the attack module 33 is further configured to perform an iterative identifier perturbation attack on the vulnerability detection model to be attacked using the second candidate adversarial code according to the Monte Carlo tree search algorithm; in response to a judgment that the attack on the target second candidate adversarial code in the second candidate adversarial code is successful, the target second candidate adversarial code is determined as an adversarial sample of the vulnerability detection model to be attacked.

[0108] It should be noted that for other corresponding descriptions of the functional units involved in the device for generating adversarial samples based on vulnerability codes provided in this embodiment, please refer to Figure 1 and Figure 2 The corresponding description in will not be repeated here.

[0109] Based on the above Figure 1 to Figure 2 The method shown in the embodiment also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned Figure 1 to Figure 2 The method shown.

[0110] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.

[0111] Based on the above Figure 1 to Figure 2 The method shown, and Figure 5In order to achieve the above-mentioned purpose, the embodiment of the present application also provides an electronic device, such as a personal computer, a server, a laptop computer, a smart phone, an intelligent robot or other intelligent terminal, which includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 1 to Figure 2 The method shown.

[0112] Optionally, the above-mentioned physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.

[0113] Those skilled in the art will appreciate that the above-mentioned physical device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different arrangements of components.

[0114] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned physical device, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.

[0115] Based on the above Figure 1 to Figure 2 The present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the above-mentioned Figure 1 to Figure 2 The method shown, the method implemented when the computer program is executed by the processor can refer to the various embodiments of the present application, and will not be described in detail here.

[0116] Through the description of the above implementation methods, the technical personnel in this field can clearly understand that the present application can be implemented by means of software plus the necessary general hardware platform, or by hardware. Compared with the current prior art, the present embodiment converts the initial adversarial code according to the first preset code rule and / or the second preset code rule to obtain the first candidate adversarial code and the second candidate adversarial code. In the conversion process, a variety of conversion methods are considered, the semantic features and grammatical features of the code are effectively retained, and the flexibility of code transformation is improved. The identifier conversion of the initial adversarial code is performed separately to avoid modifying the vulnerability location information of the code, changing the original semantics of the code, and affecting the correctness of the grammar; based on the first candidate adversarial code, the code statement of the vulnerability detection model to be attacked is disturbed, and the code statement disturbance attack and the code identifier disturbance attack are combined, so that the adversarial sample generation method of the embodiment of the present application can be compatible with a variety of vulnerability detection models, and the Monte Carlo tree search algorithm is used to guide the generation of adversarial samples, so as to improve the quality of the generated adversarial samples and the generation efficiency of adversarial samples.

[0117] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0118] The above is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features applied for herein.

Claims

1. A method for generating adversarial samples based on vulnerability codes, characterized in that: include: Obtaining a vulnerability detection model to be attacked and an initial adversarial code corresponding to the vulnerability detection model to be attacked; Performing code statement conversion on the initial confrontation code according to a first preset code conversion rule to generate a first candidate confrontation code corresponding to the initial confrontation code; Performing an iterative statement perturbation attack on the vulnerability detection model to be attacked using the first candidate adversarial code according to a Monte Carlo tree search algorithm; In response to determining that the attack on a target first candidate adversarial code in the first candidate adversarial code is successful, the target first candidate adversarial code is determined as an adversarial sample of the vulnerability detection model to be attacked.

2. The method according to claim 1, characterized in that The step of obtaining the vulnerability detection model to be attacked and the initial confrontation code corresponding to the vulnerability detection model to be attacked includes: Obtain a vulnerability detection model to be attacked and a vulnerability test code corresponding to the vulnerability detection model to be attacked; The vulnerability testing code including the first preset code conversion rule and / or the second preset code conversion rule in the vulnerability testing code is determined as the initial confrontation code.

3. The method according to claim 2, characterized in that After obtaining the vulnerability detection model to be attacked and the vulnerability test code corresponding to the vulnerability detection model to be attacked, the method further includes: Determine the vulnerability line file information corresponding to the vulnerability test code; After determining the vulnerability test code including the first preset code conversion rule and / or the second preset code conversion rule in the vulnerability test code as the initial confrontation code, the method further includes: The vulnerability line contained in the initial confrontation code is located according to the vulnerability line file information to obtain the vulnerability line position information corresponding to the initial confrontation code.

4. The method according to claim 3, characterized in that Before performing an iterative statement perturbation attack on the vulnerability detection model to be attacked using the first candidate adversarial code according to the Monte Carlo tree search algorithm, the method further includes: Perform vulnerability detection on the initial adversarial code based on the vulnerability detection model to be attacked, and obtain an initial vulnerability detection result corresponding to the initial adversarial code; The step of using the first candidate adversarial code to perform an iterative statement perturbation attack on the vulnerability detection model to be attacked according to the Monte Carlo tree search algorithm includes: When it is determined that the initial vulnerability detection result is the same as the vulnerability row position information, an iterative statement perturbation attack is performed on the vulnerability detection model to be attacked using the first candidate adversarial code according to a Monte Carlo tree search algorithm.

5. The method according to claim 4, characterized in that After performing vulnerability detection on the initial confrontation code based on the vulnerability detection model to be attacked and obtaining an initial vulnerability detection result corresponding to the initial confrontation code, the method further includes: When it is determined that the initial vulnerability detection result is the same as the vulnerability row position information, the initial adversarial code is determined as an adversarial sample of the vulnerability detection model to be attacked.

6. The method according to claim 4, characterized in that When it is determined that the initial vulnerability detection result is the same as the vulnerability row position information, performing an iterative statement perturbation attack on the vulnerability detection model to be attacked using the first candidate adversarial code according to a Monte Carlo tree search algorithm, including: For each statement perturbation attack, when it is determined that the last statement perturbation attack failed, the first candidate adversarial code for the current statement perturbation attack is determined according to the Monte Carlo tree search algorithm; The first candidate adversarial code currently used in the statement perturbation attack is input into the vulnerability detection model to be attacked to perform vulnerability detection, and a current vulnerability detection result is obtained.

7. The method according to claim 6, characterized in that After inputting the first candidate adversarial code currently used for the statement perturbation attack into the vulnerability detection model to be attacked to perform vulnerability detection and obtaining the current vulnerability detection result, the method further includes: If the current vulnerability detection result is different from the vulnerability row position information, it is determined that the current statement perturbation attack is successful, and the first candidate adversarial code used in the current statement perturbation attack is determined as the adversarial sample of the vulnerability detection model to be attacked; If the current vulnerability detection result is the same as the vulnerability row position information, it is determined that the current statement perturbation attack has failed, and it is determined whether the number of attacks corresponding to the current statement perturbation attack has reached a preset attack threshold.

8. The method according to claim 7, characterized in that If the current vulnerability detection result is the same as the vulnerability row location information, the method further includes: When the number of attacks corresponding to the currently performed statement disturbance attack reaches a preset attack threshold, analyzing the vulnerability detection model to be attacked; When the number of attacks corresponding to the current sentence perturbation attack does not reach a preset attack threshold, the first candidate adversarial code to be used for the next sentence perturbation attack is determined according to the Monte Carlo tree search algorithm.

9. The method according to claim 8, characterized in that When the number of attacks corresponding to the currently performed sentence disturbance attack reaches a preset attack threshold, the method further includes: If the vulnerability detection model to be attacked satisfies the identifier mapping condition, the initial confrontation code is converted into a code identifier according to a second preset code conversion rule to generate a second candidate confrontation code corresponding to the initial confrontation code; If the analysis of the vulnerability detection model to be attacked does not satisfy the identifier mapping condition, the candidate adversarial code currently undergoing the statement perturbation attack is determined as the adversarial sample of the vulnerability detection model to be attacked.

10. The method according to claim 9, characterized in that If the vulnerability detection model to be attacked is analyzed to satisfy the identifier mapping condition, the initial confrontation code is converted into a code identifier according to a second preset code conversion rule to generate a second candidate confrontation code corresponding to the initial confrontation code, the method further includes: Performing an iterative identifier perturbation attack on the vulnerability detection model to be attacked using the second candidate adversarial code according to the Monte Carlo tree search algorithm; In response to determining that the target second candidate adversarial code in the second candidate adversarial code is successfully attacked, the target second candidate adversarial code is determined as an adversarial sample of the vulnerability detection model to be attacked.

11. A device for generating adversarial samples based on vulnerability codes, characterized in that: include: An acquisition module is configured to acquire a vulnerability detection model to be attacked and an initial confrontation code corresponding to the vulnerability detection model to be attacked; A generating module is configured to convert the initial confrontation code into a code statement according to a first preset code conversion rule, and generate a first candidate confrontation code corresponding to the initial confrontation code; An attack module is configured to perform an iterative statement perturbation attack on the vulnerability detection model to be attacked using the first candidate adversarial code according to a Monte Carlo tree search algorithm; The determination module is configured to determine the target first candidate adversarial code as an adversarial sample of the vulnerability detection model to be attacked in response to determining that the attack on the target first candidate adversarial code in the first candidate adversarial code is successful.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.

13. An electronic device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 10 is implemented.

14. A computer program product, comprising a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.

Citation Information

Cited By

  • Large visual language model vulnerability detection method and device based on security sensitive layer activation guidance and storage medium

    CN121302380A

  • Method, device and storage medium for detecting vulnerabilities of large visual language model based on security-sensitive layer activation guidance

    CN121302380B

  • Malicious code anti-disturbance method fusing abstract syntax tree and large language model

    CN122655072A