DevSec Station is a security focused podcast for software developers who want to create amazing applications. Hosted by Tanya Janca, also known as SheHacksPurple, these short lessons will help you level up.
Use Left/Right to seek, Home/End to jump to start or end. Hold shift to jump forward or backward.
0:00
|
18:39
Your AI coding agent can read files, execute commands, modify code, and run tests. But how does it actually do all of that? And what prevents it from doing something dangerous?
Meet the AI agent harness: the software that connects an AI model to its tools, manages its workflow, and turns its decisions into actions.
In this episode of DevSec Station, Tanya Janca (SheHacksPurple) explains how AI agent harnesses work, what security controls they might provide, and why having a harness doesn't automatically make an AI agent secure.
We'll explore:
What an AI agent harness actually is, and how it connects AI models to tools and external systems.
How harnesses manage tool calls, workflows, context, errors, and approvals.
Agent harness vs. sandbox: Why they're not the same thing, and why that distinction matters.
Where agent tools execute, and whose permissions they use.
How file access, shell commands, path traversal, and symbolic links can create security problems.
What happens when the harness itself contains vulnerabilities or compromised dependencies.
How least privilege, isolation, authorization, and properly enforced security boundaries can reduce risk.
And one of my favourite reminders: Not every damn thing needs to be an AI agent! Sometimes a scheduled job, regular software, or a narrowly scoped AI feature is the safer and simpler solution.
The big takeaway: The AI model might be making decisions, but the harness is often the software turning those decisions into actions. That makes it a critical part of your security architecture.
🔧 Your one thing to do this week: Pick one AI agent you're using and investigate one of its tools. Where does it execute? On your computer, inside a container, or on a remote server? Whose permissions does it use? And what actually restricts what that tool can do?
You don't have to audit the entire harness. Just understand one tool and the environment where it runs.
DevSec Station is a podcast by Tanya Janca (SheHacksPurple), focused on short, practical lessons that help software developers build more secure software.
Train with Tanya: Want to bring practical, hands-on secure coding, application security, or AI security training to your team? Learn more at SheHacksPurple.
Imagine you have an AI agent that's supposed to help you write software. You ask it to fix a bug, and it gets to work. It reads some files, changes some code, runs your tests, tell you everything is fixed, great. Except that you never gave the AI model direct access to your computer. So how did it do all of that stuff? How did it open those files? How did it execute commands? And how did it know what happened when the tests ran? Well, that's another piece of software involved. And that software is often called an AI agent harness. Which sounds a little like something you'd put on a horse because unfortunately, AI doesn't come with a saddle. I'm Tanya Jenka, also known as She XPurple, and this is DevSecStation. Today we're going to talk about what an AI agent harness actually is, how it works, and whether it can help keep our AI agents safe. Because if we're going to give AI agents the ability to take actions on our behalf, we should probably understand the software that's making those agents and actions possible, right? First, what exactly is an AI agent harness? Let's start with the basics. When we talk about an AI agent, we're often talking about several different pieces of software working together. There's the AI model, there's the software that manages what the model is doing, and there are the tools and systems that the agent can interact with. The harness is generally that middle piece. Now, different companies and projects use this term a little differently. There's no single universal definition or architecture. But for our purpose, let's think of the harness as the software that manages the agent's workflow and connects the model to the tools it needs to complete a task. The model generates responses, including requests to use tools. The harness receives those requests, invokes the appropriate tools, and returns the results to the model. And then the model decides what it wants to do next. Let's look at an example. Suppose I ask my coding agent to fix a bug in my app. The model decides it needs to inspect a file. Sure. But the model doesn't have little virtual hands that can reach into my computer and open things. Something has to do that for it. The harness might provide a file reading tool. The model requests that tool and the harness executes the request. The file contents come back to the model. Now the model has some information to work with. It decides to change a few lines of code. So it requests a tool that can modify files. The harness executes that request. Then the model decides to run the tests. The harness invokes the test runner and sends the results back. Maybe the tests pass, maybe they fail, maybe the agent has somehow made everything significantly worse. We've all been there. But either way, the model can examine the results and decide what to do next. And this process can repeat over and over and over again. The model requests an action, the harness executes it, the results come back, the model decides it wants to do more stuff until the task is finished or something goes wrong. Or till we run out of money paying for our tokens, whichever comes first. But what's actually inside an AI harness? I want to explain a few things a harness might be responsible for because it's not necessarily one big singular piece of software. It might be several components working together, and different harnesses have different features, but there are a few common responsibilities. First, there's managing tools. The harness might provide tools for reading files, writing files, executing commands, searching the net, or interacting with external services. It makes those capabilities available to the model. And when the model requests one of those tools, the harness helps execute its request. Now, depending on the design, the harness might also decide which tools are available for a particular task. For example, maybe my coding agent has access to a file reading tool and a test runner, but it doesn't have a deployment tool. That is a useful thing to know. Second, there's managing the workflow. Remember, our agent kept requesting tools, receiving results, and deciding what to do next. Something needs to coordinate that process. The harness might handle retries, errors, timeouts, or deciding when the task should stop. For example, maybe the agent tries to run a test and the test runner crashes. What happens next? Does the agent try again? Does it receive an error message? Does the whole task just stop? The harness can help manage those decisions and interactions. Third, there's managing context because the model needs to know what's happened so far. What was the original request? Which files has it already inspected? What changes did it make? What happened when it ran the tests? The harness may maintain the conversation history, tool results, and other information the model needs to continue working. And depending on the design, it might summarize older information or retrieve information from memory, because otherwise the model could lose track of what it was doing, which would be rather inconvenient when it's halfway through modifying your application. And finally, there may be security and approval controls. That's what we want there to be. The harness might restrict which tools the agent can access. It might require approval before certain actions, it might record which tools were used and what happened. And it might launch tools inside a restricted environment. But here's something important. Not every harness provides all of these capabilities, and even when it does, we need to understand how they're implemented, because the harness is now a pretty important part of our security architecture. Let's talk about where the tools actually run. Here's something I think developers should pay particular attention to. When an AI agent requests a tool, where does that tool actually execute? Because there are a lot of possibilities. Maybe it runs directly on your computer, maybe it runs inside a container, maybe it runs on a remote server, or maybe it makes an API request to another system entirely, and all of those differences matter a lot. Let's say my coding agent has a tool that can execute shell commands. Okay, where does that shell run? If it's running directly on my laptop, it might have access to the same files, environment variables, and credentials that I do. If it's running inside a properly restricted container, it would have access to a much smaller environment. If it's running on a remote server, it might have a completely different set of permissions. And if it's calling an API, the permissions might depend on the identity and credentials used for each request. So when we say my AI agent can execute commands, that doesn't actually tell us enough about its security and permissions. We need to know where those commands execute and whose permissions they're using. Now, this brings us to a distinction that I want everyone to understand. An agent harness is not the same thing as a sandbox. A harness manages the agent's interactions and workflows, where a sandbox restricts what software running inside of it can access or affect. And those are not the same thing, those are different responsibilities. Sometimes a harness uses a sandbox, but sometimes it doesn't. And sometimes the harness itself runs outside the sandbox and has access to things the sandbox tools don't. So if someone tells you that their AI agent is secure because it runs inside a harness, I have questions. I have so many questions. What does the harness actually restrict? Where do the tools execute? What can those tools access? And what prevents them from doing something they're not supposed to do? Because putting software inside more software doesn't necessarily make it safe. If it did, my job would be a lot easier, right? But does this even need to be an agent? So that's another question, right? Before we go any further, I want to bring up something we've been talking about this season, and it's that not everything needs to be an agent. Sometimes a regular application, a scheduled job, or a fixed workflow can accomplish the same task perfectly well. Maybe we use AI to classify something or summarize some information. Sure, great, that's awesome. But that doesn't automatically mean the AI needs permission to execute commands, modify files, or decide which tools to call next. And here's why this matters when we're talking about harnesses. We could spend a lot of time building security controls into a harness to restrict all of those capabilities. Or we could design a system that never gives the AI those capabilities in the first place. Now, sometimes an autonomous agent really is the right tool for the job. And when it is, we need to secure it. But before we start figuring out how to contain an agent, we always need to make sure that we actually require one because the easiest unnecessary permission to secure is the one we never give. Okay, now let's look at what happens when a tool is called. I want to get a bit more technical. So let's imagine our agent has a tool for reading files. The model requests a file called application.py. The harness receives that request. What happens next? Does it simply read the file and return the contents? Or does it check whether the file is inside the directory the agent is allowed to access? And if it does check, how does that check work? What if the agent requests a path containing dot dot slash? What if the file is a symbolic link that points somewhere else? What if the agent requests a file that is outside its authorized directories? Does the harness reject the request or does it happily read the file and return the contents anyway? Because these are normal file system security problems. We have been dealing with them for decades, but now the requests might be generated by an AI model rather than a person sitting there typing commands at a keyboard. And that changes how frequently and how predictably that those requests are being made. Let's look at another example. Suppose the agent has a shell execution tool. Maybe it's supposed to run the application's test suite. Great. But what if the model requests a different command? How does the harness decide whether that command is allowed? Maybe it has a list of approved commands, an allow list, or maybe it blocks certain dangerous commands with a block list. Maybe it asks a human for approval. Or maybe it just allows anything. And here's where things can get really tricky. If we're trying to secure arbitrary shell execution by looking for a few dangerous words, we are probably going to have a very bad time of it because there are lots and lots of ways to accomplish the same bad thing with a shell. And attackers have been finding ways around command filters and block lists for a very long time. So if we need strong restrictions, we should use appropriately strong security controls. And by this I mean an allow list. Maybe the tool only supports a small set of predefined operations. Maybe commands execute with limited operation system permissions. Maybe they run in a restricted environment. Maybe network access is controlled completely separately. The exact solution depends on what the agent needs to do. But the important thing is that we're enforcing restrictions in the actual execution environment, not just asking the model to behave itself. Which, yes, I know we've discussed before, but I feel very strongly about this. So I'm going to keep saying it until everyone stops doing it. A prompt is not a security control. Okay. But what happens if the harness itself is vulnerable? Now that's something else that I want you to think about. We've been talking about the harness as the software that manages the agent's actions and potentially helps enforce security controls. But what happens if the harness itself has a vulnerability because it's software and software has bugs, sometimes really big, huge, completely spectacular bugs. Maybe the harness doesn't validate the file path correctly. Maybe there's a way around an approval check. Maybe it accidentally exposes credentials to tools that don't need them. Maybe it executes commands with more permissions than originally intended. Or maybe one of its dependencies gets compromised. Now the thing that's supposed to help control the agent has become part of the attack surface. And depending on what the harness can access, that could be a pretty serious problem. Let's say the harness has access to your source code, your GitHub account, your cloud credentials, and your deployment pipeline. That is a lot of power. If someone compromises that software, they might not even need to trick the AI model. They could potentially abuse the harness and attack it directly. And this is something that I want software developers to understand. And when we are relying on it to enforce restrictions, those enforcement mechanisms become security controls. And we need to treat them that way. When I teach AI security and secure coding at SheHexPurple, I spend a lot of time talking about how the security of an application depends on the security of its components and the systems it trusts. And an agent harness is no different. We need to understand what it can access, what permissions it has, which components it depends on, and what happens if one of those components fail. Because adding a harness doesn't remove our existing security responsibilities. It gives us another component that we need to secure. So can a harness actually keep an AI agent safe? Yes, sort of. A well-designed harness can absolutely help us secure an AI agent. It can control which tools are available. It can coordinate approvals. It can record actions. It can help manage the agent's execution environment. And it can provide a place to implement and enforce certain security policies. Those are all useful and fantastic capabilities. But a harness is not a magical security wrapper. It doesn't automatically isolate the agent. It doesn't automatically prevent access to sensitive data. And it doesn't automatically make every tool safe. We still need authorization in the systems the agent accesses. We still need appropriate isolation when executing code. We still need proper secret management and we still need to secure the harness itself. So I don't want people asking, does my agent have a harness as their only question? I want them asking, what does the harness do? What does it enforce? What does it trust? And what happens if it fails? Because those questions tell us a lot more about whether the agent is secure. Here is your one thing to do this week. I know more homework, right? Okay, so pick one agent that you're using. And this week, I don't want you to look at its prompt. I want you to look at the software underneath it. Find out what happens when your agent uses a tool. Where does that tool execute? On your computer, inside a container, on a remote server, and whose permissions does it use? Yours? A service account? Some other identity? Now pick one tool. Maybe it's the shell, maybe it's file system access, maybe it's a GitHub integration, and figure out what actually restricts the access to that tool. I'm not asking you to audit the entire harness in one day. Just understand one tool and the environment where it executes. Because once you understand how your agent's tools actually work, you can make much better decisions about how to secure them. And that's what I really want you to take away from this episode. The AI model might be the part making decisions, but the harness is often the part turning those decisions into actions. And that makes it a very important part of your security architecture. So understand it. Then lock it down. And don't assume that putting an AI agent inside a harness automatically just makes it safe. Because unfortunately, it doesn't come with a magical force field or a saddle or anything like that. Which seems like a bit of a lost opportunity, if you ask me. I'm Tanya Jenka, also known as She X Purple, and this is Dev Sex Station. Thank you for listening, and I'll see you in the next episode.