A CAN bus feature fusion intrusion detection method based on adversarial learning

By combining adversarial learning technology with the time characteristics and signal characteristics of the CAN bus, combined with LSTM and encoding and decoding re-encoding models, efficient intrusion detection is achieved in the absence of labeled training data, solving the operational difficulties of the existing technology under the comprehensive coverage of attack types and lack of labeled data, and significantly improving the security of the on-board network.

CN119520176BActive Publication Date: 2025-04-08HENAN SONGSHAN LAB IND RES INST CO LTD LUOYANG BRANCH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510098635.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-22
Publication Date
2025-04-08
Estimated Expiration
2045-01-22

AI Technical Summary

Technical Problem

The existing CAN bus intrusion detection technology has shortcomings in covering all types of attacks, and it is difficult to operate effectively in the absence of labeled training data, which affects the security of the on-board network.

Method used

The CAN bus feature fusion intrusion detection method based on adversarial learning is adopted. By obtaining and extracting the time characteristics and signal characteristics of messages transmitted on the CAN bus, they are fused into a comprehensive feature matrix, and data processing and adversarial training are used to use the LSTM neural network model and encoding and decoding re-encoding model to achieve intrusion detection.

Benefits of technology

This method can achieve high-precision intrusion detection without labeled training data, significantly improve detection efficiency and security, and improve detection capabilities for multiple types of attacks, especially in detecting pauses and camouflage attacks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119520176B_ABST
    Figure CN119520176B_ABST
Patent Text Reader

Abstract

A CAN bus feature fusion intrusion detection method based on adversarial learning, involving a CAN bus intrusion detection method, wherein the time features and signal features of the same CAN ID are spliced ​​into a comprehensive feature matrix for data processing and adversarial training of the detection model; each LSTM sub-network of the detection model is used for processing the corresponding CAN ID comprehensive feature matrix; the outputs of each LSTM sub-network are spliced ​​into a joint potential vector; the encoding, decoding and re-encoding model of the detection model reduces the dimension of the joint potential vector to obtain the original intermediate representation, then reconstructs the joint potential vector by increasing the dimension to obtain a reconstructed comprehensive feature close to the latest comprehensive feature, and then reduces the dimension again to obtain the reconstructed intermediate representation; the latest comprehensive feature is scored for abnormality according to the reconstruction error and the re-encoding error to determine whether there is an attack behavior. It can detect a wider range of attack types and can still operate effectively in the absence of labeled training data, significantly improving the detection efficiency and security.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a CAN bus intrusion detection method, in particular to a CAN bus feature fusion intrusion detection method based on adversarial learning. Background Art

[0002] In recent years, with the rapid development of automobile intelligence and networking technology, the security of vehicle networks has become particularly prominent. As the core protocol for communication between various electronic control units (ECUs) inside the car, the Controller Area Network (CAN) bus system faces various forms of security threats such as injection attacks, pause attacks, and camouflage attacks. In order to effectively respond to these challenges, the industry and academia have proposed a variety of intrusion detection solutions to try to enhance the security of the CAN bus system.

[0003] Early intrusion detection technologies mainly focused on methods based on time interval features. Such methods identify possible attack behaviors by monitoring the sending intervals between specific CAN ID messages or their frequency of occurrence on the bus. Given that insertion and delay attacks can cause abnormal changes in time intervals, this method can effectively reveal potential intrusion activities. However, for those disguised attacks that tamper with the payload without changing the message generation time, time interval-based technologies are powerless because such attacks do not significantly affect the regularity of the time interval.

[0004] Subsequently, methods based on CAN ID sequences gradually matured. This type of technology converts the IDs of a series of CAN messages into a two-dimensional image format and uses a convolutional neural network (CNN) for deep learning and classification processing. In this way, not only can insertion or pause attacks that disrupt the message sequence be efficiently discovered, but it can also resist the impact of payload operations to a certain extent. However, these methods also have shortcomings, that is, they mainly focus on the time series characteristics of the CAN ID, and pay less attention to the specific content of the message, which limits their ability to detect deep-level attack behaviors.

[0005] In addition, there is a class of intrusion detection techniques based on payload content. This type of method can distinguish normal and attack data streams without decoding by deeply analyzing the payload in the CAN data frame. However, for those pause attacks and spoofing attacks that do not significantly change the payload content, the payload-based method also faces challenges.

