{'fraction_non_alphanumeric': 0.03394971950966134, 'fraction_numerical': 0.010180760440473717, 'mean_word_length': 4.624211264314092, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
An Adversarial Attack Defending System for Securing In-Vehicle Networks

In a modern vehicle, there are over seventy Electronics Control Units (ECUs). For an in-vehicle network, ECUs communicate with each other by following a standard communication protocol, such as Controller Area Network (CAN). However, an attacker can easily access the in-vehicle network to compromise ECUs through a WLAN or Bluetooth. Though there are various deep learning (DL) methods suggested for securing in-vehicle networks, recent studies on adversarial examples have shown that attackers can easily fool DL models. In this research, we further explore adversarial examples in an in-vehicle network. We first discover and implement two adversarial attack models that are harmful to a Long Short Term Memory (LSTM)-based detection model used in the in-vehicle network. Then, we propose an Adversarial Attack Defending System (AADS) for securing an in-vehicle network. Specifically, we focus on brake-related ECUs in an in-vehicle network. Our experimental results demonstrate that adversaries can easily attack the LSTM-based detection model with a success rate of over 98%, and the proposed AADS achieves over 99% accuracy for detecting adversarial attacks.


I. INTRODUCTION
Nowadays, a modern vehicle, such as a connected and autonomous vehicle (CAV), contains a great number of Electronics Control Units (ECUs) that communicate with each other based on a standard communication protocol, such as Controller Area Network (CAN), in a vehicle network. With the development of CAVs, more and more ECUs are added in a vehicle for advancing driving functionalities, such as lane changing, parking assistance, and emergency braking [1]. All these features may require a vehicle to communicate with itself, other vehicles, and infrastructures, such as Vehicle-to-Vehicle (V2V) and Vehicle-to-Infrastructure (V2I) communication [2].
Securing in-vehicle networks is as important as ensuring the security of Vehicle-to-Everything (V2X) communication.
Researchers have shown that ECUs in an in-vehicle network are vulnerable to remote attacks [3], [4]. An attacker can easily access an in-vehicle network to compromise ECUs through a WLAN or Bluetooth since ECUs are all connected and vice versa. Thus, in-vehicle networks are vulnerable to a variety of attacks, such as intrusion attacks and false data injection attacks (FDIA) [5]. Deep learning methods have been widely used to detect attacks in in-vehicle networks [6], [7]. However, recent studies have shown that deep learning models are usually vulnerable to adversarial examples [8].
Adversaries can manipulate input data and force a trained model to produce mis-classified outputs. This makes a deep learning-based detection model useless. Hence, it is crucial to building a robust deep learning model against adversarial examples.
Current studies are mostly focused on developing and defending adversarial attacks in image datasets, such as crafting adversarial examples based on the MNIST dataset and attacking traffic signs in a CAV system [9]. In this paper, we explore two adversarial attacks: Fast Gradient Sign Method (FGSM) attack and Basic Iterative Method (BIM) attack on sequential datasets. To show the limitation of the machine learning based detection model, we first adopt the method used in [6] to build an LSTM-based detection model that can detect false data injection attacks with a success rate of over 98%. Then, we show that FGSM and BIM attacks can easily bypass this high performance LSTM-based detection model among 99% of the time. To countermeasure against these adversarial attacks, we propose an Adversarial Attack Defending System (AADS) for in-vehicle networks, where AADS can build a robust LSTM-based detection model that able to detect both false data injection attack and two adversarial attacks efficiently.
Our main contributions are summarized as follows: 1) To demonstrate the limitation of the LSTM-based detection model, we implement two adversarial attacks for attacking the LSTM-based detection model. Our experimental results demonstrate that adversaries can easily attack the LSTM-based detection model with a success rate of over 98%. 2) To overcome these adversarial attacks, we propose AADS to detect adversarial attacks efficiently. To be precise, we countermeasure two adversarial attacks, FGSM and BIM, by adversarially retrianing our detection model iteratively such that we obtain a robust detection model to defend aganist both attacks.
The rest of the paper is organized as follows. Section II discusses related work about in-vehicle network security and adversarial attacks. Section III presents adversarial attack models. In Section IV, we give the design of the proposed AADS. Then, in Section V, we discuss the evaluation of AADS, such as detection accuracy, adversarial attack success rate, and results of defending the adversarial attacks. Last, the conclusion of our studies and future work are presented in Section VI.

