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.

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.3.1

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.3.1
File Size Uploaded
hozo-0.3.1.tar.gz 59.0 kB Details

Built distribution (wheel)

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

Total release size: 95.1 kB

Release files / hozo-0.3.1.tar.gz

Download URL hozo-0.3.1.tar.gz
Size 59.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6fd78eb7e5b045bd67e56ef14ec751f12d35424500e449c1c78032ceafc8f05b
BLAKE2b-256 checksum
How to use checksums
8afae170b5e25365f7db9bc74a5c956782eb71e60514f81e65cbbced5e9429c8
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 4, 2026.

Transparency log

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

Download URL hozo-0.3.1-py3-none-any.whl
Size 36.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f11a8ac3926b2f9d21f6ca26a85f1dd8a862142c4cf1923d3cb7238c708e7cc7
BLAKE2b-256 checksum
How to use checksums
3f6c4c52a8a5b9dd122ffaa425e6b0036d6784ec6ed4c2d9e9c8b3c74b804c38
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 4, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.1

2 release files

0.4.0

2 release files

This release

0.3.1 This release

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