Automatic safety detection method based on machine learning

By applying machine learning models such as LSTM, GRU and Transformer in security detection systems to process complex log data, the false alarm and missed response problems of traditional security detection systems when facing complex attack chains are solved, and higher detection accuracy is achieved Sex and real-time.

CN119155066APending Publication Date: 2024-12-17赵琦民
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411134287.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2024-12-17

AI Technical Summary

Technical Problem

When traditional security detection systems face unknown attacks, complex attack chains or multi-level penetration, problems of high false alarm rates and missed alarm rates often occur, making it difficult to effectively detect complex cyber threats.

Method used

Using automated security detection methods based on machine learning, deep learning models such as LSTM, GRU, Transformer models and autoencoders are used to process massive complex log data, capture potential threat patterns, and achieve accurate detection of complex attack chains.

Benefits of technology

It significantly improves the accuracy and real-time nature of network security detection, reduces false alarms and missed alarm rates, enhances the detection capabilities of complex attack modes, and is suitable for enterprise-level network environments and scenarios with high security requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119155066A_ABST
    Figure CN119155066A_ABST
Patent Text Reader

Abstract

The invention discloses an automatic security detection method based on machine learning, and relates to the technical field of information security, and the method comprises the following steps: early-stage preparation: data collection and integration, data preprocessing and labeling, and data enhancement; model training: model selection and architecture design: LSTM, GRU and Transform model architecture selection, model training and verification, and model integration and optimization; and model use and maintenance: model deployment, user acceptance test, and production environment monitoring and maintenance. According to the method, a complex threat mode can be captured through the deep learning model, and misinformation and missing report are reduced. According to the method, mass data can be analyzed in real time, and potential threats can be found and responded in time. The model can continuously learn new threat modes as time goes on, and the long-term effectiveness of the system is improved. And the automatic detection process reduces the dependence on manual intervention, and improves the overall safety operation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information security technology, and specifically to an automated security detection method based on machine learning. Background Art

[0002] In traditional security detection systems, detection methods usually rely on predefined rules or signatures, which often have high false positive and false negative rates when facing unknown attacks, complex attack chains or multi-level penetration.

[0003] Therefore, automated security detection methods based on machine learning have become an urgent problem to be solved. Summary of the invention

[0004] The technical problem to be solved by the present invention is to provide an automated security detection method based on machine learning, which uses advanced machine learning models, especially long short-term memory networks (LSTM), gated recurrent units (GRU), Transformer models, and autoencoders, etc., to perform comprehensive automated security detection. These models can efficiently process and analyze massive amounts of complex log data from multiple sources, capture potential threat patterns through deep learning, and achieve accurate detection of various complex attack chains, thereby greatly improving the accuracy and real-time performance of network security detection.

[0005] To solve the above technical problems, the present invention provides a technical solution: an automated safety detection method based on machine learning, comprising the following steps:

[0006] S1. Preliminary preparation

[0007] (1) Data collection and integration: Collect data sources such as system logs, application logs, and network traffic;

[0008] (2) Data preprocessing and annotation: preprocess the integrated data, including removing redundant information and format conversion;

[0009] (3) Data enhancement: Implement data enhancement strategies, including generating more abnormal samples or simulating attack behaviors to enhance the model’s ability to identify abnormal behaviors;

[0010] S2. Model training

[0011] (1) Model selection and architecture design: Select LSTM, GRU, and Transformer model architectures;

[0012] (2) Model training and validation: Use TensorFlow or PyTorch to train the model and set the ratio of training set and validation set;

[0013] (3) Model integration and tuning: Improve detection accuracy through integrated learning methods;

[0014] S3. Model use and maintenance

[0015] (1) Model deployment: Deploy the model to the production environment and provide inference services using REST API or TensorFlow Serving;

[0016] (2) User acceptance testing: Perform acceptance testing in a production environment to verify the actual detection effect of the model and make necessary adjustments;

[0017] (3) Production environment monitoring and maintenance: Continuously monitor model performance and use Prometheus and Grafana tools to monitor model status in real time.

[0018] Furthermore, during data collection and integration in step S1, the collected data must be integrated and cleaned to ensure data consistency and integrity.

[0019] Furthermore, in step S1, data annotation is performed during data preprocessing and annotation to distinguish normal behavior samples from abnormal behavior samples.

[0020] Furthermore, during model training and verification in step S2, the model performance should be monitored in real time to prevent overfitting and adjust hyperparameters.

[0021] Furthermore, when performing model integration and tuning in step S2, anomaly detection is performed using an autoencoder for specific attack patterns.

[0022] Furthermore, when the model is deployed in step S3, the model should be deployed to the cloud, edge device or local server to adapt to different usage scenarios.

[0023] Furthermore, when performing production environment monitoring and maintenance in step S3, the model should be retrained and updated regularly to cope with new threat scenarios.

[0024] The present invention significantly enhances the detection capability of complex attack patterns through the following innovative methods:

[0025] Time Series Anomaly Detection:

[0026] The time series model based on LSTM and GRU can process continuous network logs, application logs and other time series data, and is particularly suitable for detecting scenarios such as consecutive failed login attempts, network traffic anomalies, and user behavior anomalies. The model learns the time dependency in the logs and captures subtle abnormal behaviors, thereby effectively detecting brute force attacks, DDoS attacks, and internal threats.

[0027] Complex pattern detection:

[0028] Complex pattern detection based on the Transformer model is suitable for dealing with complex attack patterns such as distributed attacks, advanced persistent threats (APTs), and multi-stage attack chains. Through its self-attention mechanism, the Transformer model can capture long-term correlations in large-scale, multi-source log data and identify attack chains across log sources. On this basis, this technology can effectively detect complex security threats such as DDoS attacks across multiple time periods and APT attacks triggered by phishing emails.

[0029] Unsupervised Anomaly Detection:

[0030] Unsupervised learning methods based on the Autoencoder model are particularly suitable for scenarios that lack fully labeled data. By learning the patterns of normal data, the autoencoder can detect abnormal data that cannot be well reconstructed. It is suitable for detecting new attacks, internal traffic anomalies, zero-day attacks, etc. By comparing the differences between input and reconstruction, this technology can identify attack patterns and potential threats that have never been seen before.

[0031] Multi-level attack chain detection:

[0032] Based on comprehensive detection technology of multiple models, this technology can detect abnormal behaviors in the attack chain at multiple levels of Web applications, WAF, firewalls and Web servers. Through cross-level log analysis, the model can identify the complete attack path from Web applications to the server, and detect and block complex attacks such as SQL injection, bypassing WAF, and privilege escalation in real time.

[0033] SIEM Platform Integration:

[0034] Based on the multi-log source anomaly detection of SIEM platform, this technology can integrate and analyze data from multiple log sources such as firewalls, hosts, applications, IDS, security devices, etc., and detect various security threats such as intranet penetration, malware propagation, abnormal access, etc. through the linkage analysis of machine learning models. Through the deep learning model built on the SIEM platform, comprehensive security protection can be achieved in complex network environments.

[0035] In general, the present invention can automatically extract and analyze complex threat patterns from massive log data through the adaptive learning of deep learning models, effectively reduce false positives and false negatives, and significantly improve the accuracy and efficiency of network security detection. The present invention is particularly suitable for scenarios with high security requirements such as enterprise-level network environments, multi-tenant cloud platforms, financial systems, and government networks.

[0036] The advantages of the present invention compared with the prior art are:

[0037] 1. Improve detection accuracy: Deep learning models can capture complex threat patterns and reduce false positives and negatives.

[0038] 2. Strong real-time performance: The present invention can analyze massive amounts of data in real time, and promptly detect and respond to potential threats.

[0039] 3. Strong adaptability: The model can continuously learn new threat patterns over time and improve the long-term effectiveness of the system.

