start	end	text
0	6220	Welcome, this is the attacks on GenAI data and using vector encryption to stop them talk.
6960	11280	I'm Patrick Walsh, this is Bob Wall, we're the co-founders of IronCore Labs,
11280	15080	where we help people protect data in their cloud applications by making
15080	20320	application layer encryption more easy and practical and usable.
21220	26780	So this talk is going to be about the ecosystems around LLMs, but we'll start by talking about LLMs
26780	33680	specifically. And in particular, some limitations of LLMs, right? When an LLM is trained, it's
33680	40220	trained to predict a plausible completion to a prompt, and that means it can sometimes make
40220	45020	stuff up that sounds good but isn't necessarily right. It's also trained on what, by the time
45020	49660	it's released, is typically stale data, because it takes a long time to train it, to test it,
49660	55220	to fine-tune it, etc. And then finally, it hopefully hasn't been trained on your data,
55220	59980	and therefore, if you want it to do things that are cool across, you know, your corporate data,
59980	65060	your personal data, or something like that, it's not going to work. And to fill those gaps, there's
65160	70260	a thing called RAG, or Retrieval Augmented Generation. Terrible name, basically means
70260	75180	stuff extra stuff into the prompt so the LLM can answer questions better. And it works a lot like
75180	80020	this. You have a chat app, it doesn't have to be a chat app, it's just like the most common thing
80020	85080	you use, right? A user asks a question, and now instead of passing that question to the LLM,
85080	90960	the first thing it does is a search. And that search is to find relevant documents related to
90960	96320	the query. That all gets jammed together into a prompt, which then goes to the LLM. That's it,
96320	101280	that's RAG in a nutshell, you get it. Here's a kind of more practical example of what that looks
101280	107480	like. There's a system prompt, there's a history of the previous questions and answers from the chat,
107480	112960	and then there's the current, the most recent question, and then stuffed in with that is any
112960	118640	documents or web pages or whatever it is that might be related to what the question was. In
118640	124060	this case, it's about, hey, what's that draft 10Q? It's a private document that's not public,
124060	129140	and that's how it all gets in to the LLM so it can answer questions on that private data.
129280	134180	It's fundamental to basically how everyone is using this stuff today, if you're using
134180	140760	chat inside an app. And to make all this work, you need to have some type of more intelligent
140760	145680	search than what we typically do. Call it AI search, call it semantic search or whatever you
145680	151280	want to, and there's a bunch of ways to do this. The most popular right now is an approach called
151280	155960	vector search. It's kind of what everyone is doing, although it's not the only way to do it.
156140	162740	And vector search and actually all of those AI search type techniques are important because they
162740	167760	differentiate between different meanings of words, they can understand a sentence in context,
167760	173440	they can understand when arm means a division of an organization versus when arm is a body part or
173440	181180	even a verb, right? And in practice, how these types of vector search works is you start with
181180	187020	some input document. And that input, did we lose it? And that input document then gets chunked up
187020	192640	into pieces. Sometimes it's by sentence, sometimes it's sets of, call it 30 words, or it can be any
192640	198300	strategy and often overlapping. But each of those pieces gets run through something that's very
198300	204840	similar to an LLM, that sucks, that's very similar to an LLM, but is in fact called a text embedding
204840	211440	model. And a text embedding model, unlike an LLM, produces something called a vector embedding.
211540	213120	That's not great.
215920	220740	Produces something called a vector embedding. And the vector embedding is basically just
221280	227060	a long list of very small numbers. And those small numbers can be hundreds or thousands in length.
227440	232040	And we'll get into what they mean in a minute here, but to give you some intuition on these,
232040	235860	we'll take a look at a list, like a vector that's only three long, right? Because you can graph this
235860	240000	in 3D space and you can understand it better. And if we have a bunch of different vectors,
240000	244480	let's say we have A and B and we have C, we can kind of look at this visually and say,
244480	249840	oh look, A and B kind of look like they're close together and A and C look like they're far apart.
249840	255380	In fact, if we run a distance comparison operation like this one, Euclidean distance,
255380	258440	although there's a bunch of different ones, they all have the same kind of effect,
258440	263920	you can see that A and B are 2.2 apart, whereas A and C are 5.6 apart.
264360	268740	And the way this works with search is we take a query, right? It's a sentence,
268740	273740	and we reduce it to, let's say, A. A is a vector representation of what we queried,
273740	278740	and then we search across all our vectors and we say, give me anything that's similar to A,
278740	283480	and then hopefully, if it does it right, it returns B but not C. That's it, that's what vector
283480	288640	search is doing, it's the whole shebang. The vector represents the meaning of the content.
289180	294260	And to make that work, we have this kind of new concept, or at least new to a lot of us,
294260	297840	at least to me, although I guess it's been around for quite a while, and that's called a vector
297840	303480	database. And a vector database's purpose is to be able to do these nearest neighbor or approximate
303480	309400	nearest neighbor searches across large amounts of data very quickly. And there are a lot of
309400	314540	these companies now that are doing this. In fact, last year we saw hundreds of millions of VC money
314540	318600	go into the startups that are building vector databases, startups like Pinecone and Weaviate
318600	325200	and Quadrant. And despite that, the idea of a vector database is already eroding away to nothing
325200	330460	because classic databases like Mongo and Postgres and Oracle are all adding vector capabilities
330460	333920	to their existing databases. So you're getting these type of vector comparison
333920	338600	nearest neighbor search capability pretty much everywhere that you have a database now.
339140	344260	Okay, changing tracks for a second. We started thinking to ourselves, who's using this stuff?
344680	351060	Well, we looked at the top 10 SaaS companies and we thought, how many of them are doing
351060	356080	adding LLM capabilities over private data? Which means that they're almost certainly using RAG.
356080	360620	The answer is 100%. Then we said, well, what about security companies? They wouldn't jump on
360620	364760	to just using all this new technology that we don't know how to secure yet, would they? No,
364760	372140	100% of them too. Also adding LLM capabilities on top of private data. Think about that for a
372140	376800	moment, right? It means that these AI systems, whatever cloud services and things you're using,
376800	382080	they are hoovering up this data. Probably copies of it are going into the vector databases as
382080	389080	vectors and among other places, which I'll talk about ever so briefly later. So, do these vectors
389080	395040	matter? I was talking to the CEO of one of the vector database companies who's raised tens of
395040	399120	million dollars last year and he told me that a vector was like a hash and it was basically
399120	404680	meaningless, except for comparison purposes. So, which my first thought is, well, you clearly don't
404680	411420	know how people abuse hashes. And my second thought is, you're wrong. So, that isn't how
411420	417440	it works at all. If you look at taking a phrase and you reduce it to an embedding vector, an
417440	424460	embedding model into a vector, okay, it looks pretty meaningless to us. But then again, so does
424460	429080	an animated GIF like this cat if you look at it in a text editor, right? Just because it's meaningless
429080	435200	to us to look at, doesn't mean it's meaningless to a computer or in this case, to an AI model.
435200	441440	And so, the way you go back from a vector to the original text or something approximating it
442000	445360	is using something called an inversion model. An inversion model is just a model that's
445360	451200	trained on vectors to sentences so that it can make that same prediction. In this case,
451200	455520	it comes close. It's our income is down instead of our earnings is down, right, in this example.
455800	462700	100% match on meaning, not 100% match on words. There are some tens of thousands of papers on
462700	469380	this at this point. It's heavily studied in academia, not widely known, I don't think, broadly.
469940	474440	Best paper we've seen for text inversions, and it's not just text that vectors represent,
474440	481240	I'll talk about that in a second, recovers 92% of exact words. That means full names,
481240	487160	everything coming right back out exactly as it went in on the text, okay? The other 8% is basically
487160	494620	effectively the same anyway. So are these attacks hard? What's the skill level for doing this kind
494620	501020	of attack? The answer is most of these papers have accompanying open source software on GitHub,
501020	505220	and so really you just need someone who can run the software, not someone who knows how to build
505220	510560	the software, which means it's script kiddy level. And on that note, we actually ran some
510560	515300	of these attacks ourselves. We posted some blogs you can check out. We did one on, so I mentioned
515300	519080	vectors can represent different things, they can represent images for image search, they can
519080	524680	represent faces or voice prints or other things for that. We did one against facial recognition.
524680	528040	That doesn't use an inversion model, that's a different technique by the way, so it's kind of
528040	534160	interesting for that purpose, and we did one on text inversions. Really good results, like you
534160	540000	can really get all the stuff back out or very near approximations of the inputs.
541140	544540	All right, so let's talk about these new vector database companies.
544920	551460	They probably have good security, right? Actually no, super immature. They'll fix it over time,
551460	558460	it'll be fine, but if you look closely at these as we have, two of them have no authentication
558460	563380	required by default, right, making the mistakes of Elasticsearch and MongoDB of years past but not
563380	570880	learning. One of them has services that are meant to be internal services and that, you know,
570880	575480	there's no protection or authentication on them, so that if someone goes to access that because
575480	581280	the firewall neglected to block a port, direct access back to the data without any authentication.
581860	587740	Two of them claim to have end-to-end encryption when they only have TLS in transport, and more.
587740	592240	I could go on, it doesn't matter. The point is that these vector database systems, and for that
592240	598540	matter the chat apps, either way, are like total treasure troves of information. And even if you
598540	603360	don't use it and invert it, they're at least treasure maps of information because they point
603360	608120	back to the data and you can query it. And if you think about that for a second, imagine
608120	613300	that you're in a CTF competition in that corner of this thing, and you know, you get into a machine,
613300	616680	cool, but now you have to get the flag, and it's in a database, you have to get into the database,
616680	621400	and now you have to reverse the schema and, you know, figure out a query and find the flag.
621940	627820	It ain't as easy as it sounds, right? It's a lot of expertise and time to do that versus, you know,
627820	636080	give me that data. It is, like, incredibly far, far easier to attack these systems because you
636080	642620	can do it in natural language. So, what do we think about bringing AI into our infrastructure?
642620	647400	Maybe we should pause for a moment and think a little bit about it. Or if it's in there, maybe
647400	650520	if you're a hacker in the audience, you should think about, holy shit, there's a lot here.
650520	656760	Let me give you some ideas. Obviously, everyone knows about prompt injections. Maybe you haven't
656760	661280	thought so much about the fact that you can put a prompt injection in the documents being searched,
661280	664180	and they get pulled into the prompt, and you can poison the prompt that way.
665540	669720	Logs are everywhere. If you're putting private data into the things that go to the LLMs and the
669720	674980	LLMs log it, that's a problem. But also, the prompt firewalls, if you're using those, are
674980	679180	logging that stuff, too. So, the data's kind of exploding. And don't even get me started on
679180	683520	agents. Talk to me after if you want to hear about my thoughts on that. But if you're generating
683520	690200	code to run to query a database, you're beyond hope. Today, though, we're not going to talk
690200	694760	about any of that. We're going to talk specifically about this vector stuff and how to protect it.
694900	699060	So, basically, today, the way to protect that is to encrypt it. And there's two approaches to this,
699060	703000	at least in academia, that you could do. One is fully homomorphic encryption, and the other is
703000	708660	partially homomorphic. So, fully homomorphic encryption, there's actually quite a few papers
708660	712240	on this, and they're fairly interesting. There's a lot of different approaches. Some of them require
712240	717380	sending all the vectors to the server. Some require some other stuff. They typically suffer
717380	722420	from being slow. And you would have to build your own vector database and be another logo on that
722420	727360	wall and compete with all the other vector databases on every other thing. The other option
727360	731980	is partially homomorphic encryption. And the idea here is that something that's partially
731980	737440	homomorphic is able to do some operations, but not arbitrary operations. And in this case,
737440	744540	we're talking about optimizing for that nearest neighbor search type of operation. So, in this
745200	751800	example, partially homomorphic, specific to nearest neighbor searches. And to talk more about this
751800	755790	paper and the work that we've done around it, I'm going to turn it over to Bob.
759810	768970	All right. We found this paper about a way to encrypt vectors. And you can see the title,
768970	773910	Approximate Distance Comparison Preserving Symmetric Encryption. So, that's a mouthful.
774390	781370	But this algorithm is a type of property-preserving encryption,
781370	786250	which means it's kind of like order-preserving encryption or maybe deterministic encryption,
786250	790910	if you've heard of those. The property that this algorithm is preserving, though,
790910	797870	is distance comparison instead of equality or order. And so, if you can preserve the ability
797870	803170	to compare the distance between two vectors after they've been encrypted, that means your
803170	808230	vector database continues to work on the encrypted vectors just as well as it did on the original
808230	815950	vectors. So, like deterministic and order-preserving encryption, there's a trade-off.
815950	823130	The more secure you make it, the less well the property is preserved. And so, the less well
823130	829330	queries might work on the data. So, you have a decision to make about whether you want a
829330	834230	lot of security and you can tolerate maybe a little less accuracy on queries, or you want a
834230	839250	lot of accuracy on the queries and maybe you'll have a little bit less protection of the data.
840090	846330	But the system works by, if you've got a system that's ingesting data and it's making these
846330	851250	vectors, putting them into a vector database, it's easy to add this encryption. You just,
851250	856150	in the system that's already there, after you've taken the data and run it through the
856150	860530	embedding model and generated the vector embedding, you run it through this algorithm and encrypt it,
860530	866410	it's still a vector, it looks similar enough to the original vector that the vector database is
866410	872970	going to take it and be happy with it. So, you use a secret key, you encrypt the vector,
872970	878690	you throw it in the vector database. So, very simple change to the system to be able to do that.
878690	884650	Now, most of these vector database systems support storing metadata along with the vectors,
884650	890650	and that metadata might have some sensitive data in it too. So, you might want to consider
890650	894170	encrypting that. That's a whole different thing. We're just going to focus on the vectors for
894170	899250	right now. So, once you've got all of these vectors encrypted, you've loaded them into
899250	905210	your vector database. When it's time to do a query, it's also pretty simple. Again,
905210	909070	the normal process would be to take the query, run it through the embedding model,
909070	914810	get a vector. So, then you just encrypt that vector with the same key and the same algorithm,
914810	918710	and then you do your normal search. And because the algorithm, the encryption,
918710	923970	preserves distance comparison, that means that when you give that encrypted query to the vector
923970	929870	database, it's going to return the encrypted vectors that are closest to the encrypted query,
929870	934530	and those are going to correspond to the decrypted vectors, the original vectors,
934530	940830	that are closest to the original query. So, you get the same results out, pretty much.
941750	945950	And once you get them out, you can maybe decrypt the vectors if you need to,
945950	950610	or maybe you've got some metadata that lets you look up the associated data in a database or
950610	959030	something else. So, without the key, an attacker can't really understand the queries. They are
959030	963430	enough different that they can't look at that and kind of know what the query was.
963430	967550	They can't invert the data that's in the database, even if they hacked it,
967550	975050	exfiltrated all the data, they can't easily invert it. The results are still fairly accurate. Again,
975050	978950	that's a trade-off between the security and the accuracy of their searches.
979530	987250	The whole thing is, it introduces a negligible penalty in terms of performance. The encryption
987250	993070	process is fast, so you can add this in and not add a lot of time to your process.
994150	997650	So, I'm going to talk a little bit more about this encryption function.
998050	1005530	So, it's a function that maps inputs to outputs, and it does it such that for any distance function,
1005530	1011270	the margin of error that you get when you compare two encrypted vectors will be within some factor,
1011270	1017010	we'll call that beta, the approximation factor of the original distance. And so, if you can build
1017170	1022630	a function that preserves that for any pair of vectors that you give as an input, then you have
1022630	1030510	distance comparison preserving encryption functions. So, in real systems, we kind of
1030510	1034810	talked about this, the comparison function is used for nearest neighbor and approximate
1034810	1039890	nearest neighbor searches, which is what all these vector databases are doing. So,
1039890	1045290	you know, if we can build, and we can, we've built this function that preserves distance comparison,
1045290	1051190	so we can use it to encrypt these vectors. So, the paper introduced this scale and perturb
1051190	1057010	algorithm. And I won't go into a lot of details about how it works, but I will give you a few
1057010	1064970	key points about it. So, there's a scale factor, when you, when you set up the algorithm,
1064970	1070230	you randomly choose this scale factor, and you choose a random key. And so,
1073640	1080860	there's also when you go to encrypt an individual vector, you generate an initialization vector,
1080860	1086160	an IV value, just the same as you might if you're doing symmetric encryption on data with,
1086160	1094620	you know, a normal symmetric algorithm. And you perturb each element of the vector using that key
1094620	1100620	in that initialization vector randomly. So, every element in the vector is going to get wiggled
1100620	1106080	around a little bit. And that amount that it gets wiggled around depends on that value beta,
1106080	1113060	that approximation value. And that's how it limits the change in the distance that you can get.
1114420	1121140	So, the paper had this idea of perturbing the vectors as well. And they basically had this
1121140	1126400	idea of shuffling. If you had all of the vectors, you would shuffle the order of them before you
1126400	1132200	encrypted them. And we wanted an online algorithm so that you could, you know, you just encrypted
1132200	1137640	the vectors as you saw them. So, we didn't find that shuffling to be beneficial. But
1138200	1143740	we did add a shuffle where we took the elements of the vector and shuffled them up. So, we
1143740	1148200	randomly changed the order. And it's a deterministic shuffling based on the key.
1148300	1152380	So, when you get done, all of the elements in the vector have been scaled.
1152840	1158120	And then they get shifted around, which makes it even harder. Even if you knew what the algorithm,
1158120	1162400	what the embedding model was, all of the elements of the vector are in different places,
1162400	1168480	which makes it a lot harder to look at it and try to even guess how it corresponds to the original
1168480	1176260	vectors. So, to give a little bit of a more intuition about this, you can think about these
1176260	1182600	vectors. I mean, a vector is a line from the origin to some point. And the point is defined by
1182600	1187620	the elements in the vector, right? Those are the coordinates of that point. And so,
1187620	1195740	the beta basically defines a sphere in n-dimensional space around that point. And
1195740	1202240	so, as we perturb the elements of the vector, the resulting point is somewhere within that sphere.
1202240	1207560	And the size of that sphere is governed by that beta value, the approximation factor. So,
1208620	1213560	you can see that if you bound the amount that you can move the point around,
1213560	1216340	and you've bound the amount that you've moved another point around,
1216340	1221620	the distance between those is bounded too. So, that's how it manages to preserve the distance
1221620	1228360	comparison. So, in addition, we talked about, we also scaled the vectors up so that they're,
1228360	1232640	you know, they get moved around a little bit, they get scaled. So, if you just look at them,
1232640	1239000	and then the elements get shuffled. So, it's very difficult to correlate an encrypted vector
1239000	1245820	and the original vector that was encrypted. Again, because we've preserved that distance
1245820	1252440	comparison, they're still relatively close together with each other. Here's an example,
1252440	1258300	we kind of turned off the shuffle part of it, so it wouldn't be quite as difficult to see,
1258300	1263220	but you can see, you know, we scaled it up, and then we perturb everything. So, sometimes,
1263220	1267760	depending on how much we perturb stuff, signs on elements might change, you know,
1267760	1275580	they bounce around a little bit, but they're still in this vector. So, we've implemented this
1276020	1281120	algorithm. We've got an open source library we call IronCoreAlloy that's out there on GitHub.
1281720	1288780	It's under the AGPL license. So, if you can use GPL software, you can go grab it and use it.
1288780	1293780	If you can't use GPL software, you can talk to us about a different arrangement.
1295640	1299840	Along with the library, we've got some sample code that shows how you can use it with a number
1299840	1305520	of different vector databases. And as I said earlier, it's easy. So, the examples aren't
1305520	1309960	super complicated. It's pretty easy to drop this into some code that's going to put data in one of
1309960	1316260	these vector databases. The library is written in Rust, but we've exposed it in Java, Kotlin,
1316260	1323740	and Python. We've got some more language support on the way. Along with the examples, we've got
1323740	1334280	some results of using this on some output of different LLMs, open source LLMs. And you can
1334280	1341860	see for an approximation factor of one and a half, which is a pretty modest one, we don't impact the
1341860	1346260	search performance. We measured precision and recall loss, which are pretty common measures
1346260	1352100	of search accuracy. It didn't really impact the search accuracy much at all. So, you know, it
1352100	1361760	works. So now, once we've encrypted these vectors, suppose we want to run an attack on them. We're
1361760	1367860	going to run one of the inversion models that Patrick was talking about. So, we know exactly,
1367860	1372920	somehow we know exactly what the embedding model was that was used. It was an open source one,
1372920	1377280	so we don't have to... we train this up once, and it's going to work on every embedding that
1377280	1382220	was generated by that embedding model. But we're going to try to run it on the encrypted vectors.
1382220	1391440	It turns out, because we've done the perturbation, and we shifted around all of the elements,
1392560	1400620	it's mostly gibberish that we get out. So, you really can't tell much about them.
1401760	1407320	Even if somebody knows the plain text, and they have a black box access to the model,
1407320	1413380	and they're going to submit vectors, get encrypted vectors out for a particular key,
1413380	1418020	and they're going to train their own inversion model, the randomization makes that so that
1418020	1422900	it's very difficult, and you get a lot less valuable results. You might get a little bit
1422900	1431420	of the meaning. You're not going to get exact words. And if you... and again, it depends on
1431420	1438380	what value you use for that approximation model. If you knew the plain text, and you knew the
1438380	1445100	ciphertext, can you extract the key? No. It's based on a probabilistic random function that's
1445100	1451820	essentially like a 256-bit keyed hash. And I don't know about you, but I don't want to spend my next
1451820	1459620	two billion weekends trying to brute force attack a 256-bit keyed hash. So, I'm going to turn it over
1459620	1472100	to Patrick, and he'll summarize for you. Okay, so the takeaways that we hope you have here,
1472100	1478120	as we just did a real brief fast run through on what this is and how it works, is first and foremost,
1478120	1484120	you should walk away realizing that RAG produces a lot of copies of data. So, if people are using AI
1484120	1491400	and LLMs in their applications, and somehow that they're operating over data that model wasn't
1491400	1496060	trained on, probably they're doing this and probably lots of copies of that data are being
1496060	1503240	made. It's sprinkled everywhere. And vector databases are like a key part of that. Second thing
1503240	1508940	is that vectors and vector databases can be inverted back to their original input or something
1509620	1517020	very closely approximating it, right? High fidelity and low effort attack, and oftentimes an attacker
1517020	1521020	won't even need to do that. If they have access to the chat app, they can bypass that even. But
1521020	1525420	never mind, if they have access to the vector database, that's as good as having access to the
1525420	1531640	chat app, right? And then the third takeaway that we want you to walk away with is this. It isn't
1531640	1537660	that hard in this case, because there's a built open source library to implement a solution to
1537660	1545040	this problem in your software. So, if you want to, feel free, check out the results, go try it online.
1545900	1551940	The results you get in a vector search are really close to the original. Like, it looks the same to
1551940	1556460	me pretty much across the board. The benchmarks show a few percent differences. There's almost
1556460	1561920	no performance penalty. From a latency perspective, there's almost no reason not to encrypt your
1561920	1568020	vectors if they contain sensitive data in them. And that's it. Thanks for your time today. We're
1568020	1571760	going to be out there, probably just outside the Creator Stage area, if people want to
1571760	1574720	chat with us or have any questions. Thanks for your time.
