TRANSKRIP 🔗
WEBVTT
00:00:00.000 --> 00:00:02.560
Let's say you've built an AI agent.
00:00:02.799 --> 00:00:11.439
You've given it a task, some tools, access to a few systems, and a nice little environment where it's supposed to do its work.
00:00:11.759 --> 00:00:14.880
You've tested it and everything seems fine.
00:00:15.119 --> 00:00:20.719
But then one day it does something you absolutely did not expect.
00:00:21.839 --> 00:00:25.519
Maybe it accesses a system it wasn't supposed to.
00:00:25.679 --> 00:00:29.839
Maybe it finds credentials that you didn't even realize were there.
00:00:30.239 --> 00:00:34.399
Maybe it sends information somewhere that you did not intend.
00:00:35.759 --> 00:00:44.159
Or perhaps it discovers in an entirely different way to accomplish something you specifically told it not to do.
00:00:45.119 --> 00:00:47.520
That's exciting, right?
00:00:48.159 --> 00:00:55.520
But probably not in the way you were hoping, because your AI agent might have just escaped.
00:00:56.079 --> 00:01:00.240
And now you have a potential security incident.
00:01:01.200 --> 00:01:08.319
I'm Tanya Jenka, also known as SheHacks Purple, and this is DevSec Station.
00:01:09.040 --> 00:01:14.239
In this episode, we are going to threat model an AI agent escape.
00:01:14.400 --> 00:01:23.280
And before anyone starts worrying that this is going to involve three days of meetings and a spreadsheet with 400 columns, I promise you it doesn't have to be like that.
00:01:23.519 --> 00:01:25.599
We're going to use four questions.
00:01:25.840 --> 00:01:26.719
That's right.
00:01:27.040 --> 00:01:27.680
Four.
00:01:27.920 --> 00:01:36.239
And by the end of this episode, I want you to be able to use those questions to figure out where your own AI agents might get into trouble.
00:01:36.879 --> 00:01:42.319
But first, what exactly is an agent escape?
00:01:42.719 --> 00:01:47.840
Before we start threat modeling, we need to be clear about what we're actually talking about.
00:01:48.480 --> 00:01:55.040
An AI agent escape is when an agent crosses a security boundary that was supposed to contain it.
00:01:55.439 --> 00:01:58.400
Maybe it escapes a sandbox you put it in.
00:01:58.640 --> 00:02:02.640
Maybe it accesses files or systems outside its authorized scope.
00:02:02.879 --> 00:02:08.879
Maybe it attains credentials it wasn't supposed to have, or maybe it uses one tool to reach something.
00:02:09.120 --> 00:02:12.879
Another tool was supposed to prevent it from accessing.
00:02:13.120 --> 00:02:20.879
But here's an important distinction: an agent doing something unexpected isn't necessarily an escape.
00:02:21.520 --> 00:02:24.800
Remember my Hello Queen application?
00:02:25.280 --> 00:02:33.919
Cloud published it, executed it, scheduled it to run on my computer, and connected it to an external API that I had not vetted.
00:02:34.560 --> 00:02:42.000
It didn't ask to do any of those things, but that doesn't necessarily mean that it escaped either.
00:02:42.400 --> 00:02:49.280
If the tools and permissions I gave it allowed those actions, then it was operating inside the boundaries I'd given it.
00:02:49.919 --> 00:02:59.120
It just did a whole bunch of stuff I wasn't expecting, which is a different problem and one we've already talked about the season.
00:02:59.840 --> 00:03:06.159
An escape is when the agent gets past a boundary that was supposed to prevent an action.
00:03:06.400 --> 00:03:11.919
And today we're going to focus on identifying, testing, and enforcing these boundaries.
00:03:13.360 --> 00:03:15.199
How do we identify them?
00:03:15.439 --> 00:03:17.919
How might an agent get around them?
00:03:18.159 --> 00:03:21.680
And what can we do to make sure these boundaries actually work?
00:03:23.360 --> 00:03:26.560
Now, I want to talk about threat modeling.
00:03:26.800 --> 00:03:42.080
When I teach threat modeling at SheHax Purple, I like to use Adam ShowStacks for questions because threat modeling doesn't have to be this enormous, complicated thing where you spend three days filling out spreadsheets and everyone just wants to cry.
00:03:42.560 --> 00:03:47.120
We can make it pretty straightforward and unpainful.
00:03:47.599 --> 00:03:49.199
It could even be fun.
00:03:50.319 --> 00:03:52.879
Like I said, there are just four questions.
00:03:53.120 --> 00:03:54.479
What are we doing?
00:03:54.800 --> 00:03:56.400
What could go wrong?
00:03:56.639 --> 00:03:58.479
What are we gonna do about it?
00:03:58.800 --> 00:04:01.280
And did we do a good job?
00:04:01.840 --> 00:04:02.879
That's it.
00:04:03.280 --> 00:04:11.680
Now obviously you can go much deeper than that, but these four questions give us a really useful way to think through a system.
00:04:12.240 --> 00:04:19.199
So let's use them to threat model an AI agent for a pretend example system that I made up.
00:04:19.439 --> 00:04:21.920
So, question one, what are we doing?
00:04:22.319 --> 00:04:29.279
But before we start drawing diagrams and looking for security boundaries, I actually want to back up for a second and ask something else.
00:04:29.600 --> 00:04:33.519
Does this system even need to be an AI agent?
00:04:33.839 --> 00:04:37.120
Because not everything needs to be a damn agent.
00:04:37.600 --> 00:04:47.040
I was talking with someone who wanted to build an AI agent to collect cybersecurity news, check which stories were relevant, and then put it all together for a company newsletter.
00:04:47.120 --> 00:04:49.839
And they were worried about how to secure the agent.
00:04:50.079 --> 00:04:52.720
But I, of course, had a different question.
00:04:53.120 --> 00:04:56.160
Why does this even need to be an agent in the first place?
00:04:56.399 --> 00:05:12.959
Couldn't we use a scheduled job to collect the news, regular software to remove any duplicates and store the results, and then maybe AI to help decide which stories are relevant or to summarize them, and then have a human review the newsletter before sending it.
00:05:13.519
Load full transcript
--> 00:05:21.519
We'd still be using AI where it's useful, but we wouldn't need to give an autonomous agent access to all those systems and permissions.
00:05:21.680 --> 00:05:23.920
We could just use a regular LLM.
00:05:24.639 --> 00:05:27.920
And that would mean fewer things to secure.
00:05:28.319 --> 00:05:36.079
Now, I'm not saying that regular software is magically secure because we all know that's not true.
00:05:36.319 --> 00:05:44.399
But if we can accomplish the task without giving an AI model unnecessary autonomy and permissions, why wouldn't we do it that way instead?
00:05:44.560 --> 00:05:46.639
And that's a part of threat modeling.
00:05:46.879 --> 00:05:54.079
Making sure we're building the right thing in the first place and architecting it correctly in the first place so that we reduce risk.
00:05:54.319 --> 00:05:58.000
Now let's imagine I've built an AI coding agent.
00:05:58.319 --> 00:06:03.199
Because apparently I haven't learned my lesson from the Hello Queen situation.
00:06:04.399 --> 00:06:09.279
This one is supposed to help me review code, run tests, and create pull requests.
00:06:09.519 --> 00:06:10.160
Yes.
00:06:10.560 --> 00:06:11.680
But that's it.
00:06:11.920 --> 00:06:14.399
I do not want it accessing production.
00:06:14.560 --> 00:06:28.639
I don't want it downloading all my secrets, and I definitely do not want it deploying things without asking me first, which is, as we've established, is something I apparently need to be extremely clear about.
00:06:28.959 --> 00:06:32.160
So that's all I want the agent to do.
00:06:32.800 --> 00:06:34.800
But what can it actually do?
00:06:34.959 --> 00:06:36.560
Can it do more than that?
00:06:37.040 --> 00:06:38.480
Where does it run?
00:06:38.800 --> 00:06:42.720
Is it inside a container, a virtual machine, directly on my laptop?
00:06:42.879 --> 00:06:44.560
What files can it access?
00:06:44.879 --> 00:06:47.040
Can it make network connections?
00:06:47.279 --> 00:06:48.720
What tools can it run?
00:06:48.879 --> 00:06:51.120
Does it have access to my credentials?
00:06:51.360 --> 00:06:53.600
And what can those credentials do?
00:06:53.920 --> 00:06:57.040
Because here's something that we've already learned together.
00:06:57.279 --> 00:07:05.759
The boundaries you describe in a prompt are not necessarily boundaries that are enforced by your system.
00:07:06.319 --> 00:07:10.959
I can tell my agent that it must never access production.
00:07:11.600 --> 00:07:18.000
But if I've given it credentials that allow production access, I haven't actually stopped it from doing that.
00:07:18.319 --> 00:07:20.639
I've just asked really nicely.
00:07:21.279 --> 00:07:28.319
And we all know how I feel about asking nicely for software to behave and how that usually works out for me.
00:07:28.720 --> 00:07:33.040
So the first thing that we would do is we would draw a diagram.
00:07:33.279 --> 00:07:40.399
So think of this diagram as though a data flow diagram and an architecture
diagram got together and had a baby.
00:07:40.800 --> 00:07:42.160
It doesn't need to be fancy.
00:07:42.240 --> 00:07:52.560
So put the agent in the middle and draw all the tools it can use, all the systems it can access, the credentials it has, and the places where information can leave the environment.
00:07:53.120 --> 00:07:58.079
Then you want to identify where trust boundaries are actually enforced.
00:07:58.240 --> 00:08:06.399
So not the boundaries that we wish existed, not aspirational boundaries, but real live technical enforced boundaries.
00:08:06.639 --> 00:08:08.720
So that's the answer to question one.
00:08:08.879 --> 00:08:09.759
What are we doing?
00:08:10.000 --> 00:08:12.879
So now question two, what could go wrong?
00:08:13.120 --> 00:08:15.360
This is where things are gonna get interesting.
00:08:15.600 --> 00:08:20.319
We've got our coding agent, it's supposed to review code, run tests, and create pull requests.
00:08:20.480 --> 00:08:20.959
Awesome.
00:08:21.120 --> 00:08:25.120
And we've drawn a diagram of the environment where it operates, great.
00:08:25.360 --> 00:08:28.800
Now let's look for ways that it could cross a boundary.
00:08:29.360 --> 00:08:31.199
Let's start with the network.
00:08:31.439 --> 00:08:35.440
Maybe I've configured the agent so that it can only access a few approved services.
00:08:35.679 --> 00:08:37.519
Awesome, great, good job.
00:08:37.840 --> 00:08:41.679
But can it make arbitrary outbound HTTP requests?
00:08:41.919 --> 00:08:44.879
Can it send information to an external server?
00:08:45.440 --> 00:08:49.200
What if it can't make those requests directly?
00:08:49.519 --> 00:08:53.200
Could it use another tool that can make those requests?
00:08:53.360 --> 00:08:58.399
For example, maybe the agent can modify a file that gets uploaded somewhere automatically.
00:08:58.960 --> 00:09:10.399
Or write something to a log that's forwarded to another service, or maybe it can modify a build script that later runs in an environment with broader network access than it has.
00:09:10.879 --> 00:09:12.720
See what we're doing here?
00:09:12.960 --> 00:09:16.799
We are looking for paths around the boundaries.
00:09:17.519 --> 00:09:20.000
So now let's talk about credentials.
00:09:20.159 --> 00:09:22.960
Because maybe my agent doesn't have production credentials.
00:09:23.120 --> 00:09:24.000
Excellent.
00:09:24.320 --> 00:09:26.960
But can it read the environment variables?
00:09:27.679 --> 00:09:30.159
Can it inspect the configuration files?
00:09:30.399 --> 00:09:35.759
Can it access a CICD system that does have production credentials?
00:09:36.080 --> 00:09:39.919
Could it modify a workflow that later runs with elevated privileges?
00:09:40.080 --> 00:09:53.600
Because if my agent can modify a workflow that has permissions to deploy to production, then I might have accidentally given an unintentional path right to the place I didn't want to.
00:09:54.000 --> 00:09:59.440
Even though I never gave it production credentials directly, I kind of sort of did.
00:10:00.159 --> 00:10:01.120
Oops.
00:10:02.320 --> 00:10:06.639
This is why we have to look at the entire system, not just the agent.
00:10:07.360 --> 00:10:09.279
Now let's look at tools.
00:10:09.600 --> 00:10:12.639
Suppose I've given the agent access to a shell.
00:10:13.120 --> 00:10:15.279
What permissions does that shell have?
00:10:15.519 --> 00:10:16.879
Can it install packages?
00:10:17.039 --> 00:10:18.799
Can it access files outside the project?
00:10:18.960 --> 00:10:20.240
Can it launch other processes?
00:10:20.399 --> 00:10:22.879
Can it interact with cloud infrastructure?
00:10:23.200 --> 00:10:25.919
And here's another interesting one.
00:10:26.960 --> 00:10:30.559
Can it communicate with other AI agents?
00:10:30.879 --> 00:10:37.120
Maybe agent A has very limited permissions, but agent B has access to something much more sensitive.
00:10:37.279 --> 00:10:41.200
Can agent A send instructions to agent B?
00:10:41.360 --> 00:10:48.399
Can it influence agent B through a shared document, message queue, or any other system?
00:10:48.480 --> 00:10:56.399
And if agent B acts on those instructions, have we accidentally created another path around our security controls?
00:10:56.720 --> 00:10:59.840
These are the kinds of questions I would like us to be asking.
00:11:00.000 --> 00:11:15.200
Not just could the AI come up with some incredibly clever way for it to escape, but what paths actually exist through the system and which of those paths could allow it to cross a boundary?
00:11:15.919 --> 00:11:20.320
That's a much more useful engineering question for when we're threat modeling.
00:11:20.559 --> 00:11:25.919
And now I want to ask the scary question: what are we going to do about it?
00:11:26.240 --> 00:11:26.559
Okay.
00:11:27.360 --> 00:11:30.240
So we've found some potential problems together.
00:11:30.480 --> 00:11:32.080
Now what do we do?
00:11:32.559 --> 00:11:36.960
The good news is that we already know how to solve a lot of these problems.
00:11:37.120 --> 00:11:39.600
We are security people, we've got this.
00:11:40.000 --> 00:11:45.039
We have been dealing with software that does unexpected things for a very long time.
00:11:45.279 --> 00:11:50.960
And developers have been building security controls into and around that software for pretty much just as long.
00:11:51.120 --> 00:11:52.879
So let's start with isolation.
00:11:53.120 --> 00:12:02.639
If my agent needs to execute, I probably don't want it doing that directly on my everyday computer with access to all my personal files and credentials.
00:12:02.879 --> 00:12:06.960
I can give it an appropriately restricted environment instead.
00:12:07.279 --> 00:12:16.720
Maybe a container or a temporary development environment, maybe a sandbox, something that limits what it can access and what it can affect.
00:12:16.799 --> 00:12:19.360
And I can restrict its network connections too.
00:12:19.600 --> 00:12:26.000
If
it only needs to communicate with three-approved services, why would I give it access to the entire internet?
00:12:27.600 --> 00:12:29.679
Next, credentials.
00:12:30.000 --> 00:12:40.399
My agent should have its own identity on the network, not my personal account with every permission that I have accumulated over the past decade.
00:12:41.120 --> 00:12:48.799
Give it credentials scoped to the specific task that you want to allow it to do and make them short-lived if you can.
00:12:49.360 --> 00:12:54.000
And don't give it access to secrets that it doesn't need in the first place.
00:12:54.399 --> 00:12:55.919
Okay, now tools.
00:12:56.159 --> 00:13:02.399
If an agent needs to read a repository, it doesn't automatically need permission to modify it too.
00:13:02.639 --> 00:13:07.039
If it needs to create a pull request, it doesn't need permission to merge it.
00:13:07.360 --> 00:13:13.600
And if it needs to run tests, it doesn't necessarily need unrestricted shell access.
00:13:14.000 --> 00:13:18.080
But there's something else here that I want to emphasize.
00:13:18.320 --> 00:13:22.559
The system receiving the action needs to enforce the permission.
00:13:22.960 --> 00:13:25.360
Let's say my agent wants to deploy something.
00:13:25.519 --> 00:13:36.559
The agent can request a deployment, but the deployment system should decide whether that request is authorized via a policy, not an AI.
00:13:37.039 --> 00:13:44.480
The agent probably shouldn't have deployment permissions, and it should probably require an approval.
00:13:44.799 --> 00:13:48.480
Maybe it can deploy to a development environment, but not production.
00:13:48.799 --> 00:13:54.399
Whatever our policy is, we need something outside of the AI to enforce that for us.
00:13:54.960 --> 00:14:05.519
Because the agent may get to decide what it wants to do, but it never gets to decide what it is allowed to do.
00:14:06.320 --> 00:14:11.600
And finally, let's talk about what happens if one of our controls fails, because that can happen.
00:14:11.679 --> 00:14:12.879
We've seen this.
00:14:13.600 --> 00:14:17.519
Can the agent affect one repository or 50?
00:14:17.840 --> 00:14:22.480
Can it access one cloud resource or an entire production account?
00:14:22.799 --> 00:14:26.960
Can it perform one transaction or 10,000?
00:14:27.440 --> 00:14:29.600
We want to limit the blast radius.
00:14:29.679 --> 00:14:33.200
If something goes wrong, I want the consequences to be manageable.
00:14:33.519 --> 00:14:37.120
Not an emergency meeting with every executive in the company.
00:14:37.279 --> 00:14:46.000
Nobody wants that, especially not on a Friday afternoon, because these things always, always, always seem to happen on a Friday, don't they?
00:14:47.120 --> 00:14:47.440
Okay.
00:14:48.399 --> 00:14:49.840
Question four.
00:14:50.159 --> 00:14:52.159
Did we do a good job?
00:14:52.960 --> 00:14:58.399
Now, this is my favorite question because we can design all the security controls that we want.
00:14:58.559 --> 00:15:01.200
And we can write beautiful documentation.
00:15:01.440 --> 00:15:04.080
We can create lovely diagrams.
00:15:04.240 --> 00:15:07.200
We can tell everyone how secure our system is.
00:15:07.519 --> 00:15:09.440
But do the controls actually work?
00:15:09.600 --> 00:15:10.720
Have we tested them?
00:15:10.879 --> 00:15:12.639
Let's go back to our coding agent.
00:15:12.720 --> 00:15:15.200
We said it shouldn't be able to access production.
00:15:15.440 --> 00:15:15.759
Okay.
00:15:16.399 --> 00:15:20.000
But have we actually tried to access production from its environment?
00:15:20.159 --> 00:15:22.080
And if so, what happened?
00:15:23.120 --> 00:15:24.879
Does the request get blocked?
00:15:25.039 --> 00:15:30.080
Does it succeed because someone else accidentally left a credential lying around?
00:15:30.320 --> 00:15:32.879
What if the agent tries to read a sensitive file?
00:15:33.039 --> 00:15:37.039
What if it attempts to make an unauthorized network connection?
00:15:37.279 --> 00:15:40.080
What if it modifies a CICD workflow?
00:15:40.399 --> 00:15:42.159
Do the boundaries hold?
00:15:42.480 --> 00:15:46.159
Because if we haven't actually tested them, then we don't really know.
00:15:46.879 --> 00:15:49.279
And there's another part to this question.
00:15:50.000 --> 00:15:54.159
Would we know if an agent escaped?
00:15:54.799 --> 00:15:57.840
Are we logging the actions that it takes?
00:15:58.159 --> 00:16:03.120
Can we see what tools it invoked, which creds it used, which systems it accessed?
00:16:03.279 --> 00:16:09.279
Would an unusual network connection generate an alert that a human being would actually see?
00:16:09.519 --> 00:16:13.200
And if something goes wrong, do we have the power to stop it?
00:16:13.519 --> 00:16:15.600
Can we revoke its credentials?
00:16:15.840 --> 00:16:19.840
Can we terminate its execution environment quickly?
00:16:20.159 --> 00:16:23.679
Can we prevent pending actions from completing?
00:16:24.000 --> 00:16:27.120
Investigate what it accessed or modified?
00:16:28.000 --> 00:16:37.120
These are ordinary instant response questions, but they are especially important when we're giving software the ability to take actions autonomously.
00:16:37.279 --> 00:16:40.080
And I want to make one thing very, very, very clear.
00:16:40.240 --> 00:16:45.039
We don't have to invent an entirely new field of security engineering to answer these questions.
00:16:45.279 --> 00:16:48.080
We already know how to do threat modeling.
00:16:48.320 --> 00:16:51.840
We already know how to enforce authorization.
00:16:52.159 --> 00:16:54.639
We already know how to isolate software.
00:16:54.879 --> 00:16:59.200
We know how to monitor systems and respond to security incidents.
00:16:59.600 --> 00:17:03.279
But we need to apply those skills to AI agents.
00:17:04.720 --> 00:17:08.319
Here is what I would really like you to remember.
00:17:08.559 --> 00:17:15.119
When we hear about an AI agent escaping, it's tempting to focus on how clever that escape was.
00:17:15.279 --> 00:17:16.720
How did it figure that out?
00:17:16.880 --> 00:17:18.319
How did it find that voe?
00:17:18.480 --> 00:17:20.400
How did it know to use that particular tool?
00:17:20.559 --> 00:17:27.039
And those things might be interesting for sure, but from a security perspective, I think there's a more important question.
00:17:28.079 --> 00:17:31.279
Why was that path available in the first place?
00:17:31.440 --> 00:17:34.880
What security boundary was supposed to prevent the action?
00:17:35.119 --> 00:17:36.640
Was that boundary missing?
00:17:36.799 --> 00:17:38.319
Was it incorrectly configured?
00:17:38.559 --> 00:17:41.839
Did another component provide a way around it?
00:17:42.079 --> 00:17:51.039
And what can we change so that next unexpected action doesn't have the same level of consequence?
00:17:51.200 --> 00:17:58.160
Because I don't want to build a security strategy around hoping that our AI agents don't do anything surprising.
00:17:58.400 --> 00:18:00.480
We know that they are going to surprise us.
00:18:00.640 --> 00:18:02.000
We should know that by now.
00:18:02.240 --> 00:18:07.279
And sometimes it does surprise us in wonderful ways, and that's why we use it.
00:18:07.599 --> 00:18:12.400
But sometimes it's in ways that make us seriously question our career choices.
00:18:12.720 --> 00:18:21.759
But what I want is a system where an AI agent can attempt something unexpected and the security architecture responds appropriately.
00:18:22.000 --> 00:18:24.319
Maybe the request is rejected.
00:18:24.559 --> 00:18:26.480
Maybe an approval is required.
00:18:26.640 --> 00:18:28.480
Maybe an alert fires.
00:18:28.720 --> 00:18:30.880
Maybe the agent gets stopped.
00:18:31.119 --> 00:18:36.960
But the important part is that the AI doesn't get to decide whether these controls apply to it or not.
00:18:37.279 --> 00:18:44.000
Never rely on the AI model itself to enforce the security boundary that's supposed to contain it.
00:18:44.480 --> 00:18:46.319
Here's your one thing to do this week.
00:18:46.480 --> 00:18:47.359
Oh, yeah, that's right.
00:18:47.440 --> 00:18:49.200
Of course there's more homework.
00:18:49.839 --> 00:18:59.519
Pick one AI agent that you or your org is building, testing, or using, and ask yourself: does this task actually require an autonomous agent?
00:18:59.759 --> 00:19:01.039
If yes, that's great.
00:19:01.279 --> 00:19:03.200
Then let's threat model it.
00:19:03.519 --> 00:19:05.200
Draw a simple diagram.
00:19:05.359 --> 00:19:09.039
You know, the one where the DFD and the design doc had a baby.
00:19:09.519 --> 00:19:17.279
Include the agent, its tools, its creds, the system it can access, and the places where information can leave the environment.
00:19:17.519 --> 00:19:20.240
Then ask yourself one question.
00:19:20.720 --> 00:19:26.319
Which of these boundaries are enforced by something outside of the AI?
00:19:27.200 --> 00:19:35.440
If the only thing preventing an action is a sentence in the agent's instructions, you've found something worth looking into.
00:19:36.319 --> 00:19:38.960
You don't have to solve every problem today.
00:19:39.279 --> 00:19:55.359
Just identify one boundary that needs a better security control because we know we can't prevent every unexpected action, but we do want to make sure that one unexpected action doesn't turn into a security incident.
00:19:55.920 --> 00:20:02.160
I'm Tanya Jenka, also known as She Hacks Purple, and this is DevSecStation.
00:20:02.319 --> 00:20:06.079
Thank you for listening, and I will see you in the next episode.