Defense-in-Depth
Verifiable security invariants from socket to storage.
Built from first principles so host isolation, cryptographic boundary enforcement, and anti-footgun defaults hold even under hostile mail input or compromised agent sessions.
Memory & Supply Chain
#![forbid(unsafe_code)]
Zero Unsafe Rust & Clean Audit
#![forbid(unsafe_code)] spans all 18 workspace crates including Layer-0 wire, crypto, and kernel primitives, paired with pure-Rust rustls across SMTP, IMAP, HTTPS, and CAPMail. Legacy advisories for RSA DKIM, P-256 PoP, and Curve25519 were eliminated on aws-lc-rs and v3 curves (0 cargo audit vulnerabilities).
At-Rest & Session Crypto
XChaCha20-Poly1305 + AAD
Fail-Closed Vault & Domain-Bound AAD
Argon2id credential hashing, zeroize on drop, constant-time CSRF, and Sec-Fetch-Site: same-origin checks. Stored secrets bind explicit context AAD (e.g., provider_aad(domain) and muddle-admin-totp-v1) to defeat ciphertext transplantation. When locked, APIs return 423 Locked and unauthenticated callers see zero vault-state oracle.
Browser Boundary
Strict CSP + Sandbox
Zero Inline Script & Isolated HTML Bodies
Webmail enforces script-src 'self' 'wasm-unsafe-eval', style-src 'self', zero 'unsafe-inline' or 'unsafe-eval', server-side ammonia sanitization, proxied remote images, and <iframe sandbox="" srcdoc> rendering so untrusted emails never execute scripts or phone home.
Edge & Proxy Hardening
X-Muddle-Proxy-Auth
Authenticated Proxy Hops & Smuggling Defense
Loopback-only /_internal/tls-ask and /_internal/metrics reject forwarded headers. Reverse-proxy IP trust requires a >= 32-byte BLAKE3-verified X-Muddle-Proxy-Auth secret. Listener limits enforce strict Content-Length/Transfer-Encoding parsing, per-request header deadlines, /64 IPv6 bucketing, and CatchPanicLayer.
Agent Containment
mcp-audit-verify
Separation of Duties & Hash-Chained Audit
Tokens enforce single-mailbox or domain boundaries via check_token_domain and block mixing mail.read with ops.* write scopes. Reading untrusted mail taints the session, routing outbound sends and policy changes through Inbox HITL approval while every tool call appends to a SHA-256 hash-chained, Ed25519-signed log.
Operational Resilience
BLAKE3 + WAL Backup
Hot-Reload TLS & Verified Online Backups
ReloadableCertResolver requires 0600 non-symlink private keys and reloads cleanly on SIGHUP while keeping the prior valid certificate on error. Online backups (muddle-box backup) snapshot SQLite WAL databases under read-lock protection, verify every BLAKE3 compressed blob, and validate SHA-256 manifests before atomic restore.