1 00:00:00,000 --> 00:00:15,720 Okay, so hi all Welcome to the You know, the topic of my presentation is context-aware anomaly detection in Automotive CANN without decoding So my name is Ravi Rajput. 2 00:00:15,720 --> 00:00:29,020 I'm a principal architect and information security at Neotech Global I have expertise in telecom and automotive service security and I had 3 00:00:33,700 --> 00:00:40,060 I spent my life in Advanced pen testing. 4 00:00:40,400 --> 00:01:04,720 I had launched an AutoAC OS, which is an operating system designed for automotive pen testing and it was launched in BlackHat Arsenal in Asia and it has been It has reached millions of downloads now and it has been used by VMs I am a core team member of a telecom village at DefCon I had been I had presented at DefCon, 5 00:01:04,720 --> 00:01:40,820 BlackHat, HITV, NullCon, HitCon and several besides conferences So the agenda of today's talk is we will talk about how the CAN bus is blind and how the machine learning can detect the anomaly without the use of decoding it So we will go ahead with the demo as well We will we will talk about the working mechanism of the models that are the algorithms that will be used and We will discuss about the key findings and result and the deployment possibilities as well. 6 00:01:40,880 --> 00:01:46,940 And later we will have a Q&A So CAN bus is blind, right? 7 00:01:47,340 --> 00:01:52,360 The problem with CAN bus is there is no authentication Encryption or integrity check. 8 00:01:52,360 --> 00:01:53,680 There is no sanity checks. 9 00:01:53,860 --> 00:02:01,840 It's a broadcast architecture So every ECU can receive the message or can send the message, right? 10 00:02:01,920 --> 00:02:36,420 No built-in support for access control or anomaly detection the traditional Detection is based on the rules that catches the you know patterns There is no state awareness, okay, it's a stateless protocol CAN is a stateless protocol so it allows a malicious actor to inject the inconsistent state triggering the alerts Over here, 11 00:02:36,420 --> 00:03:18,060 we will use the machine learning algorithm to detect the CAN anomalies it Rely heavily on the you know protocol decoding the traditional way depends on the decoding while the approach That can be used for anomaly detection in CAN is supervised and unsupervised learning While the challenge with the supervised learning is that we need and CAN dataset labeled to understand the anomalies while the unsupervised Unsupervised learning doesn't need that, 12 00:03:18,060 --> 00:03:21,160 and that is the reason we will go with unsupervised. 13 00:03:22,580 --> 00:03:34,580 And if we see CAN messages as sequential and time-sensitive, we will be able to detect the anomalies. 14 00:03:35,540 --> 00:03:40,240 So anomalies doesn't mean that one wrong message, it's a break in the context. 15 00:03:41,540 --> 00:03:53,520 So, you know, the problem that I was trying to address was like every vehicle model have a different structure, signal, meanings, and encodings. 16 00:03:53,520 --> 00:03:56,880 So it's not scalable across the fleets or vendors. 17 00:03:57,320 --> 00:04:10,300 The solution for it is try to find out the frequency of CAN IDs and the burst patterns, payload byte entry entropy, timing deltas, and sequence correlation. 18 00:04:11,100 --> 00:04:18,680 The algorithm that can be used for detecting will be LSTM, and the better version will be LSTM VAE. 19 00:04:20,380 --> 00:04:27,240 So it can learn what a normal sequence of CAN messages look like. 20 00:04:27,240 --> 00:04:34,420 And when the frequency changes, what will be the, you know, correction error. 21 00:04:35,420 --> 00:04:42,340 So autoencoders are trained on normal behavior, and it reconstructs the expected output. 22 00:04:42,340 --> 00:04:50,460 Whatever the deviation is, if it is above some threshold, it is detected as an anomaly. 23 00:04:51,700 --> 00:04:56,540 So and then why LSTM and LSTM VAE? 24 00:04:56,540 --> 00:05:00,760 So LSTM is long short-term memory network. 25 00:05:01,180 --> 00:05:14,360 It knows what is to forget, what is to remember, and what is to be, like, so it knows the memory to be remembered. 26 00:05:14,480 --> 00:05:24,800 So it sees the, you know, the whole network as like the whole messages as a, what we say, the sequence. 27 00:05:25,450 --> 00:05:29,350 Okay, rather than picking up the messages separately. 28 00:05:30,140 --> 00:05:43,750 It's like a musician, you know, trying to play a music and if he misses a note or do some minor mistake, the whole music is disrupted. 29 00:05:44,260 --> 00:05:47,380 That is how the LSTM also works. 30 00:05:47,380 --> 00:05:49,030 It's a sequential thing. 31 00:05:50,170 --> 00:05:57,190 So the VAE adds a variational interface, inference to the standard VAE. 32 00:05:57,190 --> 00:05:59,750 It adds actually a latent distribution. 33 00:06:01,430 --> 00:06:08,670 So the intuition behind this LSTM is feed-free, feed-forward network. 34 00:06:09,790 --> 00:06:10,190 Okay . 35 00:06:11,450 --> 00:06:18,830 So it maintains, like, it has three gates, what to forget, what to remember, and what to output. 36 00:06:19,050 --> 00:06:21,990 Okay, so it maintains the cell state. 37 00:06:22,330 --> 00:06:30,610 Okay, so why the neural net failed for the sequence is there is no understanding of sequence flow and the time dependencies. 38 00:06:30,690 --> 00:06:39,230 So if we map the message IDs with the time, we will be able to understand the pattern and if there is a burst, there is a change in the pattern. 39 00:06:39,230 --> 00:06:43,530 We will be able to detect the anomalies above some threshold. 40 00:06:45,770 --> 00:06:50,390 So the sequence-to-sequence model will be like input sequence encoder. 41 00:06:50,870 --> 00:06:56,450 It will be feed to latent vector, then decoder, and it will try to reconstruct the sequence. 42 00:06:56,990 --> 00:07:01,230 Okay, the reconstruction error is typically mean sequence error. 43 00:07:01,590 --> 00:07:07,150 Okay, it will try to minimize this sequence error, but it still gets above. 44 00:07:07,810 --> 00:07:10,470 It will try to detect that. 45 00:07:10,470 --> 00:07:32,490 It's something like if I am driving my car from 0 to 10 to 20, then 25, 30 kilometers per hour, but there is a message saying that 0, then 10 kilometers per hour, but then all of a sudden there is a 100 kilometers per hour of message, then it is the change in a pattern. 46 00:07:32,630 --> 00:07:34,750 This is what LSTM detects. 47 00:07:36,310 --> 00:08:02,970 So, so that there is an input that you have to, like the input will be the sequence of 10 frames, typically shaped as, you know, sequence length, and we have to do the feature extraction engineering, like feature engineering, and then read the, the encoders will read the input sequence one time step at a time. 48 00:08:27,540 --> 00:08:29,800 Clearly, that anomalies are there. 49 00:08:31,240 --> 00:08:40,220 So the LSTM way is basically the extension of autoencoders with a latent variable on the distribution. 50 00:08:41,040 --> 00:09:02,140 Okay, so basically it has loss function is into two parts reconstruction loss, which actually measures how well the sequence is rebuilt, and the KL divergence loss, which measures how the how far latent distribution deviates from the standard normal. 51 00:09:02,680 --> 00:09:15,200 So it's a while you can consider this autoencoder as a, you know, not distributed, but this can be taught as a distributed as like the way. 52 00:09:18,460 --> 00:09:23,770 The major part of way is latent sampling. 53 00:09:24,200 --> 00:09:26,920 Okay, which introduced the control noise. 54 00:09:26,920 --> 00:09:34,690 Okay, that's a major difference between we and auto LSTM autoencoder. 55 00:09:35,660 --> 00:09:43,180 Why uncertainty matters in a can or anomaly detection is automotive networks are noisy and busty. 56 00:09:43,180 --> 00:09:46,160 Static threshold can cause false positives. 57 00:09:46,560 --> 00:09:50,880 Okay , need models that can express confidence, not just anomalies. 58 00:09:51,840 --> 00:09:58,760 And how this LSTM way tackles uncertainty is learns the distribution of a valid behavior rather than a fixed pattern. 59 00:10:00,160 --> 00:10:04,060 It produces a latent vector with a mean and variance. 60 00:10:05,040 --> 00:10:17,460 And samples from that mean and variance to the variability and more tolerance to the natural deviation. 61 00:10:17,460 --> 00:10:27,000 So if we talk about the real-life example, replay attack basically detected with the wrong timing. 62 00:10:27,000 --> 00:10:32,360 That is a latent shift draft KL spike in the divergence spike. 63 00:10:32,860 --> 00:10:36,280 While the fuzzing is detected on the entropy spike. 64 00:10:37,820 --> 00:10:57,600 Okay, so the data pipeline for the demo that we will do currently is we will, you know, collect the log for the normal, you know, canvas for training the data for training the model. 65 00:10:58,580 --> 00:11:09,480 While the attack.log will be used for evolution, and it will extract the timestamp canid and payload byte. 66 00:11:09,580 --> 00:11:17,320 Then it will filter the, you know, this non-standard form of frames and discard that. 67 00:11:17,720 --> 00:11:28,610 We'll try to find the difference in timestamp as a delta t, then the entropy and the frequency of canid in a sliding window. 68 00:11:30,200 --> 00:11:40,310 Feature engineering constructs a sequence of windows basically and tries to normalize the min-max or Z-score. 69 00:11:41,380 --> 00:11:46,750 Then we will train the model and then inference the scoring. 70 00:11:47,480 --> 00:11:52,530 So rather than going through the slides, let's do some demo. 71 00:11:54,290 --> 00:12:01,150 The simple demo will be by using the ICSIM. 72 00:12:02,530 --> 00:12:06,830 Okay, so I'm trying to increase the speed and left and right. 73 00:12:07,210 --> 00:12:17,430 Okay, so what we will do here is we'll try to capture the normal log. 74 00:12:22,240 --> 00:12:26,280 And we will do some normal activity. 75 00:12:26,440 --> 00:12:38,720 Okay, and we'll first this other canids as well. 76 00:12:38,720 --> 00:12:43,820 So the main target canid will be on the door that is 19B. 77 00:12:44,460 --> 00:12:52,280 Okay, so the door lock and unlock mechanism that is 19B basically canid. 78 00:12:52,280 --> 00:12:54,040 So we are capturing that. 79 00:12:58,330 --> 00:13:03,130 Okay, so now it must be enough. 80 00:13:09,560 --> 00:13:11,200 Yeah, perfect. 81 00:13:13,280 --> 00:13:23,260 Now on the one screen, we will try to fuzz on particular canid 19B. 82 00:13:23,300 --> 00:13:29,440 While on the second, we'll run the... we'll capture the log. 83 00:13:44,280 --> 00:13:46,740 Okay, as you can see here. 84 00:13:47,920 --> 00:13:54,780 The door, we are basically fuzzing on the door canid. 85 00:14:02,340 --> 00:14:05,580 We'll give five more seconds. 86 00:14:09,010 --> 00:14:13,230 Hey, Ravi, just a heads up, you've got five minutes left for your presentation. 87 00:14:15,130 --> 00:14:17,790 Okay, just five minutes. 88 00:14:19,150 --> 00:14:25,030 Yeah, they need five minutes to get the next speaker on before, so sorry. 89 00:14:26,670 --> 00:14:41,250 Okay, so rather than going on this, I will show you the already experimented one and the results. 90 00:14:51,870 --> 00:14:55,550 So we'll get the logs from here and on this. 91 00:14:55,900 --> 00:15:05,060 And once you run, you will find the feature engineering and you will find the time delta and the entropy. 92 00:15:05,600 --> 00:15:20,090 Okay, the sequence generator will get the MSE loss and you will get the MSE loss graph. 93 00:15:20,090 --> 00:15:29,110 Then the model will try to detect the anomalies over the top five canids. 94 00:15:30,470 --> 00:15:34,770 Okay, over here, you can see the canid 19B is detected. 95 00:15:34,770 --> 00:15:38,610 There is a little bit of a false positive. 96 00:15:38,610 --> 00:15:54,630 While if you can see on this VE, which is more robust algorithm, you will see that 19B is detected as highest entropy and anomaly detection. 97 00:15:55,510 --> 00:16:01,930 And you can see the peak of this canid. 98 00:16:02,210 --> 00:16:09,270 While you can see this, the entropy is very much over here, which can be concluded that anomaly. 99 00:16:11,230 --> 00:16:19,970 And these are the other graphs that we can discuss, but due to the lack of time, we will go with just a simple output of this. 100 00:16:19,970 --> 00:16:23,950 I will publish this on GitHub as well after the talk. 101 00:16:25,050 --> 00:16:29,170 And it will give you the reconstruction error, but that we had already talked about. 102 00:16:29,170 --> 00:16:31,930 The reconstruction error will be high. 103 00:16:31,930 --> 00:16:35,670 That is how the anomaly detection will be detected. 104 00:16:35,670 --> 00:16:44,210 So let's talk about the key findings, the unusual or previously unseen IDs. 105 00:16:46,510 --> 00:16:47,250 Sorry 106 00:16:51,880 --> 00:17:01,050 , the unseen IDs during replays in rare IDs showing up high frequency will be detected as can anomalies. 107 00:17:01,540 --> 00:17:08,820 Payload entropy spikes and timing deviations will be shown as anomalies. 108 00:17:08,940 --> 00:17:18,140 While you can go ahead with VE is another version of like LSTM's VE is another version for the replay attack detection. 109 00:17:18,140 --> 00:17:28,440 And for the deployment possibilities are you can deploy this lighter version of this model on your ECUs as well. 110 00:17:28,440 --> 00:17:35,280 And this can be the best option for your VSOC as well as SIEM solutions. 111 00:17:35,980 --> 00:17:40,160 Yep, so let's move to the Q&A. 112 00:17:40,600 --> 00:17:44,560 Maybe we have time for one question. 113 00:17:44,560 --> 00:17:46,600 I think we might have time for one question. 114 00:17:46,600 --> 00:17:48,180 We only have two minutes left. 115 00:17:48,180 --> 00:17:51,340 Is anyone in the audience got anything to ask? 116 00:17:57,990 --> 00:18:00,770 The question was, what is the application for this? 117 00:18:00,770 --> 00:18:04,230 Is this specially designed for intrusion detection? 118 00:18:06,310 --> 00:18:08,130 Yeah, currently it is. 119 00:18:08,590 --> 00:18:12,150 I'm currently experimenting on intrusion detection only. 120 00:18:12,330 --> 00:18:17,950 Still not have figured out for the, you know, prevention part. 121 00:18:17,950 --> 00:18:21,190 Is that good? 122 00:18:21,990 --> 00:18:24,710 I think we're out of time now. 123 00:18:24,710 --> 00:18:27,450 So thank you so much, Ravi, for your presentation. 124 00:18:28,490 --> 00:18:29,790 Thank you. 125 00:18:30,010 --> 00:18:31,610 Thank you so much. 126 00:18:32,250 --> 00:18:36,350 You can reach out to me on social media anytime. 127 00:18:37,910 --> 00:18:39,030 Thank you. 128 00:18:39,030 --> 00:18:39,590 Thank you. 129 00:18:39,590 --> 00:18:40,270 Thank you.