> ## Documentation Index
> Fetch the complete documentation index at: https://axe-engine.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Security

> AXE's security model, bearer tokens, choosing a transport, and how to report a vulnerability.

## Security model

AXE is not an isolation boundary. The sandbox it runs in is: a container, gVisor or Firecracker. Anything that can reach axed's API can run any command as axed's user, by design. Your job is to make sure only your platform can reach it.

Inside the sandbox, AXE assumes the code it runs is hostile and protects itself and the workspace from that code:

* **Paths stay in the root.** File paths resolve one directory at a time against open handles, so sandboxed code cannot redirect a file operation outside `--root-dir` by swapping in a symlink. See [Confinement](https://axe-engine.mintlify.site/files/confinement.md).
* **Uploads are atomic.** An upload that creates or replaces a file makes it appear only when the upload commits, so nobody reads a half-written file. Appends write to the existing file in place.
* **Everything is bounded.** Retained output, buffered `Execute` output, the number of processes, client connections and file watches are all capped.
* **No descriptors leak.** At startup axed marks every inherited descriptor close-on-exec. Processes it starts inherit only standard input, output and error.
* **Untrusted input cannot crash the daemon.** axed is often PID 1, so a crash ends the sandbox. Deep directory trees, odd file times and files swapped for FIFOs are handled as input, not panics.
* **axed outlives its children.** Under memory pressure the kernel kills supervised processes before axed. See [Memory pressure](#memory-pressure).
* **Slow clients are cut off.** A gRPC connection must complete its HTTP/2 handshake within 10 seconds, and is closed after `--grpc-idle-timeout` (default `5m`) with no call open. REST connections idle, stuck writing or stalled mid-upload for `--http-idle-timeout` (default `60s`) are closed. MCP connections are closed after 5 minutes with no request open.

[Design](https://axe-engine.mintlify.site/design.md) has the details.

## Tokens

Without a token, anyone who can reach a TCP port can run commands. axed logs a warning at startup when a TCP listener is open with no token.

Configure one of these two flags. They are mutually exclusive.

**--auth-token-file** `path`

File holding the bearer token, for example a mounted Kubernetes Secret. Surrounding whitespace is trimmed. An empty file is an error at startup. axed reloads the file when it changes; see [Rotate the token](#rotate-the-token).

**--auth-token-sha256** `hex`

The hex SHA-256 of the token, so the token itself never appears on the command line.

Either way, axed keeps only the SHA-256 digest in memory and compares in constant time. To compute the digest of a token file:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
printf %s "$(cat token)" | sha256sum
```

Clients send the token in either header, on gRPC and REST alike:

```text theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
Authorization: Bearer <token>
X-Sandboxd-Token: <token>
```

With `axectl`, set `AXE_TOKEN` or pass `--token`.

### Rotate the token

With `--auth-token-file`, write the new token to the file. axed watches the file's directory and reloads the token when an entry there changes, which covers writing the file in place, renaming a new file over it, and Kubernetes updating a mounted Secret (it swaps a `..data` symlink). `SIGHUP` also reloads it, for changes the watch cannot see, such as a symlink into another directory.

After a reload, the previous token keeps working for 60 seconds, so clients holding it can switch without failed calls. Only one previous token is kept: a second rotation within the minute ends the first one's grace.

If the file is empty or cannot be read when axed reloads it, axed logs a warning and keeps the current token, so a half-finished update never locks clients out. axed logs that it reloaded, never the token or its digest.

A token given with `--auth-token-sha256` cannot be rotated without a restart.

### Which endpoints require it

| Endpoint | Token required when configured |
| - | - |
| TCP listeners, including the default gRPC port 9090 | Always. `?auth=none` is rejected on TCP. |
| Unix socket, vsock and `fd://` listeners | Yes, unless the listener has `?auth=none` |
| REST API on `--rest-port` | Every request except `GET /v1/health` and `GET /readyz` |
| gRPC server reflection | Yes, on the same terms as the listener's other services. It lists only the services axed serves. |
| `grpc.health.v1` | Never |
| `--mcp-listen` endpoints | Every request, on the same terms as `--listen`, sent as `Authorization: Bearer`. Without a token, requests from browsers (with an `Origin` header) are refused. |

`GET /v1/health`, `GET /readyz` and `grpc.health.v1` stay open so readiness and wakeup probes work without the token. They reveal only whether axed is ready. The native `System.Health` RPC does require it.

## Run processes as another user

A process runs as axed's user unless its request names another (`Spec.user`). Where axed runs as root, as a microVM's PID 1 usually does, start it with `--default-user` so commands run unprivileged by default:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
axed --listen 'vsock://any:1024?auth=none' --default-user 1000:1000
```

axed resolves the user at startup, against `/etc/passwd` for a name, and refuses to start if it cannot. It applies on every protocol, including the Agent Sandbox and Agent Substrate APIs, which have no user field. A request that names a user still gets that user: the default narrows what clients get by accident, not what they may ask for. Anyone who can reach the API can still ask for root.

## Memory pressure

As PID 1, axed's exit ends the sandbox, so it should be the last process the kernel's OOM killer picks. axed arranges that three ways:

* **Children are preferred victims.** Each process sets its own `oom_score_adj` to `--child-oom-score-adj` (default `500`) before it execs, so its whole tree inherits it. Raising the value needs no privilege.
* **axed lowers its own score** to `-900` when it has `CAP_SYS_RESOURCE`, unless the platform already set it lower. Without the capability it keeps the score it started with.
* **axed reserves memory in its cgroup.** With cgroups and the memory controller, axed sets `memory.min` to 16 MiB on its own leaf, so reclaim takes the supervised trees' memory first. The kernel honors it only as far as the cgroups above axed's also protect memory.

Per-process memory limits (`Limits.memory_bytes`, or `--default-memory` and `--max-memory` for every process) keep one tree from using up the sandbox in the first place. With cgroups, a tree that exceeds its limit is killed whole and its exit reports `OOM_KILLED`.

## Transports

axed serves the same gRPC services on every `--listen` endpoint. Repeat `--listen` to serve several at once. Passing any `--listen` replaces the default listener on `tcp://LISTEN_HOST:GRPC_PORT`; add it back explicitly if you still want it. `--mcp-listen` takes the same URIs and options, and serves [MCP](https://axe-engine.mintlify.site/deploy/mcp.md) instead.

| Transport | URI | Use it when |
| - | - | - |
| TCP | `tcp://0.0.0.0:9090` | Clients reach the sandbox over the network: containers, pods, gVisor, networked microVMs. Always use a token. |
| Unix socket | `unix:///run/axe.sock` | A supervisor in the same environment, or a socket bind-mounted to the host. File permissions on the socket control access. |
| vsock | `vsock://any:1024` | A microVM without guest networking, such as Firecracker. From outside the guest only the host reaches it, but processes inside the guest can connect over the loopback CID. |
| Inherited descriptor | `fd://3` | systemd socket activation, or a socket your init already bound. |

Append `?auth=none` to a Unix, vsock or fd listener when the channel itself is the trust boundary, for example vsock from the host:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
axed --listen 'vsock://any:1024?auth=none' --agent-sandbox=false
```

Without a token, axed keeps sandboxed code off the listener:

* A vsock listener with `?auth=none` refuses connections from inside the guest: the loopback CID 1 and the guest's own CID. The host and other VMs the hypervisor lets through are accepted.
* A Unix socket with `?auth=none` is created with mode `0600`, so only processes running as axed's user can connect. Processes axed starts as the same user can, so run them as another user (`Spec.user`), or require the token.
* An `fd://` listener with `?auth=none` gets no extra check; whoever bound the socket decides who can reach it.

The REST API is separate. With `--agent-sandbox` (the default), it always listens on TCP at `--listen-host` and `--rest-port`. Turn it off with `--agent-sandbox=false` if you do not need it, or bind it to loopback with `--listen-host 127.0.0.1`, which also moves the default gRPC listener to loopback.

## No TLS

axed does not terminate TLS. Put one of these in front of it:

* pod isolation plus a Kubernetes NetworkPolicy that admits only your control plane,
* a service mesh that provides mutual TLS,
* vsock or a Unix socket, which never leave the machine.

Treat the token as a second layer on top of network isolation, not a replacement for it. Without TLS it crosses the network in clear text.

## /v1/metadata

`GET /v1/metadata` on the REST port returns axed's environment variables whose names start with `--metadata-env-prefix` (default `SANDBOX_`; an empty prefix also means `SANDBOX_`). It leaves out any variable whose name contains `TOKEN`, `SECRET`, `PASSWORD`, `PASSWD`, `CRED`, `KEY`, `AUTH`, `BEARER`, `PRIVATE` or `CERT`, in any case. It requires the token when one is configured. The name filter is a safety net, not a guarantee. Do not put secrets in variables that match the prefix.

## Report a vulnerability

Report vulnerabilities privately through [GitHub's security advisories](https://github.com/vincent0426/axe/security/advisories/new). Do not open a public issue. Include what you found, how to reproduce it, and the version or commit you tested. You will get a reply within a week. See [SECURITY.md](https://github.com/vincent0426/axe/blob/main/SECURITY.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.