Security / Threat model

Threat model

This page summarises MiraServe's threat model: the assets it protects, the trust boundaries inside a deployment, the seven threat classes it is designed against with the mitigations for each, and what it does not try to protect against. The full document, docs/THREAT_MODEL.md, will be published with the source code.

Protected assets

AssetSensitivityIf compromised
TLS private keys and ACME account keysCriticalTraffic impersonation, interception, unauthorised certificate issuance
Upstream credentials (mTLS keys, OAuth secrets, API tokens)CriticalMovement into internal backends, databases and MCP servers
Publishing signing keys and the release storeCriticalSite defacement or malicious JavaScript in self-updating sites
Host files outside configured document rootsHighDisclosure of files such as /etc/passwd, .env or SSH keys
Worker availability and memoryHighDenial of service, data leaking between tenants
MCP tool access policiesHighAgents invoking destructive backend tools
Request and response confidentialityMedium to highExposure of personal data, session cookies, SNI metadata or secret headers in logs

Trust boundaries

Everything arriving from the internet is untrusted. It reaches a sandboxed worker process, which in turn crosses six boundaries:

BoundaryBetweenEnforced by
TB-1 Network edgeClients and the workerTLS 1.3 with post-quantum key exchange; QUIC anti-amplification
TB-2 Key daemonWorker and miraserve keydA restricted local socket offering only a signing operation
TB-3 WASM sandboxWorker and pluginsWasmtime with fuel, memory and capability limits
TB-4 FilesystemWorker and the host filesystemcap-std directory handles (openat2 with RESOLVE_BENEATH on Linux)
TB-5 Publish gatePublishers and the live siteEd25519 signatures and pre-flight checks before the atomic swap
TB-6 BackendsWorker and upstreamsmTLS reverse proxy, out-of-process PHP-FPM over FastCGI, the MCP gateway

Threats and mitigations

T1. Memory corruption and crash-induced denial of service

Threat: malformed HTTP/1.1, HTTP/2, HTTP/3, QUIC, FastCGI or configuration input causing buffer overflows, use-after-free, integer overflows or panics.

  • Unsafe Rust is forbidden in the high-level crates; the few operating-system calls that need it are confined to the sandbox crate.
  • Panicking shortcuts (unwrap, expect, panic) are denied by lint, so bad input produces an error rather than a crash.
  • No OpenSSL; TLS uses rustls with aws-lc-rs, and dependency policy bans OpenSSL crates.
  • Fuzz targets on the parsers that handle untrusted input.

T2. TLS private key theft

Threat: a bug in the worker, a dependency or an extension exposes worker memory (the Heartbleed class of bug).

  • Optional split-daemon mode keeps private keys in miraserve keyd; the worker requests signatures and never holds the key bytes. See key isolation.
  • Short-lived ACME certificates (6 days) with ACME Renewal Information limit how long a leaked key is useful.
  • Secret buffers are zeroed when dropped.

T3. Harvest-now-decrypt-later and SNI surveillance

Threat: a passive observer records handshakes to decrypt later with a quantum computer, or tracks visited sites through the unencrypted server name (SNI).

  • TLS 1.3 only by default, with the X25519MLKEM768 post-quantum hybrid key exchange preferred.
  • Encrypted Client Hello (ECH) key rotation and DNS record helper.

T4. Request smuggling and protocol-level denial of service

Threat: ambiguous Content-Length and Transfer-Encoding headers desynchronising proxy and backend; HTTP/2 Rapid Reset or CONTINUATION floods; QUIC amplification; slow header trickles (Slowloris).

  • A strict HTTP normaliser rejects duplicate Content-Length, both Content-Length and Transfer-Encoding, folded header lines and invalid header bytes.
  • Per-connection caps on HTTP/2 stream resets, CONTINUATION bursts, header compression memory and concurrent streams.
  • Required timeouts for the TLS handshake, header read, minimum body rate and idle keep-alive.
  • QUIC's three-times anti-amplification limit and retry tokens.

T5. Path traversal, symlink escape and legacy CMS compromise

Threat: ../ traversal, encoded tricks, symlink races, or PHP executed from a WordPress uploads directory.

  • Static files are opened only through cap-std directory handles, which stop symlink escapes at the operating-system level.
  • PHP runs only in a separate PHP-FPM process, never inside MiraServe.
  • The wordpress-hardened preset denies dotfiles, blocks xmlrpc.php and PHP under uploads, and rate-limits wp-login.php. See PHP and WordPress.

T6. Malicious AI agent publishing and MCP tool abuse

Threat: a prompt-injected or unauthorised agent overwrites a self-updating site with phishing or script injection, or calls privileged tools such as db_drop or shell_exec.

  • Publishing requires an Ed25519 signature or a scoped token, runs pre-flight checks (secret scanning, size limits, optional CSP validation), stores immutable releases and supports instant rollback. See atomic publishing.
  • The MCP gateway enforces OAuth (RFC 9728 metadata), tool allow and deny lists with default deny, JSON size and depth limits, and redacted audit logs. See MCP security gateway.
  • RFC 9421 Web Bot Auth verifies bot identity cryptographically instead of trusting the User-Agent header.

T7. Malicious or buggy plugins

Threat: an infinite loop, memory exhaustion or file theft inside a third-party plugin.

  • Plugins run only as WebAssembly in Wasmtime, with fixed memory ceilings, CPU fuel limits and no access to files, network or environment. See WASM plugins.

Out of scope

The threat model states three explicit non-goals:

  • MiraServe does not make backend application logic secure. An SQL injection in an upstream PHP or Node application remains a vulnerability, although presets and edge filtering reduce common exploit paths.
  • MiraServe does not protect against a compromised root account or a compromised kernel on the host.
  • MiraServe does not absorb network-layer floods that saturate the link; that needs upstream filtering such as anycast or scrubbing services.

How this maps to the current release

The threat model describes the design. In the current alpha, a few points differ in practice:

  • Key isolation is opt-in. The default is key-isolation "in-process", where TLS keys are in worker memory. Split-daemon mode cannot be used with built-in ACME.
  • Short-lived certificates apply only to certificates obtained through the built-in acme block, where they are on by default. Certificates you supply yourself keep whatever lifetime they were issued with.
  • ECH is not active. check rejects ech, ech-public-name and ech-rotate, because server-side ECH decryption is not yet available in the TLS library.
  • Landlock and seccomp are Linux only. On other platforms, file confinement relies on cap-std handles.
  • MCP tool lists apply per route, to every authenticated caller of that route, and policy is enforced on tools/call; other MCP methods are forwarded after authentication.
  • Publishing pre-flight checks inspect markup, not separate JavaScript files.

To report a weakness in any of these areas, see reporting a vulnerability.