II. RELATED WORK
An in-vehicle network is vulnerable to many different types of attacks due to several intrinsic vulnerabilities of a CAN bus, such as broadcast transmission, no authentication, and no encryption. The attackers can access in-vehicle networks through interfaces like Bluetooth and Wi-Fi to perform attacks, such as FDIA, replay attack, and Denial of Service (DoS) attack [10].
Recently, machine learning methods have been applied in intrusion detection for in-vehicle networks. Kang et al. [7] proposed an intrusion detection system (IDS) using a deep neural network (DNN) to secure in-vehicle networks. A pretrained unsupervised deep belief network was used to initialize the parameters of their DNN model in order to achieve better accuracy. Kuwahara et al. [11] focused on the observation of CAN messages in a fixed time window to detected intrusions. They adopted both supervised and unsupervised learning to perform intrusion detection.
Khan et al [6] proposed an in-vehicle false information attack defending framework using machine learning and adopted SDN in their framework. Their highest classification accuracy is 95% with a precision and recall of 0.95 and 0.87, respectively.
Deep learning methods have been found to be extremely successful for a variety of fields. However, researchers have recently discovered that the deep learning models can be compromised by adversarial attacks [8]. Chakraborty et al. [9] surveyed different types of adversarial attacks and present some existing countermeasures against adversarial attacks. They discussed the efficiency and challenges of those countermeasures. Most existing studies on adversarial attacks focus on attacking images [12]- [14].
More recently, there are some studies regarding adversarial attacks in the CAV domain. They mainly focus on image aspects as well, such as vehicle detection and object detection [15]. Cao et al. [16] proposed an adversarial sensor attack on LiDAR sensors to fool the LiDAR-based perception into detecting wrong objects and making wrong decisions in an autonomous vehicle. Their new attacking method increased the success rate by 2.65 times on average. In this paper, we focus on attacking an in-vehicle network. We study the sequential dataset instead of image dataset. We consider two adversarial attacks, FGSM and BIM, as our threat models. To the best of our knowledge, our study is the first to apply adversarial attacks on in-vehicle networks.

III. ATTACK MODEL
Deep learning methods have been widely applied to a variety of domains, including image classification, Natural Language Processing (NLP), speech recognition, CAVs, and malware detection. Ensuring the security of deep learning methods used in those domains has become a crucial task, especially in the area of security-critical environments, such as CAVs. Szegedy et al. [8] first found that the neural network models can be compromised by adversarial attacks. That is, attackers can create adversarial examples to limit the use of neural networks. Similarly, adversarial examples can be used by attackers to cause a vehicle to take unexpected actions and result in disastrous consequences. In this section, we first briefly present the FDIA model adopted from [6] to attack ECUs. Then, we introduce two adversarial attack methods to attack the LSTM-based detection model.

A. False Data Injection Attack (FDIA)
An adversarial attacker has various ways to modify the original data. One easy way to modify the original data is to add some uniform random noise to it. We first observe the normal range for each signal. Then, we generate a random value that follows the uniform distribution within the interval of the normal range. The equation of the FDIA model is shown as follows: where is a uniform random value added to the normal data to create the adversarial data, X max i is the maximum value of a signal, i denotes the signal number, and X i is the adversarial data of ith signal modified by the attacker. For example, X 6 is the adversarial data of the 6th signal modified by the attacker. Detailed description of the dataset can be found in [6].

