PFCP semantic attack detection method and device based on large language model
By deploying a PFCP protocol semantic attack detection method based on a large language model in the 5G core network, using the BERT model and Bi-LSTM network to identify and predict PFCP protocol semantic attacks, the problem of difficulty in detecting and defending PFCP protocol semantic attacks in the existing technology is solved, and the security of the 5G core network is improved.
Patent Information
- Application Number
- CN202411678311.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-11-22
AI Technical Summary
The existing technology is difficult to effectively detect and defend against PFCP protocol semantic attacks, resulting in the critical infrastructure of the 5G core network facing security threats.
The PFCP protocol semantic attack detection method based on the large language model is adopted, and the PFCP protocol cells are identified and predicted through the BERT model, and risk analysis is conducted in combination with the Bi-LSTM network and the comprehensive risk voting mechanism.
It realizes effective identification and prediction of semantic attacks of PFCP protocol, improves the security of the 5G core network, and enhances the security of operators.
Smart Images

Figure CN119789092A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electronic digital data processing, and in particular to a PFCP protocol semantic attack detection method and device based on a large language model. Background Art
[0002] Sinking the user plane function (UPF) to the private network means deploying the UPF close to the user side in the 5G network to achieve local data processing and diversion, reduce network latency, and improve data security and service experience. This deployment method can meet the differentiated network requirements of industry customers for data not leaving the site, uninterrupted services, and high-security isolation. By sinking the UPF, a local closed loop of data can be achieved, that is, the media plane data of 5G users is diverted within the park, avoiding the detour of data through the public bearer network, shortening the transmission path, improving the user experience, and saving the operator's transmission resources.
[0003] However, after the UPF was deployed, it faced management risks such as the lack of access control in the data room, free entry and exit of outsiders, and continuous construction of new projects. As a result, the UPF faced the risk that the network configuration could be arbitrarily tampered with, and the Packet Forwarding Control Protocol (PFCP) could be used to conduct man-in-the-middle attacks, signaling logic attacks such as duplication / missing of cells, topology sniffing, signaling storms, etc. on the 5G core network session management function (SMF), leading to failures of key infrastructure of the 5G core network.
[0004] The most influential pre-trained language model currently is the Transformer-based bidirectional deep language model - BERT. BERT is composed of a multi-layer bidirectional Transformer decoder, mainly including 2 versions of different sizes: the basic version has 12 layers of Transformers, each with 12 multi-head attention layers and a hidden layer size of 768; the enhanced version has 24 layers of Transformers, each with 24 multi-head attention layers and a hidden layer size of 1024. This shows that deep and narrow models are better than shallow and wide models. At present, BERT has excellent performance in multiple tasks such as machine translation, text classification, text similarity, and reading comprehension.
[0005] How to use large language models to conduct semantic attack security monitoring on the PFCP protocol and strengthen the security of critical infrastructure is of great significance to improving the 5G security of operators. Summary of the invention
[0006] The present invention aims to solve the problem that the currently constructed 5G core network protection measures can only target traditional network security such as HTTP security and cannot cope with PFCP protocol security incidents. A PFCP protocol semantic attack detection method and device based on a large language model are provided, which are deployed between UPF and SMF, collect and parse the PFCP signaling data between UPF and SMF, use the BERT model to identify and predict semantic attacks on the compliance of PFCP protocol cells, and analyze PFCP protocol security incidents.
[0007] The present invention provides a PFCP protocol semantic attack detection method based on a large language model, comprising the following steps:
[0008] S1. The PFCP signaling parser receives the forwarding data from UPF or SMF, obtains the source IP address / port number, destination IP address / port number and protocol type of the forwarding data through L2 to L7 layer protocol identification, and then filters and identifies the PFCP signaling process, classifies according to the PFCP signaling process to obtain the PFCP original code stream file, names it and outputs it;
[0009] S2. The data preprocessor reads the PFCP original code stream file, loads the response PFCP parsing rule according to the PFCP signaling process number in the name of the PFCP original code stream file, performs L2 to L7 layer parsing on the PFCP signaling, and names and outputs the PFCP parsing log after parsing. The PFCP parsing log is a readable text.
[0010] S3. The BERT model reads the PFCP parsing log and filters out the PFCP risk signaling text, and performs position encoding and risk classification output label embedding representation on the filtered PFCP risk signaling text;
[0011] S4. The risk identifier reads the label embedding representation, uses the Bi-LSTM network for forward propagation, backward propagation, feature merging and sequence feature extraction to obtain a feature sequence, and then uses at least two classifiers to predict the feature sequence separately and output their respective prediction results. The prediction results are then voted and fused using a comprehensive risk voting mechanism to obtain the PFCP signaling risk type classification and risk possibility. A PFCP protocol semantic attack detection method based on a large language model is completed.
[0012] The PFCP protocol semantic attack detection method based on a large language model described in the present invention is, as a preferred method, in step S1, the filtering method is: the PFCP signaling parser configures an IP whitelist, and only allows the source IP address and the destination IP address in the IP whitelist to continue to be parsed, and the forwarding data not in the IP whitelist is discarded; the PFCP signaling parser can also be configured with a protocol whitelist, and only allows the PFCP protocol to be parsed, and the forwarding data that is not the PFCP protocol is discarded.
[0013] The PFCP protocol semantic attack detection method based on a large language model described in the present invention is, as a preferred embodiment, in step S1, the categories of PFCP signaling processes include: PFCP session establishment, PFCP session modification, PFCP session cancellation, PFCP session report, PFCP heartbeat request, PFCP PFD management, PFCP association establishment, PFCP association update and PFCP association release;
[0014] The PFCP signaling process is numbered by category. The name of the PFCP original code stream file includes: a timestamp, a mask and a PFCP signaling process number arranged in sequence. The PFCP original code stream file is a pcap file.
[0015] The PFCP protocol semantic attack detection method based on a large language model described in the present invention is, as a preferred embodiment, in step S2, the data preprocessor performs PFCP signaling parsing according to the PFCP parsing rules;
[0016] For L2 to L4 layer information, the PFCP parsing rules are as follows: filter out the source / destination MAC address, and complete the source / destination IP address and source / destination port number parsing;
[0017] For L7 layer information, the PFCP parsing rules are: parse according to the full PFCP signaling cell parsing rules defined in the 3rd Generation Partnership Project;
[0018] The name of the PFCP parsing log is the timestamp, mask, and FCP signaling process number connected in sequence. The PFCP parsing log is a txt file.
[0019] The PFCP protocol semantic attack detection method based on a large language model described in the present invention is, as a preferred embodiment, in step S3, the data preprocessor is a BERT model trained by using a BERT model pre-trained with BERT-Base-Uncased;
[0020] The training method includes the following steps:
[0021] SⅠ. Construct a PFCP attack event sample library. The samples in the PFCP attack event sample library include PFCP attack threat intelligence, research results, and simulated PFCP attack event samples. The simulated PFCP attack event samples are constructed through simulation instruments, and then the attack events are marked using semi-automatic annotation tools.
[0022] The model training data is formed through the PFCP attack event sample library and divided into a training set and a test set;
[0023] SⅡ. Use the Transformers library to use the training set to fine-tune the pre-trained BERT model and Transformer variant model on the risk type of PFCP attack events, screen out the PFCP risk signaling text and perform position encoding and risk classification output label embedding representation; use the Adam optimizer during training, each model is trained for no less than 5 epochs, and the learning rate is set to 1e -4 ~1e -5 between;
[0024] SⅢ. Use accuracy, precision, recall and F1 score to evaluate the performance of BERT model parameters. After reaching the target, BERT model training is completed and the screening of step S3 is performed.
[0025] The PFCP protocol semantic attack detection method based on a large language model described in the present invention is, as a preferred embodiment, in step SⅠ, the ratio of the training set to the test set is 8:2;
[0026] In step SⅡ, the risk types of PFCP attack events include: PFCP signaling format attack, PFCP signaling protocol attack, PFCP signaling content attack, PFCP signaling logic attack, PFCP signaling storm attack, UPF man-in-the-middle attack, UPF memory leak, SMF memory leak and fake UPF access;
[0027] PFCP signaling format attacks include: attacks that exploit the duplication / missing number, duplication / missing type, or disordered order of necessary PFCP cells to cause processing logic anomalies; and attacks that exploit the fact that the necessary PFCP cell data type and cell value range exceed the requirements of the network service scope to cause processing logic anomalies.
[0028] PFCP signaling protocol attacks include malicious network element attacks caused by the mismatch between the PFCP signaling source representation (IP, SUPI, PDU session ID) and address domain and the actual characteristics of the network element, topology sniffing attacks caused by abnormal response signaling that PFCP cannot associate with request signaling, malicious network element attacks caused by ports of the PFCP protocol that are not in the 3GPP standard, unauthorized attacks caused by the mismatch between the PFCP protocol interface permissions and the network element permissions, and malicious network elements caused by the PFCP protocol signaling type exceeding the network element service scope;
[0029] PFCP signaling content attack is a cell blasting attack caused by using the PFCP protocol cell content that exceeds the network element service scope;
[0030] PFCP signaling logic attacks include malicious network element attacks caused by abnormal signaling that cannot pass the private network-large network access authentication mechanism, zombie network attacks caused by abnormal interruption of private network signaling, malicious terminal attacks caused by fixed-location devices frequently changing access locations through location update signaling, and fake base station attacks caused by dedicated devices trying to access the 4G network through 5G to 4G switching signaling;
[0031] PFCP signaling storm attack is to use PFCP protocol to attack the core network;
[0032] UPF man-in-the-middle attack is a man-in-the-middle attack that uses the N4 interface of UPF to create an N9 tunnel;
[0033] UPF memory leak is a memory leak attack caused by constantly changing the source port number of the UPF N4_Association_Setup_Request message and failing to release the message body;
[0034] SMF memory leak is a memory leak attack caused by the SMF N4_Association_Setup_Request message constantly changing the source port number and failing to release the message body;
[0035] Fake UPF access is a fake UPF access attack that uses N4_Association_Setup_Request to continuously detect the network;
[0036] The position encoding method of the BERT model is: word embedding, paragraph embedding and position embedding; the hidden layer size of word embedding is 768, and the dimension is (1, n, 768); in paragraph embedding, the word of the previous sentence is represented by 0, and the word of the next sentence is represented by 1 to help BERT distinguish the vector representation of the two sentences in the sentence pair, and the dimension is (1, n, 768); position embedding enables the BERT model to learn the sequential attribute of the input, and the dimension is (1, n, 768);
[0037] The label embedding is represented as a 768-dimensional embedding representation.
[0038] The PFCP protocol semantic attack detection method based on a large language model described in the present invention is, as a preferred embodiment, in step S4, the Bi-LSTM network is a model trained using label embedding representation; during the training of the Bi-LSTM network, the weights of the BERT model are frozen;
[0039] The Bi-LSTM network includes a pre-trained bidirectional LSTM network, the input size of the pre-trained bidirectional LSTM network is 768, and includes a hidden layer of size 64; the pre-trained bidirectional LSTM network uses the maximum value of the LSTM network output element and inputs it as a feature vector into a single-layer fully connected network for classification;
[0040] During the training of the Bi-LSTM network, standard cross entropy loss is used as the optimization criterion and Adam optimizer is used. The total training is higher than 20 epochs, and the learning rate can be set to 1e -4 ~1e -5 between;
[0041] The classifiers include any one or more of the following: support vector machine, KNN, random forest, using the scikit-learn library to implement the comprehensive risk voting mechanism and using default parameter values;
[0042] During the training of the comprehensive risk voting mechanism, the standard cross entropy loss was used as the optimization criterion and the Adam optimizer was used. The training was conducted for more than 20 epochs and the learning rate was set to 1e. -4 ~1e -5 between;
[0043] The model parameter performance of the Bi-LSTM network is measured using accuracy, precision, recall, and F1 score.
[0044] The PFCP protocol semantic attack detection method based on a large language model described in the present invention is, as a preferred embodiment, in step S4, the forward propagation is: the forward LSTM network processes the input 768-dimensional sequence from the first time step to the last time step, captures the past PFCP signaling process context information to obtain the forward output;
[0045] Backward propagation is as follows: the backward LSTM processes the input 768-dimensional sequence from the last time step to the first time step, capturing the future PFCP signaling process context information to obtain the backward output;
[0046] The feature merging is as follows: the forward output and the backward output of each time step are merged to obtain the complete PFCP signaling process context feature;
[0047] The sequence feature extraction is as follows: the Bi-LSTM network applies the attention mechanism to weight the contributions of different time steps, completes the feature extraction, and obtains the feature sequence.
[0048] The PFCP protocol semantic attack detection method based on a large language model described in the present invention is, as a preferred embodiment, in step S4, in the comprehensive risk voting mechanism, weighted voting is performed based on confidence.
[0049] The present invention provides a PFCP protocol semantic attack detection device based on a large language model, comprising a PFCP signaling parser, a data preprocessor, a BERT model and a risk identifier connected in sequence;
[0050] The PFCP signaling parser is located between UPF and SMF, collects the forwarding data between UPF and SMF, and filters, identifies and classifies the data to output the PFCP original code stream file;
[0051] The data preprocessor parses the PFCP signaling in the PFCP original code stream file and outputs the PFCP parsing log;
[0052] The BERT model performs semantic attack recognition on the compliance of PFCP protocol cells in PFCP parsing logs and outputs label embedding representations;
[0053] The risk identifier makes predictions based on the label embedding representation and uses a comprehensive risk voting mechanism to obtain the PFCP signaling risk type classification and risk likelihood.
[0054] This technical solution uses the BERT (Bidirectional Encoder Representations from Transformers) model to contextualize a wide variety of PFCP protocol cells, capture longer-range dependencies, and identify PFCP protocol attack events.
[0055] The present invention has the following advantages:
[0056] (1) The present invention is a method and device for detecting semantic attacks on the PFCP protocol using a large language model (referred to as "PFCP protocol attack detection device"), which is deployed between UPF and SMF, collects and parses PFCP signaling data between UPF and SMF, uses the BERT model to identify and predict semantic attacks on the compliance of PFCP protocol cells, and analyzes PFCP protocol security events.
[0057] (2) The PFCP protocol includes signaling such as PFCP session establishment, PFCP session modification, PFCP session cancellation, and PFCP report. Each signaling contains many information elements. Security events have the characteristics of being hidden for a long time and not easy to be discovered. The network risk identification library currently on the market cannot identify such risks. The present invention is more targeted and is convenient for realizing the identification of attack behaviors against the PFCP protocol. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 It is a flowchart of a PFCP protocol semantic attack detection method based on a large language model;
[0059] Figure 2 It is a structural diagram of a PFCP protocol semantic attack detection device based on a large language model;
[0060] Figure 3A PFCP protocol semantic attack detection method and device based on a large language model Example 1 shows the information element in the pcap file obtained after parsing the PDUSession Modify Request Figure 1 ;
[0061] Figure 4 A PFCP protocol semantic attack detection method and device based on a large language model Example 1 shows the information element in the pcap file obtained after parsing the PDUSession Modify Request Figure 2 . DETAILED DESCRIPTION
[0062] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.
[0063] Example 1
[0064] like Figures 1-2 As shown, a PFCP protocol semantic attack detection method and device based on a large language model, the PFCP protocol attack detection device consists of a PFCP signaling parser, a data preprocessor, a BERT model and a risk identifier.
[0065] The PFCP protocol semantic attack detection method based on a large language model includes the following steps:
[0066] S1. The PFCP signaling parser receives the forwarding data from UPF or SMF, obtains the source IP address / port number, destination IP address / port number and protocol type of the forwarding data through L2 to L7 layer protocol identification, and then filters and identifies the PFCP signaling process, classifies according to the PFCP signaling process to obtain the PFCP original code stream file, names it and outputs it;
[0067] S2. The data preprocessor reads the PFCP original code stream file, loads the response PFCP parsing rule according to the PFCP signaling process number in the name of the PFCP original code stream file, performs L2 to L7 layer parsing on the PFCP signaling, and names and outputs the PFCP parsing log after parsing. The PFCP parsing log is a readable text.
[0068] S3. The BERT model reads the PFCP parsing log and filters out the PFCP risk signaling text, and performs position encoding and risk classification output label embedding representation on the filtered PFCP risk signaling text;
[0069] S4. The risk identifier reads the label embedding representation, uses the Bi-LSTM network for forward propagation, backward propagation, feature merging and sequence feature extraction to obtain a feature sequence, and then uses at least two classifiers to predict the feature sequence separately and output their respective prediction results. The prediction results are then voted and fused using a comprehensive risk voting mechanism to obtain the PFCP signaling risk type classification and risk possibility. A PFCP protocol semantic attack detection method based on a large language model is completed.
[0070] The working principle of PFCP signaling parser is as follows:
[0071] The PFCP signaling parser receives the forwarding data from UPF or SMF, and identifies the source IP address and port number, destination IP address and port number, and protocol type of the forwarded data through L2 to L7 layer protocol identification. The PFCP signaling parser can be configured with an IP whitelist, allowing only the source IP address and destination IP address in the whitelist to continue parsing, and the rest of the data not in the IP whitelist will be discarded; the PFCP signaling parser can be configured with a protocol whitelist, allowing only the PFCP protocol to be parsed, and the rest of the data not in the PFCP protocol will be discarded.
[0072] The PFCP signaling parser uses the PFCP signaling identifier to identify different PFCP signaling processes and number them. The PFCP signaling process includes:
[0073] 0x1.PFCP Session Establishment Request / Response (PFCP Session Establishment Request / Response)
[0074] 0x2.PFCP Session Modification Request / Response (PFCP Session Modification Request / Response)
[0075] 0x3.PFCP Session Deletion Request / Response (PFCP Session Deletion Request / Response)
[0076] 0x4.PFCP Session Report Request / Response (PFCP Session Report Request / Response)
[0077] 0x5.PFCP Heartbeat Request / Response (PFCP Heartbeat Request / Response)
[0078] 0x6.PFCP PFD Management request / response (PFCP PFD Management request / response)
[0079] 0x7.PFCPAssociation Setup Request / Response (PFCP Association Setup Request / Response)
[0080] 0x8.PFCPAssociation Update Request / Response (PFCP Association Update Request / Response)
[0081] 0x9.PFCPAssociation Release request / response (PFCP association release request / response)
[0082] 0xA.PFCP Node Report Request / Response (PFCP Node Report Request / Response)
[0083] Parse the filtered traffic data into the original PFCP stream file and output it. The original stream file is named according to the timestamp + three-digit mask + three-digit PFCP signaling process number, such as 202410201221220010xA.pcap
[0084] The data preprocessor works as follows:
[0085] The data preprocessor reads the original code stream file, loads the response PFCP parsing rules according to the last three digits of the PFCP signaling process number, performs L2 to L7 layer parsing on the PFCP signaling, and outputs the parsing log.
[0086] For L2 to L4 layer information, the PFCP parsing rule filters out the source / destination MAC address and completes the source / destination IP address and source / destination port number parsing.
[0087] For L7 layer information, the PFCP parsing rules follow the full PFCP signaling cell parsing rules defined in Section 7 of TS29.244 of the Third Generation Partnership Project (3GPP). For example, the PFCP Association Update response message (Section 7.4.4.4 of TS29.244) has four cells: Node ID, Cause, UPFunctionFeatures, and CP Function Features. The PFCP parsing rules load the original code stream of the response message numbered 0x9 and parse the four cells in the original code stream.
[0088] After the data preprocessor completes the PFCP signaling L2 to L7 layer data parsing, it outputs the parsed data as readable text. The text is named according to the timestamp + three-digit mask + three-digit PFCP signaling process number, such as 202410201221220010xA.txt
[0089] The tag handler works as follows:
[0090] The label processor utilizes the pre-trained version of BERT-Base-Uncased.
[0091] The BERT model receives the filtered and classified PFCP signaling readable text output by the data preprocessor, filters out the PFCP risk signaling text, and classifies the filtered PFCP risk signaling text into risk categories.
[0092] The BERT model needs to be trained first. Since there is no comprehensive and widely accepted PFCP attack event library, PFCP attack events are synchronized through 3GPP, the Global System for Mobile Communications Association (GSMA), well-known domestic and foreign operators, and well-known domestic and foreign universities. PFCP attack threat intelligence and research results are obtained to obtain diverse and high-quality attack samples; a large number of PFCP attack event samples are constructed using simulation instruments, and semi-automatic annotation tools are developed to mark attack events to create a more diverse PFCP attack event sample library. Through the PFCP attack event sample library, 10Gbps model training data is formed and divided into training sets and test sets, with a ratio of 8:2 between training sets and test sets.
[0093] Using the Transformers library, we used the training set data to fine-tune the pre-trained BERT model and variant models, improve the classification performance of the BERT model, and obtain the optimal BERT model with the best experimental results. The Adam optimizer was used during the training process, and each model was trained for no less than 5 epochs. The learning rate can be set to 1e -4 ~1e -5 The other hyperparameters use the default values.
[0094] The list of PFCP attack events is as follows:
[0095]
[0096] Model parameter performance is measured using standard metrics including accuracy, precision, recall, and F1 score.
[0097] The Risk Identifier works as follows:
[0098] The BERT model creates an embedding of dimension 768 for each label of the output and provides the label embedding as input to the Bi-LSTM network for training. During the training of the Bi-LSTM network, the weights of the BERT model are frozen.
[0099] The Bi-LSTM network in the RNN network has a pre-trained bidirectional LSTM network with a unit input size of 768 and a hidden layer size of 64. The pre-trained model uses the maximum value of the element output by the LSTM network and inputs the maximum value of the element as a feature vector into a single-layer fully connected network for classification.
[0100] During the training of the Bi-LSTM network, standard cross entropy loss is used as the optimization criterion and Adam optimizer is used. The total training is higher than 20 epochs, and the learning rate can be set to 1e -4 ~1e -5 between.
[0101] The comprehensive risk voting mechanism consisting of support vector machine (SVM), KNN, and random forest was implemented using the scikit-learn library with default parameter values.
[0102] During the training of the comprehensive risk voting mechanism, the standard cross entropy loss is used as the optimization criterion and the Adam optimizer is used. The total training time is higher than 20 epochs, and the learning rate can be set to 1e -4 ~1e -5 between.
[0103] Model parameter performance is measured using standard metrics including accuracy, precision, recall, and F1 score.
[0104] Finally, the comprehensive risk voting mechanism outputs the PFCP signaling risk type classification and possibility.
[0105] Take the "UPF man-in-the-middle attack" as an example. This attack occurs during the PDU SessionModify Request signaling process of updating the PDR.
[0106] 3GPP TS29.244V16.3.0 (2020-03) Table 7.5.4.2-1 states that the PDU SessionModify Request when updating the PDR must carry the following information elements:
[0107]
[0108] 3GPP TS29.244V16.3.0 (2020-03) Table 7.5.5.1-1 states that the PDU SessionModify Response when updating the PDR must carry the following information elements:
[0109]
[0110]
[0111] After the PFCP signaling parser parses the PDU Session Modify Request, the obtained pcap file contains the following Figure 3 The cell shown.
[0112] After the PFCP signaling parser parses the PDU Session Modify Response, the obtained pcap file contains the following Figure 4 The cell shown.
[0113] The PDU SessionModify Request is parsed by the data preprocessor into a binary .txt file. The binary data of each cell is between the two "|" and "|".
[0114] |0|fa|16|3e|28|a3|e6|50|e0|ef|16|38|14|81|00|02|0a|08|00|45|00|00|75|03|ee|00|00|3f|11|4a|04|0a|b1|14| 03|0a|b1|04|22|22|65|22|65|00|61|88|1c|21|34|00|55|00|00|00|00|00|03|91|00|00|00|05|00|00|01|00|45|00| 38|00|02|00|03|00|1d|00|04|00|00|00|01|00|02|00|26|00|14|00|01|00|00|a0|00|01|0f|00|15|00|02|0d|05|00| 16|00|04|03|6e|39|75|00|7c|00|01|01|00|5d|00|05|02|46|46|46|01|00|5f|00|01|00|00|6c|00|04|00|00|00|01|
[0115] The PDU SessionModify Response is parsed by the data preprocessor into a binary .txt file. The binary data of each cell is between two "|" and "|".
[0116] |0|50|e0|ef|16|38|14|fa|16|3e|28|a3|e6|81|00|0f|ac|08|00|45|e0|00|58|0c|3d|00|00 |fe|11|81|f1|0a|b1|04|22|0a|b1|14|03|22|65|22|65|00|44|a2|d5|21|35|00|38|00|00|0 0|00|00|00|27|11|00|00|05|00|00|13|00|01|01|00|08|00|23|00|38|00|02|00|03|00|15| 00|19|03|40|03|91|06|0a|b1|04|23|20|20|01|77|00|00|00|00|00|00|00|00|00|00|04|35|
[0117] The above two .txt files are used as samples to input into the BERT model for pre-training. The BERT model uses three position embedding methods to encode the position of each data:
[0118] Token Embeddings, the vector representation of each token. Since the basic version of the BERT pre-trained model is used, the hidden layer size is 768 and the dimension is (1, n, 768);
[0119] Segment Embeddings, where the words in the previous sentence are represented by 0 and the words in the next sentence are represented by 1 to help BERT distinguish the vector representation of the two sentences in a sentence pair, with a dimension of (1, n, 768);
[0120] Position Embeddings, which allows BERT to learn the sequential properties of the input, with a dimension of (1, n, 768)
[0121] The pseudo code for implementing BERT position encoding using Python is:
[0122] #Assumed parameters
[0123] vocab_size=30522 # vocabulary size
[0124] type_vocab_size = 2 #Number of paragraph types, usually 2 (single sentences and sentence pairs) max_position_embeddings = 512 #Maximum sequence length
[0125] embedding_size=768#The dimension of the embedding vector
[0126] #Word embedding matrix
[0127] word_embeddings=np.random.normal(size=(vocab_size,
[0128] embedding_size)
[0129] #Paragraph embedding matrix
[0130] segment_embeddings=np.random.normal(size=(type_vocab_size,
[0131] embedding_size)
[0132] # Position embedding matrix
[0133] position_embeddings=np.zeros((max_position_embeddings,
[0134] embedding_size)
[0135] forpos in range(max_position_embeddings):
[0136] for iin range(0,embedding_size,2):
[0137] position_embeddings[pos,i]=np.sin(pos / np.power(10000,i / embedding_size))
[0138] position_embeddings[pos,i+1]=np.cos(pos /
[0139] np.power(10000,(i+1) / embedding_size))
[0140] # Input data
[0141] input_ids = [...] # word ID sequence
[0142] token_type_ids = [...] # Paragraph type ID sequence, used to distinguish the two sentences in a sentence pair
[0143] # Token Embedding
[0144] word_embeddings_input=word_embeddings[input_ids]
[0145] #Paragraph embedding
[0146] segment_embeddings_input=segment_embeddings[token_type_ids]
[0147] #Position embedding
[0148] position_embeddings_input=
[0149] position_embeddings[range(len(input_ids))]
[0150] #Add word embedding, paragraph embedding and position embedding
[0151] token_embeddings=word_embeddings_input+
[0152] segment_embeddings_input+position_embeddings_input
[0153] #Output
[0154] returntoken_embeddings
[0155] in:
[0156] 1. word_embeddings is a matrix of vocabulary size multiplied by embedding vector dimension, used to store the embedding vector of each word.
[0157] 2.segment_embeddings is a matrix of the number of paragraph types multiplied by the embedding vector dimension, which is used to store the embedding vector of each paragraph type.
[0158] 3.position_embeddings is a matrix of the maximum sequence length multiplied by the embedding vector dimension, used to store the embedding vector for each position.
[0159] 4.input_ids is a sequence containing the word IDs of the input text.
[0160] 5.token_type_ids is a sequence used to distinguish the two sentences in a sentence pair. Usually, all the token IDs of the first sentence correspond to one value, and all the token IDs of the second sentence correspond to another value.
[0161] 6.word_embeddings_input is obtained by looking up the corresponding embedding vector of input_ids in word_embeddings.
[0162] 7.segment_embeddings_input is obtained by looking up the corresponding embedding vector of token_type_ids in segment_embeddings.
[0163] 8.position_embeddings_input is obtained by finding the position index in
[0164] The corresponding embedding vector in position_embeddings is obtained.
[0165] 9. Finally, add these three embedding vectors to get the final embedding representation of each word.
[0166] After BERT completes position encoding, Bi-LSTM completes PFCP SessionModify Request / PFCP SessionModify Response feature extraction through position encoding.
[0167] Input sequence: Bi-LSTM receives the PFCP SessionModify Request / PFCP SessionModifyResponse sequence encoded by BERT as input, and each time step contains a 768-dimensional vector.
[0168] Forward propagation: The forward LSTM processes the input 768-dimensional sequence from the first time step to the last time step, capturing the past PFCP SessionModify Request / PFCP SessionModify Response context information.
[0169] Backward propagation: The backward LSTM processes the input 768-dimensional sequence from the last time step to the first time step, capturing the future PFCP SessionModify Request / PFCP SessionModify Response context information.
[0170] Feature merging: The forward and backward outputs at each time step are merged (usually concatenated) to form the complete PFCP Session Modify context features.
[0171] Sequence feature extraction: Bi-LSTM applies the attention mechanism to weight the contributions of different time steps to complete feature extraction.
[0172] The pseudo code for extracting features using the Bi-LSTM model using Python is:
[0173]
[0174]
[0175] The comprehensive risk voting mechanism scores the extracted features of PFCP Session Modify Request / PFCP Session ModifyResponse and selects the signaling with higher probability. In the PFCP protocol semantic attack detection, the comprehensive risk voting mechanism can reduce false positives and false negatives and improve the accuracy of attack detection.
[0176] Independent prediction: Each classifier (such as SVM, KNN, random forest) independently predicts the feature sequence and outputs its own risk score or category label.
[0177] Voting mechanism: Voting is done based on the prediction results of the classifier. Weighted voting based on confidence.
[0178] Result fusion: Finally, the network instance = n9u feature is selected as "man-in-the-middle attack". Comprehensive risk voting mechanism to identify risks
[0179] The pseudo code for implementing the comprehensive risk voting mechanism using Python is:
[0180]
[0181] random_forest_pred=random_forest_predict(feature)
[0182] #Comprehensive Risk Voting
[0183] final_pred=vote_predictions(svm_pred,knn_pred,random_forest_pred)
[0184] predictions.append(final_pred)
[0185] return predictions
[0186] defsvm_predict(feature):
[0187] #SVM classifier prediction
[0188] pass
[0189] defknn_predict(feature):
[0190] #KNN classifier prediction
[0191] pass
[0192] defrandom_forest_predict(feature):
[0193] # Random Forest Classifier Prediction
[0194] pass
[0195] defvote_predictions(svm_pred,knn_pred,random_forest_pred):
[0196] #Implement voting logic, such as majority voting or weighted voting
[0197] Pass.
[0198] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A PFCP protocol semantic attack detection method based on a large language model, characterized by: The following steps are involved: S1, PFCP signaling parser receives forwarding data from UPF or SMF, obtains source IP address / port number, destination IP address / port number and protocol type of the forwarding data through L2 to L7 layer protocol identification, then filters and identifies PFCP signaling process, classifies according to the PFCP signaling process to obtain PFCP original code stream file, names it and outputs it; S2. The data preprocessor reads the PFCP original code stream file, loads the response PFCP parsing rule according to the PFCP signaling process number in the name of the PFCP original code stream file, performs L2 to L7 layer parsing on the PFCP signaling, and names and outputs the PFCP parsing log after parsing, and the PFCP parsing log is a readable text; S3, the BERT model reads the PFCP parsing log and filters out the PFCP risk signaling text, and performs position encoding and risk classification output label embedding representation on the filtered PFCP risk signaling text; S4. The risk identifier reads the label embedding representation, uses the Bi-LSTM network to perform forward propagation, backward propagation, feature merging and sequence feature extraction to obtain a feature sequence, and then uses at least two classifiers to predict the feature sequence respectively and output their respective prediction results. The prediction results are then voted and the results are integrated using a comprehensive risk voting mechanism to obtain a PFCP signaling risk type classification and risk possibility. A PFCP protocol semantic attack detection method based on a large language model is completed.
2. The PFCP protocol semantic attack detection method based on a large language model according to claim 1, characterized in that: In step S1, the filtering method is: the PFCP signaling parser configures an IP whitelist, only allows the source IP address and the destination IP address in the IP whitelist to continue parsing, and discards the forwarding data not in the IP whitelist; The PFCP signaling parser may also be configured with a protocol whitelist, allowing only the PFCP protocol to be parsed, and discarding forwarded data that is not of the PFCP protocol.
3. The PFCP protocol semantic attack detection method based on a large language model according to claim 1, characterized in that: In step S1, the categories of the PFCP signaling process include: PFCP session establishment, PFCP session modification, PFCP session cancellation, PFCP session report, PFCP heartbeat request, PFCP PFD management, PFCP association establishment, PFCP association update and PFCP association release; The PFCP signaling process is numbered by category, and the name of the PFCP original code stream file includes: a timestamp, a mask and the PFCP signaling process number arranged in sequence, and the PFCP original code stream file is a pcap file.
4. The PFCP protocol semantic attack detection method based on a large language model according to claim 1, characterized in that: In step S2, the data preprocessor performs PFCP signaling parsing according to PFCP parsing rules; For L2 to L4 layer information, the PFCP parsing rule is: filter out the source / destination mac address, complete the source / destination IP address and source / destination port number parsing; For L7 layer information, the PFCP parsing rule is: parsing according to the full PFCP signaling cell parsing rule defined in the 3rd Generation Partnership Project; The name of the PFCP parsing log is the timestamp, mask and FCP signaling process number connected in sequence, and the PFCP parsing log is a txt file.
5. The PFCP protocol semantic attack detection method based on a large language model according to claim 1, characterized in that: In step S3, the data preprocessor is a BERT model trained using a BERT model pre-trained with BERT-Base-Uncased; The training method includes the following steps: SⅠ. Construct a PFCP attack event sample library, wherein the samples in the PFCP attack event sample library include PFCP attack threat intelligence, research results, and simulated PFCP attack event samples. The simulated PFCP attack event samples are constructed by using simulation instruments, and then the attack events are marked using a semi-automatic annotation tool; Model training data is formed through the PFCP attack event sample library, and is divided into a training set and a test set; SⅡ. Use the Transformers library to use the training set to fine-tune the pre-trained BERT model and the Transformer variant model on the risk type of PFCP attack events, screen out the PFCP risk signaling text and perform position encoding and risk classification to output the label embedding representation; use the Adam optimizer during training, each model is trained for no less than 5 epochs, and the learning rate is set to 1e -4 ~1e -5 between; SⅢ. Use accuracy, precision, recall and F1 score to evaluate the performance of BERT model parameters. After reaching the target, BERT model training is completed and the screening of step S3 is performed.
6. The PFCP protocol semantic attack detection method based on a large language model according to claim 5 is characterized in that: In step SⅠ, the ratio of the training set to the test set is 8:2; In step SⅡ, the PFCP attack event risk types include: PFCP signaling format attack, PFCP signaling protocol attack, PFCP signaling content attack, PFCP signaling logic attack, PFCP signaling storm attack, UPF man-in-the-middle attack, UPF memory leak, SMF memory leak and fake UPF access; The PFCP signaling format attack includes: an attack on processing logic anomaly caused by duplication / missing of the number of necessary PFCP cells, duplication / missing of types, and disordered order, and an attack on processing logic anomaly caused by the type of necessary PFCP cell data and the cell value range exceeding the requirements of the network service scope; The PFCP signaling protocol attacks include malicious network element attacks caused by the mismatch between the PFCP signaling source representation (IP, SUPI, PDU session ID) and address domain and the actual characteristics of the network element, topology sniffing attacks caused by abnormal response signaling that PFCP cannot associate with request signaling, malicious network element attacks caused by ports specified by the PFCP protocol that are not in the 3GPP standard, unauthorized attacks caused by the mismatch between the PFCP protocol interface authority and the network element authority, and malicious network elements caused by the PFCP protocol signaling type exceeding the network element service scope; The PFCP signaling content attack is a cell blasting attack caused by using the PFCP protocol cell content that exceeds the network element service scope; The PFCP signaling logic attacks include malicious network element attacks that cannot pass the private network-large network access authentication mechanism through abnormal signaling, zombie network attacks caused by abnormal interruption of private network signaling, malicious terminal attacks caused by fixed-location devices frequently changing access locations through location update signaling, and fake base station attacks caused by dedicated devices trying to access the 4G network through 5G to 4G switching signaling; The PFCP signaling storm attack is to use the PFCP protocol to carry out a signaling storm attack on the core network; The UPF man-in-the-middle attack is a man-in-the-middle attack behavior that uses the N4 interface of the UPF to create the N9 tunnel; The UPF memory leak is a memory leak attack caused by constantly changing the source port number of the UPF N4_Association_Setup_Request message and failing to release the message body; The SMF memory leak is a memory leak attack caused by continuously changing the source port number of the SMF N4_Association_Setup_Request message and failing to release the message body; The pseudo UPF access is a pseudo UPF access attack that continuously detects the network using N4_Association_Setup_Request; The position encoding method of the BERT model is: word unit embedding, paragraph embedding and position embedding; the hidden layer size of the word unit embedding is 768, and the dimension is (1, n, 768); in the paragraph embedding, the word of the previous sentence is represented by 0, and the word of the next sentence is represented by 1 to assist BERT in distinguishing the vector representation of the two sentences in the sentence pair, and the dimension is (1, n, 768); the position embedding enables the BERT model to learn the sequential attribute of the input, and the dimension is (1, n, 768); The label embedding representation is a 768-dimensional embedding representation.
7. The PFCP protocol semantic attack detection method based on a large language model according to claim 1, characterized in that: In step S4, the Bi-LSTM network is a model trained using the label embedding representation; during the training of the Bi-LSTM network, the weights of the BERT model are frozen; The Bi-LSTM network includes a pre-trained bidirectional LSTM network, the input size of the pre-trained bidirectional LSTM network is 768, and includes a hidden layer with a size of 64; the pre-trained bidirectional LSTM network uses the maximum value of the LSTM network output element and inputs it as a feature vector into a single-layer fully connected network for classification; During the training of the Bi-LSTM network, standard cross entropy loss is used as the optimization criterion and Adam optimizer is used. The total training is higher than 20 epochs, and the learning rate can be set to 1e -4 ~1e -5 between; The classifier includes any one or more of the following: support vector machine, KNN, random forest, using the scikit-learn library to implement the comprehensive risk voting mechanism, and using default parameter values; During the training of the comprehensive risk voting mechanism, the standard cross entropy loss was used as the optimization criterion and the Adam optimizer was used. The training was conducted for more than 20 epochs and the learning rate was set to 1e -4 ~1e -5 between; The model parameter performance of the Bi-LSTM network is measured using accuracy, precision, recall, and F1 score.
8. The PFCP protocol semantic attack detection method based on a large language model according to claim 1, characterized in that: In step S4, the forward propagation is: the forward LSTM network processes the input 768-dimensional sequence from the first time step to the last time step, captures the past PFCP signaling process context information to obtain the forward output; The backward propagation is as follows: the backward LSTM processes the input 768-dimensional sequence from the last time step to the first time step, captures the future PFCP signaling process context information and obtains the backward output; The feature merging is as follows: the forward output and the backward output of each time step are merged to obtain a complete PFCP signaling process context feature; The sequence feature extraction is as follows: the Bi-LSTM network applies an attention mechanism to weight the contributions of different time steps to complete feature extraction and obtain the feature sequence.
9. The PFCP protocol semantic attack detection method based on a large language model according to claim 1, characterized in that: In step S4, in the comprehensive risk voting mechanism, weighted voting is performed based on confidence.
10. A PFCP protocol semantic attack detection device based on a large language model according to any one of claims 1 to 9, characterized in that: It includes the PFCP signaling parser, the data preprocessor, the BERT model and the risk identifier connected in sequence; The PFCP signaling parser is located between UPF and SMF, collects the forwarding data between UPF and SMF, and filters, identifies and classifies the data to output the PFCP original code stream file; The data preprocessor parses the PFCP signaling in the PFCP original code stream file and outputs the PFCP parsing log; The BERT model performs semantic attack identification on the compliance of the PFCP protocol cells in the PFCP parsing log and outputs the label embedding representation; The risk identifier makes predictions based on the label embedding representation and uses a comprehensive risk voting mechanism to determine the PFCP signaling risk type classification and risk likelihood.
Citation Information
Patent Citations
Method, system, medium and equipment for testing PFCP protocol data
CN115696335A
Abnormal signaling attack analysis method and device and readable storage medium
CN116600302A
Decentralized network DDoS attack identification method based on large language model
CN116781341A
Network security autonomous operation and maintenance method and system based on large language model
CN118250068A
Large language model migration attack-resisting method and system based on thinking chain
CN118796981A