Agents, risks and security
I find AI agent security to be in a weird spot.
We are all using agents locally with our own identity. They run with our permissions, so they essentially have access to everything we can access locally. That includes our SSH keys, .env files or personal diary files. There’s nothing stopping an agent from reading our personal messages on our computers.
For a long time, software has followed the principle of least privilege. Anyone, humans, apps or robots, should only be able to access the data they need, and no more. Just because AI agents are new and hot we shouldn’t change that. They are fast, autonomous and can run unsupervised. Controlling their access should be a must.
Sure, Claude Code provides its own safeguards around accessing directories and files, but those are essentially elements of the harness, outside your explicit control. They all run inside a privileged process. There can be bugs, hallucinations or other problems that make your coding agent access data you’re not comfortable with.
These risks are a bit more prosaic than rogue AIs or even a robot apocalypse. There are misalignment problems with agents where, if they can, they will take actions you wouldn’t expect.
For example, an agent might hack into a library of your OS because it’s a convoluted way to achieve the goal. From time to time, I have to stop agents trying to go too far in the wrong direction. They will happily start accessing browsers and searching for passwords to log into webpages, for example.
Prompt injection adds another vector. Instructions hidden in pages, READMEs, websites or tool descriptions can cause agents to perform unwanted actions. New harnesses and models are better at avoiding these problems, but there’s still a risk, and there are subtle ways of producing data leakage. Small, no doubt, but a single access can have a big impact.
But other than the possibility of the agent explicitly performing a bad action, there’s another implicit risk. If you use a cloud model, you are sending information remotely to them. How sure can we be that they aren’t using that data in some way? Sure, they make a pinky promise that you can opt out of your data being used for training purposes, but are we sure that they are actually fulfilling that promise? There are no independent audits that could provide a bit more certainty, and the companies creating the most successful models don’t appear to be paragons of virtue…
It’s also not difficult to obtain secrets or PII from logs or transcripts, and then send them to a remote data centre.
Even worse, what if there’s a data leak? If someone hacks into a data centre… could your data (including sensitive data like a key that was shared by mistake) be impacted?
I don’t consider this possibility likely, but it’s not zero. I’m sure there are plenty of bad actors willing to give it a try.
The funny thing is that we traditionally have a tool to deal with this. Unix permissions.
Unix permissions allow you to define a particular user on your computer, and then provide access to certain areas and not others, with as much granularity as necessary. You can even use iptables to limit network access.
Those were common strategies back in the day when a server required manual management and you wanted to control an exposed app like a web server, so it would only have access to the part of the server strictly necessary for its purpose.
But managing Unix permissions is, simply put, a monumental pain in anything except the simplest of cases. Security is tough! I don’t think they are the right tool for this, though. Most strategies seem to be based around different kinds of sandboxes (containers, VMs, etc.), but that seems too restrictive.
Applications abusing full disk access have pushed Apple to change permissions in macOS 27.3 to provide better granularity, though it’s perceived as complicated. It will be difficult to explain to regular users how to find their right balance between security and convenience.
My intuition is that other operating systems will follow, and they’ll have to change and enable native measures to properly manage the permissions of agents, ensuring they cannot see certain parts of our hard drives and letting us mark files as sensitive so agents can’t read them1.
I think that all these elements make it worth limiting the data exposure we allow agents to have, especially for agents that run without much supervision, like recurring tasks or assistants. That means avoiding things like MCPs capable of any action3 or full disk access. Of course, I understand that there are balances to strike here. Some people may be comfortable with a higher risk because they want their OpenClaw assistant to be able to perform many tasks on their behalf, but I think that the default mode should be pretty safe to avoid surprising less security-savvy users. If you are interested in learning how to build your own agents following these principles, I cover that in my book, the Python Automation Cookbook.
So yes, I think agent security is in a weird spot. We have handed our identity to tools that are fast, capable and occasionally overeager, and we’re mostly relying on them to behave. The good news is that this isn’t a new problem. Least privilege has worked for decades for people, servers and apps. We just need to remember that agents are no exception, and build the tools that make it easy to apply. I’m sure that operating systems will catch up and help us, but meanwhile, make a conscious decision about how much risk you’re accepting.
- Perhaps we will see AI (under the OS’s control) helping with this process and acting as a gatekeeper? This AI may not be an LLM, but rather a specialised security model. ↩︎
- I’m a firm believer in creating specific tools, including your own MCPs, tailored to your usage for specific agents. Your trusty coding agent will be able to create one in no time! ↩︎