B. Fast Gradient Sign Method (FGSM)
In this paper, we assume that an attacker has complete knowledge of a neural network model. That is, the attacker can access the architecture of the neural network model and all parameters from the model. This is considered as a whitebox attack.
First, let's give out some notations. Let F (X) be the neural network model that takes the input X ∈ R n for some integer n and yields the output y. Given a valid input X, attackers will try to create a similar input X so that the output of adversarial input does not match its original one, that is F (X ) = F (X), but ||X − X || < η for some specified small number η ∈ R. Note that the || * || is some application specific metrics for measuring the similarity between X and X . In this paper, the distance metric we use is L2 metric, which is a standard Euclidean distance between X and X .
There are two types of adversarial attacks: targeted and untargeted adversarial attacks. Targeted adversarial attacks search for an adversarial input X such that it will be classified as the specified class t. That is, F (X ) = t, t = y. On the contrary, untargeted adversarial attacks only search for an adversarial input X so that F (X ) = y.
An attacker can attack the deep learning based detection model by using the fast gradient sign method [14]. The deep learning model is obtained through gradient descent optimization to minimize the cost function J(X, y label ), i.e., reduce the error between the true label y label and the predicted labels y pred . On the contrary, an attacker wants to increase the error, and a simple but effective way to do it is increasing the error by gradient ascent of the cost function ∇ X J(X, y label ). That is, an attacker can simple add noise in the direction of gradient ascent of the cost function sign(∇ X J(X, y label )). Hence, X can be calculated using FGSM as follows: where is included to control the magnitude of the noise. In order to keep the adversarial examples X as similar as X, we usually try to choose a value of that is as small as possible.

C. Basic Iterative Method (BIM)
BIM is an iterative version of FGSM proposed by Kurakin [13]. BIM generates the adversarial examples iteratively using a smaller step α. First, we set up the initial: and then X i+1 is calculated as follows: where α is the step size and Clip X, { * } is the element-wise clipping of X to make the clipped value belong to the range of [X i,j − , X i,j + ]. This ensures that the generated adversarial examples are in the original range of the input X so that it cannot be easily detected by a simple outlier detector.
To craft adversarial data using FDIA, we observe the normal range for each signal from the DBC file for KIA Soul and generate a random value that follows the uniform distribution within the interval of the normal range. For the sample that has a period of 10 seconds, we then randomly choose 1 second to attack. Figure 1(b) shows an example of FDIA attack to the normal signal in Figure 1(a). A LSTM-based detection model proposed in [6] can easily detect this attack model with nearly 100% success rate. However, such a type of deep learning based detection model itself is vulnerable to adversarial attacks. For instance, we can modify the attack signal in Figure 1(b) slightly with fast gradient sign method described in subsection B. As shown in Figure 1(c), there is still attack at 393-394 seconds and its signal is quite similar to one shown in Figure 1(b). Intuitively, we can assume if LSTM-based detection model can correctly identify the attack signal in (b), it likely ables to detect the attack signal in (c). However, the LSTM-based detection model unable to detect it; i.e., it classifies signal in (b) as "Attack" but misclassifies signal in (c). as "Normal." Similarly, in the case of BIM, Figure 1(d), the LSTM-based detection model fails to recognize that signal in (d) is the attack signals.

IV. METHODOLOGY
CAN is a standard bus communication protocol that has been widely used for in-vehicle network communication. It uses a broadcasting method to transmit messages from one ECU to other ECUs on the bus. The source and destination information are not included in the transmitted messages. Thus, it is vulnerable to attacks due to a lack of authentication. An attacker can easily modify the data on the CAN bus, and this can result in vehicle malfunctions. In this section, we first describe the dataset and data processing method used in this study. Then, we introduce our AADS in details.