[0006] Recently, signal value-based intrusion detection methods have begun to attract widespread attention. This method focuses on analyzing the specific signal values ​​carried in CAN messages, such as important information such as sensor readings, to detect potential malicious activities. Although it performs well in identifying certain types of attacks (such as injection attacks), signal-based methods may be difficult to work when faced with pause attacks and masquerade attacks because the attacker cleverly maintains the consistency of the signal value.

[0007] The existing CAN bus intrusion detection technology still has obvious shortcomings in fully covering all types of attacks, and requires training sample data for model training. It is difficult to operate effectively in the absence of labeled training data, and it is difficult to ensure the security of the vehicle network. Summary of the invention

[0008] The technical problem to be solved by the present invention is to improve the applicable scope of the intrusion detection method for CAN bus attack types, and to realize intrusion detection in the absence of labeled training data, so as to ensure the security of the vehicle network.

[0009] The technical solution adopted by the present invention to solve the above technical problems is: a CAN bus feature fusion intrusion detection method based on adversarial learning, obtaining messages transmitted on the CAN bus, selecting the CAN ID corresponding to the message containing the key signal, and extracting the time characteristics and signal characteristics of the message sent by the selected CAN ID; splicing the time characteristics and signal characteristics corresponding to the same CAN ID to obtain a comprehensive feature matrix in the form of a time series for each CAN ID;

[0010] The comprehensive feature matrix corresponding to all selected CAN IDs is input into the detection model for data processing and adversarial training, and the latest features in the comprehensive feature matrix corresponding to all selected CAN IDs are spliced ​​to obtain the latest comprehensive features. ;

[0011] The detection model includes an LSTM neural network model and an encoding, decoding and re-encoding model;

[0012] The LSTM neural network model has a number of LSTM subnetworks corresponding to the number of selected CAN IDs, each LSTM subnetwork is used to process the corresponding CAN ID comprehensive feature matrix; the outputs of each LSTM subnetwork are spliced ​​to obtain a joint potential vector ;

[0013] The encoding, decoding and re-encoding model includes an encoder , Decoder and encoder , where the encoder For the joint latent vector Perform dimensionality reduction to obtain the original intermediate representation of low dimension , the decoder is used to convert the original intermediate representation Up-dimensional reconstruction obtains close to the latest comprehensive features Reconstruction of comprehensive features ; Encoder Used to reconstruct the comprehensive features Dimensionality reduction to obtain low-dimensional reconstructed intermediate representation ;

[0014] Based on the reconstruction of the comprehensive characteristics With the latest comprehensive features The difference between them is used to obtain the reconstruction error; according to the reconstructed intermediate representation With the original intermediate representation The difference between them is used to obtain the recoding error; the latest comprehensive feature Anomaly scoring is performed to determine whether aggressive behavior occurs.

[0015] The time feature of the message sent by the CAN ID is the log-likelihood sequence of the time intervals of the messages of the CAN ID in the past period of time, where the time interval between the latest message and the previous message of the same CAN ID is calculated. , and the time interval from receiving the latest message of the CAN ID to the current time point , select two time intervals and The larger value of is taken as the time interval between messages and its log-likelihood value is calculated; the log-likelihood value of the time interval between messages in the past period of time is used to construct a log-likelihood sequence.

[0016] The signal feature of the message sent by the CAN ID is a time series composed of key signal values ​​in the messages within a period of time in the past.

[0017] The time characteristics and signal characteristics of the message sent by the CAN ID are both time series. The time series of the time characteristics and signal characteristics are horizontally spliced ​​to obtain a comprehensive feature matrix in the form of a time series for each CAN ID, and the comprehensive feature matrix is ​​normalized.

[0018] The dimension of the comprehensive feature matrix is ,in is the number of signals corresponding to the CAN ID, is the length of the time window; the corresponding LSTM sub-network has hidden units, where is the size of the hidden layer; the output dimension after the LSTM sub-network processing corresponding to the comprehensive feature matrix input is The hidden state of all LSTM sub-network outputs is concatenated to form a length of The joint latent vector ,in, , The number of the selected CAN ID.

[0019] The encoder The formula used is:

[0020] ,in, is the activation function, is the weight matrix, is the bias vector.

[0021] The decoder The formula used is:

[0022] ,in, is the activation function, is the weight matrix, is the bias vector;

[0023] Constructing the loss function To guide the encoder and decoder The optimization of As close to the latest comprehensive features as possible .

[0024] The encoder The formula used is:

[0025] ,in, is the activation function, is the weight matrix, is the bias vector;

