<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title>dtg</title><id>https://example.com/feeds/tags/security.xml</id><subtitle>Tag: security</subtitle><updated>2026-11-16T12:35:46Z</updated><link href="https://example.com/feeds/tags/security.xml" rel="self" /><link href="https://example.com" /><entry><title>Sandboxed AI Agents using Agent Circus</title><id>https://example.com/sandboxed-ai-agents-using-agent-circus.html</id><author><name>Dylan Gleason</name></author><updated>2026-11-11T11:00:00Z</updated><link href="https://example.com/sandboxed-ai-agents-using-agent-circus.html" rel="alternate" /><content type="html">&lt;p&gt;Lately I have been using AI coding agents more frequently, and after
reading about notable incidents of &amp;quot;rogue&amp;quot; agents doing bad things, it
became increasingly apparent that I should take steps to improve my
security hygiene when using AI agents.&lt;/p&gt;
&lt;h2&gt;Running AI Agents Locally&lt;/h2&gt;
&lt;p&gt;The security implications of running non-deterministic LLM systems
locally, which have access to my file system and the ability to
communicate to the internet, should have been an obvious red flag from
the start. But it is all too easy (and I include myself in this) to be
lulled into complacency based on thin assurances from AI vendors,
despite their inherent untrustworthiness.&lt;/p&gt;
&lt;p&gt;I won't go through the points here—my friend Ian did a much better
job &lt;a href=&quot;https://blog.ianwwagner.com/stop-playing-russian-roulette-with-coding-agents.html&quot;&gt;writing about the problem&lt;/a&gt;
than I ever could—but suffice it to say, I can do better. While Ian
took the approach of sandboxing his agents in a fully remote
development environment using FreeBSD jails (which, I gotta say, is
just really neat), I don't have the resources and hardware to do that
right now. Someday, perhaps, but for now I am stuck with a local
development environment.&lt;/p&gt;
&lt;h2&gt;Containerizing Agent Harnesses&lt;/h2&gt;
&lt;p&gt;Since I am using macOS and not FreeBSD, I decided to investigate
running agents using containers. Docker is the most obvious solution
for hosting containers, but I have been curious about using
&lt;a href=&quot;https://podman.io/&quot;&gt;Podman&lt;/a&gt; because its containerization engine is
rootless and per-user by default, whereas Docker requires additional
configuration to run without root access.&lt;/p&gt;
&lt;p&gt;While Docker for Mac uses a thin Linux virtualization layer to host
containers, and therefore the attack surface isn't as large as it
would be when running a rootful Docker daemon on Linux, it still runs
as a daemon with root privileges on the VM and can access privileged
resources on the host. Docker Sandboxes greatly improve upon this with
its daemon-per-sandbox isolation model, but each daemon still has root
privileges that could potentially exploit things like, oh, a path
resolution bug in VirtioFS that allows arbitrary &lt;a href=&quot;https://www.cve.org/CVERecord?id=CVE-2026-77179&quot;&gt;code execution&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Admittedly, Podman on macOS isn't immune from the above vulnerability
(it also uses VirtioFS), but its rootless user model provides a
secondary line of defense. At any rate, I think I kinda sold myself on
trying Podman well before this point anyway since I hadn't really used
it much before and I didn't feel like installing Docker for Mac 😝.&lt;/p&gt;
&lt;p&gt;In order to simplify configuring and running the sandbox for my agent
harness, I evaluated a couple of existing solutions. Since I am using Emacs
Agent Shell (see my earlier &lt;a href=&quot;emacs-as-an-agentic-coding-environment.html&quot;&gt;post&lt;/a&gt;
describing how I set that up), I settled on &lt;a href=&quot;https://github.com/Embedded-Focus/agent-circus&quot;&gt;Agent Circus&lt;/a&gt;,
which integrates with the former using Agent Context Protocol.&lt;/p&gt;
&lt;h2&gt;Testing Agent Circus&lt;/h2&gt;
&lt;p&gt;Before tackling the Emacs side, I wanted to give it a spin just using
the command line, which shouldn't be too hard. First I need to install
it, and since it is a Python application I will do so using &lt;code&gt;uv&lt;/code&gt;, per
the &lt;code&gt;README&lt;/code&gt; instructions:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uv tool install agent-circus
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, time to test it out in a project. I build the Agent Circus image
in a test project, specifying Podman as the runtime environment:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;agent-circus build --runtime podman
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With that, I can run the Claude CLI using the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;agent-circus exec --runtime podman claude-code -- claude
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Configuring Agent Circus&lt;/h2&gt;
&lt;p&gt;Agent Circus will seed its configuration from vendor directories like
&lt;code&gt;~/.claude&lt;/code&gt;, &lt;code&gt;~/.codex&lt;/code&gt;, and &lt;code&gt;~/.opencode&lt;/code&gt;, including any auth
credentials contained therein. Agent Circus then copies each to a
per-project directory in &lt;code&gt;~/.local/state/agent-circus&lt;/code&gt;, which in turn
gets mounted to the sandbox container for the given project.&lt;/p&gt;
&lt;h3&gt;Global config file&lt;/h3&gt;
&lt;p&gt;Beyond the default configuration, there are some additional bits I
need to configure via a TOML file. Agent Circus reads the global
config file at &lt;code&gt;${XDG_CONFIG_DIR:-$HOME/.config}/agent-circus/config.toml&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-toml&quot;&gt;env_passthrough = [&amp;quot;CHUTES_API_KEY&amp;quot;, &amp;quot;CLAUDE_CODE_OAUTH_TOKEN&amp;quot;]

