Injection attack detection method based on multi-dimensional feature fusion and time optimization
Through multi-dimensional feature fusion and time optimization methods, an efficient injection attack detection model is built, which solves the problems of missed and false alarms in complex attack recognition by traditional WAF, and achieves efficient and real-time detection effects.
Patent Information
- Application Number
- CN202510646633.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-20
- Publication Date
- 2025-08-22
AI Technical Summary
Traditional rules-based WAFs are prone to missed or false alarms when facing complex and variant network attacks, while deep learning-based methods have high computational complexity and are difficult to meet real-time requirements. A detection method that can accurately identify complex injection attacks is urgently needed.
By deeply mining the multi-level feature information of network traffic, combining the optimization of the automated model structure, multi-dimensional feature fusion and time optimization methods are adopted, and a dual-channel deep sequence feature extractor, heterogeneous interaction module, adaptive feature attention mechanism and multi-scale hollow pooling are used to build an efficient injection attack detection model.
It improves the detection accuracy and recall rate of complex injection attacks, reduces dependence on fixed rules, meets the real-time requirements of WAF, reduces the computational complexity, and improves model development efficiency.
Smart Images

Figure CN120528645A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network security technology, and in particular to an injection attack detection method based on multi-dimensional feature fusion and time optimization, which is used for injection attack detection of a Web application firewall (WAF). Background Art
[0002] Web Application Firewalls (WAFs) are key components for protecting web applications from various network attacks, such as SQL injection and cross-site scripting (XSS). Traditional rule-based WAFs primarily rely on predefined attack signature libraries for pattern matching. While effective against known, simple attacks, this approach often becomes rigid and prone to missed detections when faced with increasingly complex, obfuscated, or mutated attack payloads. Furthermore, as attack techniques evolve, traditional WAF mechanisms may also face issues such as high false positive rates, poor adaptability, and low recognition rates for new attacks. On the other hand, while deep learning-based detection methods have potential for recognizing complex patterns, model design often relies on expert experience and can suffer from high computational complexity and significant inference latency, making them difficult to meet the real-time processing requirements of WAFs. Therefore, there is an urgent need for a new detection method that can accurately identify complex injection attacks while balancing detection efficiency and real-time performance. Summary of the Invention
[0003] To solve the above technical problems, the present invention deeply mines the multi-level feature information in network traffic and combines it with automatic model structure optimization to improve the accuracy and robustness of injection attack detection and optimize the reasoning efficiency of the model to meet real-time requirements.
[0004] The present invention relates to an injection attack detection method based on multi-dimensional feature fusion and time optimization, comprising:
[0005] S100: Data reception and preprocessing: receiving network traffic data to be tested, including the URL, header, or body of an HTTP request; performing necessary cleaning and normalization processing;
[0006] S200: Multidimensional feature extraction; using a dual-channel deep sequence feature extractor to extract both character-level fine-grained features and subword-level high-level semantic features from preprocessed data; this extractor is based on a multi-layer Transformer encoder architecture, where each layer includes a self-attention mechanism and a feedforward network;
[0007] S300: Heterogeneous feature interaction and fusion: Between feature extraction levels, the hidden state representations from the character channel and subword channel are fused through the heterogeneous interaction module; the features output by the multi-layer Transformer are fused within and / or between layers to obtain fused features;
[0008] S400: Adaptive feature weighting: Applying the adaptive feature attention mechanism to weight the fused multi-layer features to obtain weighted features, highlighting the feature contributions of important layers and spatial locations;
[0009] S500: Multi-scale feature capture: Using the multi-scale dilated pooling module, dilated convolution operations with different dilation rates and kernel sizes are applied to the weighted features in parallel, followed by an optional pooling operation to capture attack patterns of different lengths and distances, and the results are concatenated or integrated.
[0010] S600: Attack classification and discrimination; the fixed-length feature vector obtained by the final processing is input into a classifier consisting of at least one fully connected layer, and the probabilities of each predefined category are output through the Softmax activation function. The predefined categories include: normal traffic, SQL injection, XSS injection, and RCE injection; and the discrimination is completed.
[0011] Optionally, the dual-channel deep sequence feature extractor in S200 includes:
[0012] Character channel: treats the input data as a character sequence, extracts the initial character-level representation through the character embedding layer and the bidirectional gated recurrent unit Bi-GRU or similar sequence model, and then inputs it into the Transformer encoder;
[0013] Subword channel: Use a word segmentation algorithm such as WordPiece to split the input data into subword sequences, obtain the initial subword-level representation through the subword embedding layer, and then input it into the Transformer encoder.
[0014] Optionally, in S300, the heterogeneous interaction process includes: after each layer or several layers of the Transformer, using convolutional neural network CNN and residual connection to fuse the character-level and subword-level hidden states of the current layer to generate an enhanced representation and send it to the next layer; the intra-layer fusion process includes: after splicing the character-level and subword-level outputs of the same Transformer layer, performing dimensionality reduction fusion through one-dimensional convolution; the inter-layer fusion process includes: after splicing the character-level or subword-level outputs of all layers, performing fusion through one-dimensional convolution to capture cross-layer features.
[0015] Optionally, in S400, the adaptive feature attention mechanism is selected from at least one of the following: a channel attention module CAM, a spatial attention module SAM, a hybrid attention module CBAM, a Squeeze-and-Excitation attention module SE, an efficient channel attention module ECA-Net, a global attention module GE, or a skip connection without attention.
[0016] Optionally, the multi-scale dilated pooling module in S500 includes: using in parallel dilated convolution or ordinary convolution with different dilation rates and / or different convolution kernel sizes, and optional maximum pooling or average pooling operations.
[0017] Optionally, a time-sensitive neural architecture search (NAS) optimization step is performed during the model design phase, which includes:
[0018] S010: Define an optimization objective function that includes the model inference time complexity:
[0019] Ltotal=Lval+λ·C / Cmax,
[0020] Ltotal is the total loss function, which includes a composite objective of accuracy and inference time; Lval is the validation set loss, which measures the performance of the model on the validation set; λ is a balancing factor used to adjust the relative importance of accuracy loss and time complexity in the optimization objective; C is the model inference time complexity. According to the documentation, FLOPs is used to dynamically evaluate the computational overhead of the architecture; Cmax is the most complex FLOPs in the search space, which is used as a normalization factor;
[0021] S020: In a predefined search space containing candidate operations of feature fusion, attention mechanism and pooling module, a differentiable architecture search method such as PC-DARTS is used to optimize the architecture parameters (α, β, γ) to find the optimal model structure that can minimize the optimization objective function.
[0022] The present invention has significant advantages over the prior art:
[0023] (1) By fusing character-level and subword-level dual-channel features and combining multi-layer feature fusion with the attention mechanism, we can gain a more comprehensive and in-depth understanding of traffic content, effectively identify complex, variant, and even unknown injection attacks, and improve detection accuracy and recall.
[0024] (2) It has better recognition capabilities for attack payloads that have been obfuscated, encoded, or deformed, reducing dependence on fixed rules.
[0025] (3) In the embodiment, the introduction of time-sensitive neural architecture search (FPD) can significantly optimize the computational complexity of the model while ensuring high detection performance, shorten the inference time, and meet the real-time requirements of scenarios such as WAF.
[0026] (IV) In the embodiment, the application of NAS reduces the reliance on manually designed model structures and improves the efficiency of model development. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0028] Figure 1 The present invention provides a flow chart of an injection attack detection method.
[0029] Figure 2 2 is a schematic structural diagram of a dual-channel deep sequence feature extractor in an embodiment of the present invention.
[0030] Figure 3 It is a structural diagram of a heterogeneous interaction module in an embodiment of the present invention.
[0031] Figure 4 It is a structural diagram of a hybrid attention mechanism CBAM in an embodiment of the present invention.
[0032] Figure 5 This is a structural diagram of the multi-scale dilated pooling module in an embodiment of the present invention, with a convolution kernel size of 3, a step size of 1, and three different dilated convolutions with dilation rates of 1, 2, and 4 from left to right. DETAILED DESCRIPTION
[0033] To facilitate understanding of the present invention, the present invention will be described more fully below with reference to the accompanying drawings. The present invention can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present invention more thorough and comprehensive.
[0034] Reference Figure 1 , showing the process of an injection attack detection method based on multi-dimensional feature fusion and time optimization proposed by the present invention. The method mainly includes: data input and preprocessing, dual-channel feature extraction, feature fusion, adaptive attention, multi-scale pooling and final classification output; the specific process is as follows:
[0035] S010: Define an optimization objective function that includes the model inference time complexity:
[0036] Ltotal=Lval+λ·C / Cmax,
[0037] Ltotal is the total loss function, which includes a composite objective of accuracy and inference time. Lval is the validation set loss, which measures the model's performance on the validation set, such as classification accuracy. λ is a balancing factor used to adjust the relative importance of accuracy loss and time complexity in the optimization objective. C is the model inference time complexity, which, according to the documentation, uses FLOPs to dynamically evaluate the architecture's computational overhead. Cmax is the most complex FLOPs in the search space, used as a normalization factor. The design philosophy of this optimization objective function is to optimize the model's inference efficiency by introducing the time complexity constraint C / Cmax while ensuring model detection accuracy, thereby meeting the real-time requirements of the WAF. The λ parameter is used to balance accuracy and inference speed.
[0038] S020: In a predefined search space containing candidate operations for feature fusion, attention mechanism, and pooling module, a differentiable architecture search method is used to optimize the architecture parameters (α, β, γ) to find the optimal model structure that minimizes the optimization objective function.
[0039] S100: Receive network traffic data to be tested; specific process: input is the key part of the HTTP request, such as URL parameters, POST data; perform data cleaning, such as removing irrelevant spaces, decoding; decoding, such as URL decoding;
[0040] S200: Multidimensional feature extraction; Specific process: Input data is fed into a dual-channel feature extractor; Character channel: Input character sequence X char By embedding the matrix W e ∈R( |V|×768 ) is mapped into the embedding E char , E char Input bidirectional GRU, forward output H char,f ∈R len×384 , backward output H char,b ∈R len×384 , the two are spliced together to get H char,fb =[H char,f ,H char,b ]∈R len ×768 , as the initial input to the channel character Transformer encoder Subword channel: Use WordPiece to split the input into subword sequences and get the initial representation through a subword embedding layer such as a lookup table
[0041] and The input is respectively fed into a 12-layer parallel Transformer encoder. Each layer of Transformer contains 12 attention heads and the hidden layer dimension is 768. Its internal calculation follows the standard self-attention, residual connection, layer normalization and feedforward network process. Each layer outputs and
[0042] S300: Heterogeneous feature interaction and fusion; Specific process: between layers, for example, after the lth layer Transformer and before entering the l+1th layer, and Transform the dimensions through their respective fully connected layers and concatenate the transformed representations Input a one-dimensional convolution layer, with a convolution kernel size of 3 and padding of 1, keeping the sequence length unchanged, and obtain the fusion vector Using residual connections and LayerNorm, For each layer l, and Splice to Use a 1×1 one-dimensional convolution kernel Compressed to R len ×768 get All layers Stacked together to form the final feature tensor Or you can output all the character layers After splicing, use one-dimensional convolution to fuse H char,fuse ; Perform similar operations on the subword layer to obtain H sub,fuse ; Use these two vectors or their combination;
[0043] S400: Adaptive feature weighting; specific process:
[0044] Apply the attention mechanism to the feature tensor X obtained in the previous step, and regard it as C = 12, H = len, W = 768; for example: CBAM: first apply channel attention CAM, perform maximum pooling and average pooling on the feature map X in the spatial dimensions (H, W), and obtain two C×1×1 vectors; these two vectors are passed through a shared multi-layer perceptron MLP, which contains a fully connected layer for dimensionality reduction and dimensionality increase. The dimensionality reduction rate r can be selected from 3, 4, and 6. The results are added and then passed through Sigmoid to obtain the channel weight M channel ;
[0045] M channel Multiply back to the original feature X;
[0046] Then, the spatial attention mechanism SAM is applied to perform maximum and average pooling on the channel-weighted features in the channel dimension C to obtain two 1×H×W images, which are then concatenated and passed through a convolutional layer and Sigmoid to obtain the spatial weight M. spatial , convolutional layer and Sigmoid kernel size 5 or 7;
[0047] Then M spatial Multiply back the features; ECA-Net: perform global average pooling on the feature map X to obtain the channel descriptor z; pass a one-dimensional convolution Conv1D(z,k) with a kernel size of k, k can be 5 or 7, and then pass Sigmoid to obtain the channel weight s; multiply s back to the original feature X;
[0048] S500: Multi-scale feature capture: The weighted feature X weighted Input this module. Apply multiple dilated convolutional layers in parallel: for example, use three convolutional layers with kernel size 3x3 and dilation rates of 6, 8, and 12 respectively; and three convolutional layers with kernel size 5x5 and dilation rates of 6, 8, and 12 respectively; it can also include ordinary convolutions with kernel size 3 or 5 and 1x1 convolutions for channel adjustment; concatenate the outputs of all parallel convolutional layers in the channel dimension Y i =Concat(Y i,1 ,…,Y i,N ), if the input is a multi-layer feature, then Y stack =Stack(Y1,…,Y 12 ); In order to obtain a vector of fixed length, cross-dimensional pooling may be performed, such as two average pooling AvgPool(AvgPool(AvgPool(Y stack )));
[0049] S600: Attack classification judgment: Finally, the dimension d final The feature vector Y is input into one or more fully connected layers; for example, a fully connected layer with an output dimension of 4 corresponds to normal, SQLi, XSS, and RCE, and is connected to the Softmax activation function to obtain the predicted probability of each category.
[0050] Time-sensitive architecture optimization: Automatically find the specific combination of operations used in feature fusion, attention, and pooling modules to make the model loss L on the validation set val As small as possible, while estimating the computational complexity of the model C(α, β, γ) by FLOPs does not exceed a certain threshold or is as low as possible; Optimization goal:
[0051]
[0052] Based on PC-DARTS, partial channel connection is used, that is, the mixing operation is only calculated on C / K channels and edge weights β(i,j) to stabilize and accelerate the search;
[0053] Adopt a two-level optimization strategy: min on the training set w L train The inner layer optimizes the network weight w, and the outer layer optimizes the architecture parameters α, β, γ on the validation set.
[0054]
[0055] Update w and (α, β, γ) alternately through gradient descent; after the search is completed, according to α (i,j) Select the best operation on each edge (i, j) It is also possible to prune edges based on β(i,j) to obtain an efficient model architecture for final deployment.
[0056] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for injection attack detection based on multi-dimensional feature fusion and time optimization, characterized in that: The process includes the following: S100: data reception and preprocessing; Receive network traffic data to be tested, including the URL, header, or body of the HTTP request; perform necessary cleaning and normalization processing; S200: Multidimensional feature extraction; using a dual-channel deep sequence feature extractor to simultaneously extract character-level fine-grained features and sub-word-level high-level semantic features from the preprocessed data; the dual-channel deep sequence feature extractor is based on a structure including a multi-layer Transformer encoder, where each layer includes a self-attention mechanism and a feedforward network; S300: Heterogeneous feature interaction and fusion: Between feature extraction levels, the hidden state representations from the character channel and subword channel are fused through the heterogeneous interaction module; the features output by the multi-layer Transformer are fused within and / or between layers to obtain fused features; S400: Adaptive feature weighting: Applying the adaptive feature attention mechanism to weight the fused multi-layer features to obtain weighted features, highlighting the feature contributions of important layers and spatial locations; S500: Multi-scale feature capture: Using the multi-scale dilated pooling module, dilated convolution operations with different dilation rates and kernel sizes are applied to the weighted features in parallel, followed by an optional pooling operation to capture attack patterns of different lengths and distances, and the results are concatenated or integrated. S600: Attack classification and discrimination; the fixed-length feature vector obtained by the final processing is input into a classifier consisting of at least one fully connected layer, and the probabilities of each predefined category are output through the Softmax activation function. The predefined categories include: normal traffic, SQL injection, XSS injection, and RCE injection; and the discrimination is completed.
2. The injection attack detection method based on multi-dimensional feature fusion and time optimization according to claim 1 is characterized in that: The dual-channel deep sequence feature extractor in S200 includes: Character channel: treats the input data as a character sequence, extracts the initial character-level representation through the character embedding layer and the bidirectional gated recurrent unit Bi-GRU or similar sequence model, and then inputs it into the Transformer encoder; Subword channel: Use the word segmentation algorithm to split the input data into subword sequences, obtain the initial subword-level representation through the subword embedding layer, and then input it into the Transformer encoder.
3. The injection attack detection method based on multi-dimensional feature fusion and time optimization according to claim 1 is characterized in that: In the S300, the heterogeneous interaction process includes: after each layer or several layers of the Transformer, using convolutional neural network CNN and residual connection to fuse the character-level and subword-level hidden states of the current layer to generate an enhanced representation and send it to the next layer; the intra-layer fusion process includes: after splicing the character-level and subword-level outputs of the same Transformer layer, performing dimensionality reduction fusion through one-dimensional convolution; the inter-layer fusion process includes: after splicing the character-level or subword-level outputs of all layers, performing fusion through one-dimensional convolution to capture cross-layer features.
4. The injection attack detection method based on multi-dimensional feature fusion and time optimization according to claim 1 is characterized in that: In S400, the adaptive feature attention mechanism is selected from at least one of the following: a channel attention module CAM, a spatial attention module SAM, a hybrid attention module CBAM, a Squeeze-and-Excitation attention module SE, an efficient channel attention module ECA-Net, a global attention module GE, or a skip connection without attention.
5. The injection attack detection method based on multi-dimensional feature fusion and time optimization according to claim 1 is characterized in that: The multi-scale dilated pooling module in S500 includes: using dilated convolution or ordinary convolution with different dilation rates and / or different convolution kernel sizes in parallel, and optional maximum pooling or average pooling operations.
6. The injection attack detection method based on multi-dimensional feature fusion and time optimization according to claim 1 is characterized in that: Before S100 is executed, the following process is also included: S010: Define an optimization objective function that includes the model inference time complexity: Ltotal=Lval+λ·C / Cmax, Ltotal is the total loss function, which includes a composite objective of accuracy and inference time; Lval is the validation set loss, which measures the performance of the model on the validation set; λ is a balancing factor used to adjust the relative importance of accuracy loss and time complexity in the optimization objective; C is the model inference time complexity, which uses FLOPs to dynamically evaluate the computational overhead of the architecture according to the documentation; Cmax is the most complex FLOPs in the search space, which is used as a normalization factor; S020: In a predefined search space containing candidate operations of feature fusion, attention mechanism and pooling module, a differentiable architecture search method is used to optimize the architecture parameters (α, β, γ) to find the optimal model structure that can minimize the optimization objective function.
Citation Information
Cited By
SQL injection prediction model training method and system and storage medium
CN121234215A