[0026] Constructing the loss function To guide the decoder and encoder The optimization makes the reconstructed intermediate representation after re-encoding As close as possible to the original intermediate representation .

[0027] The detection model is trained adversarially using the adversarial training mechanism of the generator and the discriminator. The generator is composed of the encoder and decoder composition, whose goal is to reconstruct the comprehensive features As close to the latest comprehensive features as possible , the discriminator is a binary classifier whose goal is to maximize the latest comprehensive features and reconstruct comprehensive features The classification accuracy of the generator and the discriminator is optimized alternately through adversarial training.

[0028] Calculate the latest comprehensive features Anomaly score , by scoring the anomaly Compare with the set threshold to distinguish normal messages from attack behaviors;

[0029] Anomaly Scoring The calculation formula is:

[0030] ,in, and are the reconstruction error and the re-encoding error, respectively. and is the weight parameter.

[0031] The beneficial effects of the present invention are as follows: combining time features and signal features helps the model capture comprehensive time and signal dynamics, thereby being able to detect a wider range of attack types. The encoding, decoding and re-encoding model can more accurately capture and represent complex feature relationships through a multi-level feature processing mechanism; by combining the encoder-decoder-encoder architecture with adversarial learning, it is possible to achieve high-precision intrusion detection in an unsupervised learning environment without the need for a large amount of labeled data. The system can still operate effectively in the absence of labeled training data, significantly improving detection efficiency and security, and improving the ability to detect multiple types of attacks, especially in detecting pauses and disguised attacks, providing enhanced security and real-time intrusion detection solutions for vehicle networks. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 It is a process schematic diagram of the detection method of the present invention.

[0033] Figure 2 It is a schematic diagram of the time feature extraction process of the present invention.

[0034] Figure 3 It is a schematic diagram of the splicing process of time characteristics and signal characteristics of the present invention.

[0035] Figure 4 It is a schematic diagram of the detection model architecture of the present invention. DETAILED DESCRIPTION

[0036] The technical solution of the present invention is described clearly and completely below in conjunction with the accompanying drawings and specific implementation methods. The specific contents listed in the following embodiments are not limited to the technical features necessary for the technical problems to be solved by the technical solutions recorded in the claims. At the same time, the enumerated embodiments are only part of the present invention, not all embodiments.

[0037] The CAN bus feature fusion intrusion detection method based on adversarial learning in the present invention fuses time features and signal features, and adopts an encoder-decoder-encoder architecture combined with adversarial learning. Through a multi-level feature processing mechanism, the learning ability and generalization performance of the model are enhanced.

[0038] like Figure 1 As shown in the figure, in order to effectively detect attack events on the CAN bus, it is necessary to obtain CAN messages from the CAN bus and process them in terms of time and data to extract time features and signal features. The time interval features include the sending interval and frequency between messages, and the signal features cover the specific signal values ​​and their changing trends in the CAN data frame. Through multi-feature fusion, not only common injection attacks and pause attacks can be effectively detected, but also complex attacks that evade single feature detection by disguising payloads can be identified. This method first needs to obtain the transmitted messages from the CAN bus and extract the timestamp and related message content. The specific process is as follows:

[0039] 1. Use a CAN bus reading device (such as an OBD-II adapter or a dedicated CAN analyzer) to connect to the vehicle's CAN bus interface. Make sure the device is properly configured to receive and parse messages on the CAN bus. Once connected, start the data acquisition program and begin monitoring all messages on the CAN bus.

[0040] 2. Start the data acquisition program and start monitoring all messages on the CAN bus in real time. Whenever a new CAN message is received, record the CAN ID of the message and its corresponding timestamp. The timestamp can be the current time of the system or a relative time from a fixed starting point.

[0041] 3. Store the collected data in a structured data file, such as a CSV file or a database. Each record should contain the following fields: CAN ID, which is a unique ID that identifies the source of the message; timestamp, which is the time when the message was received; message content, which is the specific content of the message, including a payload that can be used for detection and subsequent analysis.

[0042] 4. In order to record the timestamps of the latest two messages for each CAN ID, create a dictionary or hash table to store these timestamps. The key of the dictionary is the CAN ID, and the value is a list containing two timestamps, representing the timestamps of the latest message. and the timestamp of the previous message ,in Represents the serial number of the CAN ID. In the initial state, the lists corresponding to all CAN IDs are empty.