[0040] 4. Reduce labor costs: The automated detection process reduces reliance on manual intervention and improves the efficiency of overall security operations. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 It is a flow chart of the preliminary preparation stage of the automated safety detection method based on machine learning of the present invention.

[0042] Figure 2 This is the mid-term model training process of the automated safety detection method based on machine learning of the present invention Figure 1 .

[0043] Figure 3 This is the mid-term model training process of the automated safety detection method based on machine learning of the present invention Figure 2 .

[0044] Figure 4 It is a flow chart of the use and maintenance of the later model of the automated safety detection method based on machine learning of the present invention. DETAILED DESCRIPTION

[0045] Various exemplary embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that unless otherwise specifically stated, the relative arrangement of components and steps, numerical expressions and numerical values ​​set forth in these embodiments do not limit the scope of the present invention.

[0046] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.

[0047] 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 as part of the specification.

[0048] In all examples shown and discussed herein, any specific values ​​should be interpreted as merely exemplary and not as limiting. Therefore, other examples of the exemplary embodiments may have different values.

[0049] Working principle of the present invention:

[0050] Model training process

[0051] 1. Preliminary preparation stage:

[0052] Data collection and integration: including the integration and cleaning of data sources such as system logs and network traffic logs.

[0053] Data preprocessing and annotation: Remove redundant information and annotate data to distinguish normal from abnormal behaviors.

[0054] Data enhancement: Improve the model's ability to identify abnormal behaviors by generating more abnormal samples or simulating attack behaviors.

[0055] 2. Mid-term model training stage:

[0056] Model selection and architecture design: Select the appropriate model architecture (such as LSTM, GRU, Transformer, autoencoder) based on the security goals.

[0057] Model training and validation: Use TensorFlow or PyTorch for training, monitor model performance in real time, and adjust hyperparameters to avoid overfitting.

[0058] Model integration and tuning: Improve detection accuracy and perform anomaly detection through integrated learning methods (such as voting and stacking).

[0059] 3. Later stage of model use and maintenance:

[0060] Model deployment: Deploy the model to the production environment and provide inference services.

[0061] User Acceptance Testing (UAT): Perform acceptance testing in a production environment to verify the actual detection effect of the model.

[0062] Production environment monitoring and maintenance: Continuously monitor model performance, and regularly retrain and update the model.

[0063] Safety assessment logic of formula and improved model

[0064] Formulas involved: For models involving time series data (such as LSTM, GRU), the following formulas are usually involved:

[0065] LSTM unit formula:

[0066] 1. Forget Gate:

[0067] f t =σ(W f ·[h t-1 ,x t ]+b f )

[0068] The forget gate controls the cell state C at the previous moment t-1 How many parts can be passed.

[0069] 2-input gate

[0070] i t =σ(W i ·[h t-1 ,x t ]+b i )

[0071] The input gate controls the input x at the current moment t and the hidden state h at the previous moment t-1 For cell status C t How many updates are there.

[0072] 3. Cell status update (candidate value)

[0073]

[0074] This formula calculates the candidate cell states Used to update the cell status at the current moment.

[0075] 4. Cell status update:

[0076]

[0077] The current cell state C t is the cell state C at the previous moment. t-1 Through the forget gate t Controlling the amount of forgetting and the state of candidate cells Through the input gate i t The amount of control update is jointly determined.

[0078] 5. Output gate:

[0079] o t =σ(W o ·[h t-1 ,x t ]+b o )

[0080] The output gate determines the cell state C t By tanh(C t ) will be output to the hidden state h t .

[0081] 6. Hidden state update:

[0082] h t =o t tanh(Ct )

[0083] The hidden state h at the current moment t The output gate o t The result of nonlinear transformation of the cell state is determined.

[0084] In summary, the process of LSTM can be described as follows: after the input is processed by the gate mechanism, it decides how to update the cell state and hidden state, so that the model can remember long-term information and gradually forget irrelevant information.

[0085] Cross-Entropy Loss is a commonly used loss function in machine learning, especially in classification tasks such as binary or multi-classification problems. It measures the difference between the probability distribution of the model output and the true distribution. The smaller the cross-entropy loss, the closer the probability distribution predicted by the model is to the true distribution, and the better the model performance.

[0086] 1. Definition of cross entropy loss function

[0087] For the binary classification problem, the cross entropy loss function is defined as follows:

[0088]

[0089] in:

[0090] NNN is the number of samples.

[0091] yiy_iyi is the true label (0 or 1) of the iii-th sample.

[0092] y^i\hat{y}_iy^i is the probability value predicted by the model that the iiith sample belongs to category 1, ranging from [0,1].

[0093] 2. Explanation in binary classification scenario

[0094] In the binary classification problem, the two parts of the cross entropy loss correspond to different situations:

[0095] When the true label yi=1y_i=1yi=1, the loss function mainly depends on the first term If the probability y^i\hat{y}_iy^i predicted by the model is close to 1 (i.e. correct classification), the value of this item will be close to 0; conversely, if y^i\hat{y}_iy^i is close to 0 (i.e. wrong classification), the value of this item will be large.

[0096] When the true label yi=0y_i=0yi=0, the loss function mainly depends on the second term -log(1-y^i)-\log(1-\hat{y}_i)-log(1-y^i). If the probability y^i\hat{y}_iy^i predicted by the model is close to 0 (i.e. correct classification), the value of this term will be close to 0; conversely, if y^i\hat{y}_iy^i is close to 1 (i.e. wrong classification), the value of this term will be large.

[0097] 3. Extension in multi-classification scenarios

[0098] For multi-classification problems (assuming there are CCC categories), the cross entropy loss function is defined as follows:

[0099]

[0100] in:

[0101] yicy_{ic}yic is the true label of the iii-th sample in category ccc (one-hot encoding, only one position is 1 and the rest are 0).

[0102] y^ic\hat{y}_{ic}y^ic is the probability predicted by the model that the iiith sample belongs to category ccc.

[0103] 4. Details in practical application

[0104] Numerical stability: In actual calculations, directly calculating log(y^i)\log(\hat{y}_i)log(y^i) or log(1-y^i)\log(1-\hat{y}_i)log(1-y^i) may cause instability due to floating-point precision. When y^i\hat{y}_iy^i is close to 0 or 1, taking the logarithm may produce an infinite value. To solve this problem, a slight adjustment is usually made to the probability value before calculation, such as limiting y^i\hat{y}_iy^i to the range of [∈,1-∈][\epsilon,1-\epsilon][∈,1-∈], where ∈\epsilon∈ is a very small positive number.

[0105] Softened labels: In some applications, the true label may not be completely 0 or 1, and the cross entropy loss can handle these "soft labels" for smoother and more generalized prediction tasks.

[0106] Safety assessment logic of formula and improved model

[0107] Formulas involved: For models involving time series data (such as LSTM, GRU), the following formulas are usually involved:

[0108] -LSTM unit formula:

[0109] \[f_t=\sigma(W_f\cdot[h_{t-1},x_t]+b_f)\]

[0110] \[i_t=\sigma(W_i\cdot[h_{t-1},x_t]+b_i)\]

[0111] \[\tilde{C}_t=\tanh(W_C\cdot[h_{t-1},x_t]+b_C)\]

[0112] \[C_t=f_t\ast C_{t-1}+i_t\ast\tilde{C}_t\]

[0113] \[o_t=\sigma(W_o\cdot[h_{t-1},x_t]+b_o)\]

[0114] \[h_t=o_t\ast\tanh(C_t)\]

[0115] The loss function of the autoencoder (reconstruction error):

[0116] \[L(x,\hat{x})=||x-\hat{x}||^2\]

[0117] Among them, \(x\) is the original input and \(\hat{x}\) is the reconstructed output.