A. Data Processing
In order to examine the efficacy of proposed AADS, the dataset from real in-vehicle CAN bus is used in this paper. It is collected from the KIA SOUL by Hacking and Countermeasure Research Lab [17]. In order to better understand and process the dataset, the raw CAN data frames need to be decoded. We use a generic KIA DBC file decoder from OpenDBC repository to decode the dataset [18]. OpenDBC is created by CommaAI with a repository of DBC files for different models of vehicles. The DBC file is usually used to describe the data over a CAN bus. It has the information to decode CAN data frames. For instance, we can use the scale and offset values in the DBC file to convert raw bits of data into signal values. In the raw dataset, the CAN IDs (CID) are in hexadecimal format whereas the Message IDs (MID) are decimal in the DBC file. Therefore, we first need to convert the CIDs in the raw dataset to match the MIDs in the DBC file for decoding.
Each CAN ID has a specific ECU associated with it, and each ECU has multiple signals. Each signal has its own decoding information like scale and offset. For the comparison purpose, we explore 20 signals associated with five ECUs the same as Khan et al. [6]. These ECUs are Motor Driven Power Steering (MDPS), Engine Management System (EMS), Anti-lock Braking System (ABS), Electronic Parking Brake System (EPB), and Electronic Stability Control System (ESC). MDPS and EMS ECUs send CAN messages/frames to ABS, EPB, and ESE. EMS broadcasts four types of CAN messages (MSG), including EMS11, EMS12, EMS14, and EMS16, whereas MDPS ECU broadcasts SAS11 CAN messages. Each type of CAN messages contains different signals, such as TQI ACOR, TQFR, N, TQI, TPS, VB, etc. The detailed information of message type and signals as well as the detailed information for decoding the raw CAN data frames can be found in [6].
Since we only investigate brake related ECUs, we first need to filter out all unrelated data. After filtering, we have 952,101 rows of CAN data frames. The number of CAN data frames for each CAN ID is evenly distributed. We use 20 signals presented in [6].
Then, the dataset is divided based on the timestamps. We choose each 10 seconds as one sample. For example, the first sample lasts from the 1st second to the 10th second, and the second sample lasts from the 2nd second to the 11th second, and so on. Thus, we creates 1894 samples in total. Among these samples, half of them are randomly selected to craft adversarial data.

B. AADS Architecture
In this study, we propose an adversarial attack defending system to defend against adversarial attacks. We create a malicious ECU that is connected to the CAN bus. There are six ECUs connected to the CAN bus. EMS and MDPS ECUs can only broadcast CAN messages, whereas ABS, ESC, and EPB ECUs can only receive CAN messages. The malicious ECU can both broadcast and receive CAN messages.
1) LSTM-based Detection Model: In the AADS, we build an LSTM-based detection model to detect FDIA by following [6]. We use 20 signals as input features, and each input feature is a sequence of decoded CAN signal values. In our model, the LSTM layer contains 128 neurons. Then, an output layer with only one neuron follows the LSTM layer. This is because we are dealing with a binary classification problem, whose output is either 1 (Attack) or 0 (Normal). The activation function we use for this layer is sigmoid. The cost function we use is binary cross-entropy. The optimization function we choose is Adam [19], which is an adaptive learning rate optimization algorithm. It computes individual learning rates for different parameters.
In our dataset, we have 1894 instances in total. Among these instances, we use 80% of the dataset for training, 10% for validation, and 10% for testing. To be precise, we have 1516 samples for training, 189 samples for validation, and 189 samples for testing. The total trainable parameters are 76,417.
2) Adversarial Attacks Defending Scheme: Adversarial attacks can compromise the trained machine learning model to produce incorrect classification results. In a scenario like CAVs, it can cause a deadly outcome if the system failed to perform correctly. In this paper, we explore two adversarial attacks, FGSM and BIM. First, we generate adversarial examples using both FGSM and BIM on the test dataset to see the efficiency of compromising the trained LSTM model. Then, we propose an adversarial retraining method to make the LSTM model more robust against both the FGSM and BIM attacks.
In order to build a robust LSTM detection model, we iteratively re-train the LSTM model using both the adversarial examples and the original training samples. Let S denote original samples, S denote samples after adversarial attacks on S, let N denote the batch size, and let i be the i-th iteration of re-training. Algorithm 1 shows the method of our adversarial attack defending scheme. For iteration i, the detailed steps of iterative re-training are 1) randomly choose In this section, we first evaluate the LSTM-based detection model. Then, we evaluate the effectiveness of FGSM and BIM attack followed by the evaluation of our adversarial attack defending scheme.

