# Browsers, desktops, SSH and mounts

> Let your agent do it: Set up Hermitbox's native tools on this host. Run `hermitbox doctor` and tell me which tiers and tools are on, and why any are off. On the container tier, create the prepared templates with `hermitbox template create desktop`, `hermitbox template create browser` and `hermitbox template create tools`. Host changes such as the seccomp profile need root: show me those commands and run them only after I confirm. Then use the page's TypeScript calls for the browser, desktop or SSH I ask for. Follow the exact steps in https://docs.hermitbox.dev/v0.3.2/guides/browser-and-desktop.md.

Give your agent a headless browser to drive, a desktop it can screenshot, click and type in, SSH,
and S3 bucket mounts, all inside a sandbox. You can step into the same box: open its desktop in
your browser through noVNC, or SSH in with one command. From a warm desktop template, a new
sandbox returns its first screenshot in 752 ms at p50 ([measurements](https://docs.hermitbox.dev/v0.3.2/reference/speed.md#native-tools)).

Each tool wraps a maintained open-source program. The sandbox agent serves it on scoped routes,
and every URL or key you get is short-lived and goes through Hermitbox's authenticated front, the
edge.

## A browser and a kernel

```ts
// A process sandbox on a host that can run the sandboxed browser.
const box = await hb.sandbox({
  isolation: 'process',
  require: ['browser-sandbox'],
})

// Take a screenshot, or drive the browser over CDP.
const page = await box.browser.screenshot('https://example.com')
const { url: cdp } = await box.browser()

// Run Python in the same box.
const python = await box.python()
const answer = await python.run('6 * 7')
console.log(answer.text) // 42
```

## Which tools each tier has

| Tool | `container` | `process` |
| --- | --- | --- |
| Browser | yes | yes, if the host meets its prerequisites |
| Desktop | yes | yes, if the host meets its prerequisites |
| SSH | yes | yes, if the host meets its prerequisites |
| Python and Node kernels | yes ([interpreters](https://docs.hermitbox.dev/v0.3.2/guides/code-interpreter.md)) | yes, if the host meets its prerequisites |
| Bucket mounts | yes, on a host that turns on FUSE | refused by capability |

On the container tier, the tools run as the sandbox user. On the process tier, they come from a
separately verified tool bundle (below). Wasm refuses native tools. `hermitbox doctor` says which
tools a host serves and why any are off.

Process-tier tools start more slowly: from sandbox creation to a desktop screenshot takes 8.96 s
at p50, against 740 ms on a container ([startup by tool](https://docs.hermitbox.dev/v0.3.2/reference/speed.md#startup-by-tool)).
`toolsVersion` is versioned separately from the stable agent API.

## Process tools

Process-tier tools come from a digest-pinned runtime that stays out of the base installation. A
release carrying `process-tools.json` beside its installed agent supplies that runtime and, as a
separate release asset, its corresponding source.

On a host without kernel network policy, the first browser or kernel request fetches the runtime
over verified HTTPS. It checks the archive and its complete file inventory, then publishes a
read-only per-user cache outside sandbox data. On a host with kernel network policy, the node
fetches the pinned runtime into its protected host cache before it launches the supervisor, so a
workload's egress rules can't block trusted runtime setup.

Consumers still verify the complete immutable cache. Their downloads and scratch stay private to
their UID and keep their existing retirement. Older agents that can't verify a sealed host-owned
cache report native tools unavailable on policed hosts until upgraded; their ordinary per-user
cache still works.

Placement and capability probes never fetch tools. A source-only build without the descriptor
names the missing artifact and keeps these tools off.

### Host requirements

The upstream builds are python-build-standalone CPython 3.12.16 (20261110), Node's official
24.22.1 tarball and Chrome Headless Shell 158.0.8127.18. Small launchers select the bundle's
libraries and use **host glibc**, without rewriting binaries or shipping a private glibc. The
complete dependency set needs x86_64 Linux with glibc **2.34** or later. The probe reports the
host's actual version, and names the minimum on an older host. Pinned inputs, complete notices
and corresponding-source directions are in the
[bundle documentation](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/templates/process-tools/README.md).

Private IPC needs enforced Landlock ABI 6 abstract-socket scopes and fresh signed proof from every
live managed supervisor. Legacy or unverified peers keep tools off, with a reason. Unknown process
history on the current boot needs a host restart. Ordinary process commands stay available.
Process tools currently refuse `network: none` rather than loosen its socket restrictions.

The process browser also needs usable unprivileged user namespaces under the host's security
policy. It always keeps Chromium's sandbox, and bubblewrap gives it private mount, PID, IPC and
temporary-file namespaces. Its debugging pipe and scoped Unix proxy expose the same expiring
browser capability through the edge; it adds no browser TCP listener.
`require: ['browser-sandbox']` needs both host readiness and the copy's observed launch policy.
An operator can turn on namespaces in the host policy; the user installer changes no sysctl, LSM
profile or container policy.

### Process desktops and SSH

The full desktop and OpenSSH component needs x86_64 Linux with host glibc **2.36** or later,
usable unprivileged user namespaces, and the private IPC and history checks above. The core
browser and kernels keep their **2.34** minimum. When either is off, `hermitbox doctor` reports
`process-desktop` and `process-ssh` with the requirement it observed. The installer doesn't change
host policy.

Xvfb and headful Chromium run with software rendering in a private PID, IPC and temporary-file
view; Chromium keeps its own sandbox. Each sandbox has its own display. VNC, websockify and the
desktop command adapter use scoped Unix sockets, so no shared host display or VNC TCP port is
exposed. The same desktop methods and expiring noVNC URL work through the HTTP edge. No window
manager runs by default.

```ts
// A process sandbox whose host can prove the desktop and SSH tools.
const box = await hb.sandbox({
  isolation: 'process',
  units: 4,
  requiredTools: ['desktop', 'ssh'],
})

// Take a screenshot, then click, type and press a key.
const png = await box.desktop.screenshot()
await box.desktop.click(100, 100)
await box.desktop.type('hello')
await box.desktop.key('Return')

// Open SSH with hermitbox sandbox ssh <sandbox-id>, or access.connect() with an SSH client.
const access = await box.ssh()

// Revoke the SSH lease when you're done.
await box.ssh.revoke()
```

`requiredTools` is optional. With it, placement requires the verified native desktop and SSH
capability, and so does every wake; a node or tier that can't prove it is refused by name.
Without it, native services start on demand, and policed process hosts prepare the runtime
archive before the supervisor starts, as above. Existing container templates and calls behave as
before and don't claim the native process bundle's capability. `network: none` refuses these
native tools and keeps its egress restrictions.

Native OpenSSH serves accepted Unix connections as the sandbox's own user, with its normal
authentication, host keys and command and PTY behavior. The HTTP-only user preset carries those
bytes over the authenticated agent WebSocket, using OpenSSH ProxyCommand. Private client keys stay
in memory, and authorization stays outside persistent sandbox data. Lease capacity, expiry,
revocation, wake and neighbour isolation apply to this transport too. Startup measurements
comparing the process and container tools are in [speed](https://docs.hermitbox.dev/v0.3.2/reference/speed.md).

## Container tools

Create the three prepared templates:

```sh
hermitbox template create desktop
hermitbox template create browser
hermitbox template create tools
```

They use a released version of the three prepared images; pass `--image` to use your own build.
The native-tools image holds OpenSSH, Mountpoint S3, rclone and the desktop dependencies; the
desktop image selects its X11 start command.

The browser image takes the official Playwright image as a donor, keeps only its open-source
headless shell and FFmpeg, and publishes a sanitized, flattened filesystem. No published layer
contains the donor's proprietary Widevine module.

Templates keep complete upstream notices and source URLs. The licence inventories are
[native tools](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/docs/licences/native-tools-debian.json), [browser](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/docs/licences/browser.json),
[Playwright](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/docs/licences/playwright.json), [desktop Python](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/docs/licences/desktop-python.json) and
[rclone](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/docs/licences/rclone-modules.json).

### Desktop

```ts
// A sandbox from the desktop template.
const box = await hb.sandbox({ template: 'desktop', units: 2 })

// Get the noVNC URL and a screenshot.
const { url } = await box.desktop()
const png = await box.desktop.screenshot()

// Click, type, press a key, move the pointer and scroll.
await box.desktop.click(100, 100)
await box.desktop.type('hello')
await box.desktop.key('Return')
await box.desktop.move(120, 100)
await box.desktop.scroll(0, 1)
```

Open `url` in your browser to see and use the same desktop. The display is 1280×720 by default; set
`HERMITBOX_DESKTOP_WIDTH`/`HERMITBOX_DESKTOP_HEIGHT` between 64 and 8192 in the template
environment. The `desktop` starter project runs TigerVNC's Xvnc server and JWM. The `desktop`
template image runs Xvfb, JWM and x11vnc.

Both turn off the X11 TCP listener, restrict VNC to loopback and bind websockify to loopback on
6080. `desktop()` exposes noVNC with a fresh random capability in the URL fragment, valid for at
most five minutes and no longer than the agent token.

Minting another URL rotates access. The WebSocket must present that token, and websockify's
TokenFile adapter also checks wall-clock expiry. Requests are not logged with tokens. An
authenticated MCP caller can use `screenshot`, `click`, `type` and `key`; screenshots come back as
native PNG image content.

### Browser

```ts
// A sandbox from the browser template.
const box = await hb.sandbox({ template: 'browser', units: 4 })

// Connect with Playwright using chromium.connectOverCDP(cdp).
const { url: cdp } = await box.browser()

// Or take a screenshot directly.
const page = await box.browser.screenshot('https://example.com')
```

In containers, CDP stays on loopback 9222. The exposed 9223 HTTP/WebSocket proxy requires a
random expiring capability, delegates forwarding to http-proxy, and rewrites discovery for the
edge URL prefix. Keep the returned URL private. New connections fail after expiry or rotation;
browser and VNC WebSockets already open can live until they disconnect, as other authenticated
streaming sessions do. Screenshots need HTTP(S) URLs without embedded credentials and return
bounded PNG bytes. The browser's network access is the sandbox's own network policy.

### SSH

```ts
// A sandbox from the tools template.
const box = await hb.sandbox({ template: 'tools', idle: '10m' })

// Pin hostKey and pass key to an SSH client in memory.
const { host, port, user, key, hostKey } = await box.ssh()

// Revoke the SSH lease when you're done.
await box.ssh.revoke()
```

From a terminal, `hermitbox sandbox ssh <sandbox-id>` wraps OpenSSH. It loads the one-time private
key into a dedicated local ssh-agent over stdin, pins the returned host key, and revokes on exit.
It never writes the client private key. Each call creates an independent ECDSA P-384 key and a
listener that requires hybrid post-quantum key exchange (`mlkem768x25519-sha256` or
`sntrup761x25519-sha512@openssh.com`).

Raw SSH goes through the edge's hold/wake front with a session-bound preface, so connecting wakes
a sleeping sandbox. Raw slots are absent from HTTP previews and disk-restored assignments.
Revocation retires routes and closes sessions.

Keys expire at the earliest of the scoped capability, five minutes and **idle from issue**. This
conservative bound means a sandbox that sleeps past its idle time can't revive access. OpenSSH
checks wall-clock public-key expiry even straight after a wake. A stop or a new agent invalidates
old raw slots; request a new lease. Only public lease metadata reaches control. Ordinary
serialization of SDK SSH handles leaves out `key`.

New leases can also advertise `webSocketUrl` and `transport`. When its live advertisements report
an HTTP-only deployment, the CLI uses OpenSSH's ProxyCommand through the authenticated HTTP edge;
an available raw front stays the default. Both paths use the same lease, host key, expiry,
revocation and epoch checks. TypeScript `access.connect()` and Python `access.connect()` open the
authenticated binary WebSocket for an SSH client; await the Python call in async mode. The
connection carries OpenSSH bytes without interpreting them. Registration needs a live edge
advertising a transport the agent can serve.

### Bucket mounts

```ts
// Mount a bucket prefix at /mnt/data.
const box = await hb.sandbox({
  image: 'ghcr.io/hermitbox/hermitbox-tools:<release-version>',
  mounts: [
    {
      bucket: 's3://my-bucket/prefix',
      path: '/mnt/data',
      readOnly: false,
      credentials: {
        accessKeyId: process.env.S3_ACCESS_KEY!,
        secretAccessKey: process.env.S3_SECRET_KEY!,
        region: 'us-east-1',
        endpoint: 'https://storage.example.com',
      },
    },
  ],
})

// Lists source, path, backend and state, never the credentials.
console.log(await box.mounts())
```

A create with only mounts uses the prepared tools image when no source is given; in production,
pin the released image explicitly. Mountpoint S3 comes first; an image with rclone but without
Mountpoint uses rclone mount. Both need working FUSE (see [host set-up](#host-set-up-for-the-browser-sandbox-and-fuse))
and obey the same host policy. Their normal filesystem semantics apply: Mountpoint doesn't
promise full POSIX behavior, and rclone buffers writes in a bounded private temporary cache.

The agent refuses unsupported tiers and unavailable workers rather than emulate a mount. Paths
must be below `/mnt` or persistent data and pass the descriptor-relative no-follow walk. Roots and
agent state can't be covered.

#### How mount credentials are kept

Control seals credentials with Node's AES-256-GCM and the operator seal key, binding the
ciphertext to the sandbox and project. Specs, logs, listings, operation responses and data
archives hold no mount credentials. The agent receives them over its scoped transport and passes
them only in the mount worker's environment, with ambient AWS config and metadata providers turned
off. It serves health while it holds the entrypoint until every initial mount is ready.

A failed create is deleted. A dead worker is reported and needs an explicit restart, never an
implicit remount. The running-state hook sets up mounts on start and wake, and mounted-only
maintenance handles agent restarts that happen on their own. Ready agents don't receive credentials again.

Forking a mounted snapshot needs explicit credentials. Deletion erases sealed credentials. Keep the
operator seal key across control restarts.

Mount workers run as the sandbox's own uid, so the image installs `mount-s3`, `rclone` and
`fusermount3` execute-only (mode 0111). The kernel then leaves a worker non-dumpable after exec.
Sandbox commands, which hold no capability, can't read its `/proc` environment or memory or trace
it, and the credentials never appear in its command line.

The agent execs each worker from a sealed, execute-only copy of itself in memory, so the worker
isn't dumpable from its first instruction either, while `/.hermitbox-agent` stays readable.

A worker refuses to start a readable helper, so a custom image that installs one readable fails
its mount instead of exposing the credentials. This doesn't hold against a same-uid process with
`CAP_SYS_PTRACE`, which no sandbox command is given.

### Host set-up for the browser sandbox and FUSE

By default, the container browser runs under the container's default policy. Its inner Chromium
sandbox needs user namespaces and the approved native-tool policy; `hermitbox doctor` reports
whether the caller can use them. The public `browser-sandbox` guarantee also needs the node's
native-tool policy. A create can require a missing guarantee, and placement then refuses it. See
[host capabilities](https://docs.hermitbox.dev/v0.3.2/reference/host-capabilities.md) for the difference between false and
unknown. FUSE also needs the real `/dev/fuse` character device. Install the
[host profile](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/deploy/native-tools-seccomp.json) as a protected root-owned file:

```sh
sudo install \
  -m 600 \
  deploy/native-tools-seccomp.json \
  /etc/hermitbox/native-tools-seccomp.json
```

```toml
[docker]
native_tools_seccomp = "/etc/hermitbox/native-tools-seccomp.json"
native_fuse = true
# On AppArmor hosts, load the provided profile in enforcing mode first.
native_tools_apparmor = "hermitbox-native-tools"
```

On an AppArmor host, also load `deploy/hermitbox-native-tools.apparmor` with
`sudo apparmor_parser -r deploy/hermitbox-native-tools.apparmor`. It is derived from Docker's Moby
profile and keeps its other denials. The node requires the selected profile to be in enforcing
mode already; `unconfined` and complain-mode profiles are refused. On hosts without AppArmor,
leave out `native_tools_apparmor`. The default policy is unchanged.

The host seccomp profile wraps Playwright 1.65.0's Apache-2.0 seccomp profile and explicitly
permits the mount/unmount and chroot syscalls. Chromium chroots inside its own user namespace; the
kernel still requires that namespace's CAP_SYS_CHROOT, which ordinary commands don't have.

FUSE uses a nested user and mount namespace; the sandbox never receives SYS_ADMIN in the host or
original Docker namespace. Only a mount worker keeps that capability, inside its own namespace,
sharing only the approved target. Ordinary commands and PTYs drop it.

A bounded 16-MiB private `/mnt` tmpfs holds mountpoint metadata while the image root stays
read-only. Native FUSE needs a non-root sandbox user; the prepared native templates use UID 1000.
Namespace setup runs only for native templates or creates with mounts. Ordinary images, root
images included, keep their normal bootstrap on a host that approves FUSE.

Default hosts keep all capabilities dropped, a read-only root, no-new-privileges and their
existing seccomp policy. A request can't select a host profile or a device. Hosts without this
opt-in don't advertise `native-fuse-mounts`, so placement refuses a request with mounts before
starting compute.

The host must permit nested user namespaces under its own LSM or AppArmor policy; this setting
doesn't turn off an LSM. An operator must configure a host that refuses that operation. The node
binds the container browser's inner-sandbox choice to its observed host policy, through the
actual agent executable's announced bootstrap support. With no approved profile, the browser
uses the container's existing outer isolation and reports `browser-sandbox` off, and a request
that requires that guarantee is refused. Legacy agents stay strict. The process browser always
requires Chromium's sandbox and refuses a host that can't provide it.

## From Python

Python has the same callable handles in its sync and async clients: `box.desktop()`,
`box.desktop.screenshot()`, `box.browser()`, `box.browser.screenshot(url)`, `box.ssh()`,
`box.ssh.revoke()` and `box.mounts()`; await them in an async context. Credentials use the public
camelCase mount fields inside the `mounts` list. See [speed](https://docs.hermitbox.dev/v0.3.2/reference/speed.md) for measured
readiness.

## How this is tested

CI's ordinary-user acceptance exercises real application input, screenshots and noVNC through the
edge, plus SSH commands, HTTP wake, the installed CLI and both Python SDK modes.
