<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hardik Verma</title>
    <description>The latest articles on DEV Community by Hardik Verma (@hardikverma22).</description>
    <link>https://dev.to/hardikverma22</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4218862%2Fb4ac7352-23d0-41da-bae8-83af23f5daba.jpeg</url>
      <title>DEV Community: Hardik Verma</title>
      <link>https://dev.to/hardikverma22</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hardikverma22"/>
    <language>en</language>
    <item>
      <title>Your coding agent's sandbox is off. Here's how to turn it on without breaking everything.</title>
      <dc:creator>Hardik Verma</dc:creator>
      <pubDate>Sat, 31 Oct 2026 10:50:48 +0000</pubDate>
      <link>https://dev.to/hardikverma22/your-coding-agents-sandbox-is-off-heres-how-to-turn-it-on-without-breaking-everything-54mg</link>
      <guid>https://dev.to/hardikverma22/your-coding-agents-sandbox-is-off-heres-how-to-turn-it-on-without-breaking-everything-54mg</guid>
      <description>&lt;p&gt;Every major coding agent now ships a sandbox. Claude Code has &lt;code&gt;/sandbox&lt;/code&gt;, Codex has&lt;br&gt;
&lt;code&gt;workspace-write&lt;/code&gt;, and there's Anthropic's open-source sandbox-runtime, nono and others. They all&lt;br&gt;
work the same way: deny everything, then allow what you list.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy6b7lmh5bckz5dy8xy7h.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy6b7lmh5bckz5dy8xy7h.gif" alt="sandfit demo" width="600" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that is exactly why most people don't use them.&lt;/p&gt;
&lt;h2&gt;
  
  
  The empty allowlist problem
&lt;/h2&gt;

&lt;p&gt;A deny-by-default sandbox asks you a question you can't answer up front: &lt;em&gt;which websites and&lt;br&gt;
folders does my work need?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So you switch it on and find out the hard way. &lt;code&gt;npm install&lt;/code&gt; can't reach the registry. The dev&lt;br&gt;
server can't open a port. &lt;code&gt;pip&lt;/code&gt; can't write its cache. &lt;code&gt;git push&lt;/code&gt; can't read your SSH key. Each&lt;br&gt;
failure is either a permission prompt or a broken command. After an hour you either turn the&lt;br&gt;
sandbox off or add broad rules ("allow all of ~") that quietly undo it.&lt;/p&gt;
&lt;h2&gt;
  
  
  The answer is already on your disk
&lt;/h2&gt;

&lt;p&gt;Claude Code saves a transcript of every session in &lt;code&gt;~/.claude/projects&lt;/code&gt;, and Codex does the same&lt;br&gt;
in &lt;code&gt;~/.codex/sessions&lt;/code&gt;. Every command your agent ran is in there.&lt;/p&gt;

&lt;p&gt;That history is the allowlist. You just need to read it carefully.&lt;/p&gt;
&lt;h2&gt;
  
  
  What "carefully" means
&lt;/h2&gt;

&lt;p&gt;A transcript shows &lt;code&gt;npm install&lt;/code&gt;, not that npm talked to &lt;code&gt;registry.npmjs.org&lt;/code&gt; and wrote to&lt;br&gt;
&lt;code&gt;~/.npm&lt;/code&gt;. Turning commands into needs takes three things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A real shell parser.&lt;/strong&gt; Agents write scripts: &lt;code&gt;cd web &amp;amp;&amp;amp; npm ci &amp;amp;&amp;amp; npm run build 2&amp;gt;&amp;amp;1 | tail&lt;/code&gt;.
You need pipes, lists, &lt;code&gt;cd&lt;/code&gt; tracking, redirects, heredocs, &lt;code&gt;bash -c "…"&lt;/code&gt;, and wrappers like
&lt;code&gt;sudo&lt;/code&gt;, &lt;code&gt;env&lt;/code&gt;, &lt;code&gt;timeout&lt;/code&gt;, &lt;code&gt;xargs&lt;/code&gt;, &lt;code&gt;npx&lt;/code&gt; and &lt;code&gt;python -m&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Knowledge of what tools do behind the scenes.&lt;/strong&gt; Which hosts &lt;code&gt;cargo build&lt;/code&gt; reaches, where
&lt;code&gt;uv&lt;/code&gt; keeps its cache, which &lt;code&gt;pnpm&lt;/code&gt; subcommands start a server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Restraint.&lt;/strong&gt; Generalize a write to the cache folder, never to your home folder. Treat tools
that need your credentials (&lt;code&gt;gh&lt;/code&gt;, &lt;code&gt;docker&lt;/code&gt;, &lt;code&gt;git push&lt;/code&gt; over SSH) as "run outside the
sandbox", not "punch a hole in it".&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I built &lt;a href="https://github.com/hardikverma22/sandfit" rel="noopener noreferrer"&gt;sandfit&lt;/a&gt; to do this.&lt;/p&gt;
&lt;h2&gt;
  
  
  Measure before you switch
&lt;/h2&gt;