[0118] Model security assessment logic: Based on the characteristics of each model, detailed description and assessment are given respectively:

[0119] For LSTM and GRU models, evaluate their ability to detect continuous abnormal behaviors (such as brute force cracking and DDoS attacks) and capture subtle anomalies through time series analysis.

[0120] For the Transformer model, its ability to detect complex patterns in scenarios across time periods and multiple data sources is evaluated, especially its performance in detecting distributed attacks and APT attacks.

[0121] For the autoencoder model, its ability to detect unknown attack patterns is evaluated, and zero-day attacks and new threats are identified through reconstruction errors.

[0122] Detailed explanation of the formula combined with the purpose of the model

[0123] LSTM

[0124] Detailed explanation of LSTM unit formula and model purpose

[0125] LSTM (Long Short-Term Memory) is designed to process and predict problems based on time series data, and it can effectively capture long-term dependencies.

[0126] 1. Forget Gate:

[0127] \[

[0128] f_t=\sigma(W_f\cdot[h_{t-1},x_t]+b_f)

[0129] \]

[0130] In LSTM, the forget gate determines how much of the cell state \(C_{t-1}\) at the previous moment is retained in the current state. This is crucial for long-term dependencies because the forget gate can filter out irrelevant historical information, thereby avoiding the problem of gradient disappearance caused by excessive accumulation of information.

[0131] 2. Input Gate:

[0132] \[

[0133] i_t=\sigma(W_i\cdot[h_{t-1},x_t]+b_i)

[0134] \]

[0135] The input gate controls how new information updates the cell state. Through this gate, LSTM can extract important information related to the prediction from the current input and store it in the cell state.

[0136] \[

[0137] \tilde{C}_t=\tanh(W_C\cdot[h_{t-1},x_t]+b_C)

[0138] \]

[0139] The candidate state \(\tilde{C}_t\) is compressed to between -1 and 1 through the \(tanh\) function to ensure the numerical stability of the cell state.

[0140] 3. Cell status update:

[0141] \[

[0142] C_t=f_t\ast C_{t-1}+i_t\ast\tilde{C}_t

[0143] \]

[0144] The update of the cell state combines old and new information, ensuring that LSTM can effectively learn and retain long-term sequence information, which is particularly critical for processing time series data such as continuous login attempts and user behavior patterns.

[0145] 4. Output Gate:

[0146] \[

[0147] o_t=\sigma(W_o\cdot[h_{t-1},x_t]+b_o)

[0148] \]

[0149] The output gate controls the output information of the cell state at the current moment. The final hidden state:

[0150] \[

[0151] h_t=o_t\ast\tanh(C_t)

[0152] \]

[0153] In model prediction, the hidden state \(h_t\) is the result of combining the memory of a long time series with important information at the current moment, which is suitable for applications such as DDoS attack detection that need to pay attention to historical behavior patterns.

[0154] Transformer

[0155] Transformer self-attention mechanism formula detailed explanation and model purpose

[0156] The Transformer model captures the dependencies between each element in the input sequence and other elements through the self-attention mechanism, which is very suitable for processing complex pattern detection across time periods or cross-source data, such as APT (advanced persistent threat) attacks.

[0157] 1. Calculate the attention score:

[0158] \[

[0159] Attention(Q,K,V)=softmax\left(\frac{QK^T}{\sqrt{d_k}}\right)V

[0160] \]

[0161] In the Transformer model, the dot product of the query matrix \(Q\) and the key matrix \(K\) determines the correlation between each query and all keys. Through this mechanism, the model is able to identify which parts of the sequence are related, which is crucial for identifying complex cross-source attack chains (such as distributed DDoS attacks).

[0162] 2. Softening score:

[0163] The Softmax function is applied to the dot product results, converting them into weights that represent the importance of different keys to the query. Through this process, the Transformer is able to focus on the most relevant sources of information in the sequence.

[0164] 3. Weighted summation:

[0165] Finally, by weighting and summing the value matrix \(V\) through these weights, the model can obtain an output that integrates all the important information in the sequence. This enables Transformer to effectively capture the associations between different steps in the attack chain and is suitable for complex scenarios such as APT detection.

[0166] Autoencoder

[0167] Detailed explanation of the autoencoder loss function and the purpose of the model

[0168] Autoencoders are unsupervised learning models suitable for detecting unusual patterns in networks, such as zero-day attacks, which often lack labeled data.

[0169] 1. Loss function definition:

[0170] The main goal of an autoencoder is to minimize the difference between the input data and the reconstructed data:

[0171] \[

[0172] L(x,\hat{x})=||x-\hat{x}||^2

[0173] \]

[0174] This loss function is used to measure the model's ability to reconstruct input data. For network traffic anomaly detection, when some data points are difficult to be reconstructed by the model, these data points are likely to be abnormal, indicating potential security threats.

[0175] 2. Loss calculation:

[0176] The loss is usually calculated using the mean squared error (MSE), which reflects the Euclidean distance between the input data and the reconstructed data. By minimizing the loss, the autoencoder is able to learn the patterns of normal data and thus raise an alarm when a high loss (abnormal data) is detected.

[0177] 3. Optimization process:

[0178] During the training process, the model gradually adjusts the weights through back propagation and optimization algorithms, ultimately minimizing the reconstruction loss of normal data. This mechanism makes the autoencoder particularly suitable for detecting new and unknown threats such as internal traffic anomalies and zero-day attacks.

[0179] RNN / LSTM

[0180] ###RNN / LSTM time series formula detailed explanation and model purpose

[0181] RNN and LSTM are designed for processing time series data and can capture the dependencies between previous and next time steps in the sequence. RNN and LSTM provide an effective solution for time series anomaly detection in network security (such as login behavior and traffic patterns).

[0182] 1.RNN time step recursive formula:

[0183] \[

[0184] h_t=\sigma(W_h\cdot x_t+U_h\cdot h_{t-1}+b_h)

[0185] \]

[0186] In RNN, the current hidden state \(h_t\) is determined by the current input \(x_t\) and the hidden state \(h_{t-1}\) at the previous moment. This formula is used to capture the dependencies between time steps in the input sequence and is suitable for detecting anomalies in continuous behavior patterns, such as multiple attempts in brute force attacks.

[0187] 2. Output layer formula:

[0188] \[

[0189] y_t=W_y\cdot h_t+b_y

[0190] \]

[0191] The output layer converts the hidden state \(h_t\) into the model's prediction result \(y_t\). In network security applications, this result can be a security assessment of a certain behavior, such as whether a certain operation is a potential attack behavior.

[0192] 3. Improvements of LSTM:

[0193] Based on RNN, LSTM solves the gradient vanishing problem in long-term dependencies by introducing cell state and gating mechanism. This makes LSTM perform well in tasks that require long-term memory, such as DDoS attack detection or long-term user behavior analysis.

[0194] Combined with Figure 1-3 The specific implementation process of the automated security detection method based on machine learning of the present invention is as follows:

[0195] Example 1: Time series anomaly detection based on RNN, LSTM, and GRU

[0196] When processing a large number of network logs or application logs, it is usually necessary to capture the time series features in the logs. RNN, LSTM, and GRU models are very suitable for processing such time series data and can identify potential security threats by learning the temporal dependencies in the logs.

[0197] Application scenarios include:

[0198] 1. Consecutive failed login attempts: Use the LSTM model to analyze login behavior over a period of time and identify brute force attacks.

[0199] 2. Network traffic anomalies: Use the GRU model to monitor continuous network traffic data and detect the occurrence of DDoS attacks.

[0200] 3. User behavior monitoring: Use the RNN model to analyze user operation logs and identify abnormal behavior patterns, such as internal threats.

[0201] Scenario 1: Application example of time series anomaly detection based on RNN, LSTM, and GRU

