start	end	text
680	7260	Hello DEF CON! Thank you so much for being here. It's like the second to last talk.
7260	11820	It's a great turnout. I'm very honored to be here. My name is Yusro Lomarski.
11820	16980	I'm a Zuckerman Faculty Scholar at Ben-Gurion University and head of the Offensive AI Research
16980	22440	Lab there. And with me here today are my brilliant graduate students who will be coming up on stage
22440	29000	also to present. They did all the hard work. There's Daniel Eisenstein and Roy Weiss in
29000	35120	collaboration with Guy Amit, who couldn't make it. Okay, so today we're going to talk about
35760	40380	a new side channel attack against AI assistants that enables adversaries
40380	45920	to read encrypted response traffic, such as responses from ChatGPT.
48260	52860	Okay, so I'm not going to go into, you know, what are AI assistants. You guys all know this
52860	58980	very well. You have OpenAI's ChatGPT, you have Google's Gemini, you have Microsoft Copilot,
58980	64680	the list goes on and on. And these AI assistants are integrated throughout industry in all
64680	69860	different kinds of use cases. What's more interesting to me is the use cases of the
69860	75520	personal level, right? A lot of users are using these AI assistants, such as ChatGPT, to get
75520	81160	personal advice. So, for example, you may ask it some medical questions like,
81160	85720	why do I have a rash on my back, right? And ChatGPT will get back to you and say,
85720	90680	I'm sorry to hear you have a rash on your back. Let me give some tips how to take care of that.
91020	96380	Or maybe you may ask ChatGPT for some relationship advice. What are the signs
96380	100940	I'm having? My wife is having an affair, right? And get some good tips on there.
101840	105580	Or maybe you're getting into hacking and you're going to ask ChatGPT how to get into your
105580	111780	neighbor's Wi-Fi, right? Lots of good use cases. Or my favorite, a lot of people are using ChatGPT
112340	118200	to edit their documents. They'll take whole documents or emails, dump it into ChatGPT and
118200	122960	say, hey, make it better. Or, you know, finish this paragraph or what have you. And these are
122960	127740	all very good and legitimate use cases. They're actually very productive for our society to help
127740	133720	us, you know, progress and automate things. But the problem is that what happens if these
133720	141760	chats aren't actually private? What happens if somebody could read these chats beyond,
141760	151000	right? So this would be a huge breach in privacy. So in truth, we know they're encrypted, right? So
151000	155920	you know, OpenAI is encrypting all the traffic going between the client and the servers.
156220	160020	But is that enough? You know, maybe a little foreshadowing.
161080	166120	So let me go back to the beginning of this story here. So several months ago, you know,
166120	171540	late at night, I was using ChatGPT for very important stuff, such as trying to figure out
171760	178740	what would the world be like if every country had ninjas, but Japan had the worst ninjas,
178740	185900	right? So as I'm looking at the text glide across the screen and looking at this very insightful
185900	193320	and thoughtful response, it kind of hits me. Wait a second. Could it possibly be that OpenAI
193320	200700	is sending every single word as a separate packet? And could it be that every single packet has no
200700	210120	padding so I can count the number of characters in each of these words? So I open up Wireshark
210120	216440	and sure enough, what do I see? For every single word that's being sent from the AI assistant,
216440	222120	I see another packet and the size of that packet increases. And if I take the delta between these
222120	228100	packets, I know exactly how many characters in every single word. And I could use this,
228100	237020	for example, to try and guess what those words are and potentially learn or identify what is
237020	242380	being said in those responses. Now, before I go on to explain how we figured out what those words
242380	248460	are, I need to take a little bit of a technical aside and clarify something. That what ChatGPT
248460	253220	and all these different AI services are sending are not exactly words, but rather something called
253220	261760	tokens. What tokens are, are basically the basic building block of AI language models. When you
261760	268240	give text to a language model, it's going to first parse it down into these tokens and then each
268240	274120	token goes to the model and the model generates text using these tokens as well. So in general,
274120	279300	these tokens more or less correlate directly to words, but there are some cases where these
279300	284900	tokens won't. So for example here, Lama's tokenizer will split the word cream into two separate
284900	291940	tokens. But what's important to note is that although there's not a direct correlation from
291940	297280	token to word, these tokenizers are public information. Doesn't matter if it's open AIs,
297280	302460	if it's metas, you can go through the entire list, you can get the tokenizer and you can learn the
302460	307180	exact mappings. So for all intents and purposes, these are words and we're trying to guess what
307180	317660	these words are. So what's the threat model? So the victim types some private chat into his web
317660	324520	browser, hits enter, and that encrypted text goes across the wire. Now we're not gonna be able to
324520	329240	figure out what that prompt was because that's just one big block of encrypted text. But what
329240	335560	happens after that is the AI assistant starts responding token by token by token back and we
335560	339760	can count exactly how many characters are in each of these tokens. And once again, if we can guess
339760	347540	what those words are, then boom, we know exactly what the response was. So why do we care? I mean,
347540	352640	I can't figure out what the prompt was, I can't figure out what the exact question was, but
353460	360160	it's, it turns out that a lot of information is leaked by the response itself. So imagine I read
360160	366060	one of the responses off the network that somebody was receiving and it said, I'm sorry to hear that
366060	372340	you have a rash. Right? I think it's pretty clear we know exactly what that user was asking for.
373740	379180	So basically this boils down to a big wheel of fortune game, right, where I have to start guessing
379180	384860	what those words are. And this can be a particularly challenging problem because, you know,
384860	389760	there's many different ways you can solve this puzzle. But it gets even more challenging when
389760	394080	you think about real responses from these AI assistants, right? They're not just one sentence,
394080	399200	they're typically whole paragraphs with hundreds of words. So how do we solve this problem? So we
399200	405940	turn to the age-old solution, which is AI, and we look towards a task which is very popular,
405940	411540	which is language translation, right? But here, instead of going from a language such as
411540	419380	French to English, we're going to go from token length sequences to plain text English.
419760	425820	And what we'll do is we'll train an AI with lots and lots of examples of these token lengths to
425820	433180	real English, and we'll be able to translate them very effectively. In our case, we used a
433180	439600	state-of-the-art model called a large language model, or LLM, and this is the exact same technology
439600	444700	that's being used in AI assistants such as ChatGPT. I'm not going to go too much into detail how it
444700	450200	works, leave that for other YouTube videos. All right, so what's the entire attack end-to-end,
450200	454480	how does it look like? So the attacker is looking through the network, looking for responses from a
454480	460020	particular AI service such as ChatGPT, sees the traffic going across the network, and records
460020	466680	down the token length sequence from those packets. He then passes that token length sequence to his
466680	470440	trained model, which has seen lots and lots of examples, and it predicts what it thinks
470440	478680	the original plain text was. So there's something else we can do to make this even better. So if we
478680	484080	just, you know, give our model random arbitrary text, it's going to do so-so. It's not going to
484080	488100	do so great, because as I said, you know, there's lots of ways we can solve that puzzle. But as it
488100	493680	turns out, AI assistants have a very specific style of speaking, right? They're not just going to
493680	498340	respond with some arbitrary sentence, they typically start with something like, oh sure, yeah, I can
498340	504040	give you a recipe for tomato soup, right? So there's a certain style that's intrinsically in those
504040	510720	responses. So what I can do is if I'm, let's say I'm trying to target Microsoft Copilot, I can send
510720	517360	lots and lots of prompts to Microsoft Copilot and build a huge data set of responses. And those
517360	524600	responses capture the style of that particular AI service. And once I have that, I can fine-tune my
524600	529960	model on that, and I'll get much, much better results. And as it turns out, I can get something
529960	536820	around 55% attack success rate. So more than half of the responses that we see in the encrypted
536820	544820	traffic, we can decipher. Okay, so let's look at some examples. So on the screen here is the first
544820	550280	sentences that we're trying to decipher. The first line is the original text that is being sent from
550280	555700	the AI assistant. And the second line is our prediction. So sometimes you can see in the first
555700	561690	example there, we get it right on the first go. And sometimes we make some mistakes. So for example,
562100	568520	in the bottom there, the original response was, yes, there are several important legal considerations
569080	575980	that couples should be aware of when considering a divorce. And then if we look at the inferred
575980	583140	response, we got, yes, there are several potential legal considerations that someone should be aware
583140	588360	of when considering a divorce. So even though we had some mistakes in the words, we're still, it's
588360	595420	very, very clear what was the topic that the, uh, user was trying to ask the AI assistant.
596800	603320	And then if we move over to entire paragraphs, we get something around a 35% attack success rate,
603320	610120	which is also very, uh, significant considering how hard it is to try and guess what all these words are.
610980	615200	And since we're using AI models, this isn't a perfect science. You know, we're using a lot of
615200	621300	heuristics here, so we sometimes get it wrong. So here's some fails. So in the, uh, ground truth, it
621300	624780	was something like, I would like to suggest some following strategies for team leaders to balance
624780	631240	the needs of individual team members with the needs of the team as a whole. And we inferred it as,
631240	637080	I would suggest the following strategies, so far so good, but then for film studios to balance
637080	641920	the needs of production, so on and so forth, something is completely unrelated. And sometimes
641920	646700	it gets even worse, right? So here's a case where the response has something to do with apple cider,
646700	652120	and we thought it had to do with coral bleaching. Okay, so it's not a perfect science, but what's
652120	656360	interesting to note is that because we're using machine learning model, the model also gives us
656500	663280	a confidence score. How confident it is that this prediction is correct, right? So what we can do is
663280	667400	we can look, and we're trying to attack a particular, uh, you know, token-linked sequence that
667400	671180	we see in the network, we can try to look at the confidence of the model and say whether or not we
671180	681040	should trust this, uh, inference or not. All right, so how common is this vulnerability? So, uh,
681040	686960	you know, around the time of our disclosure, or prior to our disclosure around, uh, February 2024,
686960	692860	uh, nearly every major AI vendor out there had this vulnerability. And, uh, you know, when you
692860	698200	start wondering why is that the case, how do they overlook the seemingly obvious side channel,
698200	703220	and there's a few reasons that might come to mind. First, uh, you know, they might, perhaps they
703220	707840	didn't think that token links the same as word links, so maybe there was just a simple blunder.
707840	713060	Or maybe they thought there's no way that an adversary can guess entire paragraphs of text.
713060	717620	That's just too hard of a problem. But what I think is more likely the case is that it has something
717620	723380	to do with the big AI gold rush, right? There's so many industries that are jumping on the AI
723380	727460	chatbot idea and throwing it into services willy-nilly, and they don't really think about
727460	732300	security by design. They're saying, oh, you know, the text is encrypted, not a big deal, let's move
732300	738260	on, right? So this is probably more likely what happened there until they, of course, patched it
738260	745540	after the fact. So why are they even sending, you know, text to streaming or token streaming across
745540	751480	the network? Why don't they just send it as one big batch, right? So for example, Google's Gemini
751480	756860	does this already. When you get a response from Google Gemini, it's not sending a token, token,
756860	761220	token, it sends it as one big block, and therefore they're not vulnerable to the side channel attack.
761220	766040	So why aren't the other vendors doing this? So there's a simple answer for that, and the answer
766040	771260	is that, you know, these AI models are actually incredibly complex, and it takes a lot of effort
771260	776360	to execute them. So instead of having the user wait there for, you know, a good, you know, 30 seconds
776360	781360	for this loading screen to go by to get their response, it makes perfect sense to send those
781360	786620	words or tokens one at a time in real time so they can read it as it's being generated.
787520	793420	All right, so to recap so far, what we've accomplished here is that we've discovered
793880	798540	a novel side channel attack which we call the token length side channel, and we found it's
798540	806620	common in LLM services all over. And we've also found a way to exploit that side channel to read
806620	813280	the hidden information behind it directly using AI and improve that performance using a known
813280	820520	plaintext attack. Okay, so for the rest of this talk, we're going to get down into the nitty-gritty
820520	826500	details, and first we're going to talk about how we identified response traffic inside network
826500	832540	traffic and how we then extract the token length sequences from there. And after that, we'll talk
832660	838520	a little bit about how we train AI models and our specific RAI model. And finally, we'll end
838520	843020	up with some demos, defenses, and we'll talk about some bug bounties that we got along the way.
843020	847000	So with that, I'm going to hand it off to Daniel who's going to take it from here.
852640	859180	Thanks Israel. So, let's jump to the nitty-gritty details. So, we will talk about how to find the
859180	868460	side channel and how to extract the token length sequence. So, the first thing we'll have to do
868460	874000	is to capture the traffic containing the response from the assistant. So, we'll need to be positioned
874000	880140	between the victim and the assistant. Or, we can be in the same local network as the victim
880140	887260	sitting in the same cafe using Wi-Fi. So, we collected a lot of traffic and not all of it
887260	893440	containing our response data from the AI assistant. So, we'll need to filter the traffic. We can do
893440	898480	that by filtering by the IP address of the assistant. Uh, that information can be collected
898480	905040	by OSINT or by connecting as a legitimate client to the assistant server for two different times
905160	911420	a day from different locations and making our own data set of those IP addresses and basically
911420	918840	filtering by those. Also, what we can do is filter by the protocol. So, every vendor is using
918840	924300	different protocol. For example, JGPT is using quick protocol. So, we would like to search for
924300	930940	UDP packets that are coming from port 443. And again, every vendor is using different protocol
930940	936040	so we'll need to account for that. And also, there is a slight problem because it will add us
936040	941640	more complexity when we will try to extract the token length sequence because again, every
941640	950580	protocol looks differently on the wire and it has its own metadata. So, we captured the traffic,
950580	955440	we filtered out most of the traffic that don't contain our tokens. We have the traffic that
955440	960560	contains the response from the assistant. Let's extract the token length sequence.
961860	967640	So, our objective is to find the token lengths. We need to remember that the traffic is
967640	973940	encrypted so we can't really see where are the tokens and what packets contain them. But what
973940	992120	we can see is the bandwidth patterns. Basically, the packet sizes. Oh, I'm sorry. So, we found
992120	997920	that there is two main ways that the vendors are using to send their tokens. The first way is
997920	1004080	base plus next token. Basically, each token is sent in a separate packet by itself. So, we can
1004080	1009860	infer the size of the token by just analyzing the size of the packet. The second way is token
1009860	1016280	accumulation. Basically, the tokens accumulate. We are sending each time the token with all of
1016280	1021920	the tokens that were previously sent. So, the packets are increasing in size. In the next
1021920	1027180	slides, we'll talk more about token accumulation because this is the way that Microsoft and
1027180	1035440	OpenAI are using. So, basically, our main target was JGPT. So, we'll talk about this more. So, to
1035440	1041400	simplify the problem, we'll first try to identify which messages, which packets are
1041400	1048840	containing the response. So, to simplify it, let's try to find the start and the end. So, again,
1048840	1054420	we can analyze the bandwidth patterns and we found out that at the beginning, at the end of
1054420	1060200	the response, we saw, uh, bumps, like increases in the packet sizes. That's because at the
1060200	1064820	beginning, you have this, all of those handshakes and establishing of the new channel and at
1064820	1070380	the end, you have those, uh, communication of the end of the response. So, you have those
1070380	1076260	increases and we can basically find the start and the end. Between those two points, the start
1076260	1083360	and the end, we'll try to search for this incremental pattern, the red line that you see. The
1083360	1089300	packets that follow this trend contain our tokens, but sometimes we have packets that don't
1089300	1094720	follow this trend. Those are sometimes control packets that do not have our tokens. So, we'll
1094720	1100680	filter those out and we will be left after that filtering with a nice and smooth incremental
1100680	1110500	pattern from which we can extract our token links by calculating the delta as Israel said. So, it
1110500	1117540	sounds pretty simple, and some would say even easy, and too good to be true. And in reality,
1117540	1123340	it's really the case. So, we have more challenges. The first challenge is message size
1123340	1129000	limits and the second one is message buffering, uh, that will cause message groupings. So,
1129000	1135260	let's talk about that. Message size limits. In the internet, we have this thing called MTU,
1135260	1140440	Maximum Transmission Units. Basically, a maximum size that the packet can have and if we go
1140440	1147640	above this value, we, we can be fragmented on the IP layer. And what we found is JGPT over
1147640	1157660	QUIC has even a lower maximum size of 1,200 bytes. And as you remember, JGPT is accumulating its
1157660	1163720	tokens. So, at certain point, it will reach this maximum size. So, what will happen is basically
1163720	1169760	that the payload will overflow to the next packet. So now, we have two packets that are sending
1169760	1175300	this token because our payload is just too big. And what will happen is basically the sort of
1175300	1181340	pattern that you see now. And also, as the conversation grows and goes deeper and deeper and
1181340	1186000	makes it more and more long, we basically can also overflow to the third and fourth and fifth
1186000	1191620	packet. And at the filtering phase, we'll need to account for that because we don't want to
1191620	1199120	throw those packets. They contain our tokens. Another challenge is that the business of the
1199120	1206520	network will cause basically buffering that will cause our groupings. What does it mean? So,
1206520	1212680	when the network is busy and lots of clients are connecting to the assistant servers and many
1212680	1220040	chat with JGPT, what happens is that the servers tend to buffer their responses. And what it
1220040	1226780	looks for the user is that basically he has a small freezes that he sees and for us, what it
1226780	1233640	looks like is that some packets will contain more than one token. More than one new token. So,
1233640	1240020	basically this new packet will be double the size of the original trend and what we can infer
1240020	1247120	from that size is the size, is the sum of those tokens that are contained in the packets. But
1247120	1255020	what we cannot infer is the size of each individual token. And this problem will be overcome
1255020	1262620	in the next phase which Roy will talk about. Uh, with exploitation with AI. So, we will worry
1262620	1269080	about that later. You probably wonder how did we find all of this out? So, we basically
1269080	1274020	reverse engineered the traffic. We connected as a legitimate client to the assistant servers.
1274020	1279080	We got the SSL key, the encryption key between our computer and the assistant server. Uh, we
1279080	1284340	plugged this into Wireshark and we were able to watch the decrypted traffic, learn it, like
1284340	1290440	analyze the metadata and make rules to extract the token length sequence from the encrypted
1290440	1297880	traffic. So, to sum this up, we captured the traffic, we filtered the traffic and then we
1297880	1302900	extracted the token length sequence. And now we would like to translate those token length
1302900	1309580	sequence to plain text English and that's what Roy will talk about next in the next part,
1309580	1318950	exploitation with AI. All right. Thank you Daniel. Um, let's indeed talk about how to
1318950	1323750	exploit the side channel using a machine learning. But don't worry, I'm not a typical
1323750	1329710	machine learning guy. We'll keep it simple. So, the first step in training a machine learning
1329710	1335130	model is to basically gather a data set. We need to have a data set which will contain inputs
1335130	1340770	and outputs. Then we train the model by feeding him examples of the inputs and what the
1340770	1347830	outputs should look like. Training an LLM is no different. So, in our case, the attacker will
1347830	1354230	first gather a huge corpus of text. He will transform the text into token length sequences and
1354230	1360230	then pass them to the model. We hope that the outputs of the model, if not exact, will have the
1360230	1366650	same similar semantic meaning. All right. So, now begs the question, how do you, how do you
1366650	1375650	even use the model? When a, um, LLM output you, uh, gives you a response and outputs, each
1375650	1381410	time you get it a bit differently. As Israel said, each time with the output you get a
1381410	1387230	confidence score. Then you can basically, uh, prompt the model many times and saw the
1387230	1392330	outputs based on the confidence score. And most often, the most confident output will
1392330	1399270	have, um, will be the closest to the real thing. So, that sounds really simple and, uh, fun and
1399270	1404730	that's what we did. We took the AI system response, transformed it into token length
1404730	1413470	sequence, passed it to our trained, uh, model and it failed miserably. Well, the problem was too
1413470	1419750	hard, even for an LLM. But we still had a glimpse of hope because although the semantic
1419750	1426550	meaning, uh, similarity was nowhere, uh, to be found, the model still learned the high level
1426550	1433090	structures such as list structure. So, we started to look around on ways to improve our
1433090	1440830	approach. Um, we noticed a really interesting phenomena about AI system responses. The first
1440830	1447610	sentence almost always holds the essence of the entire response. The first sentence is like a, an
1447610	1454870	introduction to the coming paragraph. Learning from history, we took the hard problem and
1454870	1460790	divided it into smaller problems to deal with each at the time. Because, uh, the first
1460790	1466590	sentence is really unique, we first tackled it and tried to solve it and then all of the others
1466590	1472210	because if you think about it, if we crack down the first sentence, we will win. We could,
1472210	1479590	we could build upon that with a preserved topic in mind. But, wait, hold on. Isn't the traffic
1479590	1486430	encrypted? What do we even have in the end? Token length sequence. How are we able to divide it
1486430	1493890	into segments of sentences? Well, most tokenizers encode punctuation marks as a separate
1493890	1500710	token. This means that almost always a token length of one is a punctuation mark. So, this
1500710	1508010	means we can basically look at the token length sequence, search for one and divide it. But, um,
1508010	1513250	we want to avoid false positives. For example, too short of a sentence because comma at the
1513250	1518850	start. So, we apply the simple heuristic that uh, basically says we won't divide it if the
1518850	1525410	sentence is too short. Alright, with this idea, because the first sentence is really unique, we
1525410	1532110	train the model only on first sentences, meaning it's data set contain only first sentences. And
1532110	1538670	we train another model for all of the other sentences to further help the second model try to
1538670	1545490	figure out what is the right topic. We took the output which was generated by the first sentence
1545490	1551850	and then passed it as part of the input to the next model. And then, uh, with other
1551850	1558710	generations, we did the same and, uh, just like that, we, we have preserved the context in mind
1558710	1566890	when generating the entire paragraph one by one. Alright, um, this approach is nice and we got 10
1566890	1573830	percent attack success rate, but it's not enough. Uh, we are at DEF CON after all. So, uh, there
1573830	1581750	is one more thing that could help us improve. As we said, AI assistant responses are not just
1581750	1587450	random Wikipedia pages. They are not random text. This, uh, they have predictive, predictable
1587450	1594390	style and low response diversity. This means that we can use it to our advantage and relate to
1594390	1602310	this problem as a known plain text attack. AI assistant responses have predictable style. They
1602310	1609010	have warnings, templates, they follow safeguards and structure. This means that if we will
1609530	1616430	train a model on those responses, the model will be able to learn those patterns and it will
1616430	1624410	make our life easier. Also, as we can see here, many different prompts that talk about the same
1624410	1631330	rather topic will have the same response. This means that, um, a model which is trained on AI
1631330	1639210	system responses will be able to generalize to many different prompts. So, to summarize, the
1639210	1647070	entire process is first collecting a data set of prompts. Then we will pass it to our target
1647070	1654750	model like JGPT-4. Then we will collect the responses, transform them into token length
1654750	1661810	sequences and train the model as we saw. This combined approach yields a huge boost of
1661810	1669250	performance. This plot compares, uh, the, uh, performance of the combined approach, the green
1669250	1675570	one, the blue one which is, uh, training the model on random text and the red one which is
1675570	1681910	plainly asking JGPT please help me solve this side channel. And we can see, uh, that all of
1681910	1687270	the examples to the right of the vertical line are considered successes and the green one was
1687270	1693430	much better than all of the other approaches. And the numbers, we, as, as we said before, we
1693430	1699430	got about 55 percent attack success rate on first sentences and 38 on entire paragraphs. We
1699430	1707470	have also encountered a really interesting phenomena. Different topics were susceptible, uh,
1707470	1714610	than others. In our example, uh, mental health and financial status were much more susceptible
1714610	1722650	than, for example, sex, sexual health. This is mainly to the fact that those topics were much
1722650	1727630	more common in the data set. This means that we've, we've, if we have an attacker with a
1727630	1733570	specific goal in mind, he can train his own model on those subtopics and get better results.
1733570	1739150	All right, so what about the network noise and traffic and all of the stuff Daniel said?
1739750	1745930	Um, when we have high network, uh, traffic, we get grouping and buffering. So we first wanted
1745930	1752390	to evaluate how much groupings were actually there. We ran a 24-hour experiment against
1752390	1760090	open AI JGPT and we measured the amount of groupings we got in each hour of the day. As
1760090	1766650	expected, in the day, there were much more groupings than in the night. But as we will see,
1766650	1773990	it is manageable. To solve this challenge, we took our training process and our data set and
1773990	1780730	just applied random groupings on the token length sequences. Then, as we can see in the first
1780730	1786890	row, we still got 35 percent attack success rate on first sentences, which is really nice
1786890	1792270	because the, it is way more challenging. Also, when looking around on different, uh,
1792270	1799210	susceptible vendors, we found out that open AI API transmitted their messages as paired tokens,
1799210	1807490	meaning each packet holded two tokens. Okay, this is more challenging, but we wanted to
1807490	1815470	evaluate if we can break it and get more reward. So, uh, we took our training process and
1815470	1821710	applied, uh, random, uh, not random, sorry, and we applied pairing, uh, pairing on the
1821710	1827390	tokens, meaning we took the token lengths and just paired them. We still got 17 percent attack
1827390	1835570	success rate on first sentences with this approach. Alright, so, after I've yucked you out
1835570	1843990	with theory, let's talk business. So, um, as we all know, training an LLM from scratch is
1843990	1849930	really hard. It takes, uh, months of computer time and millions of dollars in hardware and
1849930	1855630	energy. We didn't have to go through such hassle. Rather, we used a common technique called
1855630	1860770	fine tuning, which means we took a trained model and further trained it on, on our own
1860770	1866710	translation task. We took a model called T5, which was trained...
1866710	1875560	Pause, pause for a second. We need to do a small disruption, I'm sorry.
1876760	1883760	Attention dev pod hackers. Halls 2 and 4 are now closed. Heavy equipment will begin operations
1883760	1889560	soon. All humans need to vacate the premises before they contract and are forced to become
1889560	1896400	goons for eternity. Villages and contests have now closed. All hacking of the planet must be
1896400	1902480	done elsewhere. Please join us for the contest closing ceremonies in chapters 1 and 2.
1902900	1909900	Attention dev pod hackers. You must vacate the hall before you become impaled by a forklift.
1910080	1920260	Thank you and have a good day. Okay, good day to, uh, to you too. Yeah. So, let's recap, uh, our
1920260	1926300	model was based on the T5 model, which is, uh, trained by Google and this is, it is, uh,
1926300	1932560	public, publicly available. Uh, we also didn't have to go to the hassle of gathering our own
1932560	1937020	data set. Rather, we used an open source one called UltraChat, which basically contains
1937020	1944540	dialogues with GPT-4. We also used Hugging Face as our framework, uh, trainer, trainer, which
1944540	1950780	was, which makes the technicalities of training a model much easier, even for a guy like me.
1950780	1957480	Um, okay, our, uh, model was trained for, uh, two days of compute time and if we have an
1957480	1963860	attacker with, uh, no GPA, GPU in hand, he can use Azure, for example, for only $200, which is
1963860	1972480	fairly affordable. So, let's see some demos. Um, in this case, um, we have, uh, the victim,
1972480	1979800	Quarry, uh, Microsoft Copilot. He asked the random question of what are the some, some of the
1979800	1984800	latest development in machine learning and AI that could revolutionize the health industry.
1984800	1990720	Besides him, the attacker, he's dropped the entire traffic. He collects, uh, traffic using
1990720	1998640	Wireshark and after collecting for a bit of time, um, he will try to filter the traffic. As
1998640	2006500	Daniel said, one of the common techniques to filter is based on the IP. So, the attacker does
2006500	2014920	just that. And, uh, in this case, uh, the attacker manually, uh, figures out where the start is.
2014920	2020700	Well, of course, the traffic is encrypted, so, uh, you just need to do it by hand and by eye.
2020720	2027400	And after figuring out where the start is, the attacker will put inside the tool the token
2027400	2034580	lengths, uh, so, excuse me, the packet, uh, sizes. Then the tool will calculate the deltas
2034580	2040900	between the packet, uh, sizes and we will have a token length sequence. Then basically, the
2040900	2048560	tool will pass it to the model to try generate the ground truth. And as we will see in a bit,
2048560	2057460	um, hold on, yes, we got, we got the token lengths and now the model thinks, actually really
2057460	2064560	fast and, alright, so, uh, it will be, it will zoom out in a bit. We basically got the same
2064580	2068880	rather, uh, topic. Several recent advancements in machine learning and artificial
2068880	2076300	intelligence, that could be a game changing tool, yada, yada. Alright, so, for the public use,
2076300	2084360	we've, uh, deployed a full plug and play tool on GitHub called GPT Keylogger. Um, the tool, uh,
2084360	2089220	has, has, uh, two main models, the attacker model and the trainer model. I will elaborate
2089220	2097260	them in a bit. And, uh, our model is also publicly available, uh, and it is trained on GPT4
2097260	2104220	responses from February 2024. The first model, the attack model, is for you guys, uh, to try
2104220	2110740	attack different vendors, um, it can receive as input packet lengths, as we saw in the demo,
2110740	2116300	token lengths, which is straightforward, and the original text. The tool will basically, uh,
2116300	2122760	tokenize the text, calculate the token length sequence, and, uh, try to predict. And, uh, you
2122760	2129540	can use it with this simple command. If you want to target a different vendor, with a different
2129540	2135180	backend LLM, you should train your own model, uh, because every LLM works differently and our
2135180	2142300	model is based on GPT4 responses. So, if you want to, uh, target a model, uh, like Llama, you
2142300	2148440	should train. And, uh, we offer this for you to make life much more easier, uh, with those
2148440	2154560	commands. Uh, also the configuration file is also available in the GitHub, uh, page, uh, which is
2154560	2161600	nice. And, uh, all right, so let's talk some defenses. We have contacted all of the vendors
2161600	2167720	that we found vulnerable up to, uh, February 8th this year. Uh, all of the major vendors were
2167720	2173580	really responsive and they patched the problem really quickly, uh, until March 1st. And we
2173580	2179700	come, uh, we came public with this vulnerability on, um, on Ars Technica on 4th, uh, on the
2179700	2187060	14th of March this year. Out of the vendors, those five had bug bounty programs, which
2187060	2193580	awarded us a small reward, which was really nice. Um, all right. So, although this side
2193580	2199160	channel is really difficult to exploit, as we saw, the defenses are really easy to make.
2199160	2204900	After, uh, consulting with the engineers on the, of the different vendors, we came up with
2204900	2212300	three solutions. Random padding to the packets, padding to the nearest value, like nearest 100
2212300	2218980	size, or applying more buffering. Here is the mapping between the different vendors and the
2218980	2227700	deployed defenses. When diving a bit deeper, OpenAI basically did padding to the nearest, uh,
2227700	2235320	to the closest 32 value by adding a pad field on the transmitted JSON. And as we can see on
2235320	2242020	Wireshark, the size is a line. And CloudFlare, for example, uh, deployed random pa- padding
2243220	2248960	and, uh, we can see that the sizes are all messed up. All right. Let's run the demo.
2248980	2255000	Let's wrap things up. So, what did we discover? We've identified a new side channel
2255000	2260980	vulnerability based on token lengths. This is significant because, as we saw, it impacts
2260980	2269160	multiple vendors expo- exposing sensitive information through their AI systems. This work,
2269160	2275840	uh, has shown how to break a side channel use, uh, with generative AI and it is the first
2275840	2282440	work to do so. While some vendors have patched this vulnerability, there is still a real
2282440	2290820	concern about how new AI services will handle this issue. Now on to the key takeaways. First
2290820	2296880	off, it is crucial to use encryption schemes correctly. This has repeated itself throughout
2296880	2303020	history, time and after time, uh, and, uh, yeah, leading to multiple side channels and
2303020	2309160	cracking of encryptions. Similarly, in modern times, even subtle details like token lengths
2309160	2316180	can leak sensitive data if not properly protected. AI services are no exception to this
2316180	2322360	rule. They must be designed and implemented up to the highest security measures as any other
2322360	2329120	software domains. Remember, AI is your friend. It is a powerful tool both for offensive and
2329120	2333940	defensive applications. We should harness its potential to identify and mitigate
2333940	2340080	vulnerabilities. What seemed impossible is now possible thanks to advancements in AI.
2340620	2346460	Finally, our discovery raises an important question. What other side channels are
2346460	2351840	vulnerable? We encourage the community to explore and secure these potential weak points.
2351840	2357120	To sum it up, we have joined throughout the process of identifying, exploiting and defending
2357120	2362900	against this new side channel. This research highlights the importance of considering even the
2362900	2370100	smallest details in data transmission within AI systems. I hope this inspires you to think
2370100	2377960	creatively about both offensive and defensive capabilities of AI in cyber security. Thank you
2377960	2383540	all for your attention. Uh, check out our tool GPTKeylogger and our labs page when we update
2383540	2392160	on more research. Stay secure, stay curious and enjoy the rest short bit of DEF CON. Thank you.
