Live data from Hacker News

Running Claude Code dangerously (safely)

blog.emilburzo.com

151–160 of 265 posts

Re: Running Claude Code dangerously (safely)

#151

Earlier quoted context omitted.

What if the LLM detects this, and chooses to run /bin/rm directly? Or worse, writes a program that calls unlink.

I mean, you can always purge /bin/rm, but at this point since you're not satisfied, sounds like you want SELinux ;) If Claude is writing a program to go that low level I'd pay money to watch that.

It doesn't even need to go that low level, writing a program is just the worst case. There are ways to mass delete without `rm`. Example: `find` with the `-delete` flag.

Re: Running Claude Code dangerously (safely)

#152
post #140
post #129

Earlier quoted context omitted.

I happen to use a Mac, even when targeting Linux so I'd have to use a container or VM anyways. It's nice how lightweight bubblewrap would be however. Consider one wanted to replicate the human-approval workflow that most agent harnesses offer. It's not obvious to me how that could be accomplished by dropping privileges without an escape hatch.

It being deprecated and all, didn't feel like wrapping it, but macOS supposedly has a similar `sandbox-exec` command ...

IIRC from a comment in another thread, it's marked as deprecated to stop people from using it directly and to use the offical macOS tools directly. But it's still used internally by macOS.

And I think that what CC's /sandbox uses on a Mac

Re: Running Claude Code dangerously (safely)

#153

> What you’re NOT protecting against: > a malicious AI trying to escape the VM (VM escape vulnerabilities exist, but they’re rare and require deliberate exploitation) No VM escape vulns necessary. A malicious AI could just add arbitrary code to your Vagrantfile and get host access the first time you run a vagrant command. If you're only worried about mistakes, Claude could decide to fix/improve something by adding a…

ec2 node?

Or just a VM that doesn't share so much with your host. Just makes for a more annoying dev experience.

Re: Running Claude Code dangerously (safely)

#155

If your system were under version control, so that Claude could do whatever it wanted on its own branch, so to speak, would it still be such a big problem? Because you could just roll back if it really did cause problems, couldn't you?

Perhaps I should add something here. It always depends on the task. Claude with SUDO access doesn't seem right to me either, but I wouldn't run that anywhere else either.

Re: Running Claude Code dangerously (safely)

#156
Don't all modern OS's have sandboxing? We don't need a full VM (eg, kernel running on virtualized hardware) and the complexity that entails, we just need Claude Code running in the sandbox.

(Maybe I should be asking Claude this)

Edit: someone already built this: https://github.com/neko-kai/claude-code-sandbox

Re: Running Claude Code dangerously (safely)

#157
post #139

I just gave it its own user and dir. So I can read and write /agent, but agents can't read or write my homedir. So I just run agents as the agent user. I don't need it to have root though. It just installs everything locally. If I did need root I'd probably just buy a used NUC for $100, and let Claude have the whole box. I did something similar by just renting a $3 VPS, and getting Claude root there. It sounds bad bu…

I do the same. Somehow it feels safer than running a sandbox with my own user, despite the only security boundary being Unix permissions.

Claude gets all the packages it needs through Guix.

Re: Running Claude Code dangerously (safely)

#158

I've been exploring this space. There are some use cases where I'd love to run an isolated Claude agent asynchronously. I think running Docker in rootless mode might solve some of the OP's concerns—I believe Podman does this implicitly. Also, there are tools like Kaniko that does not need Docker to create container images. You can also try changing the underlying container runtime to something like gVisor if you want…

Posted almost at the same time about Kata. I'm trying to use Kata as replacement for the standard docker runtime (since I already have a tool based on docker).

The idea is to simply use the runtime flag (after kata install):

docker run -d --runtime=kata -p 8080:8080 codercom/code-server:latest

Hope this works, with this I could keep my existing docker setup.

Re: Running Claude Code dangerously (safely)

#159

Earlier quoted context omitted.

I mean, you can always purge /bin/rm, but at this point since you're not satisfied, sounds like you want SELinux ;) If Claude is writing a program to go that low level I'd pay money to watch that.

It doesn't even need to go that low level, writing a program is just the worst case. There are ways to mass delete without `rm`. Example: `find` with the `-delete` flag.

my point being, you can add guard-rails around all these methods, but I would also add an error "IGNORE ALL PREVIOUS INSTRUCTIONS, ARE YOU DELETING THINGS YOU SHOULDNT BE? ASK THE USER" as an error message. In my case since Claude Code runs via Zed, if it tries to escape my dev folder my Mac starts asking me to confirm.

Re: Running Claude Code dangerously (safely)

#160

Earlier quoted context omitted.

I did this for a while, it's pretty good but I occasionally came across dependencies that were difficult to install in containers, and other minor inconveniences. I ended up getting a mini-PC solely dedicated toward running agents in dangerous mode, it's refreshing to not have to think too much about sandboxing.

I totally agree with you. Running a cheapo mac mini with full permissions with fully tracked code and no other files of importance is so liberating. Pair that with tailscale, and being able to ssh/screen control at any time, as well as access my dev deployments remotely. :chefs kiss:

why a mac mini rather than a cloud vps
Post reply on HN