[0202] Application scenarios:

[0203] Consecutive failed login attempts:

[0204] Model: LSTM

[0205] Description: Use the LSTM model to analyze login behavior over a period of time and identify brute force attacks.

[0206] Network traffic abnormality:

[0207] Model: GRU

[0208] Description: Use the GRU model to monitor continuous network traffic data and detect the occurrence of DDoS attacks.

[0209] User behavior monitoring:

[0210] Model: RNN

[0211] Description: Use the RNN model to analyze user operation logs and identify abnormal behavior patterns, such as internal threats.

[0212] 1. Preliminary preparation stage

[0213] Data collection and integration:

[0214] Log type:

[0215] Login log: records the time, IP address, device information, etc. of each user login.

[0216] Network traffic log: records the source IP, destination IP, packet size, protocol type, etc. of network requests.

[0217] User operation log: records user operations in the system, such as file access, permission changes, etc.

[0218] Data fields:

[0219] Login log: Timestamp, UserID, IP, Device, Success / Failure.

[0220] Network traffic log: Timestamp, SourceIP, DestinationIP, Protocol, PacketSize.

[0221] User operation log: Timestamp, UserID, ActionType, Resource, Result.

[0222] Data annotation:

[0223] Normal data: successful login, normal network traffic, regular user operations.

[0224] Abnormal data: Login failures (especially consecutive failures), abnormally large traffic, abnormal user operations (such as unauthorized file access). Data quantity:

[0225] Normal data: no less than 100,000 records to ensure that the model can capture patterns of normal behavior.

[0226] Abnormal data: All potential threats should be covered, and as much real or simulated attack data as possible should be collected.

[0227] Data preprocessing and annotation:

[0228] Time synchronization: Ensure that all logs have the same timestamp.

[0229] Feature extraction: Extract meaningful features from logs, such as the number of login attempts based on time series, traffic peak detection, etc. Data enhancement: Simulate more abnormal behaviors through data generation technology, such as generating multiple brute force cracking attempt patterns.

[0230] 2. Mid-term model training stage

[0231] Model selection and architecture design:

[0232] Model Architecture:

[0233] LSTM: used to capture the temporal dependency of consecutive login failures.

[0234] GRU: Suitable for processing large amounts of continuous network traffic data.

[0235] RNN: Monitor user operation logs to capture potential internal threats.

[0236] Hyperparameter settings:

[0237] LSTM / GRU: 3-4 layers, 128-256 hidden units, and a learning rate of 0.001.

[0238] RNN: 2-3 layers, 64-128 hidden units, learning rate 0.001.

[0239] Model training and validation:

[0240] Training / validation split: 70% of the data is used for training, 20% for validation, and 10% as a test set.

[0241] Model training:

[0242] Use TensorFlow or PyTorch for model training.

[0243] Monitoring indicators: Use the validation set to monitor the model's loss and accuracy to ensure that the model is not overfitting.

[0244] Early stopping mechanism: If the validation loss does not decrease within 5 epochs, the training is stopped.

[0245] Debugging and model packaging:

[0246] debug:

[0247] Overfitting processing: increase the regularization parameter or use Dropout.

[0248] Training is unstable: try adjusting the learning rate or batch size.

[0249] Model packaging:

[0250] Use TensorFlow Serving or Flask to encapsulate the model and provide REST API services.

[0251] Model correction:

[0252] False positive handling: Adjust the decision threshold (such as 0.5 to 0.6), or add more features to improve the model's resolution.

[0253] False negative processing: increase abnormal samples in the training data, or use ensemble learning methods to improve the model's detection capabilities.

[0254] 3. Later model use and maintenance stage

[0255] Model deployment:

[0256] Deployment scenarios:

[0257] Cloud deployment: suitable for processing large amounts of real-time data, such as network traffic monitoring.

[0258] Local server deployment: suitable for user behavior monitoring in the enterprise intranet.

[0259] User Acceptance Testing (UAT):

[0260] Test content: Test through log data in actual scenarios to verify the model's detection effect on abnormal events, collect user feedback and adjust the model.

[0261] Production environment monitoring and maintenance:

[0262] Monitoring indicators: Continuously monitor the model's response time, memory usage, CPU load and other key indicators.

[0263] Model update: Regularly retrain the model to respond to new threat scenarios and maintain the effectiveness of the model.

[0264] Scenario 1: Time series anomaly detection based on RNN, LSTM, and GRU

[0265] 1. Preliminary preparation stage

[0266] Data collection and integration:

[0267] Login log: Timestamp, UserID, IP, Device, Success / Failure

[0268] Network traffic log: Timestamp, SourceIP, DestinationIP, Protocol, PacketSize

[0269] User operation log: Timestamp, UserID, ActionType, Resource, Result Data preprocessing and annotation:

[0270] Time synchronization: All log data is processed uniformly according to timestamps.

[0271] Feature extraction: Time series modeling of the number of failed logins.

[0272] Network traffic peak detection feature construction.

[0273] Time-dependent feature extraction of user operation sequences.

[0274] Data augmentation: Use techniques such as SMOTE to oversample outliers.

[0275] 2. Mid-term model training stage

[0276] Model selection and architecture design:

[0277] LSTM model: h t =σ(W xh x t +W hh h t-1 +b h )

[0278] GRU model: y t =W hy h t +b y

[0279] z t =σ(W z [x t ,h t-1 ])

[0280]

[0281] Training process:

[0282] Using the cross entropy loss function:

[0283]

[0284] Early stopping mechanism: If the loss of the validation set does not decrease within 5 epochs, stop training.

[0285] Model Evaluation:

[0286] Accuracy: 90%, false positive rate: 5%, false negative rate: 8%

[0287] 3. Later model use and maintenance stage

[0288] Model deployment: Deployed in a cloud environment, using TensorFlow Serving for inference services.

[0289] Production environment monitoring and maintenance:

[0290] Monitoring indicators: model response time, memory usage, CPU load

[0291] Model update frequency: quarterly or when new attack patterns are discovered.

[0292] Example 2: Complex pattern detection based on Transformer

[0293] For more complex data patterns, such as attacks across multiple time periods or distributed attack patterns, the Transformer model performs well. Its self-attention mechanism can capture data correlations over long time spans, making it ideal for detecting complex attacks.

[0294] Application scenarios include:

[0295] 1. Distributed attack detection: Use the Transformer model to analyze attack traffic from different sources and identify distributed denial of service (DDoS) attacks.

[0296] 2. Advanced persistent threats (APT): Capture low-frequency attack behaviors that exist in the network for a long time through cross-log source analysis.

[0297] 3. Multi-stage attacks: Analyze complex attack chains and identify penetration attacks that unfold in multiple stages in the network.

[0298] Scenario 2: Application example of complex pattern detection based on Transformer

[0299] Application scenarios:

[0300] Distributed Attack Detection:

[0301] Model: Transformer

[0302] Description: Use the Transformer model to analyze attack traffic from different sources and identify distributed denial of service (DDoS) attacks.

[0303] Advanced Persistent Threat (APT):

[0304] Model: Transformer

[0305] Description: Through cross-log source analysis, low-frequency attack behaviors that exist in the network for a long time can be captured.

[0306] Multi-stage attack:

[0307] Model: Transformer

[0308] Description: Analyze complex attack chains and identify penetration attacks that unfold in multiple stages within a network.

[0309] 1. Preliminary preparation stage

[0310] Data collection and integration:

[0311] Log type:

[0312] Distributed attack logs: collected across multiple data sources, such as network traffic logs from different servers.

[0313] APT logs: system logs, user behavior logs, and network traffic logs with a long span of time.

[0314] Multi-stage attack logs: Includes attack logs generated by penetration testing tools.