A. LSTM-based Detection Model Evaluation
The LSTM-based detection model has an input layer, a LSTM layer with 128 neurons, and an output layer. The number of epochs is set to 50. The training process is carried out on GAIVI2, which is a computer cluster with large scale parallel computing capabilities. GAIVI2 has a TensorFlow version of 2.0. We test with different optimizers, such as SGD, Adam, RMSprop, and Adagrad. Table I shows the evaluation of accuracy, recall, precision, F1 score, and training time for different optimizers. The accuracy is the accuracy of the unseen test set, and the Time column reports the time used to train the model in seconds.
We can see from Table I that with Adam optimizer, we have achieved the best performance with an accuracy of 99.47%. The recall, precision, and F1 score for the Adam optimizer are   Figure 2 shows the final results of the LSTM-based detection model. The training process runs for 50 epochs. On the top of Figure 2, it can be seen that we achieved a training accuracy of 99.93% and the validation accuracy of 99.98%. On the bottom of Figure 2, we report the binary cross-entropy loss, where the losses are 0.0012 and 0.00096 for training and validation respectively.

B. Adversarial Defending Scheme Evaluation
In this subsection, we demonstrate the limitation of the LSTM-based detection model by implementing two adversarial attacks for attacking the LSTM-based detection model obtained in the previous section. Then, we introduce our defending method.
We generate the adversarial example and use it to show the limitation of LSTM-based detection model. In order to keep the adversarial examples as similar as the original input, we try to choose a as small as possible. Figure 3(a) shows the attack success rates on the test dataset using both FGSM and BIM with different values. In the BIM attack, we find that when we set α = 1 and iterate five times, we can achieve the best results. We can see from Figure 3(a) that when = 5, BIM has reached the best success rate of 99.47%. Similarly, when = 13, FGSM has achieved the best success rate of 98.42%. In general, the BIM attack is more efficient than the FGSM attack to compromise our LSTM model. Table II shows the success rates, accuracies, best , and time used to craft adversarial examples on the test dataset for both FGSM and BIM. In our adversarial attack defending scheme, we apply iterative re-training to countermeasure adversarial attacks. We choose batch size N = 200 and iterate 100 times. Figure 3(c) shows the re-training accuracies against the FGSM attack at each iteration. The accuracies are evaluated on the validation set. We can see that when we run approximately 62 iterations, the training and validation accuracies become stable. This indicates that the FGSM attack can no longer affect our retrained LSTM model. In the early iterations, there are some large fluctuations, which is because for each iteration we randomly choose 200 samples from the training dataset and it takes some iterations to cover all the training dataset to be selected. Figure 3(d) shows the re-training accuracies against the BIM attack. When we run around 56 iterations, the training and validation accuracies become stable. Figure 3(b) compares the test accuracy of iterative re-training against FGSM and BIM, respectively. It shows that BIM attack performs better than FGSM to fool the LSTM model for the first 56 iterations. However, after more iterations, our LSTM model becomes more robust. Neither attack can reduce the performance of the retrained LSTM. Our results demonstrate that our adversarial attack defending method can successfully defend against both FGSM and BIM by iterative re-training.

VI. CONCLUSION
In this research, we proposed an adversarial attack defending system for in-vehicle networks. To demonstrate the need for such a system for any deep learning-based detection model and to show the limitation of the general deep learningbased detection model, we follow a recent paper by Khan et al. [6] to build an LSTM-based detection model. This LSTMbased detection model can successfully detect an attack signal Fig. 3. Evaluation of adversarial attack defending scheme generated by FDIA over 98% time. This may seem to be a good detection model initially; however, we are able to attack this LSTM-based detection model using FGSM and BIM attacks, respectively. The accuracies of the LSTM-based detection model are only 1.58% and 0.53% under FGSM and BIM attacks, respectively. This basically makes the LSTMbased detection model useless. This clearly indicates the drawback of using a deep learning-based detection model. Then, we present our proposed defending scheme against these attacks. The experimental results demonstrated that after our adversarial attack defending scheme is used, the retrained LSTM-based detection model becomes robust and is no longer affected by both FGSM and BIM attacks. Actually, we achieved an accuracy of 99.47% for detecting FDIA. In the future, we will explore more complex adversarial attack models to craft adversarial CAN messages, as well as to formalize the security guarantee.