aien-edge
aien-dev/aien-edge
Brought by drakestapleton
aien-edge / AUDIT_SCOPE.md
| 1 | # Audit scope |
| 2 | |
| 3 | Written for an outside, independent security audit. Revision described: |
| 4 | `cf3369b10a167f028e705456626088ae2c1307d5` on `main`, 2026-11-01. Everything below is taken from |
| 5 | the repository's own files at that revision; items marked NOT_RUN were not executed while writing |
| 6 | this document. |
| 7 | |
| 8 | ## What this repository is |
| 9 | |
| 10 | aien-edge is a small native Rust web server (hyper and rustls) that serves prebuilt static sites |
| 11 | from memory, with brotli and gzip precompression, ETags, virtual hosts and automatic Let's |
| 12 | Encrypt 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 |
| 14 | infrastructure, not part of the AIEN core. One binary crate. |
| 15 | |
| 16 | ## What to review, in priority order |
| 17 | |
| 18 | 1. `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. |
| 20 | 2. `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). |
| 23 | 3. `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. |
| 25 | 4. `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. |
| 27 | 5. `deploy/aien-edge.service`: `DynamicUser=yes`, `CAP_NET_BIND_SERVICE` only, read-only |
| 28 | `/srv/sites`. |
| 29 | 6. `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. |
| 31 | 7. 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 | |
| 53 | A stable Rust toolchain; edition 2021; no `rust-toolchain.toml`, so the exact version is unknown |
| 54 | from the repository. `Cargo.lock` is committed. |
| 55 | |
| 56 | ```sh |
| 57 | git clone https://github.com/aien-dev/aien-edge.git |
| 58 | cd aien-edge |
| 59 | cargo build --release |
| 60 | ``` |
| 61 | |
| 62 | ## Run every test |
| 63 | |
| 64 | ```sh |
| 65 | cargo test |
| 66 | cargo 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. |