[0315] Data fields:

[0316] Distributed attack log: Timestamp, SourceIP, DestinationIP, Protocol, PacketSize, GeoLocation.

[0317] APT log: Timestamp, UserID, ActionType, Resource, Result, Duration.

[0318] Multi-stage attack log: Timestamp, AttackStage, SourceIP, DestinationIP, ActionType, Result.

[0319] Data annotation:

[0320] Normal data: normal daily operations such as logging in, file access, and regular network requests.

[0321] Abnormal data: including identified DDoS attacks, APT attacks, penetration attacks, etc.

[0322] Number of data:

[0323] Large-scale normal data (such as millions of records) and abnormal data should cover various complex attack modes as much as possible.

[0324] Data preprocessing and annotation:

[0325] Time synchronization: Ensure the consistency of all log times, especially data spanning multiple time periods.

[0326] Feature extraction: Extract key features related to attack patterns, such as attack frequency and cross-log correlation analysis.

[0327] Data augmentation: Generate more simulated data of complex attacks to ensure that the model can identify rare attack patterns.

[0328] 2. Mid-term model training stage

[0329] Model selection and architecture design:

[0330] Model Architecture:

[0331] Transformer: Self-attention mechanism is used to capture attack correlations across multiple time periods.

[0332] Hyperparameter settings:

[0333] The number of layers is 6-12, the number of attention heads is 8-16, the hidden units are 512-1024, and the learning rate is 0.0001-0.001.

[0334] Model training and validation:

[0335] Training / validation split: 70% of the data is used for training, 20% for validation, and 10% as a test set.

[0336] Model training:

[0337] Use large-scale distributed training frameworks (such as TPU or Horovod) to handle large amounts of data.

[0338] Monitoring indicators: Use the validation set to monitor the model's Precision, Recall, and F1-Score to ensure high precision and recall. Early stopping mechanism: Stop training when the performance on the validation set no longer improves.

[0339] Debugging and model packaging

[0340] debug:

[0341] Computing resource issues: Consider distributed computing and optimize parallel processing capabilities.

[0342] Model tuning: Improve the model's ability to capture complex patterns by adjusting the number of attention heads and layers.

[0343] Model packaging:

[0344] Use TensorFlow Serving or Docker to containerize models for easy cross-platform deployment.

[0345] Model correction:

[0346] Insufficient accuracy: Adjust the model architecture (increase the number of layers or attention heads), or further optimize through longer training time. Overfitting: Prevent model overfitting by increasing the size of the dataset or introducing regularization.

[0347] 3. Later model use and maintenance stage

[0348] Model deployment:

[0349] Deployment scenarios:

[0350] Cloud-based analysis of multiple data sources: Deploy models to cloud platforms that support large-scale data processing.

[0351] High-security scenario: Deployed in the intranet for advanced threat detection, such as APT detection.

[0352] User Acceptance Testing (UAT):

[0353] Test content: simulate distributed attacks and APT scenarios, test with actual cross-source log data, and verify the model's detection effect on complex attack patterns.

[0354] Production environment monitoring and maintenance:

[0355] Monitoring indicators: Continuously monitor the model's Throughput, Latency, Accuracy, etc.

[0356] Model update: The model is retrained regularly and kept up-to-date by introducing new attack samples.

[0357] Scenario 2: Complex pattern detection based on Transformer

[0358] 1. Preliminary preparation stage

[0359] Data collection and integration:

[0360] Distributed attack log: Timestamp, SourceIP, DestinationIP, Protocol, PacketSize, GeoLocation

[0361] APT log: Timestamp,UserID,ActionType,Resource,Result,Duration

[0362] Multi-stage attack log: Timestamp, AttackStage, SourceIP, DestinationIP, ActionType, Result

[0363] Data preprocessing and annotation:

[0364] Time synchronization: Ensure that timestamps of different data sources are consistent.

[0365] Feature extraction: Construction of attack correlation features across time periods.

[0366] Abnormal traffic analysis of different source IPs.

[0367] Data augmentation: Use data simulation tools to generate distributed attack samples.

[0368] 2. Mid-term model training stage

[0369] Model selection and architecture design:

[0370] Transformer Model:

[0371]

[0372] Among them, Q, K, and V are query, key, and value vectors respectively.

[0373] Training process:

[0374] Loss function: Use the cross entropy loss function.

[0375] Optimization method: Adam optimizer, learning rate is set to 0.0001.

[0376] Model evaluation: F1-Score: 92%, detection latency: 20 milliseconds, false positive rate: 3%

[0377] 3. Later model use and maintenance stage

[0378] Model deployment: Deployed in high-security scenarios, such as APT detection.

[0379] Production environment monitoring and maintenance:

[0380] Monitoring indicators: Throughput, Latency, Accuracy

[0381] Model update frequency: Updated every 6 months based on the frequency of APT attacks.

[0382] Example 3: Unsupervised Anomaly Detection Based on Autoencoder

[0383] In some cases, it is difficult to obtain a complete annotated dataset, and unsupervised learning methods can be used for anomaly detection. Autoencoders reconstruct the input data and identify abnormal data that cannot be reconstructed well.

[0384] Application scenarios include:

[0385] 1. Novel attack detection: Use autoencoder models to analyze log data and detect unseen attack patterns.

[0386] 2. Internal traffic monitoring: By learning the patterns of normal traffic within the network, the autoencoder can effectively identify abnormal internal traffic.

[0387] 3. Zero-day attack detection: Use autoencoders to identify zero-day attacks, which often do not appear in existing signature libraries.

[0388] Scenario 3: Unsupervised Anomaly Detection Based on Autoencoder

[0389] Application scenarios:

[0390] New attack detection:

[0391] Model: Autoencoder

[0392] Description: Use autoencoder models to analyze log data and detect unseen attack patterns.

[0393] Internal traffic monitoring:

[0394] Model: Autoencoder

[0395] Description: By learning the patterns of normal traffic within the network, the autoencoder can effectively identify abnormal internal traffic.

[0396] Zero-day attack detection:

[0397] Model: Autoencoder

[0398] Description: Use autoencoders to identify zero-day attacks that are not present in existing signature libraries.

[0399] 1. Preliminary preparation stage

[0400] Data collection and integration:

[0401] Log type:

[0402] Internal traffic log: records detailed data of internal network communications, such as traffic source and destination, packet size, etc.

[0403] Application log: records detailed information about application operations, including access time, user ID, operation type, etc.

[0404] System log: records various system operations and events, such as process startup, file access, etc.

[0405] Data fields:

[0406] Internal traffic log: Timestamp, SourceIP, DestinationIP, PacketSize, Protocol, Duration.

[0407] Application log: Timestamp, UserID, ActionType, Resource, Result.

[0408] System log: Timestamp, ProcessID, FileAccessed, OperationType, Result.

[0409] Data annotation:

[0410] Normal data: Regular internal traffic, application operations, and system events.

[0411] Anomalous data: Potential anomalies identified by comparing the input and reconstructed errors.

[0412] Number of data:

[0413] The amount of normal data should be large enough to ensure that the autoencoder can learn all normal behavior patterns.

[0414] As much abnormal data as possible, especially simulated data for zero-day attacks.

[0415] Data preprocessing and annotation:

[0416] Feature extraction: Extract statistical features of network traffic, such as packet size distribution, communication frequency, etc. Data enhancement: Use data enhancement technology to generate more abnormal samples and improve the detection ability of the model.

[0417] 2. Mid-term model training stage

[0418] Model selection and architecture design:

[0419] Model Architecture:

[0420] Autoencoder: It uses a symmetric encoder-decoder structure with the same input and output sizes.

[0421] Hyperparameter settings:

[0422] The encoder and decoder layers are 3-4, with 64-128 hidden units and a learning rate of 0.001.

