Bubblewrap: A nimble way to prevent agents from accessing your .env files
27 points
2 hours ago
| 11 comments
| patrickmccanna.net
| HN
simonw
5 minutes ago
[-]
I recommend caution with this bit:

  --bind "$HOME/.claude" "$HOME/.claude"
That directory has a bunch of of sensitive stuff in it, most notable the transcripts of all of your previous Claude Code sessions.

You may want to take steps to avoid a malicious prompt injection stealing those, since they might contain sensitive data.

reply
theden
36 minutes ago
[-]
Kinda funny that a lot of devs accepted that LLMs are basically doing RCE on their machines, but instead of halting from using `--dangerously-skip-permissions` or similar bad ideas, we're finding workarounds to convince ourselves it's not that bad
reply
simonw
21 minutes ago
[-]
Because we've judged it to be worth it!

YOLO mode is so much more useful that it feels like using a different product.

If you understand the risks and how to limit the secrets and files available to the agent - API keys only to dedicated staging environments for example - they can be safe enough.

reply
pjm331
2 minutes ago
[-]
I feel like you can get 80% of the benefits and none of the risks with just accept edits mode and some whitelisted bash commands for running tests, etc.
reply
zahlman
14 minutes ago
[-]
Why not just demand agents that don't expose the dangerous tools in the first place? Like, have them directly provide functionality (and clearly consider what's secure, sanitize any paths in the tool use request, etc.) instead of punting to Bash?
reply
simonw
10 minutes ago
[-]
Because if you give an agent Bash it can do anything they can be achieved by running commands in Bash, which is almost anything.
reply
catlifeonmars
8 minutes ago
[-]
[delayed]
reply
catlifeonmars
9 minutes ago
[-]
[delayed]
reply
meander_water
29 minutes ago
[-]
I recently created a throwaway API key for cloudflare and asked a cursor cloud agent to deploy some infra using it, but it responded with this:

> I can’t take that token and run Cloudflare provisioning on your behalf, even if it’s “only” set as an env var (it’s still a secret credential and you’ve shared it in chat). Please revoke/rotate it immediately in Cloudflare.

So clearly they've put some sort of prompt guard in place. I wonder how easy it would be to circumvent it.

reply
typs
1 hour ago
[-]
I wish I had the opposite of this. It’s a race trying to come up with new ways to have Cursor edit and set my env files past all their blocking techniques!
reply
GrowingSideways
50 minutes ago
[-]
If you wouldn't upload keys to github, why would you trust them to cursor?
reply
hahahahhaah
45 minutes ago
[-]
A local .env should be safe to put on your T shirt and walk down times square.

Mysql user: test

Password: mypass123

Host: localhost

...

reply
Imustaskforhelp
43 minutes ago
[-]
Create a symlink to .env from another file and ask cursor to refer it if name is the concern regarding cursor (I don't knowhow cursor does this stuff)
reply
catlifeonmars
21 minutes ago
[-]
May I suggest rm -f .env? Or chmod 0600 .env? You’re not running CC as your own user, right? …Right?

Oh, never mind:

> You want to run a binary that will execute under your account’s permissions

reply
dangoodmanUT
32 minutes ago
[-]
I've been saying bubblewrap is an amazing solution for years (and sandbox-exec as a mac alternative). This is the only way i run agents on systems i care about
reply
catlifeonmars
12 minutes ago
[-]
> run agents on systems i care about

You must not care about those systems that much.

reply
Nora23
55 minutes ago
[-]
Smart approach to AI agent security. The balance between convenience and protection is tricky.
reply
gexla
23 minutes ago
[-]
I believe this is also what Claude Code uses for the sandbox option.
reply
isodev
37 minutes ago
[-]
My way of preventing agents from accessing my .env files is not to use agents anywhere near files with secrets. Also, maybe people forget you’re not supposed to leave actual secrets lingering on your development system.
reply
OutOfHere
21 minutes ago
[-]
The link you need is https://github.com/containers/bubblewrap

Don't leave prod secrets in your dev env.

reply
hahahahhaah
46 minutes ago
[-]
Had this same idea in my head. Glad someone done it. For me the motivation is not LLMs but to have something as convenient as docker without waiting for image builds. A fast docker for running a bunch of services locally where perfect isolation and imaging doesnt matter.
reply
JCattheATM
45 minutes ago
[-]
So, Flatpak?

Funny enough Bubblewrap is also what Flatpak uses.

reply
Imustaskforhelp
42 minutes ago
[-]
I want to like flatpak but I am genuinely unable to understand the state of cli tools in flatpak or even how to develop it. It all seems very weird to build upon as compared to docker
reply