Skip to main content

Hozo

Simple wrapper around bubblewrap (Linux) and sandbox-exec / Seatbelt (macOS) that provides composable profiles for sandboxing. The backend is chosen automatically by platform; the CLI and profiles are the same on both.

Read/write/network access are all deny by default except for a minimal set of directories.

Note: Hozo is not a full isolation solution, but it does make it easier to run untrusted code with a sane default policy and a few composable profiles. This won't protect you against entirely malicious code or kernel exploits, but will help avoid accidentally leaking secrets/files, and also reduce the blast radius of a misbehaving tool. On Linux it uses bubblewrap (kernel namespaces); on macOS it uses Seatbelt, which filters filesystem/network access but does not isolate processes (no separate PID namespace), so isolation there is weaker.

Requirements

  • Linux with bubblewrap (bwrap), or macOS with sandbox-exec (ships with macOS).
  • Python ≥ 3.11. On Linux, proxy mode also needs python3 inside the sandbox (for the egress bridge); macOS needs nothing extra.

Install

uv tool install hozo
hozo --help

Quick start

hozo +untrusted -- make test          # no network, no secrets, cwd writable
hozo +untrusted -- bash               # sandboxed shell
hozo explain +untrusted -- echo hi    # shows the resolved policy (bwrap args / SBPL profile)
hozo +node +proxy -- npm install      # network limited to the npm registry
hozo --allow-net=pypi.org -- pip install requests   # grant just this host
hozo --allow-read=/etc/hosts +untrusted -- cat /etc/hosts
hozo audit -- ./some-tool             # what would this need? (see below)
hozo profile list                     # built-in + your profiles

By default, the current directory is mounted read-write at the same path inside the sandbox. So if you're in /home/user/myproject, then /home/user/myproject is mounted read-write inside the sandbox. Other adjacent directories like /home/user/myotherproject are NOT visible.

This allows you to run commands like make or pytest in a sandboxed environment without worrying about them accessing other files on your system.

Profiles

Profiles are composable YAML files that define what is allowed inside the sandbox. Multiple profiles can be combined and merged to create a final policy for the sandbox.

Several built-in profiles are provided with Hozo, but you can create your own custom profiles by putting them in ~/.config/hozo/profiles/<name>.yaml. Built-in profiles can also be overridden by a user profile of the same name.

hozo profile list shows what's available. hozo explain +a +b -- cmd shows the merged result.

Policies

Profiles are deny-by-default. The base profile always applies, and other profiles can be added to grant more access.

Network is also off by default. The +proxy profile enables egress through a host-side proxy, but still allows no hosts by default. Grant hosts with --allow-net=HOST,HOST.

Ad-hoc allows can be granted on the cli:

  • --allow-net=HOST,HOST allows connecting to these hosts via the proxy
  • --allow-net with no value opens full host networking, no proxy required
  • --allow-read=PATH,PATH / --allow-write=PATH,PATH allows reading/writing to specific paths.

Syscall filtering (Linux)

base loads a seccomp filter denying io_uring_*, bpf, userfaultfd, perf_event_open, the kernel keyring, and module/kexec loading: syscalls with a history of kernel privilege-escalation bugs. Denied calls return ENOSYS, which callers that probe for a feature handle as "unsupported". unshare and ptrace stay allowed, so nested sandboxes and hozo audit keep working.

A tool that needs one of these has to override base, since denies only accumulate across profiles.

syscalls:
  action: errno   # errno | kill | log ('log' permits and records)
  deny:
    - perf_event_open

Denies from every applied profile are unioned. Ignored under macOS Seatbelt.

Finding out what a tool needs

If you want to build a new profile for a tool or command, the easiest way to start is by using hozo audit. It runs the command in a sandbox with a very permissive policy, and reports what it accessed.

hozo audit +node -- npm install       # what does npm need beyond +node?
hozo audit --network-only -- ./tool   # egress only; no strace needed
hozo audit --show-granted -- ./tool   # also show which existing grants got used
hozo audit --audit-out=p.yaml -- make # write the suggested profile somewhere specific

A profile is generated in a temporary file and printed to stdout. You can review it and make changes before saving it to your own profile directory.

Network egress

Network egress is off by default. There are three modes:

  • Allow all egress.
  • Allow egress to specific hosts.
  • No egress at all.
hozo +proxy -- curl https://pypi.org/                        # blocked: no hosts granted
hozo --allow-net=pypi.org -- curl https://pypi.org/simple/   # 200
hozo --allow-net=pypi.org -- curl https://example.com/       # blocked: 403
hozo +python +proxy -- uv pip install ruff                   # +python grants PyPI, +proxy enables egress

Everyday use

To launch a tool sandboxed without typing the full command each time, use a shell alias:

alias claude='hozo +claude -- claude'

A tool starts with a clean home: $HOME keeps its real path, but nothing under it is visible unless a profile binds it explicitly. To persist a tool's login/config, bind its config dir read-write in a profile — it's made available at the same path inside the sandbox:

# ~/.config/hozo/profiles/mytool.yaml
name: mytool
binds:
  - { source: "~/.config/mytool", mode: rw, optional: true }

Development

uv run pytest
uv run ruff check src tests
uv run black src tests

Status

This is a personal project for my own needs. Use at your own risk. Issues and PRs welcome.

Release files for hozo 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hozo 0.4.0
File Size Uploaded
hozo-0.4.0.tar.gz 72.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hozo 0.4.0
File Interpreter ABI Platform
hozo-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 116.6 kB

Release files / hozo-0.4.0.tar.gz

Download URL hozo-0.4.0.tar.gz
Size 72.4 kB
Tags Source
SHA-256 checksum
How to use checksums
35c10313b2a9712e3a0296409d5186b27e6c06082b995075cdf2d25bb2933358
BLAKE2b-256 checksum
How to use checksums
7544f53bd828f666da3e6f34839c37b4ac8fad17313a8128a9a2104192b4771f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 6, 2026.

Transparency log

Release files / hozo-0.4.0-py3-none-any.whl

Download URL hozo-0.4.0-py3-none-any.whl
Size 44.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a49bcd9ec9a5449fdb104d7859610084e5f9762e21c247c0ab460a1b2bf5120c
BLAKE2b-256 checksum
How to use checksums
948c84e830f1183b78ec8f2325c2f074a536518751f221c1b8ad61e551d0a2b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 6, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.1

2 release files

This release

0.4.0 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page