hazbox 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -116
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,138 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
Your packages and agents see the project. Nothing else.
|
|
4
4
|
|
|
5
|
-
Every `npm install`, `
|
|
5
|
+
Every `npm install`, `npx something` or coding agent runs code from strangers with your full permissions. That code can read your SSH keys, your npm, GitHub and cloud tokens and your AI tool logins, and it can talk to Docker, which is root. hazbox runs the command in a box where only the project is there.
|
|
6
6
|
|
|
7
|
-

|
|
7
|
+

|
|
8
8
|
|
|
9
|
-
The secrets in the demo are fake
|
|
9
|
+
The secrets in the demo are fake and the demo package sends nothing. `demo/record.sh` rebuilds it.
|
|
10
|
+
|
|
11
|
+
## Try it
|
|
10
12
|
|
|
11
13
|
```sh
|
|
12
|
-
npx hazbox check
|
|
13
|
-
|
|
14
|
+
npx hazbox check # what can code running here reach? (Linux, macOS)
|
|
15
|
+
|
|
16
|
+
npm i -g hazbox # Node 18.17+
|
|
17
|
+
sudo apt install bubblewrap passt # dnf and pacman have both too
|
|
18
|
+
hazbox npm install
|
|
14
19
|
hazbox npm run dev
|
|
15
|
-
hazbox
|
|
20
|
+
hazbox claude
|
|
16
21
|
```
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
`npx hazbox check` lists what code running in your terminal can reach right now. It prints names only, never contents. Its only network call is one empty `HEAD` request to example.com, to see whether the network is reachable. On the machine I built this on it found 28 things, among them the SSH keys behind the ssh-agent, Docker, both D-Bus buses, 55 other daemon sockets (on 2026-12-01), and Claude, Codex and GitHub logins.
|
|
23
|
+
`hazbox check` prints names only, never contents. On my laptop it found 28 things. Inside the box it finds 1: the internet.
|
|
21
24
|
|
|
22
25
|
## What the box blocks
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
| services listening on your localhost (databases, dev tools, local AI proxies), abstract unix sockets, this machine's other addresses, and containers or anything else on its other networks (Docker bridges, VPNs) | unreachable when `passt` is installed: the box gets its own network from pasta. `--localhost 5432` lets one port through. Without passt, hazbox says so once. If passt is installed but can't start, hazbox warns on every run and `hazbox check` shows the fix |
|
|
31
|
-
| secret env vars | removed. Only a short allowlist passes, plus anything you add with `--env NAME`. Values you pass are never put on a command line, where other users on the machine could read them |
|
|
32
|
-
| other processes and their env, including the sandbox helper's own | invisible (separate PID namespace, helper starts with an empty env) |
|
|
33
|
-
| open files and sockets the calling program left open (editors, agents, terminal multiplexers, CI runners) | replaced with `/dev/null` before the command starts. stdin, stdout and stderr pass through as they are |
|
|
34
|
-
| your other projects | invisible |
|
|
35
|
-
| `.git` | read-only. Code inside can't plant a hook, a `core.fsmonitor` command or a `commondir` redirect, and can't rename or replace `.git`. A git command that tries to write says so and points to `--git-write` |
|
|
36
|
-
| git metadata planted by an earlier run (`core.worktree`, a `.git` file pointing at another repo) | can't widen the next run. hazbox reads the project and its git dirs from disk instead of asking git, and refuses pointers that aren't this project's worktree or submodule |
|
|
37
|
-
| the kernel session keyring, and typing into your terminal (`TIOCSTI`, `TIOCLINUX`) | blocked by a seccomp filter (x86-64 and arm64) |
|
|
38
|
-
| Node, Python, Rust, Go and other toolchains in your home | read-only, so nothing can replace a CLI you later run outside. uv's credential store isn't mounted |
|
|
39
|
-
| Claude Code | runs inside. Its installed versions are read-only, so nothing in the box can replace the `claude` you run outside. Your real `~/.claude` and `~/.claude.json` stay hidden |
|
|
40
|
-
| your agent instructions and skills | `hazbox claude` gets `~/.claude/CLAUDE.md`, `skills`, `agents` and `commands` read-only, and `hazbox codex` gets `~/.codex/AGENTS.md`, `prompts` and `skills`. Never their logins, settings or MCP config, and other commands get none of it |
|
|
41
|
-
| mounted drives (`/media`, `/mnt`) | hidden |
|
|
42
|
-
| `/etc/shadow`, `/etc/gshadow` | replaced with an empty file, in case the host's permissions are wrong |
|
|
43
|
-
| the project | read-write, as normal. hazbox adds no files to it |
|
|
44
|
-
| git | status, diff and log work. Commits need `--git-write`, which keeps hooks and config read-only. Worktrees and submodules work |
|
|
45
|
-
| dev servers | reachable from your browser at `localhost` or `127.0.0.1`. Stopping hazbox stops them |
|
|
46
|
-
| the box after hazbox stops | gone. If hazbox is killed outright, the box goes with it; a command that ignores SIGTERM is killed 5 seconds later |
|
|
47
|
-
| `--offline` | no network at all, localhost and abstract unix sockets included |
|
|
48
|
-
| your home, `~/.ssh`, `~/.config` and other credential folders, system folders, `/tmp` and `/var/tmp` themselves | refused as a project. An empty folder works as is (for scaffolders). A folder with files but no git repo or project file needs `--here` |
|
|
49
|
-
|
|
50
|
-
## Compared with other sandboxes
|
|
51
|
-
|
|
52
|
-
Measured with `scripts/compare.sh` on Ubuntu 26.04, kernel 7.0, 2026-12-01. Run it on your machine to check.
|
|
53
|
-
|
|
54
|
-
| | exposed |
|
|
55
|
-
|---|---|
|
|
56
|
-
| no sandbox | 28 |
|
|
57
|
-
| **hazbox 0.1.0** | **1** (outbound network) |
|
|
58
|
-
| nono 0.82.0, `run --allow . --read <node>` | 6: secret env vars, ssh-agent, Docker, D-Bus session, D-Bus system bus, network |
|
|
59
|
-
| srt 0.0.83 (Anthropic sandbox-runtime), default settings | did not start. Ubuntu's AppArmor user-namespace restriction blocks its seccomp helper |
|
|
60
|
-
|
|
61
|
-
nono also needed `--read` for an fnm-installed Node before it would start. I confirmed nono's gaps with real calls: the Docker API answered, `ssh-add -l` listed the keys, and the token was in the environment.
|
|
62
|
-
|
|
63
|
-
## Speed
|
|
64
|
-
|
|
65
|
-
hazbox adds a fixed cost to each command: about 0.15 to 0.2 s on my laptop, of which roughly 60 to 80 ms is pasta setting up the box's network. On anything that runs longer than a few seconds it's noise.
|
|
66
|
-
|
|
67
|
-
Measured with `scripts/bench.mjs` (median of alternating bare and boxed runs) on a laptop with an i7-8650U in its balanced power profile, Ubuntu 26.04, Node 22.17.1, bwrap 0.11.1, passt 2026-01-20, 2026-12-01. The laptop was busy with other work (load average about 3.5); I expect a quiet machine to do better, but that is a guess:
|
|
68
|
-
|
|
69
|
-
| command | bare | hazbox |
|
|
70
|
-
|---|---|---|
|
|
71
|
-
| `node -e 0` | 41 ms | 241 ms |
|
|
72
|
-
| `npm --version` | 190 ms | 348 ms |
|
|
73
|
-
| `npm run build` (new Vite + React app) | 1.08 s | 1.16 s |
|
|
74
|
-
|
|
75
|
-
The first install in a project takes as long as it does without hazbox. The box reads your npm cache through an overlay, and anything it writes goes to a separate layer for that project, so your cache and other projects never see it. Three rounds of `npm ci` in a fresh project took 17.1 to 17.6 s boxed and 17.4 to 19.5 s bare. Without the overlay the first install took 58 s, because the box started with an empty cache. The overlay needs bwrap 0.10 or newer. Ubuntu 22.04 and 24.04 ship older versions, so there the first install in each project downloads everything once.
|
|
76
|
-
|
|
77
|
-
Packages the box downloads stay in that project's layer, never in your real cache, so a second project downloads them again. Sharing them would let one project plant packages another one installs. `hazbox prune` cleans up.
|
|
78
|
-
|
|
79
|
-
pnpm's store works the same way. Measured once each on the same laptop, installing 151 packages from a lockfile with a warm store took 3.3 s in a new project and 1.3 s after that, against 1.0 s bare. Before the overlay, the first boxed install downloaded everything and took 59 s.
|
|
80
|
-
|
|
81
|
-
## Compatibility
|
|
82
|
-
|
|
83
|
-
I ran install, typecheck, lint, test and build for 9 of my own projects inside the box with `scripts/real-projects.sh`: 4 Vite + React apps, 2 Next.js sites and 3 TypeScript projects, one of them on pnpm. On the latest run (2026-12-01, with pasta networking), 28 of 30 steps passed. The other 2 failed the same way outside the box. One test suite has a test that already fails (6144 pass and 1 fails, in and out of the box), and one project has no ESLint config. No step failed only in the box.
|
|
27
|
+
- **Your home.** SSH keys, npm, GitHub and cloud tokens, Claude and Codex logins, browser profiles. The box gets an empty home of its own for each project.
|
|
28
|
+
- **Daemon sockets.** ssh-agent, Docker, D-Bus and every other socket under `/run` and `/tmp`.
|
|
29
|
+
- **Your localhost and Docker networks** (with passt installed). `--localhost 5432` lets one port through.
|
|
30
|
+
- **Secret env vars, other processes and your other projects.**
|
|
31
|
+
- **`.git` hooks and config.** `.git` is read-only; `--git-write` allows commits and keeps hooks and config read-only.
|
|
32
|
+
- **Typing into your terminal and the kernel keyring**, through a seccomp filter.
|
|
84
33
|
|
|
85
|
-
|
|
34
|
+
Your dev server still opens in the browser. With bwrap 0.10 or newer, npm and pnpm read your warm cache, so installs aren't slower. Each command costs about 0.15 to 0.2 s.
|
|
86
35
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
hazbox never reads, stores or forwards your agent login. The box can't see `~/.claude` or `~/.codex`, so an agent starts logged out, with its first-run setup screens. Your instructions and skills come along read-only (see the table above). You have two ways in:
|
|
90
|
-
|
|
91
|
-
- Pass a token yourself with `--env`. This is how I tested, with `hazbox --localhost 8317 --env ANTHROPIC_BASE_URL --env ANTHROPIC_AUTH_TOKEN claude` against a model proxy on my localhost. Code that runs during that command can read the token, so use one you can revoke.
|
|
92
|
-
- Log in inside the box. The login is saved in that project's box home, so you do it once per project. But every later run in that project can read it, a plain `hazbox npm install` included. I haven't tested logging in this way.
|
|
93
|
-
|
|
94
|
-
Turn off the agent's own sandbox. On Ubuntu 26.04, AppArmor stops a bubblewrap sandbox from starting inside another one, so Codex refuses to run commands until you use `--dangerously-bypass-approvals-and-sandbox`. hazbox is the sandbox there. Claude Code's sandbox is off by default.
|
|
36
|
+
Every item above has a test that plants fake secrets, and each test fails when its protection is removed. [The full list, the numbers and a comparison with other sandboxes →](https://github.com/MohibShaikh/hazbox/blob/main/docs/DETAILS.md)
|
|
95
37
|
|
|
96
38
|
## Limits
|
|
97
39
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
- **
|
|
101
|
-
- **
|
|
102
|
-
- **With passt, networks that appear after the box starts aren't blocked**, such as a VPN you connect mid-run. The next run picks them up.
|
|
103
|
-
- **With passt, the box is IPv4 only, and ports it listens on are forwarded to your localhost**, so dev servers work. Code in the box could listen on a free port that a program outside expects to find its own service on, such as 5432 while your Postgres is stopped.
|
|
104
|
-
- **Project files are fair game.** The box protects everything outside the project. Inside it, code can read and change anything, including `.env`, `package.json` scripts, `.vscode/` settings that your editor may run later, and `.claude/settings.json` hooks that Claude Code runs when you next use it outside the box. That includes git: in a folder that isn't a repo, or in a nested repo inside the project, code can write a `.git` whose config your editor's git integration would then run outside the box.
|
|
105
|
-
- **`--git-write` makes the git dir writable.** Hooks and config stay read-only, but code inside can add a file like `.git/commondir` that points host git at another config. The next `hazbox` run refuses to start if it finds one, but git commands you run before that will follow it. Use `--git-write` for agents you'd let commit anyway.
|
|
106
|
-
- **The box can read your npm cache and pnpm store** (`~/.npm/_cacache`, `~/.local/share/pnpm/store`), which hold every package you've installed, including private ones from other projects. It can't change them. Nothing else in `~/.npm` is visible.
|
|
107
|
-
- **Anything you pass with `--env` is visible to all code in the project.** That includes code an earlier run left in `node_modules` or in the project's box home, which persists between runs so caches stay warm.
|
|
108
|
-
- **`hazbox <command>` needs Linux and bubblewrap.** macOS support is in progress. On macOS, `hazbox check` works and `hazbox <command>` refuses to run instead of running unprotected.
|
|
109
|
-
- **The rest of the system is readable**, read-only: `/usr`, `/etc`, `/opt`, `/var/lib` and the like, as for any program you run. Your home, `/tmp`, `/run` and mounted drives are not.
|
|
110
|
-
- **It is not a VM.** A kernel exploit escapes it, as it escapes every container-style sandbox.
|
|
111
|
-
- **`hazbox check` looks for Docker only at its standard socket paths.**
|
|
112
|
-
|
|
113
|
-
## Install
|
|
114
|
-
|
|
115
|
-
```sh
|
|
116
|
-
npm i -g hazbox # or use npx hazbox ...
|
|
117
|
-
sudo apt install bubblewrap passt # Debian/Ubuntu; dnf/pacman have both too
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
passt is optional but recommended: without it, code in the box can reach services on your localhost.
|
|
121
|
-
|
|
122
|
-
Requires Node 18.17 or newer.
|
|
123
|
-
|
|
124
|
-
Ubuntu 23.10 and later block the user namespaces bwrap needs unless an AppArmor profile allows it. Ubuntu 24.04's bubblewrap package has no such profile. If yours is missing one, hazbox runs nothing and prints the one-time `sudo` command that adds it. Ubuntu 24.04's passt package has the same gap for pasta; there hazbox runs without pasta, and says so once with the matching command. CI applies both printed commands on Ubuntu 24.04 and checks that hazbox works, with pasta, afterwards. Each profile lets any program use that tool (bwrap or pasta) to create user namespaces, which is the thing Ubuntu restricts by default; nothing else changes.
|
|
125
|
-
|
|
126
|
-
## Cleaning up
|
|
127
|
-
|
|
128
|
-
Each project's box home and cache layers live in `~/.local/share/hazbox/projects`. `hazbox prune` deletes those of projects that no longer exist. `hazbox prune --all` deletes them all, agent logins made inside the box included.
|
|
129
|
-
|
|
130
|
-
## Package cards
|
|
131
|
-
|
|
132
|
-
`hazbox x <package>` shows the version, publish date and publisher, weekly downloads, size, dependency count, install scripts, and whether it was built in CI with provenance or trusted publishing. It warns on versions under 7 days old, packages under 30 days old, a publisher change since the previous version, install scripts, hand-published releases and low usage. Then it asks before running that exact version in the box. `--json` prints the card for scripts and agents.
|
|
133
|
-
|
|
134
|
-
## Sponsor
|
|
40
|
+
- **The internet is open.** Code in the box can't read your secrets, but it can still send the project's own files, `.env` included. A domain allowlist is next.
|
|
41
|
+
- **Files inside the project are fair game**, including `.vscode/` settings and `.claude/settings.json` hooks that your tools run later.
|
|
42
|
+
- **Linux only for now.** On macOS, `check` works and `hazbox <command>` refuses to run rather than run unprotected.
|
|
43
|
+
- **It is not a VM.** A kernel exploit gets out of it, as it gets out of any container.
|
|
135
44
|
|
|
136
|
-
|
|
45
|
+
[All the limits →](https://github.com/MohibShaikh/hazbox/blob/main/docs/DETAILS.md#limits)
|
|
137
46
|
|
|
138
47
|
## License
|
|
139
48
|
|