[0043] 5. Whenever a new CAN message is received, check its CAN ID. If the CAN ID already exists in the dictionary, update its timestamp list: Store as the latest timestamp and the original timestamp Updated to the timestamp of the previous message If the CAN ID does not exist in the dictionary, a new entry is created and the timestamp of the current message is Stored as the latest timestamp, the timestamp of the previous message Initially empty or set to a default value (such as 0 or a special flag).

[0044] 1. Temporal feature extraction

[0045] The present invention extracts time features based on time interval data, which is crucial for detecting attack patterns because it can help identify abnormal changes in message sending frequency. The time feature of the message sent by the CAN ID is the log-likelihood sequence of the time intervals of the messages of the CAN ID in the past period of time.

[0046] Figure 2 The figure shows a schematic diagram of the time feature extraction process. In the figure, A, B, and C are the serial numbers of the CAN ID. PDF represents the probability density function, which is used to describe the probability distribution of the time interval, so as to calculate the mean and standard deviation. The specific process is as follows:

[0047] First, extract the timestamps of the two latest messages for each CAN ID from the previously recorded timestamp data and .here Indicates CAN ID The timestamp of the latest message, and Indicates the timestamp of the previous message. Then calculate the two time interval values and .

[0048] in, The time interval between the latest message and the previous message with the same ID; ,This time interval reflects the change in the sending frequency between messages of the same CAN ID. The time interval from the last time a message with the same ID was received to the current time point; ,in, Indicates the current time point. This time interval reflects the time difference between the current time point selected and the last received message with the same ID, which helps detect message sending delays or other attacks.

[0049] To simplify processing and reduce data dimensionality, we choose two time intervals and The larger time interval value is used as the message time interval value , For normal training, It is usually not used because its smaller value reduces the likelihood. However, abnormally large Numeric values ​​are useful.

[0050] The log-likelihood value can help us better understand the distribution characteristics of the time interval and be used for subsequent intrusion detection. The present invention calculates the log-likelihood value of the time interval value of the message and uses the constructed log-likelihood sequence as the time feature. The calculation steps of the log-likelihood value are as follows:

[0051] 1. Calculate the average of all time interval values :

[0052] ,

[0053] in, It is the number of all time interval values ​​of a CAN ID. In the above process of calculating the time interval, the time interval values ​​of all messages calculated are All are saved and used to calculate the average value and subsequent standard deviation . It is The average value of the time interval. Describes the average value of the time interval, reflecting the typical frequency of message sending under normal circumstances.

[0054] 2. Calculate the standard deviation of all time interval values :

[0055] ,

[0056] Standard Deviation Describes the degree of dispersion of the time interval value and reflects the range of variation in the frequency of message sending. A larger standard deviation indicates a larger fluctuation in the time interval value, while a smaller standard deviation indicates a more stable time interval value.

[0057] 3. Calculate a time interval value The log-likelihood value of :

[0058] ,

[0059] The larger the log-likelihood value, the more the time interval value conforms to the normal distribution; the smaller the log-likelihood value, the more likely the time interval value is an outlier.

[0060] The log-likelihood sequence of the time interval is used as the feature matrix of the time feature for subsequent fusion to pay more attention to the changes in the most recent time interval. The log-likelihood sequence of To fix the size of the input sequence, we will Set to CAN ID exist The average message frequency per second. Therefore, the CAN ID The log-likelihood sequence of the time interval can be expressed as:

[0061] ,in, Indicates at a point in time CAN ID time interval.

[0062] For each CAN ID , we create a The matrix Each row of the matrix represents the log-likelihood of a time interval. In order to determine the window size ,We calculate the historical message frequency of each CAN ID in the past The average number of messages received per second If the system receives the ID The system will update the new message Specifically, the log-likelihood value of the latest time interval is added to the last row of the matrix, and the other rows are shifted up by one position, removing the oldest row. The log-likelihood sequence as the extracted time feature.

[0063] 2. Signal Feature Extraction

[0064] After extracting the message timestamp and calculating the time interval from the CAN bus, the next step is to extract the signal value from the payload of the CAN message. These signal values ​​contain rich information and can be used as signal features, which are very important for subsequent intrusion detection and data analysis.

[0065] To extract signal features, first use the CAN database (DBC) file to decode the payload of the CAN message. The DBC file is a standard format file that defines the structure and content of the CAN message, including the name, start bit, length, data type, and other information of each signal. The specific steps are as follows:

[0066] 1. Get the DBC file provided by the vehicle manufacturer, or use a generic DBC file. DBC files can usually be downloaded from the vehicle manufacturer's technical support website or obtained through third-party tools.