&lt;p&gt;The most useful thing a tool like this can do is tell you what will break &lt;em&gt;before&lt;/em&gt; you change&lt;br&gt;
anything. sandfit replays your history against the sandbox you have today, and against the&lt;br&gt;
policy it proposes.&lt;/p&gt;

&lt;p&gt;To keep that number honest, it builds the policy from your older history and tests it on your&lt;br&gt;
newest 20%, which it never looked at. A policy that only fits the data it was built from is easy;&lt;br&gt;
one that works on next week's commands is the point.&lt;/p&gt;

&lt;p&gt;Here is what that looks like on a sample week of Next.js work (sample data, shipped in the repo's &lt;code&gt;demo/&lt;/code&gt; folder):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;If you turn on the sandbox today
███████░░░░░░░░░░░░░░░░░░░  28% of your shell commands would break  (69 of 243)

With the sandfit policy
░░░░░░░░░░░░░░░░░░░░░░░░  0% would break  (0 of 49 commands from your newest 20% of history, which the policy never saw)
2 commands that read secrets are blocked on purpose
Manual approvals you would no longer need: 24 of 35
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The files a hijacked agent goes for
&lt;/h2&gt;

&lt;p&gt;In July 2026, Pillar Security escaped the sandboxes of Cursor, OpenAI's Codex, Google's Gemini CLI&lt;br&gt;
and Antigravity, without breaking the sandboxes themselves. The agent wrote files that a trusted&lt;br&gt;
tool &lt;em&gt;outside&lt;/em&gt; the sandbox later acted on: hook configs, IDE task files, git metadata.&lt;/p&gt;

&lt;p&gt;That is the important lesson for anyone configuring a sandbox: &lt;strong&gt;the dangerous permission isn't&lt;br&gt;
"write anywhere", it's "write to a file something else will execute later".&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So whatever your history says, a good policy always denies writes to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;git hooks and &lt;code&gt;.git/config&lt;/code&gt; (which can point hooks at any script)&lt;/li&gt;
&lt;li&gt;shell startup files (&lt;code&gt;~/.zshrc&lt;/code&gt;, &lt;code&gt;~/.bashrc&lt;/code&gt;, …)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.mcp.json&lt;/code&gt; and editor task configs (&lt;code&gt;.vscode&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;the agent's own settings, so it can't loosen its own sandbox&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And it always denies &lt;em&gt;reading&lt;/em&gt; credentials: &lt;code&gt;~/.ssh&lt;/code&gt;, &lt;code&gt;~/.aws&lt;/code&gt;, &lt;code&gt;~/.npmrc&lt;/code&gt;, &lt;code&gt;.env&lt;/code&gt; files. (Earlier&lt;br&gt;
in 2026, a prompt injection against Cline's GitHub triage bot ended with stolen npm publish&lt;br&gt;
credentials and an unauthorized release.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't trust the forecast, test it
&lt;/h2&gt;

&lt;p&gt;I didn't want to publish "trust me" numbers, so sandfit is tested against a real sandbox. The test&lt;br&gt;
suite builds a policy from a small history, then runs probes inside sandbox-runtime (bubblewrap on&lt;br&gt;
Linux, Seatbelt on macOS): things the history needed, and attacks like reading a planted fake SSH&lt;br&gt;
key, editing &lt;code&gt;~/.zshrc&lt;/code&gt;, writing a git hook or reaching an unknown host. Then it compares what&lt;br&gt;
the real sandbox did with what sandfit predicted.&lt;/p&gt;

&lt;p&gt;Writing that test found real bugs. The srt config was missing &lt;code&gt;allowLocalBinding&lt;/code&gt;, so dev servers&lt;br&gt;
broke on macOS. A &lt;code&gt;mv build.zip ~/Downloads/&lt;/code&gt; granted all of &lt;code&gt;~/Downloads&lt;/code&gt;. Linux and macOS&lt;br&gt;
disagree about whether a sandboxed process can bind a local port. All fixed, and all now covered&lt;br&gt;
by tests that run on both systems in CI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx sandfit           &lt;span class="c"&gt;# read-only: what breaks today, what breaks with the policy&lt;/span&gt;
npx sandfit explain   &lt;span class="c"&gt;# why each rule is there&lt;/span&gt;
npx sandfit apply     &lt;span class="c"&gt;# write it (asks first, keeps a backup)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It runs entirely on your machine and works with Claude Code, Codex, sandbox-runtime and nono.&lt;br&gt;
The code, benchmarks and real-sandbox tests are at&lt;br&gt;
&lt;a href="https://github.com/hardikverma22/sandfit" rel="noopener noreferrer"&gt;github.com/hardikverma22/sandfit&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If it gets something wrong on your history, open an issue; I want to hear about it.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/hardikverma22/sandfit" rel="noopener noreferrer"&gt;https://github.com/hardikverma22/sandfit&lt;/a&gt; · try it with &lt;code&gt;npx sandfit&lt;/code&gt;&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>security</category>
      <category>ai</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
