feat(scan): implement raw-socket SYN engine; fix Docker build and cross-container permissions; full v1.0 docs
Release / Plan (reuse the published image?) (push) Successful in 4s
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and clippy (push) Failing after 9s
CI / Dependency audit (push) Failing after 11s
CI / Tests (Linux) (push) Successful in 9m25s
Release / ci (push) Failing after 9m26s
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Skipped
Release / Gitea release (push) Skipped
Release / Plan (reuse the published image?) (push) Successful in 4s
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and clippy (push) Failing after 9s
CI / Dependency audit (push) Failing after 11s
CI / Tests (Linux) (push) Successful in 9m25s
Release / ci (push) Failing after 9m26s
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Skipped
Release / Gitea release (push) Skipped
- scan::syn_scan: raw TCP SYN half-open scanning (CAP_NET_RAW), validated end-to-end against a real target through the actual hardened Docker Compose stack (scanner uid 0 restricted to NET_RAW, xexeu uid 10001 zero capabilities). Automatic fallback to nativo-sem-raw, engine actually used recorded in every sweep manifest. - caps::has_net_raw: CAP_NET_RAW detection via /proc/self/status, shared by the scan engine selection and `xexeu doctor`. - Fix: Dockerfile never copied apps/ or logo.png, so the image never actually built until this was caught by a real `docker build`. - Fix: sweep batches were written 0600 by scanner (uid 0); xexeu (uid 10001) couldn't read them through the read-only xexeu-sweeps mount. Now written 0644/0755 explicitly. - Fix: group names from the config CRUD API weren't validated as safe path components until a sweep tried to write a batch for them; now rejected immediately. - Fix: CSV exports had no CSV/formula-injection guard; cells starting with =, +, -, @ or a tab are now prefixed to force plain-text interpretation. - docs/: full EN/PT-BR set (architecture rewritten to match the real implementation — SQLite not DuckDB, include_str!/include_bytes! not rust-embed; new cli.md, configuration.md, docker.md, interface.md, support.md) with real dashboard/report screenshots. - README, ROADMAP, CHANGELOG, SECURITY, CONTRIBUTING (EN/PT-BR): updated to reflect actual v1.0-candidate state instead of the initial-scaffolding status they still described.
This commit is contained in:
1 parent
db2cdc03ef
commit
2298117c47
35 files changed
+2007
-247
No files matched your search
+122
-32
@@ -2,58 +2,148 @@
|
||||
|
||||
**English** · [Português](pt-BR/arquitetura.md)
|
||||
|
||||
Xexéu is a lightweight, continuous attack surface management and vulnerability audit system. It follows a decoupled two-service architecture distributed via Docker Compose: a privileged packet emitter (`scanner`) and an unprivileged analytical server (`xexeu`).
|
||||
Xexéu is a lightweight, continuous attack surface management and
|
||||
vulnerability audit system. It follows a decoupled two-service architecture
|
||||
distributed via Docker Compose: a privileged packet emitter (`scanner`) and
|
||||
an unprivileged analytical server (`xexeu`), sharing one binary and one
|
||||
`crates/xexeu-core` library.
|
||||
|
||||
## Technology Stack
|
||||
## Technology stack
|
||||
|
||||
| Layer | Component | Rationale |
|
||||
|---|---|---|
|
||||
| Core Engine & CLI | Rust 2021 (MSRV 1.88) | Memory safety, native networking performance, single binary deployment. |
|
||||
| API Layer | Axum + Tokio | Asynchronous HTTP service with minimal overhead. |
|
||||
| Web Dashboard | Vanilla HTML/CSS/JS | Zero-dependency frontend embedded directly into the binary via `rust-embed`. |
|
||||
| Storage Engine | DuckDB + Parquet | Embedded columnar storage, fast analytic queries, dynamic linking to precompiled `libduckdb.so`. |
|
||||
| Core engine & CLI | Rust 2021 (MSRV 1.88) | Memory safety, native networking performance, single binary deployment. |
|
||||
| API layer | Axum + Tokio | Asynchronous HTTP service with minimal overhead. |
|
||||
| Web dashboard | Vanilla HTML/CSS/JS | Zero-dependency frontend embedded directly into the binary via `include_str!`/`include_bytes!` — no `rust-embed`, no build step. |
|
||||
| Raw-socket engine | `socket2`, hand-built TCP headers | A single `SOCK_RAW`/`IPPROTO_TCP` socket for both sending SYN probes and receiving replies — see [Scan engine](#scan-engine) below. |
|
||||
| Storage engine | SQLite (`rusqlite`, bundled) + Parquet | Embedded, zero-ops storage. **Not DuckDB**: an early design draft specified DuckDB for its analytical query strengths, but SQLite was chosen instead for v1.0 — no external `libduckdb.so` to link or ship, one less moving part, and the query patterns `xexeu serve` actually needs (point lookups by asset key, small aggregate counts) don't benefit from a columnar engine. Sweep batches themselves stay in Parquet (immutable, one file per sweep, not touched by this choice). |
|
||||
| Deployment | Docker Compose | Strict privilege isolation, container hardening, immutable batches over named volumes. |
|
||||
|
||||
## System Topology & Data Flow
|
||||
## System topology & data flow
|
||||
|
||||
```
|
||||
config/xexeu.toml (ro)
|
||||
config/xexeu.toml (rw from xexeu, ro-mounted into scanner)
|
||||
│
|
||||
┌─────────────────────┴──────────────────────┐
|
||||
▼ ▼
|
||||
scanner (NET_RAW, host net) xexeu (zero capabilities)
|
||||
- Multi-group scheduler - Batch ingestion (:ro)
|
||||
- ARP/ICMP discovery - Scoped diff calculation
|
||||
- TCP SYN & UDP probes - CPE -> CVE matching (NVD/KEV)
|
||||
- Service banner grabbing - State storage (DuckDB)
|
||||
│ - Axum API & embedded web UI
|
||||
scanner (NET_RAW, host net, uid 0) xexeu (uid 10001, zero capabilities)
|
||||
- Multi-group scheduler, hot-reload - Batch ingestion (:ro)
|
||||
- TCP connect discovery - Scoped diff calculation
|
||||
- SYN (nativo) / connect - CPE -> CVE/KEV matching
|
||||
(nativo-sem-raw) port scan - SQLite state + CVE database
|
||||
- Service banner fingerprinting - Axum API, dashboard, exec. report
|
||||
│ - config CRUD (writes xexeu.toml)
|
||||
▼ ▲
|
||||
xexeu-sweeps (Parquet batches + manifest.json) ───┘
|
||||
```
|
||||
|
||||
### 1. Privilege Separation
|
||||
### 1. Privilege separation
|
||||
|
||||
- **`scanner`:** Emits raw network packets to discover hosts and scan ports. It requires `network_mode: host` and `cap_add: [NET_RAW]`, but drops all other capabilities (`cap_drop: [ALL]`), runs with a read-only root filesystem, and only has write access to the `xexeu-sweeps` volume. It never opens listening ports, has no API, and does not access DuckDB.
|
||||
- **`xexeu`:** Runs as an unprivileged user (UID 10001) with zero capabilities. It mounts `xexeu-sweeps` as read-only, acts as the **exclusive writer** to DuckDB (`xexeu-data`), correlates findings against local vulnerability feeds, and serves the Axum API and web interface bound to `127.0.0.1:8788`.
|
||||
- **`scanner`:** emits raw network packets to discover hosts and scan ports,
|
||||
and writes sweep batches. It requires `network_mode: host` and
|
||||
`cap_add: [NET_RAW]` (hence `user: "0:0"` — see
|
||||
[`docker.md`](docker.md#why-scanner-runs-as-uid-0-restricted-to-net_raw)
|
||||
for why Docker makes that necessary), but drops every other capability
|
||||
(`cap_drop: [ALL]`), runs with a read-only root filesystem, and only
|
||||
writes to the `xexeu-sweeps` volume. It never opens a listening port, has
|
||||
no API, and never touches the SQLite database.
|
||||
- **`xexeu`:** runs as an unprivileged user (uid 10001) with zero
|
||||
capabilities. It mounts `xexeu-sweeps` read-only, is the **exclusive
|
||||
writer** of the SQLite state (`xexeu-data`), writes `xexeu.toml` back
|
||||
when the dashboard's Groups view mutates a group, correlates findings
|
||||
against the local vulnerability database, and serves the Axum API,
|
||||
dashboard and executive report bound to `127.0.0.1:8788` by default.
|
||||
|
||||
### 2. Batch Contract & Idempotency
|
||||
### 2. Scan engine
|
||||
|
||||
Two port-scanning engines share one result type (`HostPortScanResult`), so
|
||||
either can feed the rest of the pipeline unchanged:
|
||||
|
||||
- **`nativo` (raw SYN, `scan::syn_scan`):** one `SOCK_RAW`/`IPPROTO_TCP`
|
||||
socket per scan, used for both sending and receiving. On Linux, such a
|
||||
socket needs no `IP_HDRINCL` to send — the kernel fills in the IP header,
|
||||
so each probe is just a hand-built 20-byte TCP segment (SYN flag, correct
|
||||
checksum over the IPv4 pseudo-header). On receive, the kernel does the
|
||||
opposite and hands back the full IP+TCP packet, so replies are parsed by
|
||||
skipping the IP header. A `SYN-ACK` matching the probe's `(peer_ip,
|
||||
peer_port)` means `Open`; an `RST` means `Closed`; no reply by the scan's
|
||||
deadline means `Filtered`, same semantics as the connect engine. Requires
|
||||
`CAP_NET_RAW`, checked at runtime via `caps::has_net_raw()` (reads
|
||||
`CapEff` from `/proc/self/status`).
|
||||
- **`nativo-sem-raw` (TCP connect, `scan::ports`):** the documented degraded
|
||||
mode. No capability needed; every open port is a real, completed TCP
|
||||
connection.
|
||||
|
||||
`execute_scan_for_group` in `xexeu-cli` picks `nativo` whenever a profile
|
||||
asks for it **and** `CAP_NET_RAW` is actually usable, and falls back to
|
||||
`nativo-sem-raw` with a logged warning otherwise — the engine that actually
|
||||
ran, not the one requested, is what gets recorded in the sweep manifest, so
|
||||
an operator reading `/api/status` or a manifest never has to guess.
|
||||
|
||||
### 3. Batch contract & idempotency
|
||||
|
||||
Communication between `scanner` and `xexeu` happens entirely through
|
||||
filesystem batches, never a network call between the two containers:
|
||||
|
||||
Communication between the scanner and the server occurs through filesystem batches:
|
||||
- Each scan execution writes to `sweeps/<group>/<sweep_id>/observations.parquet`.
|
||||
- Upon successful completion, the scanner atomically creates `manifest.json` containing metadata, scope, and cryptographic hashes.
|
||||
- The server watches the sweeps volume, ingests batches idempotently by checking `sweep_id`, and prunes processed batches based on retention policy.
|
||||
- On successful completion, `scanner` atomically creates `manifest.json`
|
||||
(sweep id, group, scope, engine mode actually used, status).
|
||||
- `xexeu` polls the sweeps volume, ingests batches idempotently by
|
||||
`sweep_id`, and `scanner` prunes batches past the retention window.
|
||||
|
||||
### 3. Tiered Scheduling & Scope Boundaries
|
||||
### 4. Tiered scheduling & scope boundaries
|
||||
|
||||
Target configuration in `xexeu.toml` decouples asset definitions from execution policies:
|
||||
- **`[escopo]`:** Mandatory boundary. Any target or DNS resolution outside the authorized CIDR blocks causes validation failure and terminates startup.
|
||||
- **`[padrao]`:** Global default cron schedule (e.g. `@daily`), jitter, and shared packet-per-second (`taxa_maxima_pps`) budgets.
|
||||
- **`[[grupo]]`:** Named networks with customized cron cadences (e.g. `*/5 * * * *` for critical DMZs vs. `0 3 * * *` for exhaustive core audits) and assigned probe profiles.
|
||||
Target configuration in `xexeu.toml` decouples asset definitions from
|
||||
execution policy — see [`configuration.md`](configuration.md) for the full
|
||||
reference:
|
||||
|
||||
### 4. Scoped Diffs & Event History
|
||||
- **`[escopo]`:** mandatory boundary. Any target or DNS resolution outside
|
||||
the authorized CIDR blocks fails validation.
|
||||
- **`[padrao]`:** global default cron schedule, jitter, and the shared
|
||||
`taxa_maxima_pps` budget.
|
||||
- **`[[grupo]]`:** named networks with their own cron cadence (e.g.
|
||||
`*/5 * * * *` for a critical core vs. `0 3 * * *` for an exhaustive
|
||||
nightly sweep) and probe profile. Editable live from the dashboard's
|
||||
Groups view (`/api/config/groups`); `scanner` hot-reloads on its own by
|
||||
watching the config file's mtime.
|
||||
|
||||
Rather than generating disconnected point-in-time reports, Xexéu evaluates state differences against the specific scope of the completed scan:
|
||||
- **State Tables:** Maintains deduplicated current state for `assets`, `services`, and `findings`.
|
||||
- **Scoped Diff Algorithm:** Ports outside a group's profile are never marked closed by that group's scan.
|
||||
- **Oscillation Debounce:** Transient network failures require multiple consecutive missed scans (`ausencias_para_sumir`) before emitting `host_sumiu` or `porta_fechada`.
|
||||
- **Event Log:** Immutable append-only log recording surface transitions (`host_novo`, `porta_aberta`, `servico_alterado`, `vulnerabilidade_nova`, `vulnerabilidade_corrigida`) paired with deterministic JSON evidence.
|
||||
### 5. Scoped diffs & event history
|
||||
|
||||
Rather than disconnected point-in-time reports, Xexéu evaluates state
|
||||
differences against the specific scope the completed sweep actually
|
||||
covered:
|
||||
|
||||
- **State tables:** deduplicated current state for assets, services and
|
||||
findings.
|
||||
- **Scoped diff algorithm:** ports outside a group's scanned profile are
|
||||
never marked closed by that group's sweep.
|
||||
- **Oscillation debounce:** a host needs `ausencias_para_sumir` consecutive
|
||||
missed sweeps before `host_sumiu` fires — one dropped sweep never reads as
|
||||
a disappearance.
|
||||
- **Event log:** append-only log of `host_novo`, `porta_aberta`,
|
||||
`servico_alterado`, `vulnerabilidade_nova`, `vulnerabilidade_corrigida`
|
||||
and friends, each with deterministic JSON evidence.
|
||||
|
||||
### 6. Vulnerability correlation
|
||||
|
||||
`scan::fingerprint` captures a banner per open port (HTTP `Server` header,
|
||||
raw SSH banner, TLS certificate). `vuln::matcher` turns that into a
|
||||
candidate CPE and matches it against the local CVE/KEV database
|
||||
(`vuln::feeds`), producing `Finding`s with a CVSS score, KEV status and a
|
||||
confidence level (`alta`/`média`/`baixa` — lower when a distro backport is
|
||||
suspected, since a backported security fix can leave an old-looking version
|
||||
string on an actually-patched package). `vuln::checks` adds a small set of
|
||||
safe, non-intrusive configuration checks (expired/soon-to-expire TLS
|
||||
certificates, unencrypted administrative ports) independent of CVE
|
||||
matching.
|
||||
|
||||
### 7. Determinism
|
||||
|
||||
Every documented source of variation in a result is explicit, not
|
||||
incidental — the opposite of the intermittent flakiness traditional `nmap`
|
||||
runs are known for: timeouts and network congestion are the *only*
|
||||
documented sources of run-to-run difference (a dropped packet reads as
|
||||
`Filtered`, never as a silently different `Open`/`Closed` verdict), results
|
||||
are always sorted by IP then port before being returned or written, and
|
||||
scheduling jitter is a deterministic function of the slot, not a random
|
||||
draw.
|
||||
Reference in new issue
Block a user