Patching Woes0:00
Thanks, everyone, for joining in. Uh, thanks for the great intro, by the way. So yeah, my talk today is about—so the title is "We gave an agent production code access and then tried to sleep at night." So it's mostly around dependency, dependency patching, which is probably the most
glamorous problem in software engineering. I guess everyone did it here at some point in the past. It really is like vacuuming. Like, everyone loves it, can't wait to do it again next week. Now, at our scale, we have thousands of repositories, and it really is a backlog that never empties.
And you close 10 issues today, and you know next week 20 more will arrive, and you have to deal with them. So naturally you think, "Sure, let's just automate it." Dependabot exists, Renovate exists, problem solved,right? It isn't. Because these tools were really built for a world where fixing a CVE means, um, looking at the manifest in a repository and just, you know, bumping a version to the next version and that's it.
But our world is much more complicated than that, at least nowadays, since we have containers. So the first problem is that the vulnerable thing isn't necessarily the thing that these tools can see. For instance, a CVE might live in an OS package that you use in your base image.
It's not in your Dockerfile, it's just in the base image. Or if your Dockerfile pulls down a binary during the build process, it may see the URL, which might contain a version number, but it has no idea how to act on it.
So it can only look at the manifest, patch the manifest, but everything else is just simply invisible. Now, the second problem is patches never happen in isolation. So when we look at the Go codebase, sometimes you want to bump the Go runtime to the next minor version.
When you do that, sometimes you might have to also bump the Go linter, because the version log is intertwined. You have to bump both of them at the same time. So when you bump the linter, that sometimes introduces new linting rules, which then invalidates the codebase.
And you're left with this big mess. Now, these old tools, quote-unquote "old tools," Dependabot, RenovateBot, well, they just bump the Go runtime version, create a PR, and walk away. And you're just left with this mess, and you need to figure out how to fix that.
So you don't really have, like, a patching problem. You also have, like, a reasoning problem that you, um, need to address here. You really want to have a tool that looks at the CVE and understands the full surface of it.
PatchPilot2:37
Where does the CVE actually live? And it needs to figure out what else needs to move in order to, um, get to a green CI.
So that's basically what we did. Um, we built PatchPilot. We pushed to production, and eventually infosec, um, came around the corner and asked a very reasonable question: "Is this automation, or is it a supply chain incident waiting to happen?"
A useful coding agent is a supply chain actor, whether you planned for that or not. That's the thesis of this talk, basically. It's not "agents are dangerous" or "agents are fine." It's the moment where you give an agent, um, production credentials in order to, like, be useful, it really becomes a supply chain actor, just like an engineer in your department.
And you should apply similar or the same guardrails, uh, for the agent, just as you do for engineers. Now, this is a case study. We built this, we ran it in production, infosec pushed back in several places they wereright.
Um, I just want to present to you what we came up with in the end. Um, it's nothing new, it's nothing fancy. Um, I just want to share, share what we did, and then hopefully have a discussion afterwards, um, to see how we all figure this out together.
Now, PatchPilot has two layers. One, it's a simple Go application that is deterministic. It's boring. It just does orchestration. It discovers vulnerable artifacts. So artifacts, that's our OCI images. That's what we have in production, that's what we ship to our customers, and that's the thing that we really care about.
Two-Layer Design4:02
So the Go app discovers those, scans the images, um, and figures out which image is built by which repository. Um, because we need that link in order to later then work on the repositories.
And this deterministic part is very boring on purpose. It's very simple. Um, and inside that, we spawn agents. Now, these agents are there for the reasoning. For instance, when we see a CI failure, we just tell the agent, "Look, that's a CI failure.
Please figure out what the hell to do in this case." It could be that CI failed because, um, a previous change that we did. It could also be a flaky CI. It could be an infrastructure failure, just a simple timeout that just, you know, caused the CI failure.
Agent Workflow5:03
And then we would just need to retry and do nothing else in that case. Now let's have a look at it, how it looks, uh, end to end. So first and foremost, um, a little bit of color coding.
I hope you can see this. So the green bits, that's our, um, deterministic part, our Go application. And the yellow ones, that's the agent. Um, so first we start with the, um, with the assessment. That's just a simple manifest, a simple JSON file, which contains a list of images and the CVEs that it found for these particular images.
Um, it then moves on and downloads the repository it's supposed to work on, um, clones it into a local directory, and creates another directory inside it, where it then shops all the context for the agent inside there. That's a prompt, which has, like, I don't know, like 2,000 words or so.
Um, it's the assessment manifest, um, and a couple of other things for, like, communicating with the agent.
And then simply, we simply invoke the CVE remediation agent, which is, like, the first bit, um, the first agentic part that we invoke, which is supposed to do the smallest effective change set. And it should only fix the CVEs which are tied to the findings.
It shouldn't just, you know, bump the dependencies to the latest and greatest version. That's just, that introdu-introduces unnecessary risk, which we want to avoid. So just bump to the version that actually fixes the CVE and, um, nothing more.
And at the very end, the agent then, of course, should, um, just verify its own work. Should ensure that the Dockerfile is able to build. Should, um, rescan the image that it has built and all of that stuff.
Um, so the CVE remediation agent actually just modifies files in the file system. It doesn't commit, it doesn't push, it doesn't create a PR, it doesn't watch CI itself. It just modifies files in the file system. And once it's done, it hands back control to the controller, to the deterministic bit, which then quickly vets the changes for, you know, some nonsense in there, in there.
For instance, like, um, empty files or some binaries that the agent might create. Because agents are really dumb. They mess up, you know, some bash commands that are piped together, which then could, um, create empty files. Or they just, you know, compile the application and leave the binary inside the repository, which is nonsense.
So we got to take care of that. And then we commit it, we push it, we create a PR, um, and then we watch CI. Now, when CI is green, cool, we just send over Slack notifications and we're done.
Um, in case there's a CI failure, we just move to the next agentic bit, which, um, should then just remediate the PR failure. To do that, we just give it all the context that it needs. So CI logs, um, workflow metadata that we need, and everything else that is needed to work on this, uh, on this CI failure.
And then we invoke it. And this PR remediation agent just simply should do the minimum of four fixes. It kind of, like, LLMs, LLMs kind of tend to just revert the previous changes that it did. So we got to tell it to not do this.
Um, and again, it should just verify its own work. And this then goes on in a loop. Create, watch, um, the PR, or watch CI, um, fix the CI failure, and so on and so forth, until we hit, like, a maximum retry.
And then we send that over to a, to a human in case there's, like, um, the limit is reached. We then just simply tell the, tell the human to take a look at this particular issue. Because then it needs manual remediation.
Retrospective8:36
There's one more thing that I want to share here, which is that at the end of every agent invocation, we ask the agent to do a very short and simple retrospective. What went well, what went wrong, what tools are missing, and what context would help the next time it would be invoked.
And this really helps us to understand what the agent is doing and what is, what is missing out. Um, now, the observability for the agentic bits, that's still, like, an open issue and being built by the community at the moment.
That's just how we dealt, uh, dealt with this, with this particular issue. Um, so yeah, that really helps us to understand this at scale, because then we can just aggregate all this, all that information across the PRs, condense it down, and then we can see, um, what we need to fix.
We usually solve, like, two kinds of issues. One is an infrastructure-related issue. It could be, um, network failures, or that the agent didn't have enough permissions in order to, like, clone a repository. Um, or it could be some complexity issue related with a repository.
Some repositories are just hard to deal with and hard to reason about without having the, the context that the, the agent needs. Then we just need to either modify the system prompt of the agent, or we then have repository-specific instructions, um, that we then just feed, um, to our agent to work on this issue.
I brought a screenshot here with me. Um, I had to redact a lot of stuff, because it's an actual, like, production kind of screenshot. And, you know, in finance you don't want to share this kind of information. But, um, yeah, that's what I want to get out.
So here at the top where the arrow is, that's a very simple bit. We just, you know, bump the, the base image that we're using from the Go line. That's something that Dependabot can do, and that's boring. Here at the bottom, we can see that the agent, uh, updated LibCrypto3 and LibSSL3.
So, um, yeah. I also have, like, a short diff, um, that I want to quickly showcase what the agent did. Um, you can see here on the left-hand side that it, that these, um, bottom two, can I just go there?
Here. There we have these two packages here that it actually removed in the process. Because these packages, um, have been pinned previously. And then just removed those, because they have been fixed by the actual base image. So, to be honest, if I were tasked with this kind of task, I probably would have missed that.
So I'm, like, glad that the agent, um, fixed that. And he's a good, good engineer here. So that's it. So we started with a bunch of CVEs. We scanned artifacts, um, remediated, remediated the, the CVEs and the findings.
Blast Radius11:07
And now we have a proper working, um, um, PR that then just needs to be reviewed by a human and approved and merged. So to make that work, um, we gave PatchPilot a couple of things. We gave it GitHub access, um, read and write access to clone the repository, to commit and to push changes, to open a PR, to download the CI logs and trigger CI.
We also gave it OCI registry credentials in order to list images in the, in the registry to figure out, you know, what images are available, which are latest. Um, we gave it tools, like a Go runtime, Python runtime, a bunch of linters, static libs, a bash, a shell, network access, and all of that.
Um, so this is what we gave the whole application. But again, we had, like, two layers. The deterministic part and the agentic part. And we also applied the split for the credentials, also for the two different layers. So here's the thing about the capability list.
The dangerous ones, the GitHub write access, um, and triggering CI is something that we did not give the agent. Instead, we pushed, um, that functionality out to the deterministic part. Because that's the thing that we can reason about and we can rely on.
That, um, you know, it just does these kind of, kind of actions. And we do not give, um, the agent these kinds of credentials. Because that then fundamentally, fundamentally limits the blast radius of when, in case the agent gets, um, its prompt injected, prompt injected.
So that boundary really matters for the prompt injection case. Because you probably didn't see it in the screenshot earlier, but there was, like, 70,000 lines of code that were changed in that small PR. Um, that's really, like, a lot of changes that come in just by bumping a couple of dependencies.
Um, and the attack surface is really, really wide. Um, so what we did to mitigate that, I guess, like, prompt injection itself isn't solved and we cannot really solve it. All we can do is just to limit the blast radius in case that happens.
Um, what we did is to do a little bit of prompt steering, because we know what kind of directories or files contain untrusted, um, untrusted, um, information, untrusted context. We just tell the agent, "Look, the vendor directory, just don't trust that."
Or, "The CI logs, which live in that file or in that subdirectory, you know, be sure that you don't, you know, be an idiot." Um, there's another thing that we did, um, which worked quite well, which is that we, um, we essentially implemented end-to-end tests, where we created a repository and sent PatchPilot, PatchPilot added to just work on it.
Um, I guess that's what people call evals today. And then we just, um, ensure that it isn't, um, prompt injected. So we have, like, a deprecated function in there, in the, in our crafted repository, which tries to recruit the agent to do some malicious stuff.
Or we have a migration guide where a deprecated function, um, uh, points at and all of that. So we tried to, like, you know, remediate these kinds of, um, issues that we know about. But still, there are, um, unknown, um, injection vectors which we aren't aware of yet.
Sandboxing14:11
Um, so that's why, you know, we still have to pray a little bit. But at least we don't, like, build the whole system on, on hope. Now, that's the bit that kept me awake at night. Um,
now, sandboxes look great on a slide. You just draw a box, put the agent in it, and you feel secure. Right? So the problem is that at some point, the agent really wants to, um, verify its own work.
When it works with Docker files, it wants to build a Docker container. It might also want to run a, a Docker container in order to figure out what package versions are available and so on. So naturally, you give it that Docker socket.
At that point, it's more or less game over for you. Um, because the agent can then simply just spawn a privileged container, escape out of it, and then, you know, read environment variables of other processes, read the memory of other processes, can plant a Sage key.
It's game over for you, essentially, at this point.
We ran it like that in production at some point. Um, it didn't feel good. We moved off of that. Um, and we evaluated all the other obvious options in, like, the Linux sphere, Linux bubble, when it comes to, like, sandboxing.
There's a lot of technologies out there, like LandLock, Bubblewrap, STACKOMPUTE, Notify, FENCE, and a lot of options that we have for unprivileged Docker builds. Um, Canico, uh, BuildKit, and, and what else. But they don't really compose well with containers.
And none of them really can contain a Docker socket or a Docker, um, daemon that runs on a host.
So let me share a design that we came up with, which is still, like, in its, in its infancy. Um, it's the same pattern. You just draw a box, but instead of calling it a sandbox, it's just a microVM.
In our case, we're using, um, using a firecracker to have a, like, a proper isolation mechanism. And then we put the agent in, we put the Docker socket in, and then the Docker socket is powered by its own kernel, in this case.
Um, which is good, because that really solves the issue with, with the, um, Docker daemon or the agent trying to escape the sandbox. In this case, everything is just contained within that microVM, which is good. There's another thing that is, um, worth mentioning in this case.
Again, we have this two-tier architecture, these two layers, the agentic bit and the deterministic bit. And we also want to apply network policies to these two worlds separately. For the deterministic bit, we just know what kind of, um, um, network access it requires in order to function properly.
And it needs GitHub access and what else. For the agent, we don't really know in advance. It kind of depends off on the kind of repository or language, um, it works on. Whether it uses Java, it needs, like, a completely different ecosystem it works with, compared to Python or Go.
Um, so that's where we really want to need to apply different network policies. Um, so that's what you can do. You can just set up a DNS and TCP forwarder inside that microVM. But other than that, just, you know, cut it completely off from the host system.
And then everything has to flow through this, um, through this VSOC, which then, um, hands all the network packets to a post-process, which then applies the network policies to, um, to all the outgoing packets. And then you can apply, you know, rules based on host names, based on target ports, cider ranges, whatever you like.
If you really, really want to go wild, you can just, you know, set up a custom CA, plant it into the microVM, and then do all sorts of, like, TLS manual middle control. Which is really hard to do, especially when it comes to the Docker socket.
But, um, we're not going to dive into this one yet.
Tooling Gap17:46
So my take on agent sandboxing is this, that the existing agents that we have today with Codex and Claude, they come with their own sandbox. But in my opinion, it's worthless, especially when you give it, um, a, a Docker socket access.
It's just really, yeah, it's not going to be able to contain that. Other agents, like OpenCode or Py, they just don't have a sandbox, because it's not implemented. Um, or it's just not there by design. So my take is that you really have to create an environment for an agent where you can just put it in and give it everything that it needs.
Um, so it has, like, all the freedom to work on a particular issue that it's supposed to do. Um,
but there's still a gap. So the diagram that I've just shown you isn't something unique. It's just a VM with a little bit of plumbing in there. You can just vibe code it. It's not, not a big deal, honestly.
Um, you can even go downsta, downstairs to the vendor booths and just, you know, talk to the vendors there. You have, like, a lot of sandbox as a service that you can easily consume. Some of which really lack in functionality, especially in that regards to, like, containing a Docker socket or having proper network access controls.
That's still lacking, but it differs from vendor to vendor. I also recently saw the, um, MicroSandbox project, um, which is now around for, I think, like, three or four months or so. Maybe even longer. Um, which really is, would be my choice if I would build PatchPilot today again.
Because it comes with all the batteries included, network access controls, um, all of that. So keep that in mind if you really want to build this. Um, it's an open-source project. It ha, it has a community. It's currently funded by YC.
Um, so we really don't really know how it, how it goes in the next couple of months. We got to see, um, if they're able to gather enough traction to, to keep the open-source project afloat. Let's see. So the gap isn't the tool doesn't exist.
Takeaway19:45
All the tools do exist, but most of them are still in the beta phase. And there's still a big gap to, you know, getting actual enterprise traction and getting all the features, all the bells and whistles that you need in order to deploy it into a proper enterprise environment.
And I think that's something that we need to work on. Sure, now we got a sandbox. Cool. That's nice. But we still need, like, a lot of orchestration on top of it, which is something that you can take from a vendor.
There are also, like, a couple of open-source projects at the moment which are working on this. There's the Kubernetes, um, agent sandbox, uh, special interest group that's working on this. There's, um, OpenSandbox, which is also working on this to integrate these kinds of things.
So, um, keep that in mind if you really want to, you know, contain an agent in a production environment. It's not there yet. It's beta. It's very early in the, in the phase. We got to see how that goes.
Allright. If you take one thing from this, um, the blast radius of an agent is an architecture decision. We didn't, um, give the agent the credential that it needs, um, in order to, you know, trigger CI or push to GitHub or open a PR.
That's just simply not needed. You can just push that functionality into a deterministic layer. Um, that kind of really limits the blast radius of an agent. So that choice, what's deterministic and what's agentic, that really is, you know, your security model in this case.
Allright. Um, that was it for me. I just have, like, one last word, which is just an invitation to the community just to talk about the things that I've just mentioned. Um, I think tomorrow there's a, a dedicated, uh, sandbox panel where a lot of talks are just around the sandbox thingy.
And really, I want to know from you guys how you run agents in production, just to learn and to have a discussion about that, in order to, you know, bring the community on and just, just figure it out, um, all together.
Thank you.