[0423] Model training and validation:

[0424] Training / validation split: 80% of the normal data is used for training and 20% of the data is used for validation.

[0425] Model training:

[0426] Use TensorFlow or PyTorch for model training.

[0427] Monitoring indicators: mainly monitor the reconstruction error and model stability. Early stopping mechanism: stop training when the reconstruction error on the validation set no longer decreases significantly.

[0428] Debugging and model packaging:

[0429] debug:

[0430] Reconstruction error is too high: Increase model complexity or improve model performance by using more training data.

[0431] Model is unstable: Adjust the learning rate or batch size to ensure that the model converges stably.

[0432] Model packaging:

[0433] Encapsulated as a REST API service, it directly returns anomaly detection results by inputting log data.

[0434] Model correction:

[0435] False positive processing: Analyze high error samples, adjust the model structure or improve it by adding training data. False negative processing: Add abnormal data training samples, or try to use a more complex model structure.

[0436] 3. Later model use and maintenance stage

[0437] Model deployment:

[0438] Deployment scenarios:

[0439] Internal traffic monitoring: Deployed in the enterprise's internal network to monitor and detect abnormal internal traffic.

[0440] Zero-day attack detection: Applied in advanced security monitoring systems to detect unknown zero-day attacks.

[0441] User Acceptance Testing (UAT):

[0442] Test content: simulate internal network attacks, use zero-day attack samples for testing, and verify the model's detection effect on new threats. Production environment monitoring and maintenance:

[0443] Monitoring indicators: Monitor reconstruction error, response time, etc. to ensure the stability of the model in the actual environment.

[0444] Model update: New traffic patterns and attack samples are introduced regularly to keep the model effective and up-to-date.

[0445] 1. Preliminary preparation stage

[0446] Data collection and integration:

[0447] Internal traffic log: Timestamp, SourceIP, DestinationIP, PacketSize, Protocol, Duration

[0448] Application log: Timestamp, UserID, ActionType, Resource, Result

[0449] System log: Timestamp, ProcessID, FileAccessed, OperationType, Result

[0450] Data preprocessing and annotation:

[0451] Feature extraction: Extract statistical features of network traffic.

[0452] Time series feature construction of application operations.

[0453] Data augmentation: Generate more zero-day attack simulation data.

[0454] 2. Mid-term model training stage

[0455] Model selection and architecture design:

[0456] Autoencoder model:

[0457]

[0458] Among them, xix_ixi is the input data, and x^i\hat{x}_ix^i is the reconstructed data.

[0459] Training process:

[0460] Sparse autoencoder: Add sparsity regularization terms to improve the detection ability of the model.

[0461] Loss function: Total loss = reconstruction error + sparsity regularization term.

[0462] Model evaluation: false negative rate: 5%, reconstruction error threshold: 0.2, anomaly detection rate: 88%

[0463] 3. Later model use and maintenance stage

[0464] Model deployment: Deployed in the enterprise's internal network for internal traffic monitoring.

[0465] Production environment monitoring and maintenance:

[0466] Monitoring indicators: reconstruction error, response time

[0467] Model update frequency: every six months or when new traffic patterns are discovered.

[0468] Example 4: Detection of complex social engineering attack chains based on Transformer

[0469] Application scenario: multi-stage attack detection

[0470] Scenario description:

[0471] In a complex attack chain, attackers usually infiltrate in multiple stages, such as gaining initial access through spear phishing attacks, then gradually escalating permissions, moving laterally, and finally stealing data or destroying systems. In order to effectively detect and prevent such complex attack chains, it is necessary to analyze attack traces from multiple log sources and identify threats at an early stage of the attack chain.

[0472] 1. Preliminary preparation stage

[0473] Data collection and integration:

[0474] Log type:

[0475] Email Log: Records all emails entering and leaving the company network, paying special attention to attachments, links, etc.

[0476] System log: records operations such as user login, file access, and privilege escalation.

[0477] Network traffic log: Captures all network traffic for external communications, especially abnormal traffic and data packets.

[0478] Application logs: Monitor usage and abnormal operations of critical business applications.

[0479] Data fields:

[0480] Email log: Timestamp, Sender, Receiver, Subject, AttachmentName, LinkURL.

[0481] System log: Timestamp, UserID, ActionType, TargetResource, PrivilegeLevel.

[0482] Network traffic log: Timestamp, SourceIP, DestinationIP, Protocol, PacketSize, DataContent.

[0483] Application log: Timestamp, UserID, AppName, ActionType, Resource, Result.

[0484] Data annotation:

[0485] Normal data: daily email communications, system operations, network traffic, and application usage.

[0486] Abnormal data: covers data from each stage of the multi-stage attack chain, such as phishing emails, privilege escalation attempts, suspicious network communications, and abnormal application operations.

[0487] Number of data:

[0488] Normal data: At least hundreds of thousands of logs of each type to ensure that the model can learn complex normal operation patterns.

[0489] Abnormal data: It should include data from each attack stage, covering as many complex attack methods as possible.

[0490] Data preprocessing and annotation:

[0491] Time synchronization: unify the timestamps of all log sources to ensure accurate time series analysis across logs.

[0492] Feature extraction: Extract key features related to multi-stage attack chains, such as malicious scores of email attachments, system privilege escalation logs, abnormal outbound traffic, etc.

[0493] Data enhancement: Simulate more complex attack chains to ensure that the training data contains enough abnormal patterns.

[0494] 2. Mid-term model training stage

[0495] Model selection and architecture design:

[0496] Model Architecture:

[0497] Transformer: Uses self-attention mechanism to capture attack correlations across multiple time periods and log sources and identify complex attack chains.

[0498] Hyperparameter settings:

[0499] The number of layers is 6-12, the number of attention heads is 8-16, the hidden units are 512-1024, and the learning rate is 0.0001-0.001.

[0500] Model training and validation:

[0501] Training / validation split: 70% of the data is used for training, 20% for validation, and 10% as a test set.

[0502] Model training: Use TensorFlow or PyTorch for distributed training to handle large-scale datasets.

[0503] Monitoring indicators: Focus on the Precision, Recall, and F1-Score of the model on the validation set to ensure a high detection rate at each stage.

[0504] Early stopping mechanism:

[0505] If the performance indicators on the validation set no longer improve within a few rounds, training is stopped to prevent overfitting.

[0506] Debugging and model packaging:

[0507] debug:

[0508] Attention mechanism optimization: Adjust the number of attention heads and layers to improve the model's ability to capture attack chains across time periods.

[0509] Data balance: Ensure data balance at each attack stage to prevent the model from over- or under-representing an attack at a certain stage.

[0510] Model encapsulation: Encapsulate the model as a REST API service and deploy it in a production environment to detect and respond to attack chains in real time.

[0511] Model correction:

[0512] False positive handling: Adjust the model’s decision threshold to balance false positive rate and detection rate.

[0513] Improve the false positive problem by adding features or changing the model architecture.

[0514] False negative processing: Reduce false negatives by introducing more data sets or strengthening feature extraction strategies.

[0515] Use ensemble learning methods to enhance the robustness of the model.

[0516] 3. Later model use and maintenance stage

[0517] Model deployment:

[0518] Deployment scenario: Cloud analysis of multiple data sources: Deployed in the enterprise security operation center (SOC) or cloud platform to conduct centralized analysis of logs across the entire network.

[0519] Intranet: Deployed directly on the company's internal servers to monitor cross-departmental and cross-system attack chains in real time.

[0520] User Acceptance Testing (UAT):

[0521] Test content: By simulating a real multi-stage attack chain (such as from phishing emails to data leakage), the model's detection ability in the actual environment is verified.

[0522] Collect feedback and fine-tune the model’s performance at specific attack stages.