[runtime]
engine = &amp;quot;podman&amp;quot;

[logging]
level = &amp;quot;DEBUG&amp;quot;
file = &amp;quot;/tmp/agent-circus.log&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since Claude Code on macOS stores auth credentials via Keychain for
interactive sessions, it is simpler to generate an auth token and
export it to the host environment via &lt;code&gt;CLAUDE_CODE_OAUTH_TOKEN&lt;/code&gt;, which
can then be forwarded to the container via the &lt;code&gt;env_passthrough&lt;/code&gt;
setting. As of this writing, I am also evaluating Chutes AI using an
OpenCode agent, so I do the same for my &lt;code&gt;CHUTES_API_KEY&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Also, given that Docker is the default runtime environment, I want to
set the runtime environment to Podman, so I do not have to specify the
podman option every time I need to run the &lt;code&gt;agent-circus&lt;/code&gt; command.&lt;/p&gt;
&lt;p&gt;Wrapping up the global config, I also specify a temporary log file
with &lt;code&gt;DEBUG&lt;/code&gt; level logging so I can troubleshoot any issues running
the Agent Circus container.&lt;/p&gt;
&lt;h3&gt;Project specific config&lt;/h3&gt;
&lt;p&gt;Additionally, if a project I am working on contains a secrets file
like &lt;code&gt;.env&lt;/code&gt;, I want to elide its contents from the container. I can
add it to a &lt;code&gt;shadow&lt;/code&gt; list via a config file, relative to the project,
and Agent Circus will create a bind mount to &lt;code&gt;/dev/null&lt;/code&gt; on the
container. For example, I add the following to &lt;code&gt;.agent-shell/config.toml&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-toml&quot;&gt;shadow = [&amp;quot;.env&amp;quot;, &amp;quot;.env.local&amp;quot;]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This way, if app secrets are managed differently for another project,
I can add different files to the &lt;code&gt;shadow&lt;/code&gt; list. Neat!&lt;/p&gt;
&lt;h2&gt;Configuring OpenCode&lt;/h2&gt;
&lt;p&gt;Before moving onto Emacs, since I also use OpenCode to interact with
both Chutes AI and my local Ollama server, I need to make some to the
OpenCode configuration in &lt;code&gt;~/.config/opencode/opencode.json&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;{
  &amp;quot;$schema&amp;quot;: &amp;quot;https://opencode.ai/config.json&amp;quot;,
  &amp;quot;permission&amp;quot;: {
    &amp;quot;edit&amp;quot;: &amp;quot;ask&amp;quot;,
    &amp;quot;bash&amp;quot;: &amp;quot;ask&amp;quot;,
    &amp;quot;webfetch&amp;quot;: &amp;quot;allow&amp;quot;
  },
  &amp;quot;provider&amp;quot;: {
    &amp;quot;ollama&amp;quot;: {
      &amp;quot;npm&amp;quot;: &amp;quot;@ai-sdk/openai-compatible&amp;quot;,
      &amp;quot;name&amp;quot;: &amp;quot;Ollama (Local)&amp;quot;,
      &amp;quot;options&amp;quot;: {
        &amp;quot;baseURL&amp;quot;: &amp;quot;http://host.containers.internal:11434/v1&amp;quot;
      },
      &amp;quot;models&amp;quot;: {
        &amp;quot;devstral-small-2:24b&amp;quot;: {
          &amp;quot;name&amp;quot;: &amp;quot;Devstral Small 2 24B&amp;quot;
        },
        &amp;quot;gemma4:26b&amp;quot;: {
          &amp;quot;name&amp;quot;: &amp;quot;Gemma 4 26B&amp;quot;
        },
        &amp;quot;qwen3.5:9b&amp;quot;: {
          &amp;quot;name&amp;quot;: &amp;quot;Qwen 3.5 9B&amp;quot;
        }
      }
    },
    &amp;quot;chutes&amp;quot;: {
      &amp;quot;name&amp;quot;: &amp;quot;Chutes&amp;quot;,
      &amp;quot;npm&amp;quot;: &amp;quot;@ai-sdk/openai-compatible&amp;quot;,
      &amp;quot;options&amp;quot;: {
        &amp;quot;baseURL&amp;quot;: &amp;quot;https://llm.chutes.ai/v1&amp;quot;
      },
      &amp;quot;settings&amp;quot;: {
        &amp;quot;apiKey&amp;quot;: &amp;quot;{env:CHUTES_API_KEY}&amp;quot;
      }
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that the &lt;code&gt;baseURL&lt;/code&gt; option for the local Ollama provider needs to
be set to that of the container's host DNS entry, since the container
needs to egress to the host in order to query the Ollama server. In
Podman this is set to &lt;code&gt;host.container.internal&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;And, while not specifically pertaining to Agent Circus, I set the
Chutes &lt;code&gt;apiKey&lt;/code&gt; via the &lt;code&gt;CHUTES_API_KEY&lt;/code&gt; environment variable I
described earlier for the Agent Circus config.&lt;/p&gt;
&lt;h2&gt;Configuring Emacs&lt;/h2&gt;
&lt;p&gt;Now to integrate Emacs Agent Shell with Agent Circus to continue
working as I am used to. This is achieved by executing the relevant
ACP client within the Agent Circus container via &lt;code&gt;agent-circus exec&lt;/code&gt;—the same one I used from the command line test earlier.&lt;/p&gt;
&lt;h3&gt;Setting the Agent Shell Command&lt;/h3&gt;
&lt;p&gt;In my Emacs &lt;code&gt;use-package&lt;/code&gt; declaration for &lt;code&gt;agent-shell&lt;/code&gt;, I need to
customize the &lt;code&gt;agent-shell-command-prefix&lt;/code&gt; variable, which is a list
of strings representing the command line prefix. Unlike the default,
it should invoke &lt;code&gt;agent-circus&lt;/code&gt; for the selected service provider:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-emacs-lisp&quot;&gt;(use-package agent-shell
  :config
  (defun my/agent-shell-command-prefix (buffer)
    (let* ((config (agent-shell-get-config buffer))
           (service
            (pcase (map-elt config :identifier)
              ('claude-code &amp;quot;claude-code&amp;quot;)
              ('opencode &amp;quot;opencode&amp;quot;)
              ('codex &amp;quot;codex&amp;quot;)
              (_ &amp;quot;opencode&amp;quot;))))
      (list &amp;quot;agent-circus&amp;quot; &amp;quot;exec&amp;quot; service &amp;quot;--&amp;quot;)))
  (setq agent-shell-command-prefix #'my/agent-shell-command-prefix))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I've only defined mappings for Claude Code, Codex and OpenCode (with
the latter being the default), but other providers supported by Agent
Shell can be handled via &lt;code&gt;pcase&lt;/code&gt; in the same manner. Agent Shell will
append the relevant ACP client command based on the selected provider.&lt;/p&gt;
&lt;h3&gt;Resolving Files Between Container and Host&lt;/h3&gt;
&lt;p&gt;In order to resolve files located on the host from the container (and
vice-a-versa), there is an additional bit of configuration that is
required. Agent Shell provides a feature called
&lt;code&gt;agent-shell-devcontainer&lt;/code&gt; for this purpose. Specifically, I need to
add the following in the above &lt;code&gt;:config&lt;/code&gt; clause:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-emacs-lisp&quot;&gt;(use-package agent-shell
  :config
  ;; rest of config from previous example goes here...
  (setq agent-shell-path-resolver-function 
        #'agent-shell-devcontainer-resolve-path))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Because Agent Circus mounts the project directory into &lt;code&gt;/workspace&lt;/code&gt;, I
also need to create a file on the host within the file relative to the
project at &lt;code&gt;.devcontainer/devcontainer.json&lt;/code&gt; with the following
key-value pair:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;{
  &amp;quot;workspaceFolder&amp;quot;: &amp;quot;/workspace&amp;quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This tells Agent Shell where to resolve the project root. Without it,
Agent Shell will attempt to resolve workspace files relative to
&lt;code&gt;/workspaces/&amp;lt;repository_name&amp;gt;&lt;/code&gt;, which is incorrect for Agent Circus,
and the Agent Shell process will hang. As best as I can tell, there
isn't a way to override this behavior on either end.&lt;/p&gt;
&lt;p&gt;As an aside, I was able to troubleshoot and verify the above issue by
enabling ACP debug logs via &lt;code&gt;(setq acp-logging-enabled t)&lt;/code&gt;, which
causes the ACP process to log debug data to a separate buffer. In my
case, it indicated that the dev container file was not found at the
expected path, right after the protocol handshake. In fairness, the
Agent Shell README identifies where it looks for the workspace—a more
thorough reading would have possibly saved me some time here 😅.&lt;/p&gt;
&lt;p&gt;While this works, adding such boilerplate to every project is a bit
annoying. Fortunately, the Agent Circus author kindly wrote a useful
Elisp example for a &lt;a href=&quot;https://github.com/Embedded-Focus/agent-circus#emacs&quot;&gt;custom resolver&lt;/a&gt;
function that will automatically discover the container workspace and
resolve files in either direction, obviating the need to create the
above file for every project.&lt;/p&gt;
&lt;h2&gt;Other Considerations&lt;/h2&gt;
&lt;p&gt;There are a couple of other things I have not done, like allowing the
agent browser access to the web browser on the host (using the same
DNS entry to resolve the local Ollama server), nor have I configured
SSH forwarding for accessing the remote Git repository within the
container. I probably won't do the latter, as I prefer to push and
otherwise manage Git remotes myself.&lt;/p&gt;
&lt;p&gt;I also haven't dug into the network egress control mechanism Agent
Circus implements outside of the README claim of a &amp;quot;built-in firewall
restrict[ing] outbound network access to known-good destinations&amp;quot;,
which is also probably something I should verify before getting too
comfortable.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;So far, the switch to a sandboxed environment using Agent Circus and
Podman has been pretty transparent. The former's ACP-enabled
integration with Agent Shell allows me to continue with my preferred
workflow, while also raising the security floor for my agentic
development habits. While it's not a bulletproof solution (nothing is,
short of eschewing agents completely or turning off the internet,
perhaps), it is certainly an improvement.&lt;/p&gt;
</content></entry></feed>