Network intrusion detection enhancement method based on diffusion model
By introducing a diffusion model into the network intrusion detection model, synthesis of virtual samples and diversified adversarial samples, the problems of data imbalance and insufficient generalization capabilities are solved, and the detection performance and adversarial defense capabilities of the model are significantly improved.
Patent Information
- Application Number
- CN202411799270.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-03-14
AI Technical Summary
The existing network intrusion detection model has poor defense effects due to data imbalance and insufficient generalization capabilities, especially when facing confrontational attacks, it cannot effectively identify unseen confrontation samples.
The network intrusion detection enhancement method based on diffusion model is adopted to synthesize high-quality virtual samples and diversified adversarial samples through diffusion model, and enhance the training data set and adversarial sample set, thereby improving the detection performance and defense capabilities of the model.
The virtual samples and adversarial samples generated by the diffusion model are significantly improved, and the detection accuracy and adversarial defense capabilities of the intrusion detection model are better than traditional data augmentation methods.
Smart Images

Figure CN119628932A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to machine learning and network security technology, and in particular to an intrusion detection enhancement technology based on synthetic sample expansion. Background Art
[0002] With the rapid development of Internet technology, network security issues are becoming increasingly prominent. As an important means to ensure network security, network intrusion detection systems monitor and identify potential security threats and protect computer systems from attacks. Most intrusion detection systems use machine learning models to distinguish normal traffic from attack traffic. However, in practical applications, intrusion detection systems still face many challenges. Normal traffic and abnormal traffic in the network are usually unbalanced, and the traffic of each attack category in the abnormal traffic is also unbalanced, resulting in the intrusion detection model trained based on an unbalanced data set. The accuracy cannot meet the actual requirements, especially for categories with a small number of samples. The misjudgment rate is high. There are a large number of adversarial attacks on intrusion detection systems in the network. Through adversarial samples with slight perturbations, the intrusion detection system makes prediction errors, achieving the effect of network attacks. Although the intrusion detection system based on machine learning models has strong learning ability, its generalization is still not strong, and it cannot effectively identify adversarial attack samples, especially unseen adversarial samples.
[0003] To solve these problems, researchers have proposed data augmentation techniques to expand the training set, thereby enhancing the accuracy and generalization of network intrusion detection systems. The main data augmentation methods include: oversampling technology, sample synthesis technology based on variational autoencoders, and sample synthesis technology based on generative adversarial networks. The synthetic minority oversampling technique (SMOTE) interpolates minority class samples in the feature space to generate synthetic samples to solve the problem of data imbalance. The sample synthesis method based on the conditional variational autoencoder (CVAE) generates virtual samples by learning the potential representation of the data to expand the training set. The conditional generative adversarial network (CGAN) consists of a generator and a discriminator. The generator tries to generate samples that are as real as possible, while the discriminator tries to distinguish between real samples and synthetic samples. Through adversarial training, CGAN can synthesize high-quality virtual samples for expanding the training set. Although data augmentation using methods such as SMOTE, CVAE, and CGAN can alleviate the data shortage and data imbalance problems to a certain extent, the fidelity and diversity of synthetic data generated by these methods are not high due to the complexity, high latitude, and nonlinear correlation of features of real network data. In addition, GAN-based methods often encounter the problem of mode collapse. These defects cause the prediction accuracy of detection models enhanced by these methods to be greatly reduced in real complex environments, and they cannot truly defend against network intrusions. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a network intrusion detection enhancement method that can synthesize high-quality training samples and diversified adversarial samples, thereby alleviating data imbalance and improving the generalization ability of the model, in view of the shortcomings of the existing network intrusion detection model, which leads to poor defense effect due to imbalanced training data and insufficient generalization ability.
[0005] The technical solution adopted by the present invention to solve the above technical problems is a network intrusion detection enhancement method based on a diffusion model, comprising the steps of:
[0006] Training phase:
[0007] 1) Data preprocessing step: network traffic data of various types of network intrusion data and network traffic data without network intrusion data are converted according to data types and formed into data samples. The data samples are composed of network data features and labels. The labels are used to characterize the network intrusion types. Then, the network data features and labels are encoded to generate training sets.
[0008] 2) construct a diffusion model for synthesizing virtual samples;
[0009] 3) Diffusion data enhancement step: find the minority categories in the training set that cause the imbalance problem of network data in each category; input the data samples of the minority categories into the diffusion model, and the diffusion model synthesizes the virtual sample output of the minority category; add the virtual sample of the minority category to the training set;
[0010] 4) Diffusion adversarial enhancement step: Generate adversarial samples of network data features using the generator of the generative adversarial network, input the adversarial samples into the diffusion model, and the diffusion model synthesizes virtual sample outputs of the adversarial samples; the adversarial samples and virtual samples of the adversarial samples are combined to form an adversarial sample set;
[0011] 5) Intrusion detection model training step: basic enhancement training is performed on the neural network-based intrusion detection model to which the training set of virtual samples of minority categories is added, and the adversarial sample set containing virtual adversarial samples is input into the intrusion detection model that has completed the basic enhancement training for adversarial enhancement training;
[0012] Testing phase:
[0013] The network traffic data to be detected is preprocessed and then input into the trained intrusion detection model, which then outputs the network intrusion detection results.
[0014] The present invention gradually adds noise to the training data through a diffusion model, and then learns the denoising process to model the data distribution. Based on this, the present invention can enhance the training samples by synthesizing virtual samples, especially enhancing the categories with fewer samples, thereby solving the problem of low detection accuracy caused by sample imbalance. At the same time, the method can enhance adversarial samples, while maintaining the core features of adversarial samples, introduce a certain degree of change, synthesize more diverse adversarial samples, thereby enhancing the defense of the detection model against unseen adversarial samples.
[0015] Furthermore, a preferred diffusion model is provided, which gradually adds random noise to the input data, the random noise adopts adaptive nonlinear noise, and the noise level is dynamically adjusted according to time. By improving the existing diffusion model, it is suitable for intrusion detection data, and the data synthesis effect of the diffusion model is improved by adaptive nonlinear noise.
[0016] The diffusion process is expressed as:
[0017] Z t =Z0+σ(t)ε
[0018] Z0 is the input data, t is the current time, Z t is the diffusion result at time t, σ(t) is the adaptive nonlinear noise level, and ε is the random noise sampled from the standard normal;
[0019] σ(t)=σ1×exp(-γt)+σ min
[0020] γ is the decay rate, exp is the natural exponential function, σ min Represents the lower bound of the current noise level, and σ1 is the nonlinear value introduced by the cosine function:
[0021]
[0022] σ0 represents the initial noise level.
[0023] More specifically, the diffusion-based method adopted in the present invention is more stable in training. Due to its progressive denoising process, the model is not easy to fall into the local optimal solution and can explore more potential spaces, thus generating diverse and high-quality synthetic samples.
[0024] The beneficial effects of the present invention are: virtual data is synthesized for categories with a small number of samples through a diffusion model, the training data set is enhanced, the problem of data imbalance is solved, and thus the detection performance of the intrusion detection model is improved. By improving the adversarial training method, a diffusion model is used to generate more diverse adversarial samples, virtual adversarial samples are generated based on the adversarial samples, and the adversarial samples and virtual adversarial samples are used together for adversarial training, so that the intrusion detection model can obtain stronger defense capabilities after diffusion adversarial training. Verification on the intrusion detection data set shows that compared with the data enhancement methods commonly used in the industry, the present invention can obtain better data fidelity and diversity, while alleviating data imbalance, and improving the performance of the classification detection model. After enhancing the adversarial samples, the synthesized adversarial samples are more diverse, and the classification detection model after diffusion adversarial training can obtain stronger defense capabilities, which is better than only using adversarial training. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 This is the overall structure diagram of the intrusion detection enhancement method.
[0026] Figure 2 Schematic diagram of data synthesis based on diffusion model. DETAILED DESCRIPTION
[0027] The present invention discloses a network intrusion detection enhancement method based on a diffusion model, aiming to improve the performance of an intrusion detection system in a data imbalance and adversarial environment. The present invention generates high-quality training samples and diversified adversarial samples by introducing a diffusion model into network data, and applies them to an intrusion detection system to enhance the detection and defense capabilities of the system.
[0028] The intrusion detection system of the present invention includes data preprocessing, data enhancement, anti-data enhancement, and detection model. The system framework is as follows: Figure 1 shown.
[0029] The specific implementation steps are as follows:
[0030] Step 1: Data preprocessing: Preprocess the network traffic data to make it meet the requirements of the diffusion model and intrusion detection model for input data to improve the detection effect.
[0031] Step 1-1: Divide the data features in the dataset into integer, floating point, and categorical types according to data type. Convert integer and floating point types into numerical features to ensure data format consistency and avoid calculation errors or overflow problems. Convert categorical type features into binary features to prevent the model from misinterpreting categorical data as ordered data, which is convenient for subsequent processing.
[0032] Step 1-2: Feature and label encoding. To ensure that the input data meets the requirements of the model, it is necessary to perform appropriate encoding operations on all features and labels. For categorical features, use one-hot encoding or other suitable encoding schemes. For labels, select label encoding or appropriate encoding methods based on the specific application scenario.
[0033] Step 1-3: Use the MinMaxScaler method to normalize the numerical features in the data set to the interval [0,1] to eliminate the dimensional differences between different features and avoid some features having too much impact on the model due to their large numerical range, so as to improve the convergence speed and stability of the model.
[0034] Step 1-4: Feature association analysis and screening, calculate the Pearson correlation coefficient between each feature and the target label to measure the importance of the feature. According to the calculated correlation size, for example, set a threshold; screen out features with high influence, such as features greater than the predefined threshold; exclude those features with low correlation or no obvious contribution, and reduce the impact of irrelevant features on model performance. In this way, the feature set is streamlined and the model performance is improved. The preprocessed data set formed after feature selection is used as the real data set for subsequent adversarial generation, diffusion enhancement, and intrusion detection processes.
[0035] Step 2: Diffusion model construction
[0036] The diffusion model is a generative model that learns the original data distribution by gradually adding noise to the input samples and then learning the denoising process to generate data. A certain number of virtual samples are synthesized through the diffusion model to solve the problem of data imbalance or insufficient generalization. The diffusion model is divided into two stages: the forward noise introduction process, namely the diffusion process, and the reverse denoising and reconstruction process. The diffusion process gradually adds random noise to the data, and eventually the data becomes pure noise; the denoising process restores the original data distribution by learning how to gradually remove noise. The diffusion method adopted in the present invention is based on the TABSYN algorithm, which generates mixed types of tabular data through a diffusion-based model in the latent space. The specific model architecture is as follows Figure 2 As shown. The method includes the following steps:
[0037] Step 2-1: Word segmentation. Perform unique hot encoding on the categorical features in the input sample and convert each categorical feature into a vector representation; apply linear transformation to the numerical features and obtain the vector corresponding to the numerical features through the embedding lookup table created for the categorical features; the input sample is a combined vector containing numerical features and categorical features. Use N num and N cat Respectively represent the number of numerical columns and category columns in the data set. N = N num +N cat Each data sample consists of numerical features and categorical features, that is, x = [x num ,x cat ]. Assume that the i-th category feature has K i Candidate value, then First, the category features are converted into a d-dimensional vector by one-hot encoding:
[0038]
[0039] After processing, each row of data samples is represented as:
[0040]
[0041] Here Represents the total dimension of each row of data features. Then apply linear transformation to the numerical column, build an embedding lookup table for the category column, and map the category features to the embedding space through the embedding matrix:
[0042]
[0043] in, is the learnable parameter of the word segmenter, and After word segmentation, each data sample can be expressed as:
[0044]
[0045] Step 2-2: Encoding. Encode each data sample through the encoder, extract the mean and logarithmic variance of the latent variable, convert it into embedded information using the reparameterization method, and flatten it into a one-dimensional vector, thereby encoding the data sample into the original one-dimensional feature vector in the latent space, expressed as:
[0046]
[0047] Step 2-3: Diffusion. Diffusion is completed by gradually adding random noise to the original one-dimensional feature vector of the input sample in the latent space. The one-dimensional feature vector of each data sample in the latent space is input into the diffusion model. The diffusion model generates synthetic data similar to the original data by gradually adding random noise and learning the denoising process. The diffusion process can be expressed as:
[0048] Z t =Z0+σ(t)ε,ε~N(0,1)
[0049] Among them, Z0 is the input data, t is the current time, Z t is the diffusion result at time t, σ(t) is the adaptive nonlinear noise level, and ε is the random noise N(0,1) sampled from a standard normal with an expected value of 0 and a variance of 1.
[0050] In order to improve the quality and diversity of generated data, adaptive nonlinear noise is used to address the complexity of samples in network intrusion detection. The noise level is dynamically adjusted according to time as follows:
[0051] σ(t)=σ1×exp(-γt)+σ min
[0052] Where γ is the decay rate, exp is the natural exponential function, and σ min Represents the lower bound of the current noise level, and σ1 is the nonlinear value introduced by the cosine function:
[0053]
[0054] Here, σ0 represents the initial noise level of the diffusion process at time t=0.
[0055] The entire diffusion process is implemented by the denoising score matching method, and the specific loss function is:
[0056]
[0057] Where Z0 represents the initial embedding sampled from the true data distribution P(Z0), t represents the diffusion time sampled from the predefined time distribution P(t), and ∈ is the random noise sampled from the standard normal distribution. t is the diffuse embedding obtained by adding noise at time t, ∈θ (Z t ,t) is a model represented by a parameterized neural network θ, which is used to predict the noise added at time t. It means to find the expectation of all possible real data samples. To find the expectation of the distribution at time t, To find the expectation of random noise. This process ensures that the generated data is close to the real distribution and optimizes the generated effect.
[0058] Step 2-4: Denoising. The noise of the diffused one-dimensional feature vector is gradually removed to generate a synthetic embedding vector in the latent space that is similar to the original one-dimensional feature vector. The denoising process can be expressed as:
[0059]
[0060] Among them, Z t represents the embedding of the diffusion process at time t, represents the derivative of the noise level σ(t) with respect to time, Represents the logarithmic probability density of the current distribution with respect to Z t The gradient of t represents a standard Wiener process.
[0061] Step 2-5: Decode and reconstruct. Decode the denoised synthetic embedding vector in the latent space to obtain the reconstructed feature matrix. The input connector reconstructs the value of each column:
[0062]
[0063] in, are the learnable parameters of the decoder.
[0064] Step 2-6: Connection. Connect the decoded feature matrix to obtain the reconstructed virtual sample. Specifically, concatenate the values of each column after reconstruction to obtain the synthetic data sample, which can be expressed as:
[0065]
[0066] Step 3: Diffusion Data Augmentation
[0067] The diffusion model is used to synthesize virtual data for categories with fewer samples, alleviate the imbalance problem of data in each category in the training set, improve the model's detection ability for minority categories, and improve the model's overall detection performance, including the following steps:
[0068] Step 3-1: Analyze the data set to determine the minority categories that need data enhancement. By counting the number of samples of each category in the training set, calculate the proportion of each category in the data set; define the threshold of data imbalance according to the application scenario (such as setting a category as a minority category when the proportion is less than 10%, or using the ratio of the number of samples of the largest category to the target category as a measurement standard); screen the minority categories to be enhanced according to the set threshold.
[0069] Step 3-2: Synthesize virtual samples that are consistent with the feature distribution of the minority class through the diffusion model and add them to the original training set to expand the training set and alleviate the data imbalance problem;
[0070] Step 3-3: After the training set is expanded, the intrusion detection model is trained using the enhanced training set to improve the model's sensitivity to minority class samples and overall detection performance. Since the enhanced dataset can more comprehensively cover the feature distribution of minority classes, the model can more fully learn the patterns of these classes during training, thereby improving the recognition effect of minority classes.
[0071] Step 4: Diffusion against enhancement
[0072] Diffusion adversarial enhancement is an improved adversarial enhancement method that generates diverse adversarial samples through a diffusion model, so that the detection model can not only identify known adversarial samples, but also cope with more complex and diverse unseen adversarial samples, thereby enhancing the robustness and generalization ability of the detection model to cope with adversarial attacks. Specifically, it includes the following steps:
[0073] Step 4-1: Adversarial sample generation: Generate adversarial samples that mislead the model by adding specific perturbations to the original data. Common adversarial sample generation methods include Fast Gradient Sign Method (FGSM) and Adversarial Generative Adversarial Network (AdvGAN). Generate adversarial sample sets through these methods.
[0074] Step 4-2: Diffusion of adversarial samples: Diffusion enhancement of generated adversarial samples is performed through the diffusion model to generate diffusion adversarial samples, further enhancing the perturbation and diversity of adversarial samples. It includes two main steps:
[0075] Step 4-2-1: During the forward diffusion process, random noise is gradually added to the adversarial sample, so that the sample gradually tends to pure noise;
[0076] Step 4-2-2: In the reverse denoising process, the noise is gradually removed to generate diffusion adversarial samples.
[0077] Generate a richer set of adversarial examples through the diffusion model. These diffuse adversarial examples have greater uncertainty and diversity, avoiding overfitting of the model on a specific adversarial example set and improving the robustness and generalization of the detection model.
[0078] Step 4-3: Diffusion adversarial training: Add the diffusion adversarial sample set to the adversarial sample set, and perform diffusion adversarial training on the enhanced adversarial sample set to improve the detection model's adversarial defense capability.
[0079] Step 5: Detection model construction and intrusion detection
[0080] Since convolutional neural networks show high accuracy and low error rate in detecting abnormal network traffic, the present invention adopts a CNN model as an intrusion detection model, and its model structure is: input layer-convolution layer-convolution layer-pooling layer-Dropout-convolution layer-convolution layer-pooling layer-Dropout-flat layer-fully connected layer-output layer. The activation function adopts ReLU.
[0081] The original dataset, diffusion-enhanced dataset, and diffusion-adversarial-enhanced dataset are used to train the intrusion detection model. The cross entropy is used as the loss function during the training process:
[0082]
[0083] Among them, y i is the true label, is the probability predicted by the model.
[0084] Step 6: Detection experiment verification: The network intrusion detection dataset UNSW-NB15 is used for experimental verification.
[0085] Step 6-1: Diffusion enhancement effect. For binary classification tasks, the detection model trained with the diffusion enhancement dataset generally performs better than the original dataset. After diffusion enhancement, the overall accuracy of the detection model increased by 4.9%, the precision increased by 2.3%, and the recall increased by 4.7%. For multi-classification tasks, the overall performance of the detection model trained with the diffusion enhancement dataset is also better than the original dataset. After diffusion enhancement, the overall accuracy of the detection model increased by 1.5%, the precision increased by 0.9%, and the recall increased by 4.9%.
[0086] Step 6-2: Effect of diffusion adversarial enhancement. For the binary detection model, the overall accuracy on the adversarial test set increased from 77.5% of FGSM adversarial training to 87.8% of diffusion adversarial training, and from 84.6% of AdvGAN adversarial training to 87.3% of diffusion adversarial training. For the multi-classification detection model, the overall accuracy on the adversarial test set increased from 75.8% of FGSM adversarial training to 76.8% of diffusion adversarial training, and from 73.2% of AdvGAN adversarial training to 80.2% of diffusion adversarial training. Therefore, the defense effect of diffusion adversarial training is better than adversarial training.
Claims
1. A network intrusion detection enhancement method based on a diffusion model, characterized in that: The following steps are involved: Training phase: 1) Data preprocessing step: network traffic data of various types of network intrusion data and network traffic data without network intrusion data are converted according to data types and formed into data samples. The data samples are composed of network data features and labels. The labels are used to characterize the network intrusion types. Then, the network data features and labels are encoded to generate training sets. 2) construct a diffusion model for synthesizing virtual samples; 3) Diffusion data enhancement step: find the minority categories in the training set that cause the imbalance problem of network data in each category; input the data samples of the minority categories into the diffusion model, and the diffusion model synthesizes the virtual sample output of the minority category; add the virtual sample of the minority category to the training set; 4) Diffusion adversarial enhancement step: Generate adversarial samples of network data features using the generator of the generative adversarial network, input the adversarial samples into the diffusion model, and the diffusion model synthesizes virtual sample outputs of the adversarial samples; The adversarial samples and virtual samples of the adversarial samples are combined into an adversarial sample set; 5) Intrusion detection model training step: basic enhancement training is performed on the neural network-based intrusion detection model to which the training set of virtual samples of minority categories is added, and the adversarial sample set containing virtual adversarial samples is input into the intrusion detection model that has completed the basic enhancement training for adversarial enhancement training; Testing phase: The network traffic data to be detected is preprocessed and then input into the trained intrusion detection model, which then outputs the network intrusion detection results.
2. The method according to claim 1, characterized in that: The diffusion model gradually adds random noise to the input data. The random noise uses adaptive nonlinear noise, and the noise level is dynamically adjusted according to time. The diffusion process is expressed as: Z t =Z0+σ(t)ε Z0 is the input data, t is the current time, Z t is the diffusion result at time t, σ(t) is the adaptive nonlinear noise level, and ε is the random noise sampled from the standard normal; σ(t)=σ1×exp(-γt)+σ min γ is the decay rate, exp is the natural exponential function, σ min Represents the lower bound of the current noise level, and σ1 is the nonlinear value introduced by the cosine function: σ0 represents the initial noise level.
3. The method according to claim 2, characterized in that: The network traffic data is divided into integer, floating point and category types according to data type and converted into network data features; integer and floating point features are converted into numerical features and the data format is ensured to be consistent; category features are converted into binary features.
4. The method according to claim 3, characterized in that: The network data features and labels are encoded to meet the requirements of the diffusion model and intrusion detection model for input data. After that, the encoded network data features and labels are numerically normalized, and the Pearson correlation coefficients between all network data features and labels are calculated. The network data features and labels with larger Pearson correlation coefficients are selected and put into the training set.
5. The method according to claim 4, characterized in that: The specific sub-steps of the diffusion model receiving input samples to synthesize virtual samples are as follows, where the input samples are data samples or adversarial samples: The word segmentation sub-step: perform one-hot encoding on the categorical features in the input sample and convert each categorical feature into a vector representation; apply linear transformation to the numerical features and obtain the vector corresponding to the numerical features through the embedding lookup table created for the categorical features; the input sample is a combined vector containing numerical features and categorical features; Encoding sub-step: obtain the mean and logarithmic variance of the latent variable of the input sample, use the reparameterization method to obtain the embedding information of the latent variable, and flatten it into a one-dimensional vector, so as to encode the input sample into the original one-dimensional feature vector in the latent space; Diffusion process: random noise is gradually added to the original one-dimensional feature vector of the input sample in the latent space to complete the diffusion; Denoising process: gradually remove the noise from the diffused one-dimensional feature vector to generate a synthetic embedding vector in the latent space that is similar to the original one-dimensional feature vector; Decoding and reconstruction sub-step: Decoding the denoised synthetic embedding vector in the latent space to obtain a reconstructed feature matrix; Connection sub-step: connect the decoded feature matrices to obtain reconstructed virtual samples.
6. The method according to claim 1, characterized in that: The specific method to find out the minority categories that cause the imbalance problem of network data in each category in the training set is: count the proportion of data samples of each network intrusion type category in the total data samples, and regard the data samples of the network intrusion type category whose proportion is less than the preset threshold as the minority categories that need data diffusion.