Archived
initial
This commit is contained in:
59 files changed
+11046
No files matched your search
@@ -0,0 +1,38 @@
|
||||
# Architecture
|
||||
|
||||
## Trust and data boundaries
|
||||
|
||||
Public HTTPS reaches Caddy first. Caddy sends product UI, session, administration, health, and REST API routes to the Go service. Standards discovery, OAuth authorization, public JMAP, mail-client configuration, and ACME challenge routes go to Stalwart. Mail protocols reach Stalwart directly on their dedicated TLS-capable ports, so Stalwart obtains its own certificate for SMTP and IMAP while Caddy independently manages the public web certificate.
|
||||
|
||||
The branded sign-in form posts the password directly to same-origin `/api/auth`, which Caddy routes to Stalwart. The browser creates a PKCE verifier and sends only the one-time authorization code and verifier to MEOVV. The Go service exchanges that code, encrypts access and refresh tokens with AES-GCM, and returns an opaque Secure, HttpOnly, SameSite cookie. User passwords are never sent to or persisted by MEOVV.
|
||||
|
||||
Authenticated browser JMAP calls go through `/api/mail/jmap`; discovery goes through `/api/mail/session`; the event stream uses `/api/mail/events`. The Stalwart adapter is the only Go package that knows these upstream routes, which contains pre-1.0 compatibility changes.
|
||||
|
||||
## Persistence
|
||||
|
||||
Stalwart RocksDB/filesystem volumes contain:
|
||||
|
||||
- local principals, password hashes, application passwords, and authorization state
|
||||
- message bodies, MIME source, attachments, mailboxes, search indexes, and queue state
|
||||
- spam-filter data, DKIM material, and mail-server configuration
|
||||
|
||||
MEOVV SQLite in WAL mode contains:
|
||||
|
||||
- installation and product configuration
|
||||
- hashed REST API keys and approved senders
|
||||
- message envelope, size, submission, and per-recipient delivery state
|
||||
- idempotency records with a 24-hour expiry
|
||||
- webhook endpoints, encrypted-at-rest deployment secrets, attempts, and jobs
|
||||
- encrypted OAuth tokens, sessions, preferences, and administrator audit events
|
||||
|
||||
The database deliberately has no message-body or attachment column.
|
||||
|
||||
## Delivery flow
|
||||
|
||||
REST submissions are validated, MIME-encoded, and written to SQLite in `queued` state in a single transaction with any idempotency record. The application then uses authenticated STARTTLS submission to Stalwart. It returns `202` only after Stalwart accepts the message. Stalwart is therefore the durable queue for every acknowledged submission.
|
||||
|
||||
Stalwart posts signed internal telemetry events. MEOVV normalizes these into `queued`, `processing`, `deferred`, `delivered`, `partial`, `bounced`, or `failed`, keeping recipient-level state. External webhook payloads are versioned independently from Stalwart event schemas.
|
||||
|
||||
## Compatibility
|
||||
|
||||
`release/compatibility.json` is signed with Ed25519. The release public key is compiled into `mailctl`; upgrade refuses a modified signature, a mismatched MEOVV release, or a different Stalwart version/image digest. Contract fixtures and adapter tests should be updated before signing a new manifest.
|
||||
@@ -0,0 +1,40 @@
|
||||
# Operations runbook
|
||||
|
||||
## Delivery modes
|
||||
|
||||
Direct delivery is the default. Use it only when the host has a stable public IP, outbound TCP 25, correct PTR, and an IP range suitable for email. Relay mode sends through an authenticated TLS smart host and is the supported fallback. Changing mode does not require reinstalling; update the delivery configuration and run diagnostics before switching traffic.
|
||||
|
||||
## Backups and restore drills
|
||||
|
||||
`mailctl backup` stops the two data writers, archives every named volume and the host configuration/secrets, computes checksums, and starts the services again. Copy the resulting directory to storage that is encrypted, access-controlled, and separate from the mail host.
|
||||
|
||||
Run a restore drill for every release:
|
||||
|
||||
1. Prepare a clean host with the same MEOVV release.
|
||||
2. Copy the complete backup directory to it.
|
||||
3. Run `mailctl restore --from <directory> --yes`.
|
||||
4. Run `mailctl doctor` and inspect `/health/ready`.
|
||||
5. Verify administrator sign-in, mailbox counts, a historical attachment, REST status records, and DKIM output.
|
||||
6. Submit inbound, direct/relay outbound, and webhook test messages.
|
||||
|
||||
Restore checks every archive before replacing any volume and rejects cross-release restores.
|
||||
|
||||
## Upgrades
|
||||
|
||||
Only use a complete versioned release bundle. `mailctl upgrade` verifies the compatibility signature, creates a backup, pulls approved images, builds the MEOVV image, and recreates the services. Never edit the Stalwart tag or digest directly. If preflight or signature validation fails, do not force the upgrade.
|
||||
|
||||
## Lockout recovery
|
||||
|
||||
`mailctl reset-password` creates or installs a temporary recovery administrator and recreates Stalwart. Use it to enter Stalwart, change the permanent account credential, revoke suspect sessions, and verify normal sign-in. Then run `mailctl harden`, which removes the recovery environment value and recreates Stalwart and MEOVV. Leaving recovery access enabled is a critical finding.
|
||||
|
||||
## Incident checks
|
||||
|
||||
- Queue growth: check DNS, upstream response text, outbound port 25, relay authentication, and reputation.
|
||||
- Inbound failures: check public MX, TCP 25, Stalwart listeners, TLS, recipient existence, and bans.
|
||||
- OAuth loops: confirm the browser hostname exactly matches `MAIL_HOSTNAME` and `STALWART_PUBLIC_URL`.
|
||||
- Webhook retries: inspect DNS resolution, public HTTPS, response code, latency, and signature verification. Duplicates are expected after ambiguous failures.
|
||||
- Readiness failure: inspect the named database volumes and Stalwart HTTPS health before restarting repeatedly.
|
||||
|
||||
## Retention
|
||||
|
||||
Cleanup runs daily. Delivery metadata defaults to 30 days, webhook attempts to 7 days, and administrator audit events to 180 days. Retention changes affect future cleanup and should be documented in the organization's policy.
|
||||
@@ -0,0 +1,29 @@
|
||||
# Security model
|
||||
|
||||
## Primary controls
|
||||
|
||||
- Passwords and mailbox content stay in Stalwart.
|
||||
- OAuth authorization code with PKCE prevents the browser from retaining a reusable password or bearer token.
|
||||
- Access and refresh tokens are encrypted with AES-256-GCM and referenced by opaque HttpOnly session cookies.
|
||||
- Mutating browser routes reject cross-site Origin and Fetch Metadata requests; cookies are SameSite and Secure on HTTPS.
|
||||
- REST API keys are shown once, stored as SHA-256 digests, scoped, sender-bound, rate-limited, and individually revocable.
|
||||
- REST messages are limited to 25 MiB decoded and 100 recipients; header names are allowlisted and CR/LF injection is rejected.
|
||||
- Email HTML is sanitized, remote content is blocked by default, and attachment filenames are reduced to safe basenames.
|
||||
- Webhooks require public HTTPS and reject loopback, private, link-local, unspecified, and multicast resolutions.
|
||||
- External webhooks sign `{timestamp}.{raw_body}` with HMAC-SHA256 and retain event IDs across retries.
|
||||
- Caddy adds HSTS; the application adds CSP, anti-framing, MIME-sniffing, referrer, and permissions policies.
|
||||
- Only 25, 465, 587, and 993 are published for mail. POP3 and plaintext IMAP are absent.
|
||||
|
||||
## Deployment invariants
|
||||
|
||||
Before exposure, confirm that unauthenticated SMTP cannot relay to a third-party domain, sender authorization is enforced on submission, recovery administrator access is removed, and Stalwart's spam/phishing, SPF, DKIM, DMARC, TLS, abuse-ban, and rate-limit defaults remain enabled.
|
||||
|
||||
The internal Docker network is not a trust substitute. Stalwart delivery events use a separate shared HMAC secret. The Stalwart management API is not routed publicly by Caddy; administrators use the authenticated Go adapter.
|
||||
|
||||
## Audit and response
|
||||
|
||||
Administrator mutations write append-only application audit events. Production operators should additionally forward container logs to immutable external storage. Rotate an exposed API key or webhook secret rather than trying to recover it. Revoke active sessions and application passwords after an account incident.
|
||||
|
||||
## Required release review
|
||||
|
||||
Run open-relay, sender-spoofing, brute-force, CSRF, session-fixation, malicious HTML, attachment traversal, API-key leakage, and webhook SSRF tests for each supported architecture. Distribution also requires legal review of the Stalwart AGPL separation and corresponding-source offer.
|
||||
Reference in new issue
Block a user