Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
97 lines
4.6 KiB
Markdown
97 lines
4.6 KiB
Markdown
<p align="center"><a href="../README.md">◂ Back to README</a></p>
|
|
|
|
# Docker
|
|
|
|
Harpia ships as two containers from one image, defined in
|
|
[`docker-compose.yml`](../docker-compose.yml):
|
|
|
|
```
|
|
harpia.toml (ro)
|
|
│
|
|
┌─────────────────────┴──────────────────────┐
|
|
▼ ▼
|
|
scanner (NET_RAW, host net) harpia (no capabilities)
|
|
schedules + probes targets ingests batches
|
|
writes immutable batches ──batches──► correlates CVEs, computes diffs
|
|
(harpia-sweeps volume) serves the API + dashboard
|
|
(harpia-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).
|
|
- **`harpia`** 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/harpia.toml config/harpia.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 (`HARPIA_PUBLISH`
|
|
in `.env` to change the bind address/port). To add, edit or remove groups from
|
|
it, set `HARPIA_ADMIN_TOKEN` in `.env` (`openssl rand -hex 32`) or, leaving it
|
|
empty, take the one-off link from `docker compose logs harpia`; 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), `harpia` detects it automatically
|
|
(`harpia doctor` reports it, and every sweep manifest records which engine
|
|
actually ran) and falls back to `nativo-sem-raw`, never a hard failure.
|
|
|
|
## Volumes
|
|
|
|
- `harpia-sweeps`: batches written by `scanner`, read-only from `harpia`.
|
|
Pruned by `scanner` past `retencao_lotes` (see `architecture.md`).
|
|
- `harpia-data`: the SQLite state (`harpia`'s only write target) and the
|
|
local CVE/KEV database.
|
|
- `./config` (bind mount, read-only in both containers): `harpia.toml`.
|
|
Mutations from the dashboard's Groups view write back to this file from
|
|
inside the `harpia` 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 `harpia-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.
|