Training method of mirror detection model, mirror detection method and system
By training an image detection model using generative adversarial networks, the problem of identifying unknown vulnerabilities and malware in containerization migration using traditional image detection technologies has been solved, achieving efficient and accurate image security detection and ensuring image security.
Patent Information
- Application Number
- CN202310980508.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-04
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2043-08-04
AI Technical Summary
Existing image detection technologies are unable to effectively identify unknown vulnerabilities and malware, making it difficult to guarantee image security during containerization migration. Furthermore, traditional methods suffer from false positives, false negatives, and high maintenance costs.
A generative adversarial network is used to train a mirror detection model. A comprehensive analysis is performed using small sample data. By using the game between the generator and the discriminator to learn various attributes in the mirror, potential threats, including unknown vulnerabilities and malware, are identified.
It improves the accuracy and efficiency of image security detection, reduces the false negative and false positive rates, reduces maintenance costs, and ensures the security of images during containerization migration.
Smart Images

Figure CN116992290B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of network security technology, and more specifically, to a training method for an image detection model, an image detection method, and a system. Background Art
[0002] The rapid development of information technology has led to higher security requirements. For example, images obtained from public or private image repositories may contain malware or vulnerabilities (such as security vulnerabilities in the image's own software packages and dependencies). This can lead to attacks during the build, warehouse storage, and deployment phases, causing a large number of applications to crash. Therefore, there is a need to improve image security detection. Summary of the Invention
[0003] One of the objectives of the present disclosure is to propose a training method, an image detection method, and a system for an image detection model. Based on a generative adversarial network, the method comprehensively analyzes and learns various attributes in an image using small sample data to identify potential threats, thereby improving the accuracy and efficiency of security detection and ensuring the security of images.
[0004] According to a first aspect of the present disclosure, a method for training an image detection model is provided, comprising:
[0005] Obtaining image sample data and generating a training set based on the image sample data, wherein the image sample data includes normal image sample data without vulnerabilities, first abnormal image sample data with non-malicious vulnerabilities, and second abnormal image sample data with malicious vulnerabilities;
[0006] Inputting the training set into a generative adversarial network for training, and judging whether the discriminator and the generator of the generative adversarial network have reached a Nash equilibrium according to the output of the discriminator of the generative adversarial network;
[0007] When the discriminator and the generator do not reach Nash equilibrium,
[0008] The generator generates simulated mirror samples based on at least part of the mirror samples in the training set;
[0009] Update the training set based on the simulated mirror samples, and
[0010] Returning to the operation of inputting the training set into the generative adversarial network for training, and judging whether the discriminator and generator of the generative adversarial network have reached a Nash equilibrium according to the discriminator output of the generative adversarial network;
[0011] When the discriminator and the generator reach Nash equilibrium,
[0012] The training is completed, and an image detection model for detecting the presence of vulnerabilities in the image is generated based on the trained generative adversarial network.
[0013] In some embodiments, obtaining the image sample data and generating a training set based on the image sample data includes:
[0014] Scan image samples and collect running status data of image samples;
[0015] Performing at least one pre-processing operation of cleaning, noise reduction, and normalization on the image sample and its running status data; and
[0016] Feature extraction is performed on the running status data of the mirror sample to generate feature parts of at least part of the training samples in the training set.
[0017] In some embodiments, obtaining the mirror sample data and generating a training set based on the mirror sample data further includes:
[0018] Clustering the first image samples with unknown, non-malicious vulnerabilities in the scanned image samples to generate second image samples corresponding to each cluster obtained by clustering; and
[0019] Feature extraction is performed on the running state data of the second mirror sample to generate feature parts of some training samples in the training set.
[0020] In some embodiments, clustering the first mirror samples includes clustering the first mirror samples based on a K-Medoids clustering algorithm.
[0021] In some embodiments, performing feature extraction includes extracting at least one of system call features, file input / output features, network input / output features, scheduler features, and memory features.
[0022] In some embodiments, obtaining the mirror sample data and generating a training set based on the mirror sample data further includes:
[0023] Mark known vulnerabilities in the third image sample with known, non-malicious vulnerabilities among the scanned image samples.
[0024] In some embodiments, marking the known vulnerabilities in the third image sample includes marking at least one of a vulnerability name, a Common Vulnerabilities and Exposures (CVE) number, a vulnerability description, a vulnerability level, and affected software information.
[0025] In some embodiments, generating, by the generator, simulated image samples based on at least some of the image samples in the training set includes:
[0026] The generator generates simulated mirror samples based on at least part of the fourth mirror samples in the training set, wherein the fourth mirror samples are derived from the second abnormal mirror sample data.
[0027] In some embodiments, when the discriminator and the generator do not reach Nash equilibrium, inputting the training set into the generative adversarial network for training includes:
[0028] The discriminator is updated based on the K-Medoids clustering loss function.
[0029] In some embodiments, the discriminator includes a convolutional layer, a fully connected layer, and an activation function layer arranged in sequence.
[0030] In some embodiments, the image detection model includes a Softmax function layer provided at the output of the trained discriminator, and the output of the Softmax function layer is configured to indicate at least one of the following:
[0031] Whether there are vulnerabilities in the image;
[0032] Whether the vulnerability is malicious; and
[0033] Vulnerability categories for non-malicious vulnerabilities that exist.
[0034] According to a second aspect of the present disclosure, a training device for a mirror detection model is provided, comprising a first memory and a first processor, wherein the first memory stores instructions, and when the instructions are executed by the first processor, the operations of the training method described above are implemented.
[0035] According to a third aspect of the present disclosure, a mirror image detection method is provided, comprising:
[0036] Get the image to be tested;
[0037] The image detection model trained according to the training method described above is used to detect the presence of vulnerabilities in the image to be tested.
[0038] According to a fourth aspect of the present disclosure, there is provided an image detection apparatus, comprising a second memory and a second processor, wherein the second memory stores instructions, and when the instructions are executed by the second processor, the operations of the image detection method described above are implemented.
[0039] According to a fifth aspect of the present disclosure, there is provided a mirror image detection system, comprising:
[0040] A communication module configured to obtain image sample data, wherein the image sample data includes normal image sample data without vulnerabilities, first abnormal image sample data with non-malicious vulnerabilities, and second abnormal image sample data with malicious vulnerabilities;
[0041] a data processing module, the data processing module being communicatively connected to the communication module and configured to generate a training set based on the mirror sample data;
[0042] a training module, the training module being communicatively connected to the data processing module and configured to:
[0043] Inputting the training set into a generative adversarial network for training, and judging whether the discriminator and the generator of the generative adversarial network have reached a Nash equilibrium according to the discriminator output of the generative adversarial network;
[0044] When the discriminator and the generator do not reach Nash equilibrium,
[0045] The generator generates simulated mirror samples based on at least part of the mirror samples in the training set;
[0046] Update the training set based on the simulated mirror samples, and
[0047] Returning to the operation of inputting the training set into the generative adversarial network for training, and judging whether the discriminator and generator of the generative adversarial network have reached a Nash equilibrium according to the discriminator output of the generative adversarial network;
[0048] When the discriminator and the generator reach Nash equilibrium,
[0049] End of training; and
[0050] A model generation module is communicatively connected to the training module and is configured to generate an image detection model for detecting the presence of vulnerabilities in an image based on the trained generative adversarial network.
[0051] In some embodiments, the communication module is further configured to obtain an image to be tested;
[0052] The mirror detection system also includes:
[0053] A detection module is communicatively connected to the communication module and the model generation module, and is configured to detect the presence of vulnerabilities in the image to be tested based on the trained image detection model.
[0054] In some embodiments, the image detection system is configured to detect container images during a containerized migration process.
[0055] According to a sixth aspect of the present disclosure, a non-transitory computer-readable storage medium is provided, on which instructions are stored. When the instructions are executed by a processor, the operations of the training method or the mirror detection method as described above are implemented.
[0056] Other features and advantages of the present disclosure will become more apparent from the following detailed description of exemplary embodiments of the present disclosure with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0058] The present disclosure can be more clearly understood from the following detailed description with reference to the accompanying drawings, in which:
[0059] Figure 1 A schematic diagram illustrating a flow chart of a method for training a mirror detection model according to an exemplary embodiment of the present disclosure is shown;
[0060] Figure 2 A schematic diagram of a process for generating a training set according to a specific embodiment of the present disclosure is shown;
[0061] Figure 3 A schematic diagram of a process for generating a training set according to another specific embodiment of the present disclosure is shown;
[0062] Figure 4 A schematic diagram of the structure of a generative adversarial network is shown;
[0063] Figure 5 A schematic diagram showing a flow chart of a mirror image detection method according to an exemplary embodiment of the present disclosure is shown;
[0064] Figure 6 A schematic diagram showing a training method for a mirror image detection model and a mirror image detection method according to a specific example of the present disclosure is shown;
[0065] Figure 7 A block diagram of a training apparatus for a mirror detection model according to an exemplary embodiment of the present disclosure is shown;
[0066] Figure 8 A block diagram of a mirror image detection apparatus according to an exemplary embodiment of the present disclosure is shown;
[0067] Figure 9 A block diagram of a mirror image detection system according to an exemplary embodiment of the present disclosure is shown.
[0068] Note that in the embodiments described below, the same reference numerals are sometimes used in common across different drawings to denote the same parts or parts having the same functions, and their repeated descriptions are omitted. In this specification, similar reference numerals and letters are used to denote similar items. Therefore, once an item is defined in one drawing, it need not be further discussed in subsequent drawings.
[0069] To facilitate understanding, the positions, sizes, and ranges of various structures shown in the drawings and the like may not always represent actual positions, sizes, and ranges. Therefore, the disclosed invention is not limited to the positions, sizes, and ranges disclosed in the drawings and the like. Furthermore, the drawings are not necessarily drawn to scale, and some features may be exaggerated to illustrate details of specific components. DETAILED DESCRIPTION
[0070] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangements of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present disclosure unless otherwise specifically stated.
[0071] The following description of at least one exemplary embodiment is merely illustrative and is not intended to limit the present disclosure and its application or use. Those skilled in the art will appreciate that these are merely exemplary, rather than exhaustive, descriptions of exemplary methods that may be used to implement the present disclosure.
[0072] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered part of the specification.
[0073] With the rapid development of information technology, traditional virtualization deployment models may no longer meet business needs. To address this issue, a migration from virtualization to containerization is becoming a mainstream topic in security capability migration. In particular, ensuring image security during the migration process is paramount. Traditional containerized image security detection technology uses static analysis, inspection, and testing to detect known vulnerabilities or security issues in images. However, it is ineffective against unknown zero-day vulnerabilities and malware, and can suffer from both false positives and false negatives, resulting in high maintenance costs.
[0074] To solve the above problems, the present disclosure proposes a training method for an image detection model. This training method is based on a generative adversarial network and can comprehensively analyze and learn various attributes in an image through small sample data, identify possible threats, and thus improve the accuracy and efficiency of security detection and ensure the security of the image. In an exemplary embodiment of the present disclosure, Figure 1 and Figure 6As shown, the training method may include:
[0075] Step S110: Obtain mirror sample data, and generate a training set based on the mirror sample data.
[0076] Among them, the image sample data can be obtained during the containerized migration process, and by processing the image sample data, image samples (training samples) in the training set for training the image detection model can be generated. In some embodiments, the image sample data may include normal image sample data without vulnerabilities and abnormal image sample data with vulnerabilities, wherein the abnormal image sample data may include first abnormal image sample data with non-malicious vulnerabilities and second abnormal image sample data with malicious vulnerabilities. Here, malicious vulnerabilities may include cross-site request forgery (CSRF) attack vulnerabilities, cross-site scripting (XSS) attack vulnerabilities, etc. Figure 6 In the specific example shown, the first and third image samples can be derived from first abnormal image sample data, where the first image sample represents an image sample with an unknown, non-malicious vulnerability, and the third image sample represents an image sample with a known, non-malicious vulnerability. Furthermore, the fourth image sample can be derived from the second abnormal image sample data, i.e., an image sample with a malicious vulnerability. By generating a training set based on normal image sample data, the first abnormal image sample data, and the second abnormal image sample data, the training set can be made to cover as many image samples as possible with various vulnerability states, thereby improving the comprehensiveness and accuracy of image detection model training.
[0077] In some embodiments, as Figure 2 As shown, obtaining mirror sample data and generating a training set based on the mirror sample data may include:
[0078] Step S111 , scanning the image sample and collecting the running status data of the image sample.
[0079] For example, in the process of migrating security capabilities to containerization, Docker image samples can be scanned and the running status data of the corresponding Docker image samples can be collected. Docker can be used to deploy applications as portable, independent containers that can be run in the cloud or locally. When using Docker for deployment, applications and dependencies can be packaged into image samples. In some embodiments, the running status data of the image sample may include at least one of system call data, file input / output data, network input / output data, scheduler data, and memory data. It is understandable that in some other embodiments, the running status data may also include other data that can help identify the vulnerability status in the image, which is not limited here.
[0080] like Figure 2 and Figure 6 As shown, obtaining the mirror sample data and generating a training set based on the mirror sample data may also include:
[0081] Step S112: performing at least one pre-processing operation of cleaning, noise reduction, and normalization on the image sample and its running status data.
[0082] By preprocessing the image samples and their operating status data, interference can be eliminated, improving data consistency for subsequent processing, thereby helping to improve the quality of the generated training set, simplifying the training process of the image detection model, and improving the quality of the trained image detection model. It is understood that in some other embodiments, preprocessing the image samples and their operating status data may also include data screening, labeling, merging, conversion, or completion, etc., which are not limited here.
[0083] return Figure 2 , obtaining mirror sample data, and generating a training set based on the mirror sample data may also include:
[0084] Step S113 : performing feature extraction on the running status data of the mirror sample to generate feature parts of at least part of the training samples in the training set.
[0085] For example, feature extraction may include extracting at least one of system call features, file input / output features, network input / output features, scheduler features, and memory features. It is understandable that in other embodiments, other features may be extracted as needed, which is not limited here. The extracted features can reflect the running status of the image sample, and can then be used to determine the presence of vulnerabilities in the image sample, including whether there are vulnerabilities and the specific types of the vulnerabilities. For example, when there are vulnerabilities in the image sample, the system call features, file input / output features, network input / output features, scheduler features, memory features, etc., or a combination of certain features, may have abnormal values. Based on these abnormal values, information such as the specific type of the vulnerability can be analyzed.
[0086] Furthermore, considering that the first image samples with unknown, non-malicious vulnerabilities in the image samples have relatively little specific information about the vulnerabilities contained therein, in order to enhance the role played by these image samples in the subsequent training process, these first image samples can be clustered in advance to generate corresponding second image samples, and these second image samples that can typically reflect the characteristics of each cluster can be included in the training set, thereby helping to improve the training effect. Specifically, Figure 3 and Figure 6 As shown, obtaining the mirror sample data and generating a training set based on the mirror sample data may also include:
[0087] Step S114 : clustering the first image samples with unknown, non-malicious vulnerabilities in the scanned image samples to generate second image samples corresponding to the clusters obtained by clustering.
[0088] In some embodiments, the clustered second mirror samples can be used as additional training samples to expand the number of training samples in the training set. In other embodiments, the clustered second mirror samples can also replace the first mirror samples as training samples, which is not limited here.
[0089] Typically, the cluster center can be used as the corresponding second mirror sample for that cluster, representing the cluster. In some embodiments, the second mirror sample can be a subset of the first mirror sample, meaning that the clustered second mirror sample is selected from the first mirror sample and is a true mirror sample. In other embodiments, the second mirror sample may not be any first mirror sample itself, but rather a simulated mirror sample derived from multiple first mirror samples in the corresponding cluster.
[0090] In a specific example, if Figure 6 As shown, the first mirror sample can be clustered using the K-Medoids clustering algorithm. The K-Medoids clustering algorithm selects actual sample points as cluster centers, making it more robust to outliers and less susceptible to the influence of the initial value selection. Furthermore, the K-Medoids clustering algorithm has relatively low computational overhead when processing small datasets, helping to conserve computing resources.
[0091] Specifically, in the K-Medoids clustering algorithm, a set of first-mirror samples can be randomly selected as the center set (medoids); according to the principle of being closest to the medoids, the remaining first-mirror samples are assigned to the cluster represented by the current best medoids; in each cluster, the criterion function corresponding to each first-mirror sample is calculated, and the first-mirror sample corresponding to the minimum criterion function is selected as the new medoids; then, the above step of assigning the remaining first-mirror samples to the cluster represented by the current best medoids according to the principle of being closest to the medoids is returned, and the iteration is continued until all medoids no longer change or the maximum number of iterations has been reached. Here, the absolute error function can be used as the criterion function, and the criterion function is defined as follows:
[0092]
[0093] Where E represents the sum of the absolute errors between all sample points (first mirror sample) and the central cluster. The sample data set can be expressed as p = (p1, p2, ..., p i ), p iis the i-th data object in the sample data set, x i Represents cluster C i The center point (i=1,2,…,k).
[0094] In addition, the cost function of the K-Medoids clustering algorithm can be expressed as follows:
[0095] S=E2-E1,
[0096] Where E2 is the sum of the absolute errors between all sample points in the dataset and the new center point after cluster reassignment, E1 is the sum of the absolute errors between all sample points and the original center point before reassignment, and S represents the change in absolute error, which is used to detect whether clustering quality has improved. When S is less than zero, it indicates that the intra-cluster variance has decreased, the replacement is effective, and the new center point can be retained. When S is greater than or equal to zero, it indicates that clustering quality has not improved, and the new center point can be discarded, while the original center point can be retained. During the clustering process, until S remains greater than or equal to zero, it indicates that the optimal center point has been found and the clustering process can be terminated. As mentioned above, the center of the cluster obtained by clustering can be used as the second mirror sample.
[0097] It is understandable that the first image samples may also be clustered based on other clustering algorithms such as the K-Means algorithm to obtain second image samples representing each cluster, which is not limited here.
[0098] return Figure 3 , obtaining mirror sample data, and generating a training set based on the mirror sample data may also include:
[0099] Step S115 , performing feature extraction on the running status data of the second mirror sample to generate feature parts of some training samples in the training set.
[0100] Here, the characteristics of each cluster can be determined based on the running status data of the second image sample to help extract typical characteristics of the corresponding vulnerability type. Similarly, feature extraction can include extracting at least one of system call characteristics, file input / output characteristics, network input / output characteristics, scheduler characteristics, and memory characteristics. It is understood that in other embodiments, other characteristics can also be extracted as needed, and this is not limited here.
[0101] In some embodiments, obtaining image sample data and generating a training set based on the image sample data may also include marking known vulnerabilities in the scanned image sample with a third image sample having known, non-malicious vulnerabilities. By marking known vulnerabilities, it can help to better understand the characteristics of various known vulnerabilities, and it is also possible to filter out the first image sample as described above from the first abnormal image sample data to perform operations such as clustering in a targeted manner, thereby optimizing the training set and improving the training effect. In some embodiments, marking the known vulnerabilities in the third image sample may include marking at least one of the vulnerability name, Common Vulnerabilities and Exposures (CVE) number, vulnerability description, vulnerability level, and affected software information. It is understandable that in some other embodiments, other information of the known vulnerabilities may also be marked as needed, which is not limited here.
[0102] like Figure 1 and Figure 6 As shown, in an exemplary embodiment of the present disclosure, the training method of the mirror detection model may further include:
[0103] Step S120: input the training set into the generative adversarial network for training, and determine whether the discriminator and generator of the generative adversarial network have reached a Nash equilibrium based on the output of the discriminator of the generative adversarial network;
[0104] If the discriminator and generator do not reach Nash equilibrium, do the following:
[0105] Step S130, the generator generates simulated image samples based on at least part of the image samples in the training set;
[0106] Step S140, updating the training set according to the simulated mirror sample, and
[0107] Return to the operation of step S120;
[0108] When the discriminator and the generator reach Nash equilibrium, the following operations are performed:
[0109] Step S150 , ending the training, and generating an image detection model for detecting the presence of vulnerabilities in an image based on the trained generative adversarial network.
[0110] Among them, the Generative Adversarial Network (GAN) is a deep learning model based on unsupervised learning. It learns to produce fairly good outputs through the mutual game between the generator and the discriminator. Since the Generative Adversarial Network is based on unsupervised learning, it does not require the training samples in the training set to be labeled. In other words, it is not necessary to clearly identify the specific types of vulnerabilities that may be contained in the image samples, which can reduce the difficulty of preparing the training set. In addition, since the generator in the Generative Adversarial Network can generate simulated image samples to expand the training set, even with a small sample size, good training results can be achieved. The Generative Adversarial Network can learn the characteristics of various types of image samples, and then determine the existence of vulnerabilities in the image to be tested based on these characteristics, including whether there is a vulnerability, whether the existing vulnerability is a malicious vulnerability, and the specific vulnerability type.
[0111] Figure 4 The basic structure of a generative adversarial network is shown, wherein the generative adversarial network may include a generator 410 and a discriminator 420. In a specific example, as Figure 6 As shown, the discriminator 420 may include a convolutional layer, a fully connected layer, and an activation function layer arranged in sequence. However, it is understood that in other examples, the discriminator 420 may also have other structures. On the one hand, the generator 410 can be used to generate simulated data based on real input data, for example, by superimposing noise data on a fourth image sample containing a malicious vulnerability to generate a simulated image sample. Here, the training goal of the generator 410 is to generate simulated data that is difficult for the discriminator 420 to distinguish. On the other hand, the discriminator 420 can be used to determine whether the input data is real data or simulated data generated by the generator 410. Accordingly, the training goal of the discriminator 420 is to more accurately distinguish between real data and simulated data. As training progresses, when the generator 410 and the discriminator 420 reach a Nash equilibrium, each of them can achieve good performance. At this point, training can be terminated. The trained generator 410 can generate simulated data that approximates real data, and the trained discriminator 420 can effectively extract effective features of the input data, which can then be used to determine the type of the input data.
[0112] exist Figure 4 In the generative adversarial network shown, the feature distribution P of the real data is g The input is sent to the generator 410, which superimposes the real data and the noise data to generate the distribution P of the simulated data. Z (z). Where Z refers to the simulated data generated by the generator 410. The sample points in the simulated data can be expressed as {z(1),…,z(m)}. The simulated data generated by the generator 410 and the real data are input to the discriminator 420, and D(x; θ d) represents the proportion of real data in the total sample data. Among them, x represents the real data, θ d Denotes the learning parameters. D(x;θ d ) can be a number between 0 and 1, D(x; θ d ) is closer to 1, the more the discriminator 420 determines that the input data is real data, D(x; θ d ) is closer to 0, the more the discriminator 420 determines that the input data is simulated data. The generator 410 and the discriminator 420 continue to compete and make progress together, eventually reaching a Nash equilibrium, at which point the discriminator 420 cannot determine whether the input data is real data. The objective function of the generative adversarial network can be expressed as:
[0113]
[0114] Among them, E represents the mathematical expectation, P data (x) represents the distribution of real data, and the discriminant result obtained by inputting the real data into the discriminator 420 is logD(x). Z (Z) represents the distribution of the simulated data generated by the generator 410. The discrimination result obtained after the simulated data is input to the discriminator 420 is log(1-D(G(z))).
[0115] During the training process of the generative adversarial network, the training method for discriminator 420 is to fix generator 410, making D(G(z)) as small as possible and as insensitive to the judgment of discriminator 420 as possible, and D(x) as large as possible; while the training method for generator 410 is to fix discriminator 420 and make D(G(z)) as large as possible. Generator 410 and discriminator 420 constantly compete with each other, training alternately, and eventually reach a Nash equilibrium state. Generator 410 generates simulated data that can deceive discriminator 420 based on the characteristics of real data. At this point, taking the derivative of V(D, G), the discriminator output is 0.5, which means that discriminator 420 cannot distinguish between real data and simulated data. The specific formula is as follows:
[0116]
[0117] During training, if discriminator 420 and generator 410 fail to reach Nash equilibrium, generator 410 may generate simulated mirror samples based on at least a portion of the mirror samples in the training set to expand the training sample set. In one specific example, half of the mirror samples in the training set may be randomly selected and input into generator 410, so that through continuous learning, generator 410 outputs the same number of simulated mirror samples. It is understood that, as needed, other numbers of mirror samples may be selected from the training set and input into generator 410 to generate simulated mirror samples, without limitation herein.
[0118] Furthermore, in some embodiments, Figure 6 As shown, considering that the number of fourth image samples with malicious vulnerabilities is generally small, generator 410 can generate simulated image samples based on at least some of the fourth image samples to expand the number of training samples with malicious vulnerabilities and improve the detection effect of the image detection model. Alternatively, as needed, generator 410 can also generate simulated image samples based on other types of image samples, which is not limited here. The noise data input to generator 410 for superposition can be random, and generator 410 can include multiple hidden layers, and ultimately outputs simulated image samples with the same dimensions as the input image samples.
[0119] The training set can be updated based on the simulated image samples generated by generator 410. In some embodiments, during each iteration of training the generative adversarial network, the simulated image samples generated by generator 410 can be added to the training set to expand the training set. In other embodiments, during each iteration, the simulated image samples generated by generator 410 can also be used to replace at least some of the original training samples in the training set.
[0120] In addition, in some embodiments, during the training of the discriminator 420, in order to make it iterate along a meaningful gradient direction and improve the training efficiency, the discriminator 420 may be updated based on a clustering loss function or a clustering loss filter. In a specific example, Figure 6 As shown, when the discriminator 420 and the generator 410 have not reached Nash equilibrium, inputting the training set into the generative adversarial network for training may include updating the discriminator 420 based on the K-Medoids clustering loss function. By introducing the K-Medoids clustering loss function or the K-Medoids clustering loss filter into the training of the discriminator 420, it is helpful to timely update the discriminator 420 and continuously iterate along meaningful gradient directions, thereby finding more optimal parameter values and helping to improve training efficiency.
[0121] exist Figure 6In the specific example shown, in each cycle, it is possible to determine whether the discriminator and the generator have reached a Nash equilibrium by judging whether the output of the discriminator is 0.5. When the discriminator output is not 0.5, it indicates that the generative adversarial network needs to be optimized and the parameters of the discriminator and the generator need to be updated. The discriminator parameters can be updated more efficiently by introducing the K-Medoids clustering loss function. In addition, the generator also generates new simulated mirror samples and uses the generated simulated mirror samples as part of the training set for the next round of iterative training. In some embodiments, the number of iterations Limint can also be pre-set to control the computing resources that may be consumed by training. Among them, the number of iterations Limint can be adjusted according to the simulation results to achieve a Nash equilibrium between the discriminator and the generator within the number of iterations Limint.
[0122] As the training progresses, the performance of the discriminator 420 and the generator 410 can be optimized. When the discriminator 420 and the generator 410 reach Nash equilibrium, the training can be terminated. At this point, an image detection model for detecting the presence of vulnerabilities in the image can be generated based on the trained generative adversarial network. In a specific example, Figure 6 As shown, the image detection model can include a trained discriminator 420 and a Softmax function layer set at the output of the trained discriminator 420. The discriminator 420 can extract valid features from the image, and the output of the Softmax function layer can complete the classification based on the valid features extracted by the discriminator 420, that is, it is configured to determine the presence of vulnerabilities. Specifically, the presence of vulnerabilities can include information such as whether there are vulnerabilities in the image, whether the existing vulnerabilities are malicious vulnerabilities, and the vulnerability categories of non-malicious vulnerabilities.
[0123] According to another aspect of the present disclosure, a mirror image detection method is also proposed. Figure 5 As shown, the mirror detection method may include:
[0124] Step S510, obtaining the image to be tested; and
[0125] Step S520: Use the image detection model to detect the existence of vulnerabilities in the image to be tested.
[0126] Here, the image detection model can be trained using the training method described above. In some embodiments, the image to be tested can be input into the trained image detection model, and the Softmax function layer in the image detection model can output a value corresponding to the presence of a vulnerability. In a specific example, the output value of the Softmax function layer can be an integer such as 0, 1, or 2, which corresponds to different vulnerability categories.
[0127] exist Figure 6In a specific example, the image detection method can proceed as follows: When the iteration limit or Nash equilibrium is reached, a corresponding image detection model can be generated based on the trained discriminator. This image detection model can be used to determine the boundary characteristics between normal image samples and those with vulnerabilities or malicious vulnerabilities. Specifically, the Softmax function layer of the image detection model can output the corresponding classification results. Combined with the threshold determined for malicious vulnerability detection, it can achieve online, real-time monitoring of vulnerabilities or malicious attacks.
[0128] According to another aspect of the present disclosure, a training device for a mirror detection model is also proposed. In an exemplary embodiment of the present disclosure, Figure 7 As shown, the training device 700 may include a first processor 710 and a first memory 720. The first memory 720 stores instructions. When the instructions are executed by the first processor 710, the operations of the training method of the mirror detection model described above can be implemented.
[0129] According to another aspect of the present disclosure, a mirror image detection device is also proposed. In an exemplary embodiment of the present disclosure, Figure 8 As shown, the image detection apparatus 800 may include a second processor 810 and a second memory 820. The second memory 820 stores instructions. When the instructions are executed by the second processor 810, the operations of the image detection method described above may be implemented.
[0130] The first processor 710 and the second processor 810 may be the same or different processors, and the first memory 720 and the second memory 820 may be the same or different memories.
[0131] The processor can perform various actions and processes according to the instructions stored in the memory. Specifically, the processor can be an integrated circuit chip with signal processing capabilities. The above-mentioned processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The various methods, steps and logic block diagrams disclosed in the embodiments of the present disclosure can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc., which can be an X86 architecture or an ARM architecture, etc.
[0132] The memory stores executable instructions that, when executed by the processor, perform the training method or mirror detection method described above. The memory can be volatile memory or non-volatile memory, or can include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct memory bus random access memory (DRRAM). It should be noted that the memory of the methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0133] According to another aspect of the present disclosure, a mirror image detection system is also proposed, which can be used to perform the training method and / or mirror image detection method described above. In an exemplary embodiment of the present disclosure, Figure 9 As shown, the image detection system 900 may include a communication module 910 , a data processing module 920 , a training module 930 , and a model generation module 940 .
[0134] The communication module 910 can be configured to obtain image sample data, where the image sample data can include normal image sample data without vulnerabilities, first abnormal image sample data with non-malicious vulnerabilities, and second abnormal image sample data with malicious vulnerabilities. Furthermore, the communication module 910 can also be configured to obtain an image to be tested to facilitate subsequent vulnerability detection in the image.
[0135] The data processing module 920 may be communicatively connected to the communication module 910 and may be configured to generate a training set based on the mirror sample data.
[0136] The training module 930 can be communicatively connected to the data processing module 920 and can be configured to input the training set into the generative adversarial network for training and determine whether the discriminator 420 and the generator 410 of the generative adversarial network have reached a Nash equilibrium based on the output of the discriminator 420 of the generative adversarial network. The training module 930 can also be configured to, if the discriminator 420 and the generator 410 have not reached a Nash equilibrium, have the generator 410 generate simulated mirror samples based on at least a portion of the mirror samples in the training set, update the training set based on the simulated mirror samples, and return to the operation of inputting the training set into the generative adversarial network for training and determining whether the discriminator 420 and the generator 410 of the generative adversarial network have reached a Nash equilibrium based on the output of the discriminator 420 of the generative adversarial network. In addition, the training module 930 can also be configured to terminate training if the discriminator 420 and the generator 410 have reached a Nash equilibrium.
[0137] The model generation module 940 may be communicatively connected to the training module 930 and may be configured to generate an image detection model for detecting the presence of vulnerabilities in an image based on the trained generative adversarial network.
[0138] In some embodiments, as Figure 9 As shown, the image detection system 900 may further include a detection module 950. The detection module 950 may be communicatively connected to the communication module 910 and the model generation module 940, and may be configured to detect the presence of vulnerabilities in the image to be tested based on the generated image detection model.
[0139] In some embodiments, the image detection system 900 can be configured to detect container images during the containerized migration process to ensure the security of the migrated images. In a specific example, the image detection system 900 can detect the presence of vulnerabilities in images involved in the containerized migration process for security capabilities, so that vulnerabilities that affect the image security performance can be promptly addressed to ensure the security of the image.
[0140] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium is also proposed, on which instructions are stored. When the instructions are executed by a processor, the operations of the training method or the mirror detection method described above can be implemented.
[0141] The non-transitory computer-readable storage medium in the embodiments of the present disclosure may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory. It should be noted that the non-transitory computer-readable storage medium described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0142] The present disclosure also provides a computer program product, which may include instructions. When the instructions are executed by a processor, the operations of the training method or the mirror detection method described above can be implemented.
[0143] The instructions may be any set of instructions to be executed directly by one or more processors, such as machine code, or any set of instructions to be executed indirectly, such as a script. The terms "instructions," "application," "process," "steps," and "program" are used interchangeably herein. The instructions may be stored in object code format for direct processing by one or more processors, or as a script or collection of independent source code modules in any other computer language, including those interpreted on demand or compiled in advance. The instructions may include instructions that cause one or more processors to act as the various neural networks herein. The functions, methods, and routines of the instructions are explained in more detail elsewhere herein.
[0144] In the technical solution disclosed herein, a generative adversarial network (GAN) is used to comprehensively analyze and learn various attributes in an image using small sample data, thereby establishing an image detection model to identify potential threats in the image under test and improve the accuracy and efficiency of security detection. Specifically, the generator in the GAN can generate simulated image samples based on real image samples to expand the training set. Therefore, even with a small amount of data, sufficiently stable data features can be extracted to achieve good training results. For example, in some cases, the image samples used for training can include image samples without vulnerabilities, image samples with unknown vulnerabilities, image samples with unknown vulnerabilities processed by clustering, and image samples with known vulnerabilities, etc., with no restrictions on the location of the extracted image data packets. As an unsupervised learning method, the GAN can also reduce the reliance on labeled or tagged datasets, thereby further reducing the difficulty of dataset preparation. The trained GAN can learn the characteristics of various types of image samples, determine the boundary characteristics between normal images and images with vulnerabilities, and then realize real-time monitoring of malicious vulnerabilities based on the detection threshold of malicious vulnerabilities. In addition, in some cases, clustering algorithms such as K-Medoids clustering can be introduced into the training of generative adversarial networks to update the parameters in the network in a meaningful direction, thereby further improving training efficiency.
[0145] The words "left," "right," "front," "back," "top," "bottom," "up," "down," "high," "low," and the like, if any, in the specification and claims, are used for descriptive purposes and are not necessarily intended to describe invariant relative positions. It should be understood that the words so used are interchangeable under appropriate circumstances such that the embodiments of the present disclosure described herein, for example, are capable of operation in other orientations than those shown or otherwise described herein. For example, when the device in the figures is turned over, features previously described as "above" other features could now be described as "below" the other features. The device can also be otherwise oriented (rotated 90 degrees or in other orientations) and relative spatial relationships will be interpreted accordingly.
[0146] In the specification and claims, when an element is referred to as being "on," "attached," "connected," "coupled," or "in contact with," etc., another element, the element may be directly on, directly attached, directly connected, directly coupled, or directly in contact with the other element, or one or more intervening elements may be present. In contrast, when an element is referred to as being "directly" "on," "directly attached," "directly connected," "directly coupled," or "in direct contact with" another element, there will be no intervening elements. In the specification and claims, when a feature is arranged "adjacent" to another feature, it may mean that the feature has a portion that overlaps with the adjacent feature or a portion that is located above or below the adjacent feature.
[0147] As used herein, the word "exemplary" means "serving as an example, instance, or illustration," rather than as a "model" to be precisely copied. Any implementation described as exemplary is not necessarily to be construed as preferred or advantageous over other implementations. Furthermore, this disclosure is not to be bound by any expressed or implied theory presented in the technical field, background, summary, or detailed description.
[0148] As used herein, the term "substantially" is intended to encompass any minor variations due to design or manufacturing imperfections, device or component tolerances, environmental influences, and / or other factors. The term "substantially" also allows for deviations from a perfect or ideal condition due to parasitic effects, noise, and other practical considerations that may be present in actual implementations.
[0149] Additionally, terms such as "first," "second," and the like may also be used herein for reference purposes only and are not intended to be limiting. For example, the terms "first," "second," and other numerical terms referring to structures or elements do not imply a sequence or order unless the context clearly indicates otherwise.
[0150] It should also be understood that when the term “include / comprises” is used in this document, it indicates the presence of the specified features, integers, steps, operations, units and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, units and / or components and / or their combinations.
[0151] In this disclosure, the term "provide" is used in a broad sense to cover all ways of obtaining an object, and thus "providing an object" includes but is not limited to "purchasing", "preparing / manufacturing", "arranging / setting up", "installing / assembling", and / or "ordering" an object, etc.
[0152] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items. The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the present disclosure. As used herein, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
[0153] Those skilled in the art will appreciate that the boundaries between the above-mentioned operations are merely illustrative. Multiple operations can be combined into a single operation, a single operation can be distributed among additional operations, and operations can be performed at least partially overlapping in time. Moreover, alternative embodiments can include multiple instances of a particular operation, and the order of operations can be changed in various other embodiments. However, other modifications, variations, and replacements are also possible. Aspects and elements of all embodiments disclosed above can be combined in any manner and / or in combination with aspects or elements of other embodiments to provide multiple additional embodiments. Therefore, this specification and the accompanying drawings should be regarded as illustrative, not restrictive.
[0154] Although some specific embodiments of the present disclosure have been described in detail by way of examples, those skilled in the art will appreciate that the above examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. The various embodiments disclosed herein may be combined in any manner without departing from the spirit and scope of the present disclosure. Those skilled in the art will also appreciate that various modifications may be made to the embodiments without departing from the scope and spirit of the present disclosure. The scope of the present disclosure is defined by the appended claims.
Claims
1. A training method for a mirror detection model, characterized in that: The training method comprises: Obtaining image sample data and generating a training set based on the image sample data, wherein the image sample data includes normal image sample data without vulnerabilities, first abnormal image sample data with non-malicious vulnerabilities, and second abnormal image sample data with malicious vulnerabilities; Inputting the training set into a generative adversarial network for training, and judging whether the discriminator and the generator of the generative adversarial network have reached a Nash equilibrium according to the output of the discriminator of the generative adversarial network; When the discriminator and the generator do not reach Nash equilibrium, The generator generates simulated mirror samples based on at least part of the mirror samples in the training set; Update the training set based on the simulated mirror samples, and Returning to the operation of inputting the training set into the generative adversarial network for training, and judging whether the discriminator and generator of the generative adversarial network have reached a Nash equilibrium according to the discriminator output of the generative adversarial network; When the discriminator and the generator reach Nash equilibrium, The training is completed, and an image detection model for detecting the presence of vulnerabilities in the image is generated based on the trained generative adversarial network.
2. The training method according to claim 1, characterized in that Obtaining mirror sample data and generating a training set based on the mirror sample data includes: Scan image samples and collect running status data of image samples; Performing at least one pre-processing operation of cleaning, noise reduction, and normalization on the image sample and its running status data; and Feature extraction is performed on the running status data of the mirror sample to generate feature parts of at least part of the training samples in the training set.
3. The training method according to claim 2, characterized in that Obtaining mirror sample data and generating a training set based on the mirror sample data also includes: Clustering the first image samples with unknown, non-malicious vulnerabilities in the scanned image samples to generate second image samples corresponding to each cluster obtained by clustering; and Feature extraction is performed on the running state data of the second mirror sample to generate feature parts of some training samples in the training set.
4. The training method according to claim 3, characterized in that Clustering the first mirror samples includes clustering the first mirror samples based on a K-Medoids clustering algorithm.
5. The training method according to claim 2 or 3, characterized in that: Extracting features includes extracting at least one of system call features, file input / output features, network input / output features, scheduler features, and memory features.
6. The training method according to claim 2, characterized in that Obtaining mirror sample data and generating a training set based on the mirror sample data also includes: Mark known vulnerabilities in the third image sample with known, non-malicious vulnerabilities among the scanned image samples.
7. The training method according to claim 6, characterized in that Marking the known vulnerabilities in the third image sample includes marking at least one of a vulnerability name, a Common Vulnerabilities and Exposures (CVE) number, a vulnerability description, a vulnerability level, and affected software information.
8. The training method according to claim 1, characterized in that: Generating simulated mirror samples by the generator based on at least part of the mirror samples in the training set includes: The generator generates simulated mirror samples based on at least part of the fourth mirror samples in the training set, wherein the fourth mirror samples are derived from the second abnormal mirror sample data.
9. The training method according to claim 1, characterized in that When the discriminator and the generator do not reach Nash equilibrium, inputting the training set into the generative adversarial network for training includes: The discriminator is updated based on the K-Medoids clustering loss function.
10. The training method according to claim 1, characterized in that: The discriminator includes a convolutional layer, a fully connected layer and an activation function layer arranged in sequence.
11. The training method according to claim 1, characterized in that: The image detection model includes a Softmax function layer provided at the output of the trained discriminator, and the output of the Softmax function layer is configured to indicate at least one of the following: Whether there are vulnerabilities in the image; Whether the vulnerability is malicious; and Vulnerability categories for non-malicious vulnerabilities that exist.
12. A training device for a mirror detection model, characterized in that: The training device includes a first memory and a first processor, wherein the first memory stores instructions, and when the instructions are executed by the first processor, the operation of the training method according to any one of claims 1 to 11 is implemented.
13. A mirror image detection method, characterized in that: The mirror image detection method comprises: Get the image to be tested; An image detection model trained by the training method according to any one of claims 1 to 11 is used to detect the presence of vulnerabilities in the image to be tested.
14. A mirror image detection device, characterized in that: The mirror image detection device includes a second memory and a second processor. The second memory stores instructions. When the instructions are executed by the second processor, the operation of the mirror image detection method according to claim 13 is implemented.
15. A mirror image detection system, characterized in that: The mirror detection system comprises: A communication module configured to obtain image sample data, wherein the image sample data includes normal image sample data without vulnerabilities, first abnormal image sample data with non-malicious vulnerabilities, and second abnormal image sample data with malicious vulnerabilities; a data processing module, the data processing module being communicatively connected to the communication module and configured to generate a training set based on the mirror sample data; a training module, the training module being communicatively connected to the data processing module and configured to: Inputting the training set into a generative adversarial network for training, and judging whether the discriminator and the generator of the generative adversarial network have reached a Nash equilibrium according to the discriminator output of the generative adversarial network; When the discriminator and the generator do not reach Nash equilibrium, The generator generates simulated mirror samples based on at least part of the mirror samples in the training set; Update the training set based on the simulated mirror samples, and Returning to the operation of inputting the training set into the generative adversarial network for training, and judging whether the discriminator and generator of the generative adversarial network have reached a Nash equilibrium according to the discriminator output of the generative adversarial network; When the discriminator and the generator reach Nash equilibrium, End of training; and A model generation module is communicatively connected to the training module and is configured to generate an image detection model for detecting the presence of vulnerabilities in an image based on the trained generative adversarial network.
16. The mirror image detection system according to claim 15, characterized in that: The communication module is further configured to obtain an image to be tested; The mirror detection system also includes: A detection module is communicatively connected to the communication module and the model generation module, and is configured to detect the presence of vulnerabilities in the image to be tested based on the trained image detection model.
17. The mirror image detection system according to claim 15 or 16, characterized in that: The image detection system is configured to detect container images during a containerized migration process.
18. A non-transitory computer-readable storage medium, characterized in that The non-transitory computer-readable storage medium stores instructions, which, when executed by a processor, implement the operations of the training method according to any one of claims 1 to 11 or the mirror detection method according to claim 13.
Citation Information
Patent Citations
Dynamic and static combined in-container CPU vulnerability attack program detection method
CN109858239A
Method for optimizing XSS detection model to defend against countermeasure attacks based on reinforcement learning
CN112311733A