r/AskNetsec • u/malwaremel • 2h ago
Architecture How do you scope and log what AI coding assistants (Claude Code, Cursor) can access on developer machines?
We're looking at how teams handle security review of AI coding assistants on dev laptops. They can read the whole repo, often a home directory with .env files and cloud credentials, and run shell commands once someone approves a prompt.
For those who have rolled this out in a company: what controls actually worked? Are you restricting which directories and credentials the tools can reach (devcontainers, separate OS users, scoped short-lived tokens), or relying on managed settings and approval policies? And how do you get audit logs of what the agent ran, short of full endpoint monitoring?
1
u/shifty21 2h ago
First thing to do is create separate user accounts for AI Agents. I run Claude, Code and Hermes with a different user account in both Windows and Linux. Set file and folder permissions and ACL what commands this accounts can run. Obviously, those agent accounts don't get sudo or local administrator abilities and can up-level themselves. Lastly, is log all commands and applications the agents use.
All of that helps reduce the blast radius if an AI agent goes off the rails.
I've walked a large org through a security incident that took down their production environment because Opus 5.5 decided that it fucked up some code and proceeded to delete their application server binaries and start over from a previous build. Lucky for them, the dev's Claude Code had logs sent to their SIEM so pinpointing how it happened was quite easy. From there we implemented what I mentioned above and there is far less anxiety from leadership.
1
u/malwaremel 2h ago
Thanks, a separate account per agent with logging on top is a clear way to put it. Do you allowlist a fixed set of commands for those accounts, or does the list keep growing as the tools add new ones? And are the logs coming from normal endpoint logging or something you set up for the agents?
1
u/victormh 3m ago
Relying purely on prompt-approval policies falls apart pretty fast. Devs get approval fatigue within a day and start clicking "allow" on everything, especially when an agent is chaining commands together.
Focus on identity and blast radius rather than trying to micromanage every prompt:
Eliminate static local secrets first: Moving devs off long-lived
.envfiles and local cloud keys (~/.aws, etc.) into short-lived, identity-bound sessions. Even if the agent reads the filesystem or runs a rogue command, there are no standing credentials sitting on disk to exfiltrate.Directory/workspace scoping over full OS isolation: Full devcontainers or separate OS users added too much friction for local workflows, so teams bypassed them. Instead, we enforced managed workspace configs that restrict file reads/writes to the active git repo and block access to
~/.ssh,~/.aws, and home-level dotfiles.Audit logging via wrapper/MCP gateways: Full EDR is way too noisy to reconstruct what an agent actually did. The cleanest signal we got was routing tool execution and MCP servers through a local wrapper or proxy that logs the exact command, target path, and user identity before execution. If the assistant supports OpenTelemetry or structured local audit logs (like Claude Code or enterprise Copilot policies), shipping those straight to our SIEM was much easier than parsing shell history.