Live data from Hacker News

Show HN: Fence – Sandbox CLI commands with network/filesystem restrictions

github.com

11–20 of 24 posts

Re: Show HN: Fence – Sandbox CLI commands with network/filesystem restrictions

#11

pretty close to anthropic’s version, yes? or am I mistaken https://github.com/anthropic-experimental/sandbox-runtime

That's acknowledged in the readme though I don't know if there is a comparison

https://github.com/Use-Tusk/fence?tab=readme-ov-file#attribu...

Re: Show HN: Fence – Sandbox CLI commands with network/filesystem restrictions

#12
Can fence wrap applications that do their namespace-based sandboxing?

This could allow finer control than the application's own sandbox offers. For example, Flatpak apps run in bubblewrap containers with all-or-nothing network permissions. Being able to restrict access by domain name would be useful.

Re: Show HN: Fence – Sandbox CLI commands with network/filesystem restrictions

#13

pretty close to anthropic’s version, yes? or am I mistaken https://github.com/anthropic-experimental/sandbox-runtime

That's acknowledged in the readme though I don't know if there is a comparison https://github.com/Use-Tusk/fence?tab=readme-ov-file#attribu...

Hey! Yes, Fence was inspired by sandbox-runtime. Both use the same underlying OS primitives (sandbox-exec on macOS, bubblewrap on Linux) and proxy-based network filtering.

Fence adds additional controls on top of what is available on sandbox-runtime:

- Command deny rules

- SSH command filtering

- Port exposure for inbound connections (useful for running dev servers inside the sandbox). This is a key reason why I decided to create Fence - because https://github.com/Use-Tusk/tusk-drift-cli spins up users’ services locally for trace replays and Fence helps to block unintended localhost outbound connections.

- Built-in templates for common developer workflows

- Better ergonomics for violation monitoring (`fence -m` gives you real-time violation logging on both macOS and Linux via eBPF, vs sandbox-runtime where Linux requires manual strace)

In summary, Fence layers extra permission-management features for wrapping popular CLI agents. If you just need filesystem + network isolation and you're in the Node ecosystem, sandbox-runtime is great. If you want command blocking, SSH filtering, inbound port exposure, or a standalone Go binary, Fence adds that.

Re: Show HN: Fence – Sandbox CLI commands with network/filesystem restrictions

#14
post #12

Can fence wrap applications that do their namespace-based sandboxing? This could allow finer control than the application's own sandbox offers. For example, Flatpak apps run in bubblewrap containers with all-or-nothing network permissions. Being able to restrict access by domain name would be useful.

Unfortunately nested bubblewrap sandboxes don't work.

When you run `fence flatpak run `, Fence creates a bwrap sandbox with its own user namespace, Flatpak then tries to create another user namespace inside, so you'd get something like `bwrap: setting up uid map: Permission denied`.

The outer sandbox doesn't grant the capability for nested namespace creation (otherwise it would defeat much of the security), so Fence can't wrap Flatpak (or similar namespace-based sandbox tools) in a useful way. Ideally you'd need something at the network level outside any sandbox.

That said, open to suggestions if anyone knows of a feasible solution.

Re: Show HN: Fence – Sandbox CLI commands with network/filesystem restrictions

#15
post #14
post #12

Can fence wrap applications that do their namespace-based sandboxing? This could allow finer control than the application's own sandbox offers. For example, Flatpak apps run in bubblewrap containers with all-or-nothing network permissions. Being able to restrict access by domain name would be useful.

Unfortunately nested bubblewrap sandboxes don't work. When you run `fence flatpak run `, Fence creates a bwrap sandbox with its own user namespace, Flatpak then tries to create another user namespace inside, so you'd get something like `bwrap: setting up uid map: Permission denied`. The outer sandbox doesn't grant the capability for nested namespace creation (otherwise it would defeat much of the security), so Fence…

Steam creates its pressure-vessel containers using namespaces, and there is a Steam flatpak, which I think was made possible by some work a few years ago specifically for the purpose of nesting. I don't know if that work applied to flatpak, bubblewrap, or both. It might be worth investigating.

https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/t...

https://github.com/flathub/com.valvesoftware.Steam

Re: Show HN: Fence – Sandbox CLI commands with network/filesystem restrictions

#18

Is there anything like this for macOS?

- https://github.com/webcoyote/sandvault: sandboxes AI agents in a MacOS limited user account, and also uses sandbox-exec to limit access, though fence has more strict limitations

- https://github.com/webcoyote/clodpod: sandboxes AI agents in a MacOS virtual machine

Note: I’m the author of both of these Apache open-source projects

Re: Show HN: Fence – Sandbox CLI commands with network/filesystem restrictions

#20

- can i run user submitted untrusted code in this? and can it do a pip install if user wants or an npm install?

Yes, Fence is designed for exactly this, the built-in `code` template already allowlists npm and PyPI registries:

``` fence -t code pip install requests fence -t code npm install express ```

This restricts writes to workspace + cache dirs, blocks reading credentials, limits network to allowlisted domains, and blocks dangerous commands (`rm -rf`, `npm publish`, etc).

Post reply on HN