[0523] Production environment monitoring and maintenance:

[0524] Monitoring indicators:

[0525] Throughput: The number of logs processed by the model, ensuring that the system can handle massive amounts of data without delay.

[0526] Latency: The delay from log input to detection result, especially the reaction speed when facing complex attack chains.

[0527] Accuracy: The overall accuracy and detection rate at each attack stage to ensure the continued effectiveness of the model.

[0528] Model update: Regularly update the model, especially when new attack chain patterns emerge, to keep the model cutting-edge by introducing new data and retraining.

[0529] New attack patterns collected in security meetings and red-blue confrontation exercises are promptly added to model training to enhance the system's defense capabilities.

[0530] Example 5: Detection of complex social engineering attack chains based on Transformer

[0531] Scenario Example 2: Detection of complex attack chains based on vulnerability attacks

[0532] Application scenario: Multi-level attack detection from Web application to Web server

[0533] Scenario description: In a complex vulnerability attack chain, attackers may gradually penetrate the target system through multiple layers of network defense facilities. A typical attack path may involve web applications, web application firewalls (WAFs), external network firewalls, and ultimately web servers. In order to effectively detect and prevent such a complex attack chain, it is necessary to capture and analyze abnormal behaviors at each layer of defense facilities and detect potential threats in a timely manner.

[0534] 1. Preliminary preparation stage

[0535] Data collection and integration:

[0536] Log type:

[0537] Web application logs: record all web application requests and responses, especially SQL injection, XSS attacks, etc.

[0538] WAF log: records all attack attempts detected by the Web Application Firewall, including rejected and passed requests.

[0539] External network firewall log: monitors all access requests from the external network, especially abnormal access to specific ports and protocols.

[0540] Web server logs: Capture all requests entering the web server and their responses, paying special attention to abnormal requests and error codes.

[0541] Data fields:

[0542] Web application logs: Timestamp, ClientIP, RequestMethod, RequestURL, ResponseCode, UserAgent.

[0543] WAF log: Timestamp, ClientIP, RequestURL, AttackType, Block / Allow, SeverityLevel.

[0544] External network firewall log: Timestamp, SourceIP, DestinationIP, Protocol, Port, Action.

[0545] Web server log: Timestamp, ClientIP, RequestURL, ResponseTime, ResponseCode, ErrorLog.

[0546] Data annotation:

[0547] Normal data: normal web requests and responses, such as legitimate user access and regular web application operations.

[0548] Abnormal data: abnormal behaviors at all levels, such as SQL injection, cross-site scripting attacks, port scanning, privilege escalation attempts, etc.

[0549] Number of data:

[0550] Normal data: The number should be greater than 1 million to ensure that normal operating modes at all levels can be fully learned.

[0551] Abnormal data: includes attack samples at each layer, especially abnormal behaviors in complex attack chains such as Web application attacks, bypassing WAF, and bypassing external network firewalls.

[0552] Data preprocessing and annotation:

[0553] Time synchronization: unify the timestamps of all log sources to ensure accurate time series analysis of cross-level attack chains.

[0554] Feature extraction: Extract key features related to multi-level attacks, such as malicious request patterns, abnormal port access, server error codes, etc.

[0555] Data enhancement: Simulate more complex attack chains to ensure that the training data contains enough abnormal patterns, such as cross-level penetration attacks.

[0556] 2. Mid-term model training stage

[0557] Model selection and architecture design:

[0558] Model architecture: RNN / LSTM / GRU: for time series data, such as progressive attack behaviors (for example, SQL injection starting from the Web application layer, gradually passing through WAF and firewall, and reaching the attack chain of the Web server).

[0559] Transformer: Used for cross-layer log correlation analysis to capture complex behavior patterns in the attack chain.

[0560] Hyperparameter settings:

[0561] RNN / LSTM / GRU: 3-4 layers, 128-256 hidden units, and learning rate 0.001.

[0562] Transformer: 6-8 layers, 8 attention heads, 512 hidden units, and 0.0005 learning rate.

[0563] Model training and validation:

[0564] Training / validation split: 70% of the data is used for training, 20% for validation, and 10% as a test set.

[0565] Model training: Use TensorFlow or PyTorch for training to ensure that the model can identify complex attack chains across multiple layers.

[0566] Monitoring indicators: Monitor the Precision, Recall, and F1-Score of the model on log data at different levels to ensure high detection rates at all levels.

[0567] Early stopping mechanism: Stop training when the performance indicators on the validation set no longer improve to avoid overfitting of the model.

[0568] Debugging and model packaging:

[0569] debug:

[0570] Hierarchical correlation issues: Ensure that the model can correlate cross-level logs, such as by strengthening feature extraction or optimizing model structure to improve the model's cross-level detection capabilities.

[0571] Data imbalance problem: Use data augmentation or resampling techniques to solve the imbalance problem between normal and abnormal data in the training set.

[0572] Model packaging: Use TensorFlow Serving or Docker containerized deployment models to ensure efficient operation in different network environments.

[0573] Model correction:

[0574] False positive processing: Analyze the false positive log samples, adjust the model’s feature extraction method, or add more context information.

[0575] The accuracy of the model is improved by introducing more real attack samples and negative samples (i.e., samples that are normal but misclassified as abnormal).

[0576] False negative processing: Enhance the model's anomaly detection capabilities at all levels by tuning the model or increasing the weight of abnormal data.

[0577] Consider using ensemble models to improve detection rates at multiple levels of the attack chain.

[0578] 3. Later model use and maintenance stage

[0579] Model deployment:

[0580] Deployment scenarios:

[0581] Cross-layer defense analysis platform: Deployed in an integrated network security operation center (SOC), it centrally analyzes logs of web applications, firewalls, and servers to detect and respond to cross-layer attack chains in a timely manner.

[0582] Multi-level deployment: Independent deployment at each level such as Web application server, WAF, firewall, etc. for real-time monitoring and defense.

[0583] User Acceptance Testing (UAT):

[0584] Test content: Comprehensive testing is performed by simulating a real vulnerability attack chain (for example, from exploiting a Web application vulnerability to bypassing WAF, then bypassing the firewall and finally attacking the Web server).

[0585] Verify the model's detection capabilities on cross-level attack chains and further optimize the model through feedback.

[0586] Production environment monitoring and maintenance:

[0587] Monitoring indicators:

[0588] Across Layer Detection: The overall detection rate of the cross-layer attack chain ensures that the model can detect the entire attack from external to internal.

[0589] Throughput & Latency: The throughput and response time of log processing, especially the performance under high load.

[0590] Precision & Recall: Overall precision and recall, especially for abnormal behavior detection at each level.

[0591] Model update: As new vulnerabilities and attack methods emerge, the model is updated regularly to include the latest attack samples.

[0592] For newly discovered attack chains, the model is updated in a timely manner through a rapid response mechanism and retrained to maintain the forefront of defense.

[0593] Example 6: Anomaly detection of multiple log sources based on SIEM platform

[0594] Application scenario: security anomaly detection based on logs from multiple sources

[0595] Scenario description:

[0596] In a complex enterprise security environment, the SIEM (Security Information and Event Management) platform can centrally collect log data from multiple sources, including logs from firewalls, hosts, applications, IDS (Intrusion Detection System) and other security devices. By comprehensively analyzing these logs, various potential security threats can be effectively detected, such as intranet penetration, abnormal access, malware propagation, etc.

[0597] 1. Preliminary preparation stage

[0598] Data collection and integration:

[0599] Log type:

[0600] Firewall log: records all network traffic passing through the firewall, including source IP, destination IP, port, protocol and other information.

[0601] Host logs: including operating system event logs, user login logs, permission change logs, etc.

[0602] Application logs: include application operation logs, access logs, error logs, etc.

[0603] IDS logs: record all suspicious activities detected by the intrusion detection system, including attack attempts, scanning behaviors, malicious traffic, etc. Security device logs: include logs of antivirus software, anti-malware tools, data leakage prevention (DLP) systems, etc.

[0604] Other logs: such as database access logs, mail server logs, etc.

[0605] Data fields:

[0606] Firewall log: Timestamp, Source IP, Destination IP, Protocol, Port, Action, Bytes Transferred.

[0607] Host log: Timestamp, HostID, EventID, UserID, PrivilegeLevel, Action, Result.

[0608] Application log: Timestamp, AppID, UserID, ActionType, Resource, Result.

[0609] IDS log: Timestamp, SourceIP, DestinationIP, AttackType, Severity, ActionTaken.

[0610] Security device log: Timestamp, Device ID, Threat Type, Action Taken, Severity, Result.

[0611] Other logs: Extract relevant fields based on specific log types.

[0612] Data annotation:

[0613] Normal data: regular network access, system operation, application usage, etc.

[0614] Abnormal data: including intrusion attempts, malware activity, privilege escalation, unauthorized resource access, etc.

[0615] Number of data:

[0616] Normal data: Large-scale collection, usually no less than 500,000 logs of each log type to cover daily operation patterns.

[0617] Abnormal data: collected from various attack behaviors, such as network attacks, intranet penetration, malware propagation, etc., and fully annotated. Data preprocessing and annotation:

[0618] Time synchronization: synchronize timestamps for all logs to ensure the accuracy of cross-source analysis.

[0619] Feature extraction: Extract relevant features, such as the source and destination of network traffic, event type of the host, operation type of the application, etc. Data enhancement: Use simulation tools to generate more abnormal data and simulate a variety of potential attack behaviors.

[0620] 2. Mid-term model training stage

[0621] Model selection and architecture design:

[0622] Model Architecture:

[0623] Transformer / RNN: used for data association analysis across log sources and detection of complex attack patterns.

[0624] Autoencoder: Used for unsupervised anomaly detection to identify unlabeled potential threats in logs.

[0625] Ensemble learning model: combines the prediction results of multiple models to improve the overall detection accuracy and stability.

[0626] Hyperparameter settings:

[0627] Transformer / RNN: 6-8 layers, 8 attention heads, 512-1024 hidden units, and learning rate 0.0005.

[0628] Autoencoder: The encoder and decoder layers are 3-4, with 128 hidden units and a learning rate of 0.001.

[0629] Integrated model: Combine the weight settings of multiple models and adjust them according to the results of the validation set.

[0630] Model training and validation:

[0631] Training / validation split: 70% of the data is used for training, 20% for validation, and 10% as a test set.

[0632] Model training: Use TensorFlow or PyTorch for training, focusing on the correlation analysis of abnormal behaviors across log sources.

[0633] Monitoring indicators: Use the Precision, Recall, and F1-Score of the validation set to ensure good performance in all log types.

[0634] Early stopping mechanism: Stop training when the performance indicators of the validation set no longer improve to avoid overfitting.

[0635] Debugging and model packaging:

[0636] debug:

[0637] Log source correlation issues: Adjust the model structure or feature extraction method to ensure accurate correlation analysis across log sources.

[0638] Data imbalance problem: Resampling or data augmentation techniques can be used to solve the imbalance between normal and abnormal data in the training set.

[0639] Model packaging: Use Docker containerization to deploy the model to ensure that it can run efficiently on the SIEM platform.

[0640] Model correction:

[0641] False positive processing: Analyze the false positive log samples, adjust the decision threshold of the model or add more features.

[0642] Introduce more samples of normal operations to reduce the number of cases where they are misjudged as abnormal.

[0643] False negative processing: Increase the number of samples of abnormal behavior, adjust the model's learning strategy, and improve the model's detection ability in unlabeled abnormal data.

[0644] Use ensemble learning methods to combine the predictions of multiple models to reduce false negatives.

[0645] 3. Later model use and maintenance stage

[0646] Model deployment:

[0647] Deployment scenarios:

[0648] SIEM platform integration: The model is directly integrated into the SIEM platform to achieve real-time analysis and anomaly detection of multiple log sources.

[0649] Distributed deployment: Deploy the model independently at multiple key nodes (such as firewalls, IDS systems, and hosts) to perform local anomaly detection and early warning.

[0650] User Acceptance Testing (UAT):

[0651] Test content: By simulating various attack scenarios (such as network intrusion, internal threats, malware propagation, etc.), the model's detection capabilities in the actual environment are tested.

[0652] Collect user feedback and make optimization adjustments based on the model’s performance and feedback.

[0653] Production environment monitoring and maintenance:

[0654] Monitoring indicators:

[0655] Comprehensive anomaly detection rate: Ensure the anomaly detection rate of the model in multiple log sources.

[0656] Response time and processing power: The response speed and processing power of the monitoring model when processing a large amount of real-time logs.

[0657] Overall precision and recall: Regularly evaluate the precision and recall of your model in real-world settings, especially as new threats emerge.

[0658] Model update: Update the model regularly to maintain its effectiveness by introducing new attack samples and retraining.

[0659] When new attack patterns are discovered or new log sources appear, adjust the model's feature extraction and training strategies in a timely manner.

[0660] The present invention and its embodiments are described above, and such description is not restrictive. The drawings show only one embodiment of the present invention, and the actual structure is not limited thereto. In short, if ordinary technicians in the field are inspired by it, without departing from the purpose of the invention, they can design a structure and embodiment similar to the technical solution without creativity, which should belong to the protection scope of the present invention.

Claims

1. An automated security detection method based on machine learning, characterized in that: The following steps are included: S1. Preliminary preparation (1) Data collection and integration: Collect data sources such as system logs, application logs, and network traffic; (2) Data preprocessing and annotation: preprocess the integrated data, including removing redundant information and format conversion; (3) Data enhancement: Implement data enhancement strategies, including generating more abnormal samples or simulating attack behaviors to enhance the model’s ability to identify abnormal behaviors; S2. Model training (1) Model selection and architecture design: Select LSTM, GRU, and Transformer model architectures; (2) Model training and validation: Use TensorFlow or PyTorch to train the model and set the ratio of training set and validation set; (3) Model integration and tuning: Improve detection accuracy through integrated learning methods; S3. Model use and maintenance (1) Model deployment: Deploy the model to the production environment and provide inference services using REST API or TensorFlow Serving; (2) User acceptance testing: Perform acceptance testing in a production environment to verify the actual detection effect of the model and make necessary adjustments; (3) Production environment monitoring and maintenance: Continuously monitor model performance and use Prometheus and Grafana tools to monitor model status in real time.

2. The automated safety detection method based on machine learning according to claim 1, characterized in that: When collecting and integrating data in step S1, the collected data must be integrated and cleaned to ensure the consistency and integrity of the data.

3. The automated safety detection method based on machine learning according to claim 2, characterized in that: In step S1, data annotation is performed during data preprocessing and annotation to distinguish normal behavior samples from abnormal behavior samples.

4. The automated safety detection method based on machine learning according to claim 3, characterized in that: When training and validating the model in step S2, the model performance should be monitored in real time to prevent overfitting and adjust the hyperparameters.

5. The automated safety detection method based on machine learning according to claim 4, characterized in that: When integrating and tuning the model in step S2, it is necessary to use the autoencoder for anomaly detection for specific attack patterns.

6. The automated safety detection method based on machine learning according to claim 5, characterized in that: When deploying the model in step S3, the model should be deployed to the cloud, edge device or local server to adapt to different usage scenarios.

7. The automated safety detection method based on machine learning according to claim 6, characterized in that: When monitoring and maintaining the production environment in step S3, the model should be retrained and updated regularly to respond to new threat scenarios.