Files
harpia/docs/docker.md
T
Lucas RayanandClaude Opus 5.5 90ece32dac feat(api): require an admin token for configuration changes
Group CRUD decides what the scanner sweeps, yet any client that reached the
API could change it. Writes now need XEXEU_ADMIN_TOKEN (or a token generated
at startup and printed as a ?token= link, like sabia ui), compared in
constant time, and a browser Origin must match Host. The dashboard keeps the
token for the tab and asks for it on 401. Reads are unchanged.

Also track .env.example: '.env*' in .gitignore had kept it out of the
repository, although the README tells operators to copy it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 10:17:14 -03:00

97 lines
4.6 KiB
Markdown

<p align="center"><a href="../README.md">◂ Back to README</a></p>
# Docker
Xexéu ships as two containers from one image, defined in
[`docker-compose.yml`](../docker-compose.yml):
```
xexeu.toml (ro)
│
┌─────────────────────┴──────────────────────┐
▼ ▼
scanner (NET_RAW, host net) xexeu (no capabilities)
schedules + probes targets ingests batches
writes immutable batches ──batches──► correlates CVEs, computes diffs
(xexeu-sweeps volume) serves the API + dashboard
(xexeu-data volume)
```
- **`scanner`** only emits packets at the authorized targets and writes
sweep batches. It never opens a listening port, never touches the
database, never makes an outbound connection. `network_mode: host` is
required so it sees the network the same way the host does (correct
source addresses, visibility of local-segment hosts for discovery).
- **`xexeu`** never emits traffic at scan targets. It ingests batches
(mounted `:ro`), is SQLite's only writer, serves the API/dashboard, and
makes the only outbound connections the stack has (feed sync, update
check) — both opt-in and both disabled by default.
## Quick start
```bash
cp .env.example .env
cp examples/xexeu.toml config/xexeu.toml # edit the scope/groups first
docker compose pull && docker compose up -d # published image
# or, building locally:
docker compose up -d --build
```
The dashboard comes up at `http://127.0.0.1:8788` by default (`XEXEU_PUBLISH`
in `.env` to change the bind address/port). To add, edit or remove groups from
it, set `XEXEU_ADMIN_TOKEN` in `.env` (`openssl rand -hex 32`) or, leaving it
empty, take the one-off link from `docker compose logs xexeu`; inside the
container it reads `http://0.0.0.0:8788/?token=…`, so swap the host for the
published address.
## Why `scanner` runs as `uid 0` restricted to `NET_RAW`
The raw-socket SYN engine (`nativo`, see [`architecture.md`](architecture.md))
needs `CAP_NET_RAW`. Docker's `cap_add` only grants a capability to a
process that is already root (`uid 0`) inside the container — a non-root
user does **not** receive an added capability unless the binary itself
carries it as a *file capability* (`setcap cap_net_raw+ep`), and this image
intentionally doesn't bake that in (a setuid-like file capability is itself
an attack-surface decision we'd rather not make silently). `no-new-privileges`
also blocks calling `setcap` at runtime as a workaround.
So the `scanner` service runs as `uid 0` but with **every other** capability
dropped (`cap_drop: [ALL]`, `cap_add: [NET_RAW]` only), a read-only root
filesystem, `tmpfs` for `/tmp`, and `no-new-privileges`. It is still
"root" in the Linux-user sense, but it can do essentially nothing a normal
root process could — no `NET_ADMIN`, no `SYS_ADMIN`, no filesystem writes
outside the two mounted volumes, nothing privileged except crafting raw TCP
packets.
If your platform's threat model doesn't tolerate `uid 0` at all regardless
of capability restriction, run the host with
[`--userns-remap`](https://docs.docker.com/engine/security/userns-remap/):
the container's `uid 0` then maps to an unprivileged host UID, and `NET_RAW`
still works inside the remapped namespace.
If the capability isn't usable for any reason (remapping misconfigured, a
platform that strips it, a profile with `motor = "nativo"` running outside
this compose file at all), `xexeu` detects it automatically
(`xexeu doctor` reports it, and every sweep manifest records which engine
actually ran) and falls back to `nativo-sem-raw` — never a hard failure.
## Volumes
- `xexeu-sweeps`: batches written by `scanner`, read-only from `xexeu`.
Pruned by `scanner` past `retencao_lotes` (see `architecture.md`).
- `xexeu-data`: the SQLite state (`xexeu`'s only write target) and the
local CVE/KEV database.
- `./config` (bind mount, read-only in both containers): `xexeu.toml`.
Mutations from the dashboard's Groups view write back to this file from
inside the `xexeu` container, so the host directory must be writable by
the container's user even though the mount itself stays `:ro` for
`scanner`.
## Optional `nmap` variant
Profiles with `motor = "nmap"` require the separate `xexeu-scanner-nmap`
image (not built by the default `Dockerfile`), which bundles the external
`nmap` binary the way `scan::nmap` expects it on `PATH`. It is not part of
the standard image specifically to keep nmap's NPSL-licensed code out of
the default distribution.