[0067] 2. Use a tool or library that supports DBC file parsing (such as Python's cantools library) to load the DBC file. The loaded DBC file can be used to decode the payload of the CAN message.

[0068] 3. Use a CAN bus reading device (such as an OBD-II adapter or a dedicated CAN analyzer) to connect to the vehicle's CAN bus interface, start the data acquisition program, and start monitoring all messages on the CAN bus. Whenever a new CAN message is received, record the CAN ID and payload data of the message.

[0069] 4. Use the loaded DBC file to decode the payload data of the CAN message. First, find the corresponding signal definition in the DBC file according to the CAN ID of the CAN message. Then use the information in the signal definition (such as start bit, length, data type, etc.) to extract the value of each signal from the payload data. Finally, convert the extracted signal value into data with physical meaning, such as temperature, speed, voltage, etc.

[0070] To improve detection performance and reduce computational cost, we selectively analyze key signals instead of analyzing all signals generated on the vehicle CAN bus. Continuously changing signals are well suited to the model's learning capabilities in a specific context. Based on the system's detection goals and computational resources, identify key signals that need to be protected. These signals are typically those that have a significant impact on the vehicle's operating status, such as engine speed, vehicle speed, throttle position, etc. is the CAN ID set corresponding to the selected signal, and its number of elements is m. These selected signals will be used for subsequent feature extraction and model training.

[0071] The criteria for signal selection include importance, frequency of change, and computational cost. Importance refers to selecting signals that have a direct impact on the vehicle's operating status; frequency of change refers to selecting signals that change frequently during normal operation in order to better capture attack behaviors; computational cost refers to selecting signals with low computational overhead to ensure the model's efficiency and real-time performance. By selecting key signals, we can reduce unnecessary computational burden while maintaining detection performance and improve the overall efficiency of the system.

[0072] The signal characteristics of the message sent by the CAN ID are the time series composed of the key signal values ​​in the message in the past period of time. In order to better capture the time characteristics of the signal, we process the signal characteristics in the same way as the above time characteristics. The signal value of each CANID is organized into a time series, and the input of each ID is designed to contain the past The signal value in seconds. Still for ID exist The average message frequency per second. Therefore, ID The input signal sequence can be expressed as:

[0073] ,

[0074] in, Representation ID If the system receives the ID The system will update the new message .

[0075] For each CANID , we create a The matrix ,in is the number of selected signals. Each row of the matrix represents the signal value at one time step, and each column represents the value of a signal at multiple time steps. When the system receives a new CAN message, we update Specifically, the latest signal value is added to the last row of the matrix, and the other rows are shifted up by one, removing the oldest row.

[0076] 3. Feature Fusion

[0077] In order to effectively detect attack events on the CAN bus, it is necessary not only to extract time features and signal features from the CAN bus, but also to effectively fuse these features. Figure 3 As shown, it is described in detail how to splice the time interval log-likelihood value and the signal value into a comprehensive feature matrix and normalize it for subsequent model training and intrusion detection.

[0078] In the data processing stage, we have calculated and obtained the log-likelihood value of the time interval for each CAN ID and organized it into a dimension of Feature Matrix Similarly, the signal values ​​are extracted from the payload of the CAN message and organized into a dimension of The characteristic matrix In order to effectively integrate time features and signal features, we transform the time interval log-likelihood matrix Sum signal characteristic matrix Use horizontal splicing to fuse into a comprehensive feature matrix :

[0079] ,

[0080] The integrated feature matrix after fusion is a time series with dimension .

[0081] To ensure that the signal value is within a reasonable range, we use the min-max scaling method. Normalize it. First, we need to calculate Maximum With minimum , the normalized formula is:

[0082] ,

[0083] in, and They are the feature matrices Middle The minimum and maximum values ​​of the column elements, which can be obtained from the DBC file and the log-likelihood calculation results.

[0084] 4. Detection Model

[0085] The detection model of the present invention includes an LSTM neural network model and an encoding, decoding and re-encoding model. LSTM (Long Short-Term Memory) is a neural network specifically used for learning time series data. Our model uses the LSTM architecture to generate a potential vector that represents the state of the CAN bus traffic. Specifically, our model includes m LSTM sub-networks corresponding to the m CAN IDs corresponding to the selected signal, that is, the number of LSTM sub-networks is the same as the number of selected CAN IDs. The input signal sequence of each ID is fed into the corresponding LSTM sub-network.

[0086] 1. LSTM neural network model

[0087] 1.1. Input feature matrix:

[0088] For each CAN ID , input feature matrix The dimension of (the comprehensive feature matrix or its normalized matrix) is ,in is the length of the time window, 1 corresponds to the time feature, is the number of signals corresponding to the CAN ID. The input feature matrix for each time step t Contains time features and signal features.

[0089] 1.2. Construct LSTM sub-network:

[0090] For each CAN ID , build an LSTM sub-network. The input feature matrix of each LSTM sub-network The dimension is Each LSTM sub-network has hidden units, where is the total number of input features, It is the size of the hidden layer that determines the complexity of the model.

[0091] 1.3. Forward propagation:

[0092] The feature matrix of each time step t Input to the corresponding LSTM sub-network. The output of each LSTM sub-network is its hidden state , represents the state of the CAN ID at time step t. Hidden state The dimension is .

[0093] 1.4. Output feature vector:

[0094] Concatenate the outputs (i.e., hidden states) of all LSTM sub-networks into a joint latent vector :

[0095] ,

[0096] For convenience, we assume is the combination of comprehensive feature values ​​of all IDs at time step t, , then the joint latent vector The length is ,in is the number of CAN IDs, is the total number of input features for each CAN ID, is the size of the hidden layer.

[0097] Through the above LSTM processing, our model can effectively capture the long-term dependencies in time series data, improve the processing capabilities of time interval features and signal features, and thus improve the accuracy of intrusion detection.

[0098] 2. Encoding, decoding and re-encoding model

[0099] like Figure 4 As shown, the encoding, decoding and re-encoding model includes an encoder , Decoder and encoder After LSTM processing, the joint latent vector It is fed into the encoding-decoding-reencoding model to further capture and reconstruct the feature vector. First it is fed into the first encoder Perform dimensionality reduction processing.

[0100] Encoder The task is to transform the high-dimensional joint latent vector Compressed into a low-dimensional raw intermediate representation Through linear transformation and activation function, the encoder It can extract key features from the input data and compress it into a lower-dimensional space. Specifically, the encoder The intermediate representation is calculated using the following formula:

[0101] ,

[0102] in, is an activation function (such as ReLU or tanh), used to introduce nonlinearity; is the weight matrix, responsible for linear transformation; is the bias vector used to adjust the transformed result.

[0103] Next, the original intermediate representation is sent to the decoder D for reconstruction. The task of the decoder D is to convert the low-dimensional original intermediate representation Re-map back to the original high-dimensional space to reconstruct the latest comprehensive features as accurately as possible . Latest comprehensive features The comprehensive feature matrix corresponding to all selected CAN IDs The decoder D also uses linear transformation and activation function to achieve this goal. Specifically, the decoder uses the following formula to calculate the reconstructed comprehensive features :

[0104] ,

[0105] in, is the activation function (e.g. ReLU or tanh), is the weight matrix, is the bias vector. In this way, the decoder can generate Reconstruct the comprehensive features as similar as possible .

[0106] To evaluate the accuracy of the reconstruction, we define the first loss function , used to measure the latest comprehensive features and reconstruct comprehensive features The difference between:

[0107] ,

[0108] This loss function is used to guide the first encoder and the optimization of the decoder D to ensure the reconstruction of comprehensive features As close to the latest comprehensive features as possible .

[0109] In order to further verify the accuracy of the reconstruction, the comprehensive features is fed again into the second encoder Processing. Encoder The task is to reconstruct the comprehensive features Compressed again into a low-dimensional reconstructed intermediate representation The role of the re-encoder is to evaluate whether the reconstruction process retains the main features of the original input. The new intermediate representation is calculated using the following formula:

[0110] ,

[0111] in, is the activation function (e.g. ReLU or tanh), is the weight matrix, is the bias vector.

[0112] To evaluate the performance of the re-encoder, we define a second loss function , used to measure the original intermediate representation and the re-encoded reconstructed intermediate representation The difference between: .

[0113] This loss function is used to guide the decoder D and the second encoder Optimization to ensure the reconstructed intermediate representation after re-encoding As close as possible to the original intermediate representation .

[0114] Through the above encoding, decoding and re-encoding process, the combined latent vector After encoding, decoding and re-encoding, a new intermediate representation is finally generated and , and reconstruct comprehensive features This process not only helps to capture and reconstruct the feature vector, but also and To evaluate the accuracy of reconstruction, so as to improve the ability to identify attacks. and its reconstruction The loss function is also defined, so it can capture more potential information. Compared with the autoencoder, that is, the Encoder-Decoder structure, it can reduce information loss and ensure that the model can more accurately identify and distinguish normal and attack behaviors.

[0115] 5. Adversarial Training

[0116] In order to further improve the accuracy of the model's feature reconstruction, we introduced an adversarial training mechanism based on encoding, decoding and re-encoding. This mechanism enhances the robustness and generalization ability of the model through the game between the generator and the discriminator. The generator consists of the first encoder and decoder D, which is responsible for converting the joint latent vector Mapping to low-dimensional raw intermediate representation , and then reconstruct it back into a comprehensive feature The discriminator is used to determine whether the comprehensive features of the input come from the real data distribution or the reconstructed data generated by the generator.

[0117] The goal of the generator is to reconstruct the comprehensive features As close to the latest comprehensive features as possible , making it difficult for the discriminator to distinguish between real and reconstructed data. The discriminator is a binary classifier whose goal is to maximize the latest comprehensive features. and reconstruct comprehensive features To achieve this goal, we use a loss function , this loss function measures the discriminator's ability to detect the latest comprehensive features and reconstruct comprehensive features Differences in intermediate layer feature representation:

[0118] ,

[0119] in, Represents the feature representation of a layer inside the discriminator. By minimizing , we can ensure that the reconstructed comprehensive features generated by the generator As close as possible to the latest comprehensive features in feature space .

[0120] During adversarial training, the generator and discriminator are trained by alternate optimization. In each iteration, the discriminator parameters are first updated to improve its classification accuracy, and then the generator parameters are updated to deceive the discriminator. In order to ensure that the generator and discriminator can make progress together, we adopt a balancing strategy that controls the update frequency of the generator and discriminator to prevent one from converging too early and causing the other to fail to learn effectively.

[0121] Through the above adversarial training mechanism, our model can not only effectively capture and reconstruct the feature vector, but also improve the accuracy of feature reconstruction through the game between the generator and the discriminator, thereby improving the overall performance of the model. Through the adversarial learning mechanism, the present invention can not only perform well on known attack types, but also effectively deal with new attacks that have not been seen, greatly enhancing the robustness and generalization ability of the system.

[0122] Detecting Attacks

[0123] Based on encoding, decoding, re-encoding and adversarial training, our model can effectively capture and reconstruct the characteristic distribution of normal data. Through this process, we can perform intrusion detection on unknown messages during the test phase. Specifically, intrusion detection is based on reconstruction error and re-encoding error to determine whether it is an attack. The following is a detailed intrusion detection process:

[0124] 6.1 Anomaly score calculation

[0125] In the testing phase, for each of the latest comprehensive features , we calculate its comprehensive anomaly score :

[0126] ,

[0127] in, and are the reconstruction error and the re-encoding error, respectively, and and is the weight parameter used to adjust the importance of the two error terms.

[0128] 6.2 Threshold Setting and Classification

[0129] In order to distinguish normal messages from attack behaviors, we set a threshold φ for the anomaly score. When the message exceeds the threshold ϕ, the message is considered an attack. The threshold ϕ can be determined by cross-validation or based on the statistical characteristics of normal messages in the training set.

[0130] Through the above intrusion detection process, our model can not only effectively capture and reconstruct the characteristic distribution of normal data, but also identify attack behaviors through comprehensive anomaly scoring, thereby improving the accuracy and robustness of intrusion detection.

[0131] The above description of the specific implementation mode is only used to help understand the technical concept and core idea of ​​the present invention. Although the technical solution is described and illustrated using a specific preferred embodiment, it should not be understood as a limitation of the present invention itself. Those skilled in the art may make various changes in form and details without departing from the technical concept of the present invention. These easily conceived changes or substitutions should all be included in the protection scope of the present invention.

Claims

1. A CAN bus feature fusion intrusion detection method based on adversarial learning, characterized by: Get the message transmitted on the CAN bus, select the CAN ID corresponding to the message containing the key signal, and extract the time characteristics and signal characteristics of the message sent by the selected CAN ID; splice the time characteristics and signal characteristics corresponding to the same CAN ID to obtain a comprehensive feature matrix in the form of a time series for each CAN ID; The comprehensive feature matrix corresponding to all selected CAN IDs is input into the detection model for data processing and adversarial training, and the latest features in the comprehensive feature matrix corresponding to all selected CAN IDs are spliced ​​to obtain the latest comprehensive features. ; The detection model includes an LSTM neural network model and an encoding, decoding and re-encoding model; The LSTM neural network model has a number of LSTM subnetworks corresponding to the number of selected CAN IDs, each LSTM subnetwork is used to process the corresponding CAN ID comprehensive feature matrix; the outputs of each LSTM subnetwork are spliced ​​to obtain a joint potential vector ; The encoding, decoding and re-encoding model includes an encoder , Decoder and encoder , where the encoder For the joint latent vector Perform dimensionality reduction to obtain the original intermediate representation of low dimension , the decoder is used to convert the original intermediate representation Up-dimensional reconstruction obtains close to the latest comprehensive features Reconstruction of comprehensive features ; Encoder Used to reconstruct the comprehensive features Dimensionality reduction to obtain low-dimensional reconstructed intermediate representation ; Based on the reconstruction of the comprehensive characteristics With the latest comprehensive features The reconstruction error is obtained by the difference between With the original intermediate representation The difference between them is used to obtain the recoding error; the latest comprehensive feature Anomaly scoring is performed to determine whether aggressive behavior exists; The detection model is trained adversarially using the adversarial training mechanism of the generator and the discriminator. The generator is composed of the encoder and decoder composition, whose goal is to reconstruct the comprehensive features As close to the latest comprehensive features as possible , the discriminator is a binary classifier whose goal is to maximize the latest comprehensive features and reconstruct comprehensive features The classification accuracy of the generator and the discriminator is optimized alternately through adversarial training.

2. The CAN bus feature fusion intrusion detection method based on adversarial learning as claimed in claim 1 is characterized in that: The time feature of the message sent by the CAN ID is the log-likelihood sequence of the time intervals of the messages of the CAN ID in the past period of time, where the time interval between the latest message and the previous message of the same CAN ID is calculated. , and the time interval from receiving the latest message of the CAN ID to the current time point , select two time intervals and The larger value of is taken as the time interval between messages and its log-likelihood value is calculated; the log-likelihood value of the time interval between messages in the past period of time is used to construct a log-likelihood sequence.

3. The CAN bus feature fusion intrusion detection method based on adversarial learning as claimed in claim 1 is characterized by: The signal feature of the message sent by the CAN ID is a time series composed of key signal values ​​in the messages within a period of time in the past.

4. The CAN bus feature fusion intrusion detection method based on adversarial learning as claimed in claim 1 is characterized in that: The time characteristics and signal characteristics of the message sent by the CAN ID are both time series. The time series of the time characteristics and signal characteristics are horizontally spliced ​​to obtain a comprehensive feature matrix in the form of a time series for each CAN ID, and the comprehensive feature matrix is ​​normalized.

5. The CAN bus feature fusion intrusion detection method based on adversarial learning as claimed in claim 1 is characterized in that: The dimension of the comprehensive feature matrix is ,in is the number of signals corresponding to the CAN ID, is the length of the time window; the corresponding LSTM sub-network has hidden units, where is the size of the hidden layer; The output dimension of the LSTM sub-network corresponding to the comprehensive feature matrix input after processing is The hidden state of all LSTM sub-network outputs is concatenated to form a length of The joint latent vector ,in, , The number of the selected CAN ID.

6. A CAN bus feature fusion intrusion detection method based on adversarial learning as claimed in claim 1, characterized in that: The encoder The formula used is: ,in, is the activation function, is the weight matrix, is the bias vector.

7. The CAN bus feature fusion intrusion detection method based on adversarial learning as claimed in claim 1 is characterized by: The decoder The formula used is: ,in, is the activation function, is the weight matrix, is the bias vector; Constructing the loss function To guide the encoder and decoder The optimization of As close to the latest comprehensive features as possible .

8. The CAN bus feature fusion intrusion detection method based on adversarial learning as claimed in claim 1 is characterized by: The encoder The formula used is: ,in, is the activation function, is the weight matrix, is the bias vector; Constructing the loss function To guide the decoder and encoder The optimization makes the reconstructed intermediate representation after re-encoding As close as possible to the original intermediate representation .

9. The CAN bus feature fusion intrusion detection method based on adversarial learning as claimed in claim 1 is characterized by: Calculate the latest comprehensive features Anomaly score , by scoring the anomaly Compare with the set threshold to distinguish normal messages from attack behaviors; Anomaly Scoring The calculation formula is: ,in, and are the reconstruction error and the re-encoding error, respectively. and is the weight parameter.

Citation Information

Patent Citations

  • Hierarchical network attack identification and unknown attack detection method based on deep learning

    CN110691100A

  • Vehicle-mounted intrusion detection method and system based on CAN bus data frame

    CN115314311A