interplane.Get Omega
Read in your language

aien-edge

aien-dev/aien-edge

Brought by drakestapleton

branch main Branches Tags History

aien-edge / AUDIT_SCOPE.md

96 lines · 4758 bytes Raw Blame History Rendered
1# Audit scope
2
3Written for an outside, independent security audit. Revision described:
4`cf3369b10a167f028e705456626088ae2c1307d5` on `main`, 2026-11-01. Everything below is taken from
5the repository's own files at that revision; items marked NOT_RUN were not executed while writing
6this document.
7
8## What this repository is
9
10aien-edge is a small native Rust web server (hyper and rustls) that serves prebuilt static sites
11from memory, with brotli and gzip precompression, ETags, virtual hosts and automatic Let's
12Encrypt TLS (TLS-ALPN-01). It was built to run on a Raspberry Pi at the network edge. Status
13(README, 2026-10-18): not in use; the sites are served by GitHub Pages. It is hosting
14infrastructure, not part of the AIEN core. One binary crate.
15
16## What to review, in priority order
17
181. `src/site.rs`: site loading into memory, traversal-safe path normalization against an in-memory
19 map, exclusion of hidden files and source maps, encoding negotiation, ETags.
202. `src/handler.rs`: GET and HEAD only, canonical host and apex to `www` redirects, HTTP to HTTPS
21 redirects, 421 for unknown hosts, security headers (HSTS, nosniff, frame denial, referrer
22 policy).
233. `src/main.rs`: listeners (plain HTTP and TLS-ALPN-01), connection cap, header-read and TLS
24 handshake timeouts, `SIGHUP` reload that keeps the old site if the new one fails to load.
254. `src/config.rs`: TOML schema with `deny_unknown_fields`; `[tls]` with `production` switching
26 between Let's Encrypt staging and production; `cache_dir` for ACME state.
275. `deploy/aien-edge.service`: `DynamicUser=yes`, `CAP_NET_BIND_SERVICE` only, read-only
28 `/srv/sites`.
296. `deploy/publish-site.sh` and `deploy/publish.env.example`: builds a site, uploads it over ssh
30 and rsync to `EDGE_HOST`, repoints a symlink and reloads.
317. There are no CI workflows in this repository.
32
33## Trust boundaries
34
35- Untrusted: every network client (request line, Host header, Accept-Encoding, path).
36- Trusted: the config file (read at startup only); site files under the configured roots; the
37 ACME cache directory; the operator who runs the publish script.
38- The server never connects to the build machine; deploys push to it over ssh (README).
39
40## Threat model summary
41
42- Assets: integrity of served sites, TLS private keys in the ACME cache, availability.
43- Attackers considered: remote clients sending crafted paths, hosts or slow connections;
44 connection floods up to and beyond the cap.
45- Defended: no per-request filesystem access, traversal-safe normalization, method restriction,
46 timeouts, connection cap, systemd sandboxing, security headers.
47- Not defended / explicitly out of scope: compromise of the publishing host or ssh credentials;
48 content of the sites; rate limiting beyond the connection cap is not described in the
49 repository.
50
51## Build from source at a pin
52
53A stable Rust toolchain; edition 2021; no `rust-toolchain.toml`, so the exact version is unknown
54from the repository. `Cargo.lock` is committed.
55
56```sh
57git clone https://github.com/aien-dev/aien-edge.git
58cd aien-edge
59cargo build --release
60```
61
62## Run every test
63
64```sh
65cargo test
66cargo clippy --release -- -D warnings
67```
68
69- AGENTS.md: `cargo test` runs 9 unit tests in `src/site.rs` and `src/handler.rs`.
70- The Pi deployment and `deploy/publish-site.sh` need sudo and a remote host and are not a test.
71- Run 2026-11-04 on this branch merged with `main` at `cf3369b` (rustc 1.98.1, aarch64 Linux):
72 `cargo test --locked` 9 passed, 0 failed; `cargo clippy --locked --release -- -D warnings` exit 0;
73 `cargo build --locked --release` exit 0; `cargo audit` exit 0, no advisories (EXERCISED).
74
75## Known limitations and NOT_RUN
76
77- Not deployed; no current production use.
78- `deploy/publish-site.sh` still runs `npm ci` and `npm run build`, which no longer matches how
79 the sites are built; it must be updated before any redeploy.
80- The config is read only at startup; changes need a restart.
81- The README throughput figures were measured on other hardware from commit 59df18c and cannot be
82 repeated from this repository alone; not measured on a Pi.
83
84## Dependencies and provenance
85
86- `Cargo.lock`: hyper, rustls, rustls-acme, tracing, brotli and gzip encoders, `tempfile` for
87 tests. The TLS library was updated for security on 2026-10-17 (README); `rustls-webpki`,
88 `webpki-roots` and `tokio` were patched on 2026-11-01 (`cf3369b`, #14).
89- External services: Let's Encrypt.
90- Licence: AGPL-3.0-or-later (`LICENSE`, `Cargo.toml`); `COVENANT.md` is nonbinding.
91
92## Evidence
93
94- No `evidence/` directory. The recorded throughput run is in the message of commit 843cc77.
95- Whether `aien-dev/aien-receipts` holds `aien-edge/<sha>/` entries is unknown from the
96 repository. Receipts are append-only and never edited.