TRANSCRIPT 🔗
WEBVTT
00:00:00.080 --> 00:00:02.799
Your AI worked 59 times.
00:00:03.200 --> 00:00:05.040
But what about the 60th?
00:00:05.839 --> 00:00:19.039
I was teaching secure coding to a class of about 60 people, and everyone was using the same AI assistant, the same programming language, the same security prompt, the same build prompt.
00:00:19.760 --> 00:00:24.480
And for 59 people, it worked pretty much the way you would expect.
00:00:24.800 --> 00:00:28.559
And then one student called me over and said, Tanya, what's this?
00:00:29.120 --> 00:00:35.359
I looked at the code their AI had generated and it had done something wild.
00:00:36.560 --> 00:00:42.320
It had added comments telling the Python linter not to expect the following lines.
00:00:42.560 --> 00:00:49.759
And then in those lines, it was intentionally leaking secrets to an external file.
00:01:01.679 --> 00:01:03.920
And it was not fine.
00:01:05.280 --> 00:01:07.040
I'm Tanya Jenka.
00:01:07.599 --> 00:01:11.680
Welcome to season two of DevSec Station.
00:01:13.280 --> 00:01:21.359
Here's the security question that I think we need to start asking about AI assisted development and AI agents.
00:01:22.319 --> 00:01:24.719
What happens on the really weird run?
00:01:25.840 --> 00:01:30.560
Because we're used to testing software and asking questions like: does this work properly?
00:01:30.719 --> 00:01:32.319
Does it behave as intended?
00:01:32.480 --> 00:01:34.959
Does it produce the results we're expecting?
00:01:35.200 --> 00:01:42.239
But with an AI agent, we might run something five times or 10 times or 50 times and think, oh my gosh, this is great.
00:01:42.319 --> 00:01:43.760
It works perfectly.
00:01:44.480 --> 00:01:52.319
Except now we're dealing with a probabilistic system, which means a non-deterministic system.
00:01:53.519 --> 00:02:02.799
The fact that it behaved correctly the last 59 times does not guarantee that run number 60 will look anything like the previous 59.
00:02:03.280 --> 00:02:11.120
And that's not necessarily a huge security problem if the AI isn't able to do very much.
00:02:11.439 --> 00:02:17.280
If I ask an AI agent to suggest a sentence for an email and it gives me something completely bizarre, that's fine.
00:02:17.439 --> 00:02:20.400
I just don't send that weird sentence.
00:02:21.520 --> 00:02:25.759
Because obviously I would proofread that email before I send it, right?
00:02:27.759 --> 00:02:33.120
But we're increasingly giving AI systems the ability to do things.
00:02:33.680 --> 00:02:48.400
Write code, access files, invoke tools, access secrets, send messages on our behalf, modify infrastructure, publish software, deploy things.
00:02:50.080 --> 00:03:02.560
And now consistency starts to become an important security property because the potential consequences of a weird run have changed dramatically now.
00:03:02.879 --> 00:03:06.560
And I would like to make an important distinction at this point.
00:03:07.439 --> 00:03:11.520
The AI does not need to escape for this to become a security problem.
00:03:11.680 --> 00:03:18.319
We hear a lot about agents escaping sandboxes or bypassing controls or finding clever ways around the restrictions that we have set for them.
00:03:18.400 --> 00:03:19.360
And that is interesting.
00:03:19.439 --> 00:03:22.639
And we are definitely going to talk about that during season two.
00:03:23.520 --> 00:03:26.800
But that's not what happened in my classroom.
00:03:27.360 --> 00:03:29.199
The AI didn't escape.
00:03:29.360 --> 00:03:30.639
It wasn't even an agent.
00:03:30.719 --> 00:03:35.120
It was generating code because I literally asked it to generate code.
00:03:35.199 --> 00:03:42.000
It was operating entirely within the environments and the capabilities that we had given it.
00:03:43.039 --> 00:03:46.800
It just generated something we really, really, really did not want.
00:03:46.879 --> 00:03:49.360
And that is a completely different problem.
00:03:50.400 --> 00:04:02.240
Because if an AI can cause damage while staying completely inside the boundaries that we gave it, then making those boundaries stronger doesn't necessarily solve the problem.
00:04:03.360 --> 00:04:10.080
We also have to ask whether we've given it too much power inside those boundaries.
00:04:11.759 --> 00:04:15.599
So what do we do about this, right?
00:04:16.160 --> 00:04:19.040
For starters, the answer is not write a better prompt.
00:04:19.120 --> 00:04:24.240
So prompts are useful and we should absolutely give AIs good instructions.
00:04:24.399 --> 00:04:26.879
We should tell them what we expect and what we want.
00:04:27.360 --> 00:04:31.360
But a prompt is not a security control.
00:04:32.959 --> 00:04:43.360
If the consequences of the AI doing something unexpected is severe, we need controls outside the AI that limit what can actually happen.
00:04:44.399 --> 00:04:48.879
And I mean, fortunately, we know how to build those, right?
00:04:49.040 --> 00:04:52.399
We've been implementing least privilege for decades.
00:04:53.360 --> 00:05:00.319
If an agent only needs access to one repository, then we should not give it access to every single repository we have.
00:05:00.480 --> 00:05:05.439
If it needs to read something, why are we giving it CRUD permissions?
00:05:05.759 --> 00:05:13.199
If it needs credentials briefly, maybe it doesn't need that credential forever and it should expire.
00:05:13.839 --> 00:05:17.839
And then on top of that, there are independent security tools.
00:05:18.079 --> 00:05:28.480
If an AI is writing code, that code should probably go through code review, static analysis, linters, peer review, etc.
00:05:28.879 --> 00:05:36.879
It should still go through all the security checks we would expect other code to go through, including and especially testing.
00:05:37.519 --> 00:05:48.800
And yes, I appreciate the absolutely delightful irony of saying that after telling you a story in which the generated code tried to tell the linter not to look at that.
Load full transcript
00:05:49.279 --> 00:05:58.560
But that's actually the best argument for making sure that the AI isn't in charge of deciding whether controls run or not, right?
00:05:59.439 --> 00:06:04.720
For higher impact actions, we also need to add approvals.
00:06:04.959 --> 00:06:12.160
Maybe the agent can prepare a deployment, but something or someone else has to authorize it.
00:06:12.399 --> 00:06:15.759
Maybe it could draft an email, but it cannot send it.
00:06:16.000 --> 00:06:22.879
Maybe it can propose an infrastructure change, but it can't independently push that change to production.
00:06:23.519 --> 00:06:26.560
We can make operations reversible when possible.
00:06:26.720 --> 00:06:27.680
That's a great idea.
00:06:27.839 --> 00:06:42.319
We can use dry run modes, we can plan for rollback, and we need to log what happened so that when something weird occurs, we can figure out what it actually did, not just what we think it did.
00:06:43.360 --> 00:06:52.079
And always, especially with all the things we are seeing in the news right now, we need to try to limit the blast radius.
00:06:52.879 --> 00:07:01.519
The goal isn't to make a probabilistic system behave in a perfectly predictable way because that is not going to happen.
00:07:01.920 --> 00:07:08.720
I don't think that that's a useful security strategy because we have all seen it fail repeatedly.
00:07:09.040 --> 00:07:17.439
Our goal needs to be to design systems around it so that one strange output doesn't become a catastrophic event.
00:07:17.759 --> 00:07:21.519
Think about the difference between these two questions.
00:07:22.000 --> 00:07:24.480
Does our AI usually do the right thing?
00:07:24.720 --> 00:07:31.519
And what is our AI actually allowed to do if something goes wrong?
00:07:32.240 --> 00:07:34.240
Obviously, very different questions.
00:07:34.399 --> 00:07:37.040
And obviously the second one's more important.
00:07:37.600 --> 00:07:47.680
Because if your AI works correctly 59 times and does something bananas on number 60, I want number 60 to be boring.
00:07:48.959 --> 00:07:51.680
Maybe a security tool rejects the code.
00:07:51.839 --> 00:07:56.079
Maybe an authorization check blocks that action from happening.
00:07:56.240 --> 00:07:59.600
Maybe someone has to approve it and they don't.
00:07:59.920 --> 00:08:06.160
Maybe a transaction limit kicks in, maybe it gets logged and an alert gets sent and you go investigate.
00:08:06.319 --> 00:08:08.399
Maybe you have to roll something back.
00:08:08.800 --> 00:08:14.079
But if there's a weird run, it shouldn't become a security incident.
00:08:14.879 --> 00:08:19.120
And that is going to be a recurring theme this season.
00:08:19.279 --> 00:08:23.680
We don't have to prevent AI systems from ever doing anything surprising.
00:08:23.920 --> 00:08:30.079
What we need to do is engineer our systems so they can safely survive a surprise.
00:08:31.199 --> 00:08:34.639
So here's your one thing to do this week.
00:08:35.120 --> 00:08:49.360
Pick one AI assistant or agent that you or your organization is using and ask, if this does something completely unexpected one time out of 60, what's the worst thing that it can actually do?
00:08:49.759 --> 00:09:04.159
Not what you've asked it to do or what the prompt says it should do, but from a technical perspective, what it is capable of doing with the permissions, credentials, tools, and access that it actually has.
00:09:05.360 --> 00:09:09.440
If you don't like the answer, don't rate a better prompt.
00:09:09.600 --> 00:09:11.440
Change its permissions.
00:09:12.080 --> 00:09:16.240
And we're going to talk about how to do that this entire season.
00:09:17.600 --> 00:09:20.080
Thank you for listening to DevSecStation.
00:09:20.320 --> 00:09:23.279
I'm Tanya Janka, and I'll see you next time.