ServerDock — Threat model
Draft 6, M4a close-out (2026-12-02; plan 0006 step 14; the M4a steps were each reviewed by security, the close-out itself is for security to review and the maintainer to confirm). Draft 5, M3b close-out (2026-12-02; plan 0005 step 15; reviewed by security, who asked for the fix round recorded in plan 0005 Revision 11). Draft 4 was the M3a close-out (2026-11-27). Draft 3 was the M2 close-out (2026-11-21); Draft 2 was reviewed by security at the M2 entry gate (2026-11-20); the M2 and M3a steps were each reviewed by security. AI-written; not confirmed by the maintainer. Earlier drafts are in git history. The M3a close-out was reviewed by security (plan 0004 step 15, 2026-11-27): APPROVE after one revision; ADR 0012 is accepted.
This draft matches the code on branch phase-1-m3a at the close of M3a (plan 0004, steps 1–14: the op protocol v1, the Docker client, the agent ops, jobs and the scheduler, actors in jobs, the policy and container spec, app routes in the embedded Caddy, the service actions, the deploy runner, stop-first, restart, rollback and delete, the reconciler, deploy logs, and the Services, Service and Deploy screens). See M1 close-out status, M2 close-out status and M3a close-out status. The earlier M1 and M2 text is kept where it still holds. The M3a surface is in M3a surface and the accepted risks it adds are under "Added by M3a" in Accepted risks. Draft 5 adds M3b (plan 0005, steps 1 to 15: env vars and secrets, registry credentials, volumes and bind mounts, per-project networks with service DNS, resource limits and OOM reports, the Docker engine check and the Docker RC job, and the screens for them): see M3b surface, M3b close-out status and "Added by M3b" in Accepted risks. The code is on branch phase-1-m3b (PR #15, merged before this change reaches main). Draft 6 adds M4a (plan 0006, steps 1 to 14: domains with automatic HTTPS, certificates you upload, the panel domain, diagnostics, and the screens for them): see M4a surface, M4a close-out status and "Added by M4a" in Accepted risks. The code is on branch m4a (PR #35, merge pending).
Status words used in every table:
- Built means it is in the code on
phase-1-m3a(or the branch of the milestone named in the row), with tests. - Planned (Mx) means it is a binding requirement in plan 0002 for milestone Mx. It is not built.
- Accepted means it is a risk we know about and choose to carry, with the reason given.
- Gap Gn means the plan does not cover it yet. See Gaps.
What we protect
Scroll sideways for more columns
| # | Asset | Where it lives | Why it matters |
|---|---|---|---|
| 1 | Host control | The server process is in the docker group, and the local agent runs in the same process. A remote agent also holds its host's Docker socket. |
Docker socket access is root. Code execution in the control plane means root on the host. |
| 2 | Ingress availability | The embedded Caddy runs in the server process (ADR 0004). | If the server process crashes or is OOM-killed, every app's HTTP(S) goes down, even though the containers keep running. |
| 3 | Hub CA key | DATA/pki/ca.key (0600, directory 0700) |
Today it signs the hub leaf. In Phase 2 it signs agent client certificates. With this key an attacker can impersonate the hub to every pinned agent. |
| 4 | Shared agent token | SD_AGENT_TOKEN, or DATA/agent.token (0600) |
It is the only credential on the agent channel until Phase 2. It lets the holder claim any non-reserved agent id (open item #3). |
| 5 | Admin credentials (M2) | Password hash (argon2id), TOTP seed, recovery-code hashes, in SQLite | Together they grant full control. |
| 6 | Bearer secrets (M2) | Session cookies, API tokens (sd_…) and the setup token (DATA/setup-token, 0600). Only hashes are stored. |
Each one is an authenticated identity while it is valid. |
| 7 | Secretbox master key (M2) | DATA/keys/master.key (0600) |
It decrypts every app secret (from M3b), every uploaded certificate key (M4a), S3 key and notification secret. |
| 8 | Panel TLS key (M2) | DATA/pki/panel.pem (0600, under the 0700 pki/ tree; G10) |
With it, an attacker can impersonate the panel on the IP. |
| 9 | Integrity of history | The hash-chained audit log (built, M1 step 8) and deploy records | Used for incident reconstruction. Tail truncation can only be detected against an older head hash (state backups, M7b). |
| 10 | Release and CI integrity | GitHub repository, branch protection, required checks, and the release signing key (Q5, M7a) | A tampered release, or a tampered self-update, gives root on every install. |
| 11 | App data and state backups | Docker volumes (M3b: named volumes sd-<install id[:8]>-s<service id>-<name>) and bind-mounted host directories, DATA/backups/, DATA/caddy (M4a), S3 |
These hold user data. Until M6 nothing backs up app volumes or bind directories (the early-use rule: disposable or externally backed-up data). A service delete keeps its volumes unless delete_volumes is set, and ServerDock never deletes a bind directory. State backups also contain items 3, 4 and 7, encrypted (M7b): env-version and registry-password ciphertexts are in the database and are useless without the master key; the kept deploy-log files (DATA/deploy-logs/, 0600) are not encrypted and can hold a transformed copy of a secret (accepted risk below), so the M7b backup decides whether to include them. |
| 12 | Domain TLS keys and the ACME account key (M4a) | DATA/caddy: every managed certificate with its private key and the ACME account key, unsealed (directories 0700, files 0600; a secret path) |
With a domain key an attacker can impersonate that domain, the panel domain included; with the account key they can revoke its certificates. Uploaded certificate keys are not here: they are sealed in the database (row 7). |
Deployed shape and trust boundaries (as built on phase-1-m3a)
Scroll sideways for more columns
| Surface | Bound to | Who can reach it | Auth today | Status |
|---|---|---|---|---|
Public HTTP :80 (embedded Caddy, internal/agent/proxy/proxy.go) |
all interfaces | Internet | none. It answers 308 to https://{host}[:port]{uri} (the port of --https-listen as seen inside the process; wrong behind Docker port mapping) and never reaches the control plane. M4a: it also answers the ACME HTTP-01 challenge, the probe path (an HMAC of a random nonce, nothing else), the "not ready" pages for a domain with no certificate yet, and, only while the panel domain is trusted, the redirect from an IP or --panel-host name to the panel domain (GET and HEAD, never /api/, never loopback). |
Built (M2 step 3). The same Host allowlist applies on :80: any other Host gets 421, never a redirect to a name the client chose (TestPanelRedirectHostAllowlist, built in M2 step 6a). |
Panel HTTPS :443 (--https-listen, embedded Caddy) |
all interfaces | Internet | TLS 1.2+ with the self-signed panel leaf (DATA/pki/panel.pem, never issued by the hub CA, fingerprint logged at every start); every handshake gets that leaf (default_sni/fallback_sni = localhost), except a name an admin added: since M4a that name gets its Let's Encrypt certificate or the certificate the admin uploaded, and a listed name with neither gets the panel leaf. Proxied to the control-plane socket, only for panel hosts: with any domain configured, every other Host is routed to the app or answered 421 by Caddy and never reaches the control plane. Every route declares its auth (the route table). The leaf's SANs include the host's addresses at creation; if the host's IP changes, name the panel with --panel-host (a stable name or address), which regenerates the leaf. |
Built (M2 step 3). |
Control-plane HTTP on the unix socket --control-socket (default DATA/run/cp.sock, cmd/serverdock/socket.go) |
no TCP listener; socket 0600 in a 0700 directory owned by the service user, at most 256 connections | Caddy, and the service uid | the route's own auth kind (see the route matrix). Every request must carry exactly one X-Forwarded-For value, which only Caddy sets. |
Built (M2 step 2, G2). |
Agent listener --agent-listen (server.go:220, internal/hub/hub.go) |
the configured address; off by default | Internet when enabled | TLS 1.3 with the hub leaf (pinned CA, role URI SAN), then a shared bearer token checked in constant time after the per-IP failure limiter | Built (ADR 0009, M1 steps 5–6) |
Debug unix socket --debug-socket (cmd/serverdock/socket.go) |
a filesystem path; off by default | the service uid only (0600 socket in a 0700 directory owned by the service user) | filesystem permissions. It can stream any container's logs through the hub. | Built |
Local agent session (net.Pipe, server.go, hub.Attach(LocalID)) |
in-process memory | nobody outside the process | LocalID is reserved: a remote agent can't claim it in any letter case. Only runServer attaches it. |
Built |
| Docker Engine socket | /var/run/docker.sock |
the server process (and a remote agent on its own host) | docker group |
Built. Root-equivalent by design. |
App ports (M3a): one embedded-Caddy server with one listener per service that has a public port (internal/agent/proxy) |
all interfaces, ports 1024–65535, never 80, 443 or ServerDock's own | whoever can reach the host port (the host firewall applies on top) | none of ours. Plain HTTP, h1 only, with the panel's public limits; the app's own login is the only gate. The service's public-port change is an admin action with a confirmation dialog |
Built (M3a steps 6, 6b, 7). By design, not a flaw: an app exposed on a public port is on the internet until the owner firewalls it (QM3a-2). SEC6 warnings below. |
App network (M3a): one Docker bridge serverdock-<install id[:8]> with a subnet ServerDock chose and static addresses |
the host (the subnet is routed on the host); not published on any host port | the containers on it (enable_icc=false: no direct container-to-container traffic), the host, and on Docker before 28 possibly hosts on the same LAN (N13, accepted; Docker 28 and later block this on default settings, an operator can turn that protection off) |
label ownership and the allocator; no firewall of ours | Built (M3a steps 3, 4a, 8a). See B10 and N13 in Accepted risks. |
Deploy logs DATA/deploy-logs/<service id>/<deploy id>.log.gz (M3a) |
the data directory | the service user; deploys.log readers with write scope |
files 0600 in directories 0700; the content is the app's own output and may hold app credentials | Built (M3a step 11). Accepted risk below. |
| Data directory | /var/lib/serverdock by default, created 0700; an existing one must be owned by the running uid with no group or other bits, or the server refuses to start (internal/datadir) |
the service user only | filesystem permissions | Built (M2 step 1). See G6. |
CI (.github/workflows/ci.yml) |
GitHub Actions | PR authors, including forks (read-only token) | Actions pinned by SHA; permissions: contents: read; actions: read only on changes; inputs passed through env:; never pull_request_target; CODEOWNERS on .github/; fail-closed bench-gate |
Built (M1 step 1) |
| Release pipeline, install script, self-update | — | — | — | Not built (M7a, M7b) |
M2 added these surfaces (all built):
:443on the server IP, served by Caddy with a self-signed ECDSA panel leaf. It is never issued by the hub CA (ADR 0009 §3, ADR 0010).:80only redirects to HTTPS until M4a; since M4a it also answers ACME HTTP-01 challenges and the "being set up" pages (see the trust-boundary table).- The SPA embedded in the binary (
-tags spa), served with a hash-based CSP and pre-compressed assets (no Node at runtime). - The setup endpoint, login, TOTP and recovery codes.
- Session-authenticated REST and WebSocket routes, and API-token REST routes.
- The console command
serverdock admin reset.
Trust direction on the agent channel. The agent trusts the hub completely: a compromised control plane controls every server. This is accepted and inherent to the design. The hub trusts nothing an agent sends. An agent may only answer the streams the hub opens, and Phase 1 remote agents get logs only.
Attackers
Scroll sideways for more columns
| ID | Attacker | Example |
|---|---|---|
| A1 | Internet, unauthenticated | Scans :80, :443, :7443; brute-forces login or the setup token; floods connections |
| A2 | On-path network attacker | Sits between the admin's browser and the panel during first run on a self-signed certificate, or between an agent and the hub |
| A3 | Holder of the shared agent token / compromised remote-agent host | Has root on a remote node (or read its environment) and talks to the hub as any agent id |
| A4 | Compromised app container / malicious image | Code running in a user's container, writing hostile log output, probing the host network |
| A5 | Local unprivileged user on the server host | A shell account or another service on the same VPS that is not in the docker group |
| A6 | Holder of a stolen session cookie or API token (M2) | XSS, token leaked from a CI system, laptop theft |
| A7 | Hostile web page in the admin's browser | CSRF, DNS rebinding, clickjacking, cross-origin WebSocket |
| A8 | Malicious repo / PR author (M5, M6) | Hostile Dockerfile, Compose file, symlinks, build args, webhook replay |
| A9 | Prompt injection (M9, and Phase 3 AI) | Log lines or README text steering an MCP client that reads ServerDock output |
| A10 | Supply chain and CI | A malicious dependency, a compromised Action, a tampered release, or a stolen signing key |
| A11 | Console operator (trusted) | Root or the service user on the host. Listed because the recovery paths (admin reset, state restore) exist for them and must not be reachable by anyone else. |
Threats and mitigations by attacker
A1 — Internet, unauthenticated
Scroll sideways for more columns
| Threat | Mitigation | Where | Status |
|---|---|---|---|
Plain-text agent token on ws:// |
wss with TLS 1.3 only; ws:// accepted only for loopback IP literals |
internal/agent/client.go ValidateURL, internal/pki |
Built (open item #1) |
| Agent channel dropped by Caddy reloads | Own listener, not behind Caddy | server.go, ADR 0009 |
Built (open item #2) |
| Guessing the agent token | 256-bit generated token; a hand-made one needs ≥ 43 chars and ≥ 16 distinct; 5 failures/min per IP (burst 10) checked before the compare; one log line per IP per minute | internal/hub/token.go, hub.go ServeHTTP |
Built |
Connection and handshake floods on :7443 |
4 TCP connections per IP and 128 total, closed in Accept before TLS; 5 s handshake/header timeout; no keep-alives |
internal/limits, server.go |
Built. Accepted: a botnet can hold the 128 slots and block legitimate agents. It doesn't touch the panel. |
| Too many sessions | 16 sessions (503 before upgrade) | hub.go reserve |
Built |
| Header and body abuse on HTTP | 64 KiB header limit, 1 MiB body, 10 s header timeout; Caddy read_header 10 s, idle 2 m |
internal/api/api.go, proxy.go |
Built |
| Unauthenticated debug routes over TCP | TCP debug listener and --debug-allow-remote removed; unix socket only |
cmd/serverdock/socket.go |
Built |
| Setup takeover: someone else completes first run (Portainer's init lesson) | Setup token: ≥ 128 bits, single use, stored hashed, compared in constant time, 1 h expiry, sent in the POST body only, file 0600, only its path is logged; setup returns 404 once an admin exists | internal/auth, internal/api |
Built (M2 steps 5–7, G4): TestSetupChecksBeforeHash, TestSetupCompleteIsAtomic, TestConcurrentSetupOneWinner, TestSetupTokenFileModeAndRemoval, TestSetupReopensOnlyWithNewTokenAfterReset, TestFirstRunOverHTTP; Playwright setup.spec.ts (the token screen, an expired token, no token). |
| Password brute force | argon2id (19 MiB, t = 2); per-IP back-off (IPv6 keyed by /64) checked before hashing; one hash at a time with a 2 s bounded wait, then a fast 503 | internal/auth, internal/limits |
Built (M2 steps 4 and 6b, G3): TestBackoffCheckedBeforeHash, TestHasherFast503, TestLoginBusyHasher; sign-in over HTTP in Playwright (setup.spec.ts: busy, back-off countdown). |
| TOTP brute force once the password is known | ±1 step; last counter stored, so codes are never reused; per-account slowdown across IPs with an admin notice | internal/auth, internal/limits |
Built (M2 steps 4 and 6b, G3): TestSecondFactorBackoffAcrossIPs, TestAdminNoticeAfterTOTPFailures, TestReauthFailuresRevokeSession, TestTOTPCounterNeverReused. |
| Per-IP back-off evaded by rotating IPv6 /64s, or by evicting blocked keys | /64 keying; map capped at 4096 keys | internal/limits |
Built. Gap G3: a /48 holds 65,536 /64s (M2: a second per-/48 bucket). Built (M1): evict never drops a currently blocked bucket; when every key is blocked a new key is refused and Blocked reports it as blocked (fail closed). |
| Login availability: distributed attempts keep the single argon2 slot busy | Per-IP limit before hashing; existing sessions keep working; the console can admin reset |
M2 | Accepted (see Accepted risks). Login can be denied while an attack runs; no account is taken over. |
| User enumeration | One admin. A single client gets identical bodies, statuses and timing for a user that exists, one that does not and a reset one (a dummy argon2 hash). Accepted: a multi-IP attacker who first saturates the shared <unknown> back-off bucket can tell a name that does not exist (429) from one that does (401); the user name is not a secret, and the password plus TOTP still guard the account (see Accepted risks). Also accepted: the sub-millisecond lookup differences outside the hasher (a name that fails ValidateUsername skips the UserByName query, and a real admin gets one extra KnownIP query): each is a SQLite read next to a hash of about 40 ms, swamped by network jitter, and TestNoUserEnumeration covers status, body and hash count, not timing |
M2 | Built (M2 step 6b): TestNoUserEnumeration, TestUnknownBucketRevealsExistenceToAMultiIPAttacker |
| Old default credentials (CapRover's lesson) | No default password; first run needs the console token | internal/auth |
Built (M2 step 5): no default password; setup needs the console token (TestFirstRunOverHTTP). |
| ACME on-demand abuse | Names are listed, not discovered (rule 12, plan 0006 D1). Only a name an admin added reaches certificates.automate; every on-demand path is denied by one global deny-all permission module (serverdock_deny), which is present in every configuration that names a domain; a catch-all automation policy with an explicit issuer keeps a leftover name from falling to Caddy's default public issuer. An unknown name in a handshake gets the panel leaf and no order |
internal/agent/proxy (tlsgen.go, deny.go, manager.go) |
Built (M4a steps 4, 5, 8): TestDenyModulePresentWheneverAutomateIsNonEmpty, TestDenyPermissionNeverIssuesOnDemand, TestGeneratorInvariants, TestALeftoverManagedNameIsNeverRenewedOrSentToACA (real Caddy). Without a domain there is no tls app change and no order. |
A2 — On-path network attacker
Scroll sideways for more columns
| Threat | Mitigation | Where | Status |
|---|---|---|---|
| Impersonating the hub to an agent | The agent pins the CA by SHA-256; verifies the leaf against that CA only, for the dialed host, with EKU serverAuth; requires urn:serverdock:role:hub; never consults system roots |
internal/pki/client.go |
Built |
| A leaf for another purpose accepted as the hub | Role URI SAN; CA has MaxPathLenZero; the panel leaf is never issued by the hub CA |
internal/pki/pki.go |
Built; the panel leaf is never issued by the hub CA (TestPanelLeafNotFromHubCA, M2 step 3) |
| Agent bearer token moved by an HTTP redirect | Only a party with a leaf from the pinned CA can send one | client.go (CheckRedirect refuses every redirect) |
Built (M1) (G12) |
| MITM of the first run on the self-signed panel: relaying the setup token, password and TOTP seed | The console prints the leaf fingerprint; onboarding asks the user to compare it with the browser's certificate details before entering the token | M2, ADR 0010 | Built (M2 steps 5 and 12, G5) as far as software can: the token path and the SSH-tunnel hint are on the setup page, the fingerprint is never shown on an unauthenticated page (TestSetupStatusNeverReturnsFingerprint; Playwright checks it), and "Admin created from |
| Cookies or tokens over plain HTTP | __Host- cookie, Secure; :80 redirects (and, since M4a, answers HTTP-01 challenges and "being set up" pages only); API tokens accepted only from the Authorization header |
internal/api |
Built (M2 steps 3 and 6a): TestPanelServedOnHTTPSAndHTTPOnlyRedirects, TestRouteMatrix, TestRouteMatrixSubsetThroughRealCaddy (the redirect, TLS, Host and Origin rules through the real proxy). |
| Users trained to click through certificate warnings forever | An optional panel domain with a trusted certificate; while it is trusted, the IP and --panel-host names redirect to it and refuse sign-in; HSTS on the domain only |
internal/agent/proxy, internal/deploy/panel*.go, internal/api |
Gap G15 closed (M4a step 10). The self-signed panel still teaches a click-through at first use, and always without a panel domain (accepted). See the M4a surface. |
A3 — Shared-token holder / compromised remote agent
Scroll sideways for more columns
| Threat | Mitigation | Where | Status |
|---|---|---|---|
| Claiming another agent's id, replacing its session, feeding fake logs | Remote agents are off by default and experimental; LocalID is reserved in every case |
hub.go |
Accepted until Phase 2 (open item #3; per-agent mTLS identity) |
| Receiving write or secret-bearing ops | Op table where the zero value is local-only; The remote allowlist is {hello, logs} (hello is a read-only version handshake with a 256-byte result); every other op is LocalOnly; unknown ops refused; enforced in Session.open and again in the remote agent's own handler table (two-sided); the negotiated version never widens it; a test pins the allowlist |
internal/agent/protocol.go, hub.go open |
Built (rule 9; M3a step 1) |
| A hostile agent answering a v1 op with oversized, malformed or endless lines, or hostile text | Op protocol v1 framing (ADR 0012): request lines at most 64 KiB, strict decode (unknown fields and any byte after the object refused), progress and event lines at most 1 KiB, one result at most the op's MaxResult (hello 256 B), a progress-line count per op, 4 MiB per op; any violation fails the op as agent_protocol, closes the stream and logs once per op per minute; every string the hub stores or shows is cleaned by agent.CleanText (invisible and control characters, bidi, Zl/Zp, tag block); op payloads stay raw until the op's typed decoder cleans them; keys must match the struct tags exactly with no duplicates (encoding/json alone would match case-insensitively and keep the last duplicate); event lines are exempt from the 4 MiB per-op cap (each is at most 1 KiB, and events is local-only); hello violations are logged at debug only (an old agent answers it with an error line); hello takes no stream slot (one per session, 5 s; see row 110) |
internal/agent/v1.go, clean.go, internal/hub/call.go |
Built (M3a step 1): TestHostileAgentIsRefused, FuzzParseAgentLine, FuzzParseV1Request, TestCleanText. The remote agent process also serves only RemoteOK ops (TestRemoteAgentProcessServesOnlyRemoteOKOps). |
| Pinning hub memory with agent-opened streams | The first agent-opened stream ends the session; the hub opens at most 8 streams per remote session, plus one transient hello stream that takes no slot (row 109); window fixed at 256 KiB (16 sessions x 9 = 36 MiB worst case) |
hub.go attach |
Built (open items #4, #8) |
| Crashing the control plane with a yamux ping flood: each ping SYN makes yamux start a goroutine that waits up to 10 s to queue its reply. An agent that sends pings and never reads makes these pile up without limit. | none | hub.go:228 (yamux.Client on the raw conn), internal/agent/session.go:36 |
Gap G1 (High), built in M1: measured at 640k goroutines / 2 GiB in 1 s over an in-memory pipe (1.88M goroutines with the guard removed in the regression test). Fix: agent.GuardPings wraps the connection on both ends (hub.attach, ServeSession), parses yamux headers, and closes the connection past 4 ping SYNs/s (burst 16), which bounds the goroutines yamux starts per ping (ConnectionWriteTimeout stays at yamux's 10 s). Regression test: TestPingFloodEndsTheSessionAndGoroutinesStayBounded. |
| Oversized WebSocket messages | websocket.NetConn disables the read limit but streams the data; yamux bounds each stream's window and closes the session when a window is exceeded |
library | Built (library behaviour) |
| Hostile log bytes reaching the operator: terminal escape sequences through the debug route; later the browser and MCP | Only raw bytes, to the service uid | hub.go DebugRoutes |
Gap G13 (M8, M9) |
| Reading other nodes' data | The hub never forwards data between agents | hub.go |
Built |
A4 — Compromised app container / malicious image
Scroll sideways for more columns
| Threat | Mitigation | Where | Status |
|---|---|---|---|
| Reaching the control plane directly | The control plane has no TCP listener (a unix socket in a 0700 directory); containers are in their own network namespace; host network is denied by policy (HostConfig.NetworkMode must be our app network) |
socket.go; internal/policy/create.go |
Built (M2 step 2: --internal is removed, so there is no non-loopback case; M3a step 5: the create policy). TestCheckCreateAgentAcceptsTheAllowedBodyAndRefusesEveryFixture (NetworkMode host, bridge, none, container:x, another network) |
Escaping through Compose or service config (privileged, docker.sock, host pid/net/ipc, devices, caps, serverdock.* labels) |
Default-deny policy on the resolved model; label spoofing rejected | internal/policy (CheckCreate, CheckImage, ValidateUserLabels), M3b, M6 |
Built for image deploys (M3a step 5; policy.CheckImage is called by the control plane from the check stage in step 8, while the agent's serverdock.* label check in container_create holds today): TestCheckCreateAgentAcceptsTheAllowedBodyAndRefusesEveryFixture (every key in the plan's "anything else" list, and every wrong leaf), TestCheckCreateControlPlaneRefusesTheSameFixtures, TestCheckImage, TestIsReservedLabelKey (a long s counts as an s), TestUserLabelsRefuseTheReservedNamespaceInAnyCase, FuzzCheckCreate. Built (M3b, steps 1 to 10): the user-supplied settings widen the allowlist explicitly and only through the typed fields: environment, named volumes and bind mounts (Type volume or bind only, Propagation rprivate or unset), memory and CPU limits, SecurityOpt exactly no-new-privileges:true, and a second network on the project's internal bridge (TestCheckCreateAgentAcceptsTheAllowedBodyAndRefusesEveryFixture, TestCreateRefusesAnyMountTypeButVolumeAndBind). Planned (M6): Compose. |
| A control-plane bug or a hostile caller stops, restarts or removes a container ServerDock does not own | The agent refuses container_start, container_restart, container_stop and container_remove unless the container carries exactly our six labels with this install's serverdock.instance (refused_unowned). The ops take only a full 64-hex id (a name or a prefix is invalid, nothing is sent to Docker), inspect it, and act on the inspected id. A serverdock.* label whose value is not already clean text of at most 256 bytes, an over-long key, or more than 16 such labels is dropped and flagged, so the container fails the exactly-six rule instead of passing with a rewritten value. container_list returns only our instance's containers and marks any that fail the rule unowned (never removable); it is never partial: over 1,000 containers or the size cap fails with conflict |
internal/agentops/handlers.go (owned, ownedLabels), internal/agent/dockerapi/containers.go (ourLabels) |
Built (M3a step 3): TestAgentRefusesToTouchAnUnownedContainer, TestOwnershipOpsRefuseShortIDsAndNames, TestOwnedContainerIsActedOnByItsInspectedID, TestOurLabelsDropAndReport |
| A create request that smuggles a privileged option, a host mount, another network or another label | container_create is checked in the agent, on the exact bytes sent to Docker (CreateSpec has only the allowed fields; the policy hook gets the marshalled body). The agent sets serverdock.instance itself and refuses a request that carries it or any label outside the other five. The hook is required (Handlers refuses a nil one; there is no allow-all). policy.CheckCreate (control plane: CheckCreateControlPlane at the deploy's check stage, exactly five labels with the expected values; agent: CheckCreateAgent, exactly six) parses the body into a tree, refuses a duplicate key at any depth (arrays included) and two keys of one object that differ only in case (Docker's decoder is case-insensitive and keeps the last duplicate), caps the body (64 KiB, depth 16, 256 keys per object, 256 array items), then default-denies to the leaves: Image the checked image id; RestartPolicy exactly unless-stopped; LogConfig local with only max-size=10m and max-file=3; NetworkMode our network; PidsLimit 4096; EndpointsConfig only our network with only IPAMConfig.IPv4Address equal to the allocated address; one TCP exposed port; any other key is refused; Docker's reserved network modes (host, bridge, none, default, container:x, any case) can never be the expected network; a service with no container port (a worker) must have no ExposedPorts; errors echo nothing from the body except addresses and key names (cleaned and cut). The address must be a host address of the app network, not its network, gateway or broadcast address, and outside the dynamic range; the network must carry our instance label. The agent also inspects the expected image id and refuses (policy) an image with any serverdock.* label, which would merge into the container and make it unremovable; the container name's deploy and attempt must equal the labels |
internal/agentops/handlers.go (create), internal/policy/create.go, internal/deploy/spec.go (the builder) |
Built (M3a step 3; the full policy in step 5, which deleted InterimCheckCreate): TestCreateSetsTheInstanceLabelItselfAndSendsTheCheckedBytes, TestCreateRefusesCallerSuppliedInstanceOrExtraLabels, TestCreateRefusesAnAddressOutsideTheStaticRange, TestCreateRefusesAnImageWithServerdockLabels, TestCheckCreateAgentAcceptsTheAllowedBodyAndRefusesEveryFixture, TestFiveLabelsForTheControlPlaneSixForTheAgentEachRefusedByTheOther, TestCheckCreateRefusesDuplicateKeysAtAnyDepth (case variants and escapes included), TestCheckCreateRefusesMalformedInput, TestCheckCreateRefusesIncompleteExpectations, TestCheckCreateErrorsNeverEchoValues, TestBuildCreateOutputPassesInBothProcesses, FuzzCheckCreate |
| An image reference that points ServerDock's Docker daemon at the host's own services (a metadata endpoint, the host's loopback) or smuggles a second reference | References are parsed with Docker's grammar (lowercase path, tag and sha256 digest forms, at most 255 bytes, printable ASCII; anything else is refused, never repaired). Registry host rules: link-local addresses (169.254.0.0/16 and fe80::/10, so 169.254.169.254), the other cloud metadata literals (100.100.100.200, 192.0.0.192, 168.63.129.16, fd00:ec2::254; GCP's IPv6 metadata address was not added because it could not be confirmed from its documentation here), the names metadata and metadata.google.internal, multicast, and addresses carried in IPv4-mapped, IPv4-compatible (::a.b.c.d), NAT64 (64:ff9b::/96) and local-use NAT64 (64:ff9b:1::/48, RFC 8215) forms are always refused; the agent applies the same rules to image_pull itself (link-local and metadata always, loopback per the option the server passes from the flag), so a control-plane bug cannot pull from the host's metadata endpoint; a host made only of numeric labels must be a canonical dotted IPv4 address (so 2852039166 and 169.254.43518 are refused); loopback registries (localhost and its aliases localhost4, localhost6, localhost.localdomain, ip6-localhost, ip6-loopback, ip6-localnet and the like, this machine's own host name (full or short, any case), 127.0.0.0/8, ::1, the unspecified address) are refused unless the server runs with --allow-loopback-registry (off by default; used by the integration harness and homelab registries). Other host names are not resolved, so a name that points at an internal address, or that rebinds between the check and the pull, is not caught (accepted leftover: DNS rebinding; the daemon, not ServerDock, makes the connection). Bare names are pulled as :latest so the recorded tag is the pulled one; "same repository" (the write-token rule) compares normalised references (docker.io/library/ default, host case, :443) |
internal/policy/refs.go, cmd/serverdock/server.go |
Built (M3a step 5): TestLoopbackNamesAndThisHost, TestTranslationFormsAreJudgedByTheAddressTheyCarry, TestPullRefusesMetadataAndLoopbackRegistriesInTheAgent, TestParseRefAcceptsAndRefuses, TestRegistryHostRules, TestPullRefAddsLatestOnlyToBareNames, TestSameRepositoryTable, TestAllowLoopbackRegistryFlag, TestIntegrationAgentOpsLifecycle (the harness passes the flag), FuzzImageRef, FuzzSameRepository |
| A deploy that exhausts the host (fork bomb, many services, a full disk, memory or CPU) | CheckCreate accepts HostConfig.PidsLimit 4096 and, only when an admin has set them (M3b), Memory, MemorySwap (equal to Memory, so no extra swap), NanoCpus and SecurityOpt exactly no-new-privileges:true (internal/policy/create.go, checkHostConfig); at most 100 services per install (policy.CheckServiceCount, enforced by services.create in step 7); image_pull refuses below 1 GiB free (policy.CheckFreeDisk); names, health paths, ports and the numeric ranges are validated at the boundary (policy.Validate*) |
internal/policy, internal/agentops/handlers.go |
Built for memory and CPU (M3b steps 10 and 11), partly for the rest. services.set_resources (admin) sets a memory limit (32 MB or more, at most the host's memory; the container gets no extra swap), a CPU limit (steps of 0.05 CPU, at most the host's CPUs) and no-new-privileges, checked against Docker's totals at save and again at the check stage, and frozen into each deploy; an out-of-memory kill is recorded from the events stream (last_oom_at, at most one write per service per minute, no timer) and shown on the Overview, and a candidate that Docker restarts during its health gate fails with reason oom. The limits are off by default (QM3b-3) and there is no disk quota (Docker cannot enforce one on overlay2 over ext4; M8 adds disk alerts): an app with no limit can still use the host's memory, CPU or disk, and the kernel may kill ServerDock (accepted, see Accepted risks). PIDs (4096), the 100-service cap and the free-disk check before a pull are unchanged: TestSetResourcesNeedsAdminAndIsAudited, TestOOMEventReachesTheDatabaseThroughTheReconciler, TestOOMTrackerIsBoundedAndNilSafe, TestOOMEntryRule, TestTheHundredAndFirstServiceIsRefused, TestRangesAndCaps, TestValidatePublicPort, TestPullRefusedBelowFreeSpace, FuzzName, FuzzHealthPath |
| A create name collision (409) adopts or disturbs another container | After a 409 the agent inspects by name and reports "existed" only if the container is ours, has exactly this request's six labels (so the same service, deploy and attempt) runs the expected image id and holds the requested address; otherwise conflict, and the container is never touched |
internal/agentops/handlers.go (create) |
Built (M3a step 3): TestCreateConflictWithForeignContainerFails, TestCreateConflictWithOwnLabelsButAnotherImageFails, TestCreateConflictWithOwnContainerReturnsExisted |
health_check used as a probe of the host or the LAN |
The target must be a host address of our app network's static range: not the network, gateway or broadcast address, not the dynamic range, not another subnet. No redirects, no proxy (the transport never reads the environment), no keep-alive, Host: the IP, at most 4 KiB of body read and discarded, response headers capped at 16 KiB, a 2 s ceiling; a failed probe is reported as a short fixed word, not the Go error |
internal/agentops/handlers.go (health), addr.go |
Built (M3a step 3): TestHealthCheckRefusesTargetOutsideOurSubnet, TestHealthCheckRefusesNetworkGatewayAndBroadcast, TestHealthCheckDoesNotFollowRedirectsOrUseProxyEnv |
| A pull that fills the disk, hangs, or reports success for an image that is not there | image_pull checks free space on Docker's data root first (below 1 GiB: disk_full; unreadable: proceeds and says so), stops with stalled when no byte, status or layer is new for stall_s, throttles progress to about two lines a second, maps ENOSPC to disk_full, and runs ImageInspect after the pull: success is reported only with an image id from that inspect |
internal/agentops/handlers.go (pull) |
Built (M3a step 3): TestPullRefusedBelowFreeSpace, TestPullStallFails, TestPullProgressCoalescedToTwoPerSecond, TestPullInspectsTheImageBeforeReportingSuccess |
| Hostile or oversized agent replies to the typed client | Every reply is decoded with agent.DecodeArgs (unknown, duplicate and case-variant keys refused), checked for plausibility (full ids, canonical addresses, list bounds) and cleaned with agent.CleanText; container_list and network_inspect fail rather than drop an entry the allocator needs, and container_ports flags what it cut |
internal/agentops/client.go |
Built (M3a step 3): TestClientRefusesAMalformedReply, TestClientRefusesImplausibleValues, TestClientCleansTextFromTheAgent, TestContainerListAndPortsResultCaps |
| A new service adopts an old container, or two installs on one Docker host touch each other's containers | Every id (projects, services, deploys, jobs) is AUTOINCREMENT, so a container name and its labels are never reused after a delete; meta.install_id (16 random bytes, created inside migration 0004 and never changed) is the serverdock.instance label and names the app network, so each install acts only on its own resources |
internal/store/migrations/0004_deploy.sql, cmd/serverdock/deploywiring.go |
Built (M3a step 4a): TestIDsNeverReusedAfterDeletingTheNewestService, TestInstallIDCreatedByMigration, TestServerRecordsTheAppSubnetAtFirstStartOnly |
| Two containers get one address, or an address a stopped container still owns is handed to another service | The allocator runs under one lock and asks Docker afresh at each allocation: a fresh container_list with all states (configured address, so a stopped container still holds it), the database (active, queued and running deploys) and network_inspect; the network address, gateway, broadcast and Docker's dynamic slice are never handed out; Docker unreachable fails the deploy docker (retried); the partial unique index deploys_ip_live covers queued and running deploys and refuses a second one with the same address even if the lock were bypassed (the active deploy's address is held by the allocator's DB query and by container_list, not by the index) |
internal/deploy/alloc.go, migration 0004 |
Built (M3a step 4a; called from step 8a): TestIPAllocatorHeldRule, TestIPAllocatorSkipsNetworkGatewayBroadcastAndTheDynamicRange, TestTwoConcurrentAllocationsNeverShareAnAddress, TestDeploysIPLiveIndexRefusesASecondLiveDeployWithTheSameAddress, TestAllocatorFailsRetryableDockerWhenDockerIsUnreachable |
| The app subnet collides with a LAN, VPN or another Docker network | Chosen once at first start (the first free /24 of 10.250.0.0/16, clear of every Docker network, host interface and route), or --app-subnet (validated: /24 to /20, canonical IPv4, only RFC 1918 or 100.64.0.0/10; checked for overlap before it is saved, and an overlap refuses to start); recorded in meta.app_subnet and never changed; each allocation re-checks the overlap (our own network and bridge excluded) and refuses ("changing the app subnet of an existing install is not supported yet") instead of deploying onto a clashing range; running apps are unaffected |
internal/deploy/subnet.go |
Built (M3a step 4a): TestAppSubnetAvoidsExistingNetworks, TestAppSubnetOverlapRefusesDeploysWithAHint, TestAppSubnetFlagIsValidatedFromSlash24ToSlash20 |
| A queued job runs twice, two jobs of one service overlap, or a job table grows without bound | One running job per lock key by a partial unique index (jobs_one_running_per_lock, so even racing pickers cannot overlap), at most two workers, no unknown job state (CHECK constraint); finished jobs older than 30 days are pruned lazily, at most 100 per insert, and a deploy keeps its row with job_id NULL; deploy rows are pruned to the last 200 per service, never the active one |
internal/jobs, internal/deploy/prune.go |
Built (M3a step 4a): TestOneRunningJobPerLockKey, TestWorkerLimitTwo, TestFinishedJobsPrunedOnInsert, TestDeployRowsPrunedToTwoHundredKeepingTheActive |
| A job runs with more power than the user who queued it | Jobs run as the actor that queued them (plan 0004): the job row stores the actor (actions.Actor.JobBlob, rebuilt only by the holder of the one-time SystemInvoker with ActorFromJob, which refuses kind system, unknown kinds and malformed blobs; the runner also checks the blob against the row's kind, id and session). User-triggered kinds are never stored as actor kind system (refused at enqueue by internal/jobs and again at rebuild). At run time auth.Store.RefreshJobActor re-checks the actor against the database: a token must still exist, not be revoked or expired and its user still be the admin, with the scope read from the database (never wider than queued); a user must still be the admin and must not have changed the password or authenticator since the enqueue (admin reset included); signing out or session expiry does not stop a job, but an explicit auth.sessions_revoke (one session or all others) deletes the session and cancels the jobs it queued (queued ones at once, running ones flagged) in ONE write transaction, and enqueue refuses an actor whose session row no longer exists (TestJobQueuedByARevokedSessionIsRefusedAtEnqueue, TestSessionRevokeIsRolledBackWhenTheJobCancelFails; REST: TestRESTRevokeThatCannotCancelJobsIsReportedAndRolledBack). Checked when a job starts: a revoked or expired token, a user who lost the admin role, or a credential change denies a queued job when the runner picks it up; a job that is already running is not stopped by these (only an explicit session revoke or a cancel flags a running job). The credential comparison uses the wall clock, so a clock stepped backwards can let a job queued before a credential change run; this is accepted. The registry then checks the policy again for that actor through SystemInvoker.InvokeAs (audit rows carry the actor, executor = system), so the 5-minute fresh-2FA window and the exact Confirm apply at run time (a destructive job that waited too long fails with the "confirm again" denial). jobs.run_* actions are JobOnly: denied to every call except InvokeAs for a non-system actor, REST 404, absent from OpenAPI, and Register refuses JobOnly with a System reason |
internal/actions (jobactor.go, policy.go), internal/auth/jobactor.go, internal/jobs |
Built (M3a step 4b): TestJobQueuedByTokenCannotReachADeniedAction, TestRevokedTokenJobDeniedAtRunTime, TestExpiredTokenJobDeniedAtRunTime, TestTokenJobScopeComesFromTheDatabase, TestCredentialChangeDeniesAQueuedUserJob, TestDestructiveJobPastTheFreshWindowIsRefusedAtRunTime, TestSignOutDoesNotCancelAQueuedJob, TestExplicitSessionRevokeCancelsThatSessionsJobs, TestActorFromJobRefusesSystem, TestEnqueueRefusesTheSystemActorForUserTriggeredKinds, TestJobAuditRowsCarryTheActorWithExecutorSystem, TestJobOnlyActionsRunOnlyThroughInvokeAs, TestJobOnlyActionsAre404AndNotInOpenAPI, TestRegisterRefusesJobOnlyWithSystemReason |
| An app route sends one service's traffic to another container, reaches something other than an app, or takes the panel down | proxy_apply is LocalOnly (20 s). The agent re-validates the whole list: public ports 1024..65535, never 80, 443, --listen, --https-listen or --agent-listen, no duplicates, at most 100; every upstream must be a host address of our own app network's static range (checked against the recorded meta.app_subnet, read on each call, and the gateway and dynamic range derived from it, with no Docker call (step 6b, Revision 11): never the gateway, network or broadcast address, the dynamic range, loopback, link-local or another network; with no recorded subnet any upstream is refused and static pages still apply. The app network's instance-label and drift check (ourNetwork) is no longer made on proxy_apply: network_ensure checks the network fully at boot (label, subnet, options), and container_create and the health check check its label on every deploy, so a missing, foreign or drifted network is caught at deploy time; the recorded row is validated with the --app-subnet rule (/24 to /20, private space) and anything else is "could not be read", so no upstream is applied); a static route takes a fixed page by name only. The control plane emits an upstream only when its state map holds a container with this service's id and the target deploy's id, bound to exactly that address (the configured one), running or restarting; anything else gets the "not running" page, so an address collision cannot route to another service. All app ports are listeners of one plain-HTTP, h1-only server with the panel's public limits (step 6b, Revision 11). A serverdock_app handler looks the request's local port up in an immutable table that only the agent's Applier writes (package-global, so exactly one Applier per process, server mode only) and either answers the static page itself or sets the request variable sd_upstream for the one reverse_proxy, which dials {http.vars.sd_upstream}. A client cannot set http.vars (Caddy creates the map per request, caddyhttp/server.go:1412); the handler never calls next without setting it; the reverse_proxy has no passive health checks, max_requests, retries or dynamic upstreams, so a failing app cannot mark the shared host down for another; it ignores HTTP_PROXY and friends (network_proxy: none). Tested by TestClientCannotInjectUpstream, TestReverseProxyWithoutTheVarFailsClosed, TestHandlerUnderConcurrentSwaps, TestFailingAppDoesNotAffectAnother. The panel servers and the remote agent's config are unchanged (golden tests). A port another program holds fails alone (failed_ports, retried by RetryFailedPorts and by explicit callers); Caddy keeps the previous config when a load fails; Caddy's error text stays in the agent log. An error from proxy_apply means the outcome is unknown, so the next call always sends. One global route lock serialises every change, so concurrent switches cannot lose each other. Accepted: a route change can make a brand-new or reused connection get no response (never processed; safe to retry), see plan 0004 Revision 9 |
internal/agent/proxy (applier.go, proxy.go), internal/agentops/proxyapply.go, internal/deploy/routes.go |
Built (M3a step 6): TestPanelConfigUnchangedWithApps, TestAppRouteGolden, TestAppRouteIgnoresProxyEnvironment, TestBindFailureIsolatedToOnePort, TestProxyApplyRefusesBadRoutes, TestProxyApplyRefusesUpstreamOutsideTheStaticRange, TestProxyApplyNeedsNoDocker, TestSubnetRecordedAfterBoot, TestUpstreamOnlyForTheServicesOwnContainerAtItsAddress, TestConcurrentRouteChangesForTwoServicesLoseNothing, TestOutcomeUnknownErrorForgetsTheHashSoARevertIsSent |
| A token chooses what runs or where it is exposed beyond its power | The actions that choose what runs or where it is exposed (services.create, services.set_source, services.set_public_port, services.retry_port) need admin scope (a session or an admin token); services.update needs write and accepts an image_ref only as another tag or digest of the repository the service already deploys (policy.SameRepository, normalised), for every actor; no token can run a destructive action (services.delete is user-only with fresh 2FA and a typed target); MCP is read-only. Changing the container port of a service that has a public port also needs admin (it decides where the exposed traffic goes): a write token is refused with a clear message. Image references are validated with --allow-loopback-registry at create, update and set_source, and again by the deploy runner (step 8a): before the pull (by tag and, for a redeploy or rollback, by digest) and at the check stage, with the install's current options; |
internal/deploy/services.go, internal/actions/policy.go |
Built (M3a steps 7 and 8a): TestTokenScopesForServiceActions (including the container-port rule), TestServiceActionRiskAndScopeTable, TestServiceUpdateSameRepositoryRule, TestServiceActionsRouteMatrix, TestImageRefIsRevalidatedWithTheInstallsOptions |
| A write token queues or cancels a deploy to run something else, or undoes an admin's choice | services.deploy and deploys.cancel need write scope; services.deploy accepts an image_ref only as another tag or digest of the repository the service already deploys (policy.SameRepository, for every actor; another repository needs services.set_source, admin). The deploy's enqueue transaction refuses (conflict) when the service's image changed since the request read it, so a write token cannot undo an admin's set_source in a race. deploys.cancel checks the deploy's stage in the same transaction that sets the cancel flag (switch, commit, drain and stop_old answer 409 not_cancellable). A snapshot's repo_digest must be a digest of the snapshot's own repository |
internal/deploy/deployactions.go, internal/jobs/store.go, internal/deploy/snapshot.go |
Built (M3a step 8a): TestServicesDeploySameRepositoryRule, TestDeployCannotUndoAConcurrentSetSource, TestCancelDeployChecksTheStageAtomicallyWithTheFlag, TestSnapshotRepoDigestMustBeADigestOfTheSameRepository, route matrix rows |
| The deploy runner acts on a container that is not its own, or leaves its work behind | The runner trusts a container_inspect result only when the agent says owned AND the labels name this service, deploy and attempt, and the configured address equals the one allocated; otherwise it forgets the id and the clean-up goes by labels. After a create whose reply never came (a timeout) the clean-up lists the install's containers and removes those carrying this service, deploy and attempt, never by an id it did not receive, and a name collision with a container ServerDock does not own touches nothing. Clean-up runs on a fresh context (30 s, 5 s at shutdown) and the end of the deploy on another, so a cancelled job cannot stop it; a panic runs the same clean-up. The queue ends a deploy row with its job (jobs.Store.Finish), so no row stays queued or running holding an address |
internal/deploy/rundeploy.go, internal/jobs/store.go |
Built (M3a step 8a): TestInspectIsTrustedOnlyWhenOwnedAndTheLabelsMatch, TestTimedOutCreateIsCleanedUpByItsLabels, TestForeignNameCollisionFails, TestPanicInAStageRemovesTheCandidateAndEndsTheRow, TestFinishEndsTheDeployRowTheRunnerLeftLive, TestRecordFinalFailureStillLeavesAFinalRow |
| A deploy stops the live version before the new one is committed, or a cancel, a deadline or a failed apply leaves traffic on a container the database does not know | The previous container is stopped only after the commit transaction, on every path (stopOld refuses to run unless the commit has happened, and never touches the candidate's own deploy); the switch and the commit run on a context cut off from the job's (a cancel, a supersede, a session revoke, a shutdown or the jobs.timeout_s watchdog cannot reach them), each with its own bound (30 s, 10 s, route lock wait included; the lock is a channel semaphore taken in a select against that context); entering the switch is one write that reads the job's cancel flag and sets the stage, and deploys.cancel sets the flag in a write that checks the stage, so a cancel either stops the deploy before the switch (the candidate is removed, the old version kept) or answers 409 not_cancellable; the commit is the mutate of the no-retry route apply (it never retries or reloads for another service's failed port) with a compare-and-set on active_deploy_id and clears the override in the same step; any exit between the switch and the commit (a failure, a panic, an early return) first unwinds the routes (finish calls unwindSwitch: the override is cleared and the database's routes re-applied on a fresh context) and only then removes the candidate, so no route names a container that is gone and whose address could be handed to another service; clearing an override never needs the route lock (it is removed under its own short mutex before the re-apply, so a repair that cannot win the lock within its bound still leaves no override); a candidate the routes pointed at is stopped with stop_grace_s; a candidate is re-inspected right before the switch and refused unless running; a shutdown ends the drain through the scheduler's own stop signal even when an earlier supersede hid it from the job's cancel cause; the queue never records a committed deploy failed, cancelled or superseded; a failed switch or commit re-applies the database's routes on a fresh context, and when the proxy does not confirm that the candidate is kept (the proxy may still point at it) rather than removed and app_safe is unknown; an unknown commit outcome (the database errored and cannot be read) keeps both containers; after the commit nothing can fail the deploy: a failed write is a warning on a succeeded deploy ("record incomplete"), a panic never removes the live version, and a succeeded job settles a committed deploy row the runner could not end. A shutdown during the drain ends the committed deploy succeeded at once with an honest reason (the previous container is removed at the next start); a failed write is covered by the queue backstop and the boot pass. The routes still go through the one route lock and proxy_apply's own validation: the override can only name the candidate's own recorded address, and an upstream is emitted only for a container of this service and deploy running at that address |
internal/deploy/switch.go, internal/deploy/routes.go (CommitRoutes, the route lock), internal/jobs/store.go |
Built (M3a step 8b): TestCommitOrder, TestStopOldRefusesToRunBeforeTheCommit, TestSwitchAndCommitAreNotCancellable, TestDeadlineNeverCutsSwitchOrCommit, TestFailedSwitchReappliesOldRoutesWithAFreshContext, TestFailedReapplyKeepsTheCandidate, TestCancelRequestedJustBeforeTheSwitchRefusesTheSwitch, TestPostCommitWriteFailureIsAWarning, TestPanicAfterTheCommitKeepsTheNewVersion, TestCommitRoutesNeverRetriesAFailedPort, TestRouteLockWaitHonoursCtx, TestPanicAfterTheSwitchUnwindsTheRoutesBeforeRemovingTheCandidate, TestClearOverrideNeedsNoRouteLock, TestRepairThatLosesTheLockWaitStillClearsTheOverride, TestShutdownAfterASupersedeDuringTheDrainReturnsPromptly, TestUnknownCommitOutcomeKeepsBothVersions, TestADeadCandidateIsNeverSwitchedTo, TestSucceededJobSettlesACommittedDeployRow, TestDeployStateMachine; integration TestBlueGreenSwitchWithZeroNon2xx |
| A stop-first deploy leaves an app down, or lets traffic reach a stopped or half-started container | Stop-first shows the maintenance page (503, Retry-After: 10) as a route override (a table swap: no Caddy load on the page, the new upstream or the way back), then stops the previous container (kept, not removed), starts the candidate, gates it, switches and commits (no drain), and removes the old container last. Any failure or cancel after the page went up takes it down again; after the stop it first starts the previous container again on a FRESH context (health_timeout_s + 30 s, 5 s at shutdown), runs the same health gate on it and only then clears the override: app_safe is yes when it is serving again, no with "the previous version did not come back: previous_version_down, shown as ◆ Needs attention, and the route serves the "not running" page, never an upstream to a stopped container) when it is not, unknown when the proxy cannot confirm. A switch or commit failure puts the maintenance page back, not the stopped container's address. If the candidate is kept (the revert is not confirmed, or the commit's outcome is unknown) the previous container is NEVER started (two versions must not run): app_safe is unknown, the service is flagged versions_kept, and the resync settles it; while a service is flagged versions_kept, services.restart and every stop-first deploy, redeploy or rollback are refused (409; blue-green may go on and its commit clears the flag), so the stopped previous container is never started beside the kept candidate (TestVersionsKeptRefusesRestartAndStopFirstWork), and the flag is read again at RUN time under the service lock, so work queued before it was set (a stop-first deploy, redeploy or rollback, or a restart) fails with the same message and touches nothing (TestWorkQueuedBeforeVersionsKeptIsRefusedAtRunTime); the revert replaces the override in the map before it waits for the route lock, so the map never names a candidate that is being undone. A cancel or shutdown during the stop does not cut it (the stop runs on its own bound, then the previous version is started again); a queued delete during the gap skips the restore |
internal/deploy/stopfirst.go, internal/deploy/switch.go, internal/deploy/rundeploy.go |
Built (M3a step 9): TestStopFirstGapThenCommit, TestFailedStopFirstRestartsTheOldContainer, TestCancelAfterStopOldFirstRestartsTheOldContainer, TestOldVersionThatDoesNotComeBackIsAppSafeNoAndNeedsAttention, TestStopFirstSwitchFailureRestoresThePreviousVersion, TestShutdownDuringTheGapRestartsTheOldContainerWithinTheShortBound, TestStopFirstUnknownCommitOutcomeTouchesNothingMore, TestFailedRevertInTheGapNeverStartsTheOldContainer, TestStopFirstKnownCommitFailureRestoresThePreviousVersion, TestCancelDuringTheStopStillRestoresThePreviousVersion, TestDeleteDuringTheGapSkipsTheRestore, TestShutdownRestoreThatRunsOutOfTimeIsUnverifiedNotDown, TestReplaceOverrideWritesTheMapBeforeTheLockWait; integration TestIntegrationStopFirstGapUnderLoad, TestIntegrationFailedStopFirstRestartsOldUnderLoad (strict: only 2xx or the maintenance 503 with its Retry-After, 0 drops, 0 retries, 0 Caddy loads, 10 runs) |
| A write token runs an old or unsafe version through rollback, redeploy or restart, or one of them reloads the proxy | services.restart, services.redeploy and services.rollback need write scope (like services.deploy); their runs (jobs.run_restart, jobs.run_deploy) are JobOnly and run as the actor that queued them. A rollback target must have been live (committed_at; 400 otherwise), is never the live deploy, and runs the target's snapshot pinned to its image_id (and repo_digest, which must be a digest of the snapshot's own repository; with the local image removed it pulls that digest through the same registry rules, and with none it fails image_gone); a redeploy pins the live deploy's image. Neither changes the service's desired image. A write token cannot roll back to a version from another repository than the service's current one, nor to one with another container port on a service that has a public port (admin token or session only, as for services.deploy and services.update; checked again against the service's current image, public port and container port inside the enqueue's transaction). A restart uses the container the live deploy's labels name (owned, this service, this deploy) and succeeds only after its health gate. None of the three calls a route function beyond a deploy's own table swap, so none reloads Caddy |
internal/deploy/deployactions.go, internal/deploy/restart.go |
Built (M3a step 9): TestRollbackPinsTheImageIdAndRunsThatSnapshot, TestRollbackToADeployThatWasNeverLiveIsRefused, TestRollbackWithTheLocalImageRemovedPullsByDigest, TestRollbackWhenTheImageIsGoneFailsImageGone, TestRedeployRecreatesAMissingContainer, TestRestartKeepsTheAddress, TestRestartRedeployRollbackScopesAndJobOnly, TestRollbackNeedsAdminForAnotherRepositoryOrPort, TestCancelDuringARestartDoesNotCutItAndASuccessfulRestartClearsTheFlag; integration TestRollbackRedeployAndRestartMakeZeroCaddyLoads |
| A service delete is run by a token, without fresh 2FA, on the wrong target, or removes something that is not the service's | services.delete is destructive: admin scope, every API token is denied (read, write and admin), a user needs fresh 2FA and Confirm equal to <project>/<service>. The job (jobs.run_service_delete, JobOnly) runs as the user who queued it, re-checks the policy at run time (the window comes from the job's actor blob), and a window that passed while the service was stopping fails the job with "Confirming again is needed: the 5-minute window passed while the service was stopping", deletes nothing and flags the service delete_confirm_again (so the page can offer "Delete again"; a new delete or a committed deploy clears it; it is not delete_interrupted, so the reconciler still starts the service). Queuing cancels the service's queued deploys and restarts and flags its running job in ONE transaction; a deploy past its commit skips the rest of its drain and stops the old container with its normal grace; new work for a service with a pending delete is refused. The route is taken away FIRST: under the route lock the service's override is set to the "not running" page and the apply must be confirmed (ErrRoutesNotReady counts: nothing is routed); if the proxy cannot confirm it, the job fails with delete_interrupted before any container is touched, (a failed delete clears that override again and the routes follow the database; its rows and the active deploy's address are still held) so a stale proxy can only ever show a static page, never an upstream to an address the allocator might hand out again (the container, still existing, also keeps the address held). The run then removes only containers the agent's list calls owned (this install's instance label) AND labelled with this service (a look-alike with another instance label, a container with no labels and another service's container are never addressed, and the agent refuses them again); deletes DATA/deploy-logs/<service id> through a validated path (absolute root, positive id, exactly one level under it; a symlink is removed, never followed); then deletes the rows (and the project with its last service) as the mutate of the no-retry route apply, so the route goes with them. The run itself is not cut by a cancel (a session revoke) once it holds the service lock: it runs on a context cut off from the job's, every call under its own bound, and any failure flags the service. Deleting an exposed service is a port-set change and reloads Caddy (a documented reload case). Every step is idempotent: an interrupted delete flags the service delete_interrupted and is run again |
internal/deploy/delete.go, internal/jobs/store.go, internal/deploy/interrupted.go |
Built (M3a step 9): TestTokenScopesForServiceActions (read, write and admin tokens denied against the real services.delete), TestDeleteTokensAreDeniedAndAUserNeedsFresh2FAAndTheExactConfirm, TestDeleteAfterTheFreshWindowExpiresAsksToConfirmAgain, TestDeleteRemovesOnlyThisServicesContainersLogsAndRows, TestQueuingTheDeleteCancelsQueuedWorkAndFlagsTheRunningDeploy, TestRunningDeployPastItsCommitSkipsTheRestOfItsDrain, TestDeleteLogDirIsValidated (including a symlink inside the directory that points outside), TestDeleteTakesTheRouteAwayFirstAndNeedsItConfirmed, TestRevokeDuringADeleteNeverLeavesItHalfDone, TestInterruptedDeleteNeedsAttention, TestEnqueueDeleteCancelsQueuedFlagsRunningAndRefusesNewWork; integration TestDeleteRemovesOnlyLabelledContainers (a look-alike with another instance label survives) |
| A job runs after the actor that queued it lost the right to; a refusal leaves no trace | Every attempt rebuilds and refreshes the actor before anything runs. A refusal at the refresh (token revoked or expired, credentials changed, no longer an administrator) writes one denied audit row with the job's actor and executor system (SystemInvoker.RecordDenied), is logged at warn, and ends the deploy denied with a fixed reason; a refusal by the registry (a scope narrowed to read) writes its own denied row. Nothing is pulled or created |
internal/deploy/runner.go, internal/actions/system.go |
Built (M3a step 8a): TestDeniedAtRunTimeEndsTheDeployRowOnEveryAttempt (revoked, expired, credential change, scope narrowed; attempt 1 and a retry) |
| Deploy logs leak credentials the app printed (a generated admin password, a setup token), or a hostile log attacks the reader | Container output is sensitive. DATA/deploy-logs/<service id>/<deploy id>.log.gz is written 0600 in a 0700 directory (the root and the service directory are created 0700 and tightened with Chmod if something else made them looser; every operation (keep, read, list, prune, and the delete's RemoveAll) Lstats the root and the service directory first and refuses a link in either place, and a read opens the file with O_NOFOLLOW and checks it is a regular file; the file is written to a temporary file in the same directory and renamed, so a reader never sees a half-written log). The tail comes from the agent's logs op with follow:false, tail:2000, and at most 1 MiB is kept (header, stage lines and output together), streamed through a pooled gzip writer with no whole-log buffer. When the tail does not fit, the NEWEST lines are kept: the tail is asked for again with fewer lines (at most four more times, each read bounded by the cap), and a final cut says honestly what is missing. There is one file per deploy: a second container of the same deploy replaces the first, and the header names the container. The previous version's and an orphan's output is kept after the stop and before the removal; a failed candidate's before its stop, never at shutdown (the resync keeps a leftover candidate's log), within a third of the clean-up time left and 3 s in the stop-first gap. A service deleted while a log is written does not get its directory back. At most two deploys.log reads run at once (a third is told to try again), and the first resync after a start removes log directories of services that no longer exist. deploys.log needs write scope for a token (a read token is refused; MCP is read-only and never gets it; users need no more than their session) and returns the file through a 1 MiB io.LimitReader (a gzip bomb cannot expand in memory) and agent.CleanLogText: ESC (so CSI and OSC sequences lose their introducer), NUL, CR and every other C0 control, DEL, the C1 controls, bidirectional overrides and isolates (U+202A to U+202E, U+2066 to U+2069), the marks U+200E, U+200F and U+061C, zero-width and other format characters and the line and paragraph separators are removed; invalid UTF-8 becomes U+FFFD; the UI renders it as text only (G13). deploys.get and deploys.list return no log text. A write failure never fails a deploy: the stage says "log not kept: deploy-logs/ is not in datadir.SecretPaths (that list holds ServerDock's own secrets, and the sentinel scan treats every other DATA file as non-secret): plan 0005 adds a sentinel test over deploys.log, deploys.get reasons and stage details once app secrets exist, and plan 0009's doctor --bundle must exclude deploy-logs/ |
internal/deploy/deploylog.go, internal/deploy/deployreads.go, internal/agent/clean.go |
Built (M3a step 11): TestDeployLogFileIsGzipPrivateAndHoldsHeaderStagesAndTail, TestDeployLogDirectoryIsTightenedAndLinksAreRefused, TestDeployLogPathsValidateTheirIds, TestDeployLogCapHoldsForHugeOutput, TestDeployLogReadIsLimitedAgainstAGzipBomb, TestDeployLogRetentionKeepsTheLastTenPerService, TestDeploysLogOutputIsSanitised, TestCleanLogTextRemovesEveryControlAndBidiCharacter, TestDeploysLogNeedsWriteScopeAndMCPNeverGetsIt, TestDeleteRemovesRealDeployLogs, the route matrix rows for deploys.log; integration TestDeployLogCapHoldsForAContainerThatLogs50MiB (real Docker, 50 MiB) and the kill -9 suite on the built binary (modes 0700, 0700, 0600 and the tails of the old container and the candidate) |
| Test-only pause points ship in the binary | The deploy runner's pause points (SERVERDOCK_TESTHOOK_PAUSE, SERVERDOCK_TESTHOOK_DIR) exist only in a build made with -tags testhooks, which only internal/testbin uses; the default build has an empty function and no reference to those variables |
internal/deploy/hooks_off.go, hooks_on.go, internal/testbin/testbin.go |
Built (M3a step 8a): TestDefaultBuildHasNoTestHooks (the go list file sets), TestPausePointBlocksOnlyWhereNamed (tag build, CI) |
| A public port is set on one of ServerDock's own ports, or two services take one port | policy.ValidatePublicPort with one list of reserved ports (--agent-listen, --listen, --https-listen, plus 80 and 443) shared by the service actions and the agent's proxy_apply; uniqueness is a database UNIQUE; a port saved but not applied (routes not ready, proxy error, bind failure) is reported as not applied, never as success |
cmd/serverdock/server.go (reservedPorts), internal/deploy/services.go |
Built (M3a step 7): TestPublicPortIsUniqueAndReserved, TestReservedPortsAreOneListForTheAgentAndTheServiceActions, TestSetPublicPortBeforeTheBootGateIsNotReportedApplied, TestBindFailureIsReportedAndRetried |
| SSRF from ServerDock fetches (git, S3, webhooks, notifications) toward metadata, loopback, Docker gateways or RFC 1918 | internal/netpolicy checks the dialed IP in DialContext; per-target audited allowlist |
rule 10; M5, M6, M8 | Planned. Accepted (documented in M5): the BuildKit DNS-rebinding window. |
| Hostile log output (XSS, escape sequences, prompt injection) | Deploy logs only (M3a): cleaned on the server by agent.CleanLogText before anything is returned, rendered by the SPA as text only with the header kept visually apart from the container's output (a container can print lines that look like header lines); deploys.get and deploys.list carry no log text. Not covered: live logs in the browser (M8), the debug socket's raw bytes, and MCP (M9) |
internal/agent/clean.go, internal/deploy/deployreads.go, web/ |
Partly built (M3a steps 11 and 14, G13): TestDeploysLogOutputIsSanitised, TestCleanLogTextRemovesEveryControlAndBidiCharacter; Playwright deploy-detail-log.spec.ts (a hostile log line renders as text, zero axe violations). Gap G13 stays open for M8 and M9. |
| Accepted risk B10: an app container, or anyone who may deploy, reaches the host's network | A deployed container is unprivileged (policy), has a PID limit and cannot touch the host's files, but it can open connections like any program on the host. ServerDock does not firewall containers in Phase 1. The permission to deploy is therefore a grant of that reach. See Accepted risks | internal/policy/create.go (what the container cannot do); no network control |
Accepted (M3a, step 15). |
| Accepted risk N13: on Docker before 28.0.0, hosts on the same LAN may reach unpublished app ports | Docker 28.0.0 and later block it by default. ServerDock never publishes app ports. On an engine that knows the option (API 1.48, Docker 28.0 and later) it creates a network with both gateway_mode_ipv4 and gateway_mode_ipv6 set to nat (gatewayModeOptions, so a daemon-wide default cannot give a new network another mode); on older engines it sets none; enable_icc=false does not help against traffic from outside the host. See Accepted risks and research 06 (on GitHub) |
internal/deploy (network_ensure) |
Accepted (M3a, step 15); M3b adds the warning and a refusal. On every events (re)connect the control plane reads the engine's version; for a version before 28.0.0 it logs Pre28Warning and system.docker reports it, and the Overview Server card shows a standing warning worded "may be reachable" (it cannot see the firewall). network_ensure and project_network_ensure refuse a network whose gateway mode is not unset or nat (nat-unprotected), and any driver option ServerDock does not set; new deploys are refused and the Overview links the recovery steps (architecture.md, Gateway mode recovery). The warning is not a fix: the daemon-wide allow-direct-routing option (Docker 28.2.0 and later) is outside every network's options and ServerDock cannot see it; it opens direct routing to published ports only (ServerDock publishes none on the host) and is recorded in N13. TestNetworkEnsureRefusesNatUnprotected, TestIntegrationNetworkEnsureRefusesNatUnprotected, TestNetworkCreateSetsTheGatewayModeOnlyOnAPI148, TestPre28WarningOnlyBelow28AndNeverOnAnUnknownFormat, TestSystemDockerShowsWhatIsRemembered, TestInfoParsesVersionsLeniently, TestEventsFilterUnchanged. |
| A registry host or image pull used to reach the host's own services (SSRF through the Docker daemon) | The checks listed in the image-reference row are cosmetic against a determined deployer: the Docker daemon, not ServerDock, makes the connection, so internal/netpolicy's dial-time check (rule 10, M5) cannot sit on that path, a registry can redirect and its token realm can point anywhere, and a name can resolve to any address. They stop accidents and the plainest literals. See the registry-host deferral under Accepted risks |
internal/policy/refs.go |
Closed for what ServerDock can check, with accepted leftovers (M3b step 6). At each pull the control plane resolves the registry host (5 s bound; a failed lookup is transient) and checks every address (rule 10): a private-range address or this host's own needs the registry's allow_private, loopback needs --allow-loopback-registry, link-local and cloud-metadata addresses (6to4, Teredo and site-local forms included) are always refused, and one blocked address refuses the pull. A credential is built only for the host of the reference being pulled, tied to it by serveraddress (the agent refuses another registry), and sent in that one pull (no docker login). Docker Hub is not resolved (a fixed public service). TestPrivateAddressNeedsAllowPrivate, TestPullRechecksTheAddressAtEachPull, TestPullSendsCredentialsOnlyForTheMatchingHost, TestPullAuthIsTiedToTheImagesRegistry, TestRegistrySecretNeverReturnedOrLogged, TestPrivateRegistryDeployWithAuth, FuzzCheckRegistryAddrs. Leftovers, accepted: the check happens before the daemon connects, so DNS rebinding between ServerDock's lookup and the daemon's own still works; the registry's token realm and blob redirects can point anywhere; a daemon-side HTTPS_PROXY or registry-mirrors setting sends the daemon somewhere the check never saw; a name only the daemon can look up fails as "could not be checked". Credentials belong to one install and one exact host key (reg:443 and reg are two). The Docker Hub serveraddress (https://index.docker.io/v1/) was not verified with real Hub credentials. The registry, or whoever answers for its name where TLS is not verified, can make the daemon send the stored password to another host (the token realm). Store a pull-only, least-privilege token, not an account password, and do not pair credentials with insecure-registries. |
| Reaching the agent listener | Needs TLS and the token, like A1 | — | Built |
A5 — Local unprivileged user on the host
Scroll sideways for more columns
| Threat | Mitigation | Where | Status |
|---|---|---|---|
Calling the control plane on 127.0.0.1:7070 directly, skipping Caddy, and forging X-Forwarded-For to defeat per-IP back-off (1Panel CVE-2025-66508 class) |
ClientIP(r) reads X-Forwarded-For only on a connection marked "from our proxy" (ConnContext, set only for the control socket), and only as exactly one value holding one IP; otherwise it is ignored (RemoteAddr). Loopback is trusted for nothing. Caddy has no trusted_proxies, so it replaces a client's value. |
internal/limits, internal/api WithTrustedProxy, cmd/serverdock/socket.go |
Built (M2 step 2, G2): TestForgedXFFOnSocketIgnoredByCaddy (real Caddy), TestXFFIgnoredWithoutSocketMark, TestMultipleXFFValuesRejected, TestProxyMarkIsPerListener, FuzzParseForwarded. |
| Reading the DB, keys or tokens | DATA/pki 0700; key and token files 0600; the debug socket directory must be 0700 and owned by the service user |
pki.go, token.go, socket.go |
Built. Gap G6, partly built (M2 step 1): DATA is 0700 and checked at start (datadir.Prepare), and the process umask is 0077 (serverMain), so SQLite's -wal/-shm and Caddy storage are private. The TOTP seed is sealed in secretbox (M2 step 5, TestTOTPSeedNotInDBPlaintext). |
Reading SD_AGENT_TOKEN from the environment (systemctl show prints Environment= to any user) |
The generated-token file is the default when no env var is set | server.go:113, agent.go:72 |
Gap G11 (M7a) |
| Using the debug socket | 0600 socket, 0700 directory owned by the service user, checked at start | socket.go |
Built |
A local user, or a container with a writable bind mount, swaps a directory inside a bind root for a symlink, or leaves a setuid file or device node in its mount: a root container can chmod its own mount root, leave a setuid file there, or mknod (a default capability), so what it creates is the container's, not the operator's (plan 0005 step 8) |
Bind mounts are off without --bind-root. A root must be an existing directory outside the denied set (DATA, the Docker, control and debug socket directories, Docker's data root, /etc, /usr, /run, ... and every ancestor of them), not nested in another root, and not used while ServerDock runs in a container. The root and every source have no permission bit for "other", each ancestor up to / is not other-writable, all are owned by root or ServerDock's user and not group-writable unless the group is root's or ServerDock's own, none has a POSIX ACL; a source may not be a root itself, so a directory the container cannot chmod always lies above its mount. The defence against the container-created swap is the overlap rule: no two bind sources overlap, in any service or the same one, judged against every other service's list, every queued, running and live deploy and every container of this install in any state, with paths resolved afresh. The path is resolved and judged at save, at the check stage and again in the agent right before the create; a source must be its own real path (a link is refused at save and at the check stage, and the agent refuses instead of swapping), so what is recorded is what Docker mounts. Advice: put each root on its own nosuid,nodev mount (the mount flags decide whether a setuid file or a device node works; the start warns when a root is not on such a mount, and does not refuse, because that would keep bind mounts off on most hosts). ServerDock's group must be private to it: the rules accept a directory that ServerDock's group may write, so the start warns when /etc/group lists other members of that group, or members of root's group (gid 0) other than root. The warning reads only the member lists in /etc/group: it misses users whose primary gid is that group (/etc/passwd) and groups served by NSS sources such as LDAP or sssd, so a quiet start is not proof that the group is private. Accepted: Docker mounts a bind by path at every start of the container, so a swap after the re-resolve is followed at any later start (a restart included); the actors are a host user who can write inside the root and a container that writes the same path. On kernels before 5.12 read_only is not recursive. |
internal/policy (bind.go, mountinfo.go), internal/deploy (volumes.go, mounts.go), cmd/serverdock (--bind-root, bindRootWarnings) |
Built (M3b step 8): TestBindRootRefusesAncestorsOfDeniedPaths, TestNestedBindRootsAreRefused, TestBindRootOwnerAndModeRules, TestRootItselfIsRefusedAsASource, TestOverlapSeesQueuedAndRunningDeploysAndKeptContainers, TestOverlapAtTheCheckStageSeesEverySource, TestRollbackRerunsTheOverlapCheck, TestBindRootMustBeNosuidNodevOrWarns, TestAgentSendsTheReResolvedBindPath, TestBindConfigCarriesTheRootsAndBothSockets, FuzzBindPath |
Running admin reset or state restore |
Console only; takes the data-dir flock (refuses while the server runs); runs only as the uid that owns DATA (root against another owner is refused with a sudo -u <owner> hint, so no root-owned file can appear in DATA) |
M2, M7b | Built for admin reset (M2 step 7): TestAdminResetRefusedWhileTheServerRuns, TestAdminResetAsRootOnDataOwnedByAnotherUserIsRefused, TestAdminResetNeedsATerminalOrYes; state restore is M7b |
A6 — Stolen session or API token (M2)
Scroll sideways for more columns
| Threat | Mitigation | Where | Status |
|---|---|---|---|
| Session theft through XSS | HttpOnly; strict hash-based CSP; no inline script; SPA output-encodes (Svelte default) |
internal/api/spa.go, web/ |
Built (M2 steps 6a and 11): the CSP is computed from the embedded index.html (no unsafe-inline, TestCSPHashesMatchTheEmbeddedIndex), SvelteKit's inline-style announcer is rewritten by a build plugin, and every Playwright test fails on a CSP violation. |
| Long-lived sessions | Idle and absolute expiry; revoked on password or 2FA change; admin reset revokes all |
internal/auth |
Built (M2 step 5, G7): TestSessionLifetimes, TestExpiredSessionsPrunedOnInsert, TestSessionCapTwenty, TestLastSeenWrittenOncePerMinute; the reasons reach the screen (Playwright shell.spec.ts: idle, absolute, revoked). |
| Session fixation and the half-logged-in state between password and TOTP | internal/auth |
Built (M2 step 5, G4): TestPendingIsNotASession, TestLoginMintsNewSessionIDAndRevokesTheOldOne, TestOldSessionRevokedAtLoginAndClientChosenIDRefused. |
|
| Token used for dangerous actions | Tokens are refused for destructive and sensitive actions (Q8 default); SessionOnly for token, auth and user management; tokens created or rotated only from a session with fresh 2FA, audited; expiry required (default 90 days); scopes read < write < admin |
internal/actions (M1 step 9), M2 |
Built (M1 step 9): the policy table, SessionOnly, and tokens refused for destructive and sensitive actions, each cell tested. Built (M2 step 8, SEC10, Q8): tokens are sd_ + 256 bits, stored as SHA-256 with a display prefix, with a required expiry (default 90 days, at most 365: TestTokenExpiryDefaultMaximumAndRequired), created only by tokens.create from a user session with fresh 2FA (TestTokensCreateNeedsASessionWithFreshTwoFactor), shown once and never in an audit row, the database or the logs (TestTokenFormatHashAndPlaintextNeverInAudit); read only from Authorization: Bearer (a token in a cookie or query string is ignored: route matrix); every token, auth and session action is SessionOnly so no token at any scope can reach them (TestNoTokenReachesASessionOnlyAction); failed lookups are limited to 5 a minute per IP (burst 10) before the database is touched (TestBadTokenBucketStopsGuessingBeforeTheLookup); revoking a token or session always runs, even with the audit log down (TestRevokeRunsWhenTheAuditLogIsDown); password change and re-enrolment revoke every session and, unless keep_tokens, every token (TestPasswordChangeRevokesEverythingByDefault, TestReenrolmentSwapsTheSeedAndRevokesEverything). |
| Dangerous actions with a stolen session | Fresh 2FA (5 min) for sensitive and destructive actions; destructive actions also need Confirm == Target |
internal/actions (M1 step 9), M2 |
Built (M1 step 9) in the registry (Confirm == Target, a fresh-2FA window checked against the registry clock). Built (M2 steps 6b and 13): the step-up flow that sets the window (/auth/reauth, five wrong codes end the session: TestReauthFailuresRevokeSession), and the step-up dialog (Playwright security.spec.ts). |
An HTTP or MCP request reaching the system actor |
One-time SystemInvoker handle; import test; route-matrix assertion |
internal/actions (M1 step 9), M2, M9 |
Built (M1 step 9): the one-time SystemInvoker, InvokeAs as the only way to set the executor, and the import test. Built (M2 step 6a/9): TestRESTNeverCreatesAnotherActorKind and the route matrix. Built (M3b step 9): reconciler.remove_network is system-only like the two M3a reconciler actions (ConsoleOnly: 404 for every credential in the route matrix, absent from OpenAPI, listed under Unattended destructive actions; TestRemoveNetworkIsSystemOnlyAndListed). M9 remains (MCP never reaches system). |
| Secrets in logs, errors or audit rows | internal/redact; sentinel tests |
internal/redact, internal/audit (M1 steps 8–9), M2, M3b |
Built (M1): redaction reaches secrets in slices, maps, pointers and embedded structs; a type that marshals itself cannot hide a secret (Register refuses it); sentinel tests search the database bytes and the logs. Built (M2 step 10, G9): the M2 secrets (see the Secrets row of the M2 surface table). Built (M3b, steps 1 to 7): the app-secret store. redact.ForSecrets expands each secret into its forms (the value, each line of 8 bytes or more, the cleaned, JSON-escaped and %q forms) and every reason, detail, job error, kept log and deploys.log read goes through it, fail closed (no log kept, a 503 on read, a fixed text). The sentinel suite plants a plain value, a secret value and a registry password through a real failing run and finds the secret and the password in no response, audit row, job row, log file, server log or database byte (TestAppSecretsNeverLeakThroughDeployReads, TestEnvSecretsNeverReachTheDatabaseBytesAuditRowsLogsOrReads, TestServerRedactsAndChecksRegistriesInARealDeploy, TestSecretsNeverLeak); deploys.log reads are audited (AuditRead, no log when the intent cannot be written). Limits are in the accepted risks. |
A7 — Hostile web page in the admin's browser
Scroll sideways for more columns
| Threat | Mitigation | Where | Status |
|---|---|---|---|
| CSRF | SameSite=Strict plus an X-SD-CSRF header token |
internal/api |
Built (M2 step 6a, G8): TestRouteMatrix, TestCrossSiteOriginIsRefusedOnEveryPreSessionPost, TestStaleCookieOnPublicRouteIsIgnored; a request with Authorization ignores cookies. |
| Cross-site WebSocket hijacking | Session required, plus an exact Origin match against the configured panel origins |
M2 | Not built (no WebSocket routes exist yet: the first arrive with logs streaming in a later milestone, behind the same session and Origin rules). |
| A page served by an app on the panel's own address acts on the panel (SEC6) | A request from http://<panel ip>:<app port> carries that Origin, which never equals https:// + Host: 403 origin on every unsafe route (the route matrix has the case for every route and for every service action); services with a public port, and services.get, services.create and services.set_public_port, return the shares_panel_address warning; system.exposure (read; cached 30 s on read, no timer) lists the containers ServerDock did not create that publish a host port on the panel's address (the agent leaves this install's own containers out by their instance label). It shows container names to any read caller, MCP included. Limits: the list can be evaded by anyone with Docker access (a foreign container that carries our serverdock.instance label is excluded, because the agent matches on that label), and when the panel listens on every interface it also includes loopback- and private-address-bound ports (an SSH tunnel reaches the panel on loopback), so a read token or MCP client learns about those too |
internal/api, internal/deploy/services.go, internal/agentops/handlers.go |
Built (M3a step 7): TestRouteMatrix (case app origin), TestServiceActionsRouteMatrix, TestSharesPanelAddressWarning, TestExposureListsForeignPublishedPorts, TestContainerPortsExcludesOurOwnContainers |
| Clickjacking | X-Frame-Options: DENY (and CSP frame-ancestors 'none' in M2) |
internal/api/api.go, spa.go |
Built (header); built (M2 step 6a) CSP frame-ancestors 'none' |
| DNS rebinding against the panel on the IP | Cookies are host-bound; over HTTPS the certificate name won't match | internal/api |
Built (M2 step 6a, G8): the Host allowlist answers 421 (TestHostAllowlist, TestRouteMatrixSubsetThroughRealCaddy, TestPanelRedirectHostAllowlist). |
A8 — Malicious repo or PR author (M5, M6)
Planned, and outside the M2 gate:
- Webhook HMAC verified before parsing, a lazy replay cache, and a 2 MiB cap (M5).
- No fork builds; PR previews are Phase 2 and off by default.
- BuildKit without
security.insecureornetwork.host(M5). - Compose path confinement, no remote
include, interpolation never reads the process environment, and the full deny-list (M6). - Symlink-safe clones (M5).
A9 — Prompt injection (M9 and later)
Planned:
- MCP is read-only in Phase 1, scoped
readtokens only, output redacted and marked untrusted, and audited with themcpactor (M9). - Writes need approval in the panel, enforced on the server (Phase 2, ADR 0006).
Log text reaching MCP clients is covered by G13.
A10 — Supply chain and CI
Scroll sideways for more columns
| Threat | Mitigation | Where | Status |
|---|---|---|---|
| Compromised third-party Action, or a mutable tag | Every Action pinned to a commit SHA | ci.yml |
Built |
| Workflow token abuse from fork PRs | Top-level contents: read; no pull_request_target; event values through env: only |
ci.yml, rule 11 |
Built |
| Gaming the bench gate (reusing a result from another workflow or app) | gh run list --workflow ci.yml; pathspec-based docs-only check; fail-closed gate; required check pinned to the GitHub Actions app (maintainer setting) |
.github/scripts/bench-needed.sh |
Built |
| Changing CI without review | CODEOWNERS on /.github/ plus "require code owner review" (maintainer setting) |
.github/CODEOWNERS |
Built (file); setting per maintainer |
| Vulnerable dependency | govulncheck (pinned version) on every PR |
ci.yml |
Built. Gap G14: no Dependabot or Renovate config. |
| Bench image with the Docker socket | Base images pinned by digest; the socket is mounted only in bench scenarios 3–4 | bench/ |
Open item #7 (ongoing) |
| Tampered release or self-update | A signed manifest binds version, OS/arch, file name and SHA-256; embedded key set (current + next); install refuses without verification; downgrade refusal; trial boot with rollback | M7a (ADR 0017), M7b (ADR 0018) | Planned. Gap G14: SBOM, provenance, and the cosign wording in rule 10. |
| Stolen release signing key | Hardware key held by the maintainer (Q5a) or a protected release environment (Q5b); key rotation through the "next" key |
M7a | Planned (Q5 open) |
Tampered install.sh |
Served over HTTPS from the repository | M7a | Accepted (common curl | sh trust model; the binary it fetches is verified) |
A11 — Console operator (recovery paths)
Scroll sideways for more columns
| Threat | Mitigation | Where | Status |
|---|---|---|---|
admin reset used by a non-root local user |
Needs the data-dir flock and write access to DATA (a 0700 directory owned by the service user) |
M2 | Built (M2 step 7) |
admin reset leaving the panel half-configured, or reopening setup to the network without a token |
It clears the password and TOTP, revokes sessions and tokens, and writes an audit row through the system invoker. It writes no token itself: the next server start writes a new 0600 setup token, and setup reopens only with it (TestSetupReopensOnlyWithNewTokenAfterReset) |
M2 | Built (M2 step 7, G4): TestAdminResetClearsExactlyTheAdminState, TestAdminExistsDefinition. |
state restore from a forged archive |
AEAD archive needs the passphrase; newer schemas refused; console only | M7b | Planned |
M2 surface (as built, with the tests that pin it)
Plan 0003 and ADR 0010 carry every row below, plus Gaps G2–G10, each with a test. All rows are Built (M2); the evidence is in the notes and in plan 0003's gap table.
Scroll sideways for more columns
| Item | Requirement (plan 0002 M2) | Gap to add |
|---|---|---|
| Panel TLS | Self-signed ECDSA leaf of its own, never from the hub CA; leaf SHA-256 printed on the console; users are never told to install a CA; :80 redirects (M4a adds HTTP-01 challenges) |
G5, G10 |
| Setup token | ≥ 128 bits from crypto/rand, hashed, constant time, single use, 1 h expiry, regenerated on restart while no admin exists, POST body only, DATA/setup-token 0600 removed once used, only its path logged, 404 once an admin exists |
G4 |
| Admin + TOTP | argon2id with m = 19 MiB, t = 2, p = 1; one hash at a time with a 2 s wait then a fast 503; per-IP check first; RFC 6238 ±1 step; last counter stored; 10 hashed recovery codes | G3, G4, G6 |
| Back-off | Per-IP exponential back-off (IPv6 /64) on login, TOTP, setup and recovery; per-account TOTP slowdown with an admin notice; no hard lockout; XFF only from the control socket, and Caddy must replace client XFF (test required) | G2, G3 |
| Sessions | Opaque 256-bit __Host- cookie (HttpOnly; Secure; SameSite=Strict), hashed, idle and absolute expiry; fresh 2FA lasts 5 min; WebSockets need a session and an exact Origin |
G4, G7 |
| CSRF | SameSite=Strict plus an X-SD-CSRF header |
G8 |
| API tokens | sd_…, hashed, scoped, expiry required, Authorization header only, created only from a session with fresh 2FA, SessionOnly management, denied for destructive and sensitive actions, revoked on password or 2FA change |
G8 |
admin reset |
Console only (ConsoleOnly, registered only in the reset process), owner uid only, flock, clears credentials, revokes everything, audit row, the next start writes a new setup token |
G4 |
| Route matrix | Every route declares its auth, including the debug socket routes; no route produces a system actor |
— |
| Secretbox | AES-256-GCM, AAD = table/row/column, key id prefix, DATA/keys/master.key 0600 |
G6 |
| SPA | Strict hash-based CSP; no Node at runtime | — |
| Secrets in output | Sentinel tests over DB files, logs and bundles | G9 |
M3a surface (as built, with the tests that pin it)
Plan 0004 carries every row, with the tests named in the A4 rows above. This section is the index: what M3a added that a caller, a host or a file can reach.
Actions (all through POST /api/v1/actions/{name}; the registry is the only door, and no new REST route or WebSocket exists):
Scroll sideways for more columns
| Action | Risk | Who (scope) | Notes |
|---|---|---|---|
projects.list, services.list, services.get, deploys.list, deploys.get |
read | read token or session |
deploys.get returns stages and the live pull progress, never log text. |
system.exposure |
read | read token or session |
Names and published ports of containers ServerDock did not create (accepted risk below). |
deploys.log |
read | write token or session; never MCP |
The only action that returns container output; the answer is cleaned (G13). |
services.update |
mutate | write |
Health, strategy, timings, tag or digest of the current repository (SameRepository); a container-port change on a service with a public port needs admin. |
services.deploy, services.redeploy, services.rollback, services.restart, deploys.cancel |
mutate | write |
Queue a job that runs as the queuing actor. Rollback to another repository or container port needs admin. services.restart causes a short outage (the UI says so). |
services.create, services.set_source, services.set_public_port, services.retry_port |
mutate | admin (a session or an admin token) |
These choose what runs or where it is exposed. A public-port change is confirmed in a dialog in the SPA. |
services.delete |
destructive | admin, session only: every API token is denied |
Fresh 2FA, Confirm = <project>/<service>, re-checked when the job runs. |
jobs.run_deploy, jobs.run_restart, jobs.run_service_delete |
mutate / destructive | JobOnly |
Callable only through SystemInvoker.InvokeAs for a non-system actor; REST answers 404; absent from OpenAPI. Not unattended: they run as the user or token that queued them. |
reconciler.remove_container, reconciler.finish_deploy |
destructive / mutate | ConsoleOnly, system only |
Called only by the reconciler. Listed under Unattended destructive actions. |
Agent ops (protocol v1, ADR 0012): hello and logs stay the only RemoteOK ops. Every other op is LocalOnly, refused by the hub for any session but the in-process local agent and not served by a remote agent process: image_pull, image_inspect, container_create, container_start, container_restart, container_inspect, container_stop, container_remove, container_list, container_ports, network_ensure, network_inspect, health_check, proxy_apply and events. Tests: TestRemoteOKAllowlistIsHelloAndLogs, TestRemoteSessionRefusesEveryLocalOnlyOp, TestRemoteAgentProcessServesOnlyRemoteOKOps, TestV1NeverWidensTheRemoteOpSet.
Listeners. One plain-HTTP, h1-only Caddy server holds every service's public port (see the app-ports row of the deployed-shape table). No listener of ServerDock's own was added: the control plane is still a unix socket and the agent listener is still off by default.
Files and database. DATA/deploy-logs/ (0700; files 0600; see the logs row in A4); migration 0004_deploy.sql (projects, services, deploys, deploy stages, jobs; meta.install_id and meta.app_subnet). The migration adds no secret. deploy-logs/ is not in datadir.SecretPaths (that list holds ServerDock's own secrets); it holds app output, which is treated as sensitive on its own terms (accepted risk below).
Unattended work (no human at the keyboard): the reconciler's two system-only actions, the boot pass (database only, one outcome row per interrupted intent, with the intent's actor and executor = system), and the scheduler's start of queued jobs. A job's own run is not unattended: it is policy-checked as the actor that queued it, at the time it runs.
The delete_confirm_again hint (step 13). When a delete job is refused at run time because the 5-minute fresh-2FA window passed while the service was stopping, nothing is deleted and the runner sets needs_attention = delete_confirm_again, only over NULL (it never replaces a safety flag such as versions_kept, previous_version_down or delete_interrupted). The service page then offers "Delete again", which asks for fresh 2FA and the typed target again; the hint grants nothing by itself. Every enqueue for the service clears it in the same transaction, so it exists only while nothing is queued or running. It is not delete_interrupted, so the reconciler still starts the service. Tests: TestDeleteAfterTheFreshWindowExpiresAsksToConfirmAgain, TestQueuedWorkClearsTheConfirmAgainHint, TestConfirmAgainHintIsNotWrittenOverAnotherReason, TestBootPassWritesVersionsKeptOverTheConfirmAgainHint, TestRule3StartsAStoppedServiceCarryingTheConfirmAgainHint.
The SPA (steps 12 to 14) adds screens and no server route: Services, New service, Service detail with its Deploys and Settings pages, and Deploy detail with live progress (polling from the browser while the page is visible; no WebSocket, QM3a-6). Dialogs name the target and the consequence, default focus is Cancel, and a stale dialog cannot act on another service. The log is rendered as text only. The manual screen-reader pass for steps 12 to 14 is PENDING (maintainer; M3a screen-reader checklist (on GitHub)).
M3b surface (as built, with the tests that pin it)
What plan 0005 adds, in one place. The A4 and A5 rows above name the individual tests.
Scroll sideways for more columns
| Surface | Rule | Tests |
|---|---|---|
Env vars and secrets (services.env_get, env_set, env_reveal, services.create with env) |
Sealed with secretbox (AAD service_env_versions/<service id>/v<version>), at most 24 KiB a version, 20 versions kept besides the live one; env_set and env_reveal need the admin scope, env_reveal is Sensitive (fresh 2FA, no token, no MCP, intent row first, no-store); env_get returns plain values only, never a secret's value or length; a write token may roll back only to a deploy that ran the current env version; env_lost (after admin reset --forget-app-secrets) refuses deploys |
TestEnvGetNeverReturnsSecretValuesOrLengths, TestEnvSetKeepRefusedUnlessTheNewEntryIsSecret, TestWriteTokenRollbackToAnotherEnvVersionNeedsAdmin, TestEnvLostRefusesDeployRedeployRollback, FuzzEnvName, FuzzEnvValue |
Registry credentials (registries.list, set, delete) |
Admin scope to change; the password is sealed, never returned (only has_secret); every pull resolves and checks the host (rule 10); a credential is sent only to its own host |
A4 row on registry SSRF |
Volumes and bind mounts (services.set_volumes) |
Admin scope and fresh 2FA, no tokens; named volumes carry ServerDock's labels and are never adopted from another owner; a writable mount forces stop-first; bind mounts are off without --bind-root; the overlap rule, real-path rule and denied set are in the A5 row; QM3b-11 gates image changes of a service with a bind |
TestImageChangesOfAServiceWithABindMountNeedFreshTwoFactor, TestDeployWithAnImageRefGoesThroughTheBindGate, TestRetargetedLinkCannotHideTheMountedPath, FuzzBindPath |
| Project networks and service DNS | One internal bridge per project, a /25, joined at create with the service name as the alias; no reach across projects; removal only after the project's row is gone, never forced, never while a labelled container exists; the orphan rule runs in the full resync as the system-only reconciler.remove_network |
TestDeleteOfLastServiceRacesANewServiceDeploy, TestRemoveNetworkIsSystemOnlyAndListed, the integration tests for peers and cross-project isolation |
Limits and OOM (services.set_resources) |
Admin scope; checked against the host's totals at save and at the check stage; OOM from the events stream, one write per service per minute, no timer | A4 row 128 |
Engine facts and the RC (system.docker, system.docker_ack) |
Version and host totals read at each events (re)connect and kept in memory; one stored value, the acknowledged engine version; the integration-rc job never gates a merge |
TestSystemDockerShowsWhatIsRemembered |
| Redaction and audit | Fail closed everywhere (A6 row "Secrets in logs"); deploys.log reads are audited; kept logs are redacted when written and when read |
the sentinel suite |
| The screens (Environment, Resources, Storage, Registries, Server card, delete dialog) | No secret value is in the page, its history state or storage before Reveal or after Hide; Reveal needs a fresh code; dialogs name the target and the consequence with default focus on Cancel | web/e2e/environment.spec.ts, web/e2e/settings-m3b.spec.ts, web/e2e/m3b.docker.spec.ts |
Files and database. Migration 0005_service_config.sql adds the env versions, registries, volumes, mounts, project columns and jobs.result. No new file under DATA is secret except what the database holds (DATA/keys/master.key is the key to the new ciphertexts); the kept deploy-log files are the sensitive ones named above.
M4a surface (as built, with the tests that pin it)
What plan 0006 adds, in one place. Each row names its tests; the step that built it is in the plan.
Scroll sideways for more columns
| Surface | Rule | Tests |
|---|---|---|
| Which names get a certificate (rule 12, D1) | Only names an admin added are in the proxy's explicit automate list; a global deny-all permission is present in every config with a name; a catch-all policy with an explicit issuer stays after the last name is removed (it is sticky once a part with names was tried in the process, so a leftover can never reach Caddy's default public issuer); automatic_https is disabled on every server, OCSP stapling is off, the admin API is off and nothing persists a config |
TestGeneratorInvariants, TestALeftoverManagedNameIsNeverRenewedOrSentToACA, TestCatchAllStaysAfterTheLastNameIsRemoved |
Domain names and Host values (domains.add, services.create with a domain, the host table, SNI) |
One name function (UTS 46 to ASCII, lower case, LDH, at least two labels, not an IP literal, not a reserved suffix, not a panel host); at most 10 per service and 200 in all; one Host function for every lookup (a non-ASCII Host is 421); the generator refuses any name Caddy treats as local (an IP literal, a space, a wildcard, an empty name) because that makes Caddy try to install a root with sudo (spike finding E3) |
TestNameRulesTable, TestHostNormalisationTable, TestGeneratorNeverEmitsANameCaddyTreatsAsLocal, FuzzDomainName |
| Caddy placeholders in our own config (spike finding E2) | { and } are refused in the ACME e-mail (acme.set), in the agent's proxy_apply decode (e-mail, directory, CA root, every host, uploaded name, panel domain) and at start in --panel-host, the data-directory path, --acme-directory and --acme-ca-root; a golden walk and a fuzz target allow only generator-owned placeholders. This closes a read of any file the process can read (through {file.*} echoed back by a CA) |
TestNoBracesInGeneratedConfigExceptOwnPlaceholders, TestProxyApplyRefusesBraces, TestFlagsRefuseBraces, FuzzEmail |
Uploaded certificates (domains.set_certificate, use_automatic, remove; tls_cert_put, drop, list) |
Size caps first, standard library only, strict PEM, the key matches the leaf, the leaf covers the name (a wildcard covers one label, never a whole suffix), dates, chain links, RSA 2048 to 8192 or P-256 or P-384, no SHA-1, no encrypted key; refusals never echo input. The key is sealed in AppColumns() (AAD bound to the domain name), never returned, never in an audit row (which holds the SHA-256, issuer and names). Uploading is Sensitive (fresh 2FA, no token, no MCP); removing or switching an upload re-checks that inside the action. The control plane keeps the agent's in-memory map equal to the database (put then apply, apply then drop; a stale entry is never served) |
TestRefusalsNeverEchoPEM, TestSetCertificateIsSensitiveAndDeniesTokens, TestSetCertificateAuditRowsHoldFingerprintNotKeyOrChain, TestUploadedKeyIsNeverInTheDatabaseInTheClear, TestRetiredUploadKeyIsNeverServedAfterASwitch, TestCertPutKeyNeverInLogsOrErrors, FuzzCertUpload (both processes) |
| Certificate events from Caddy | One subscription in the deny module's Provision (server mode only), a handler that never returns an error; only the identifier, renewal flag, issuer, problem type and cleaned text are kept (no CSR, no path), with the unpause token and e-mail addresses masked; a 2 s write deadline. Events are best effort and no safety rule depends on one |
TestEventSubscribedOnceDeliveredOnce (-race), TestEventPayloadDropsCSRAndPaths, TestPausedJWTNeverReachesAnAuditRowOrTheRow, TestRedactEncoderMasksTheACMEContact |
| Let's Encrypt limits (D10a) | A restart budget in the pre-load transaction (at most 4 failed validations per name per hour, at boot too), an install-wide pause job and a batched resume job (rows of the existing jobs table, no timer of ours), back-off 1 h, 4 h, 24 h, and Let's Encrypt's own pause as a state no timer resumes | TestRestartBudgetPausesInTheLoadAlreadyHappening, TestOnePauseJobPausesAllEligibleNamesInOneLoad, TestLetsEncryptPausedIdentifierIsNeverAutoResumed, Pebble TestFailingNameAuthorizationsStayUnderTheLimitAcrossReloadsAndBoot |
Diagnostics (domains.check) |
Admin scope; the name is validated before any lookup; a random nonce per probe; only public addresses after unmapping (IANA special-purpose tables, NAT64, 6to4, Teredo, this host's addresses and on-link prefixes, Docker and app networks), checked again at dial time; at most 4 probes, no redirects, no proxy, one 4 s deadline; 6 a minute per credential, 20 per install; DNS and CA text cleaned and cut; the list never resolves or probes | TestProbeNeverDialsNonPublic, TestDialControlRechecksAfterUnmapping, TestCheckIsAdminAndRateLimitedPerCredentialAndInstall, FuzzNetpolicyClassify |
Panel domain (panel.status, panel.set_domain, panel.set_keep_ip, auth.totp_reenrol_dismiss, --panel-keep-ip) |
Set and clear are Sensitive and session-only; the redirect and the sign-in refusal as in G15 above; the Host and Origin lists follow the committed config; the panel name goes through the restart budget like an app name; while it is paused or untrusted nothing redirects, so there is no lock-out | TestSetPanelDomainIsSensitiveSessionOnly, TestPanelDomainIsBudgetedAndPausedLikeAnAppName, TestRedirectTrustUsesNotBeforeWhenObtainedEventMissed |
| Never reaches the control plane | An app domain is never routed to the control socket; no server sets trusted_proxies, so Caddy always replaces X-Forwarded-For with the real peer (the loopback-peer rule and the per-IP sign-in back-off depend on it) |
TestAppDomainNeverReachesTheControlPlane, TestNoTrustedProxiesInAnyServerWithDomains |
ACME settings and flags (acme.get, acme.set, --acme-directory, --acme-ca-root, hidden --tls-issuer internal) |
The e-mail is optional, strict and admin-only (secret-tagged: no audit row or log holds it, and the log encoder masks every address and mailto:); the directory must be https except loopback; a CA root is trusted only for that directory; --tls-issuer internal never installs trust |
TestAcmeEmailIsAdminOnlyAndNeverInAuditOrOutput, TestACMEDirectoryMustBeHTTPSExceptLoopback, TestInternalIssuerNeverInstallsTrust |
| Storage | DATA/caddy holds the ACME account key and every managed certificate with its private key unsealed; it is in datadir.SecretPaths, directories 0700, files 0600 except certmagic's locks/*.lock (0644, no secret) |
TestCaddyStorageIsASecretPathWithPrivateModes, TestSecretPaths |
| The screens | The private key lives only in the page's memory and is emptied on success, on a failed submit and on leaving; upload and removal need a fresh code; the refused page's sign-in link is validated to https://host[:port] |
web/e2e/domain-details.spec.ts, web/e2e/domains-settings.spec.ts, web/e2e/domains.pebble.spec.ts |
New inputs, fuzzed (seeds run in CI): FuzzDomainName, FuzzHostNormalise, FuzzCertUpload (the control plane's validator and the agent's structure check), FuzzEmail, FuzzProxyApplyDomains, FuzzGeneratedConfigHasNoBraces and FuzzNetpolicyClassify. The sentinel suite plants an uploaded key, an ACME e-mail and the probe HMAC key.
Files and database. Migration 0006_domains.sql adds domains, domain_certificates and acme_restart_log, with triggers that allow a certificate row only for an upload domain and refuse editing a name (the key's AAD depends on it). The new files under DATA are all in DATA/caddy. The agent protocol gains four local-only ops (tls_cert_put, tls_cert_drop, tls_cert_list, cert_status) and a domain part in proxy_apply; a remote agent serves none of them (TestRemoteAgentServesNoCertificateOp).
Rules (non-negotiable)
- No shell strings. Use the Docker API and compose-go only. Exec takes argv arrays. Use strict validators for names, image refs, domains, ports, git refs and paths, and fuzz them. (Built so far: container id, agent id, tail and op-line validation (M1); M3a adds, in
internal/policy,internal/agentandinternal/agent/dockerapi, each with a fuzz target whose seeds run in CI: project and service names (FuzzName), image references and registry hosts (FuzzImageRef), the same-repository comparison (FuzzSameRepository), the health path (FuzzHealthPath), public ports, the numeric ranges and the app subnet, the create body down to every leaf (FuzzCheckCreate, run in both processes), the agent's request line and the hub's response, progress and event lines (FuzzParseV1Request,FuzzParseAgentLine, andFuzzCheckKeysfor exact key matching), Docker's pull and events JSON lines (FuzzPullLines,FuzzEventLines), the 64-hex container id on every ownership op, and the deploy-log path (an absolute root, a positive id, exactly one level). Not yet fuzzed: thedeploys.loggzip reader (bounded by a 1 MiBLimitReaderand tested with a bomb instead).) - Compose and Dockerfiles are untrusted code. A default-deny policy blocks
privileged, host pid/network/ipc, docker.sock,/,/etc, devices and extra caps. Overrides are admin-only and audited. - Agents have no listening ports. They dial out over TLS 1.3 to a pinned hub CA. The control plane treats every agent message as untrusted: an agent may only answer streams the hub opens, and only report on its own server. Phase 1: a shared token, remote agents serve only
helloandlogs(rule 9 of plan 0002; ADR 0012). Phase 2: a single-use enrollment token, then a per-agent mTLS identity (clientAuth-only certificates from the hub CA). - No stored SSH keys. SSH is used once for install, then discarded.
- Secrets are encrypted at rest with a key outside the DB. They never appear in logs, errors, URLs, audit rows or AI/MCP output. Revealing one requires fresh 2FA and is audited intent-first.
- Auth is equal everywhere. REST, WebSocket, terminal and MCP share one authz layer (the action registry). CI runs an RBAC matrix over every route, including the debug socket's. Sessions are revoked on password or 2FA change. CSRF tokens, a strict CSP, SameSite cookies and rate limits apply.
- Dangerous actions (host terminal, delete, restore, secret reveal, destructive AI tools) need fresh 2FA and name the exact target.
- PR previews from forks are off by default and never get secrets.
- AI and MCP act with the caller's permissions or less. Writes need approval enforced on the server. Tool output is untrusted data. Secrets are redacted before anything is sent. There is no raw shell tool by default.
- Releases are signed: a signed manifest per artifact binding version, OS/arch, file name and SHA-256, verified with an embedded key set (ADR 0017, M7a). Self-update verifies the signature before any swap and refuses downgrades. Dependencies are pinned and scanned (govulncheck; dependency update bot, G14). SBOM and provenance: decided in ADR 0017 (G14).
- No unauthenticated windows. Setup needs the console token. Restore is console-only, from an authentic archive.
- Certificates are for named domains only; on-demand TLS is denied (plan 0006 D1, ADR 0004 addendum B). ACME is attempted only for names an admin added, which the control plane writes into the proxy's explicit
automatelist from its database. Every on-demand path (a name that is not listed, a name that matches no policy) is refused by one global deny-all permission module, so no connection can start an order. The old wording, "on-demand TLS gated by our DB", is retired: ServerDock never asks the database during a handshake. - Every limiter fails toward refusing, never toward allowing. A limiter that evicts state must not evict an active block (G3).
Gaps
These are found in this review and not yet covered by plan 0002. Each has a severity and a recommended owner milestone. The fix belongs in that milestone's plan, with a test.
Scroll sideways for more columns
| # | Severity | Gap | Owner | Recommended fix |
|---|---|---|---|---|
| G1 | High (built in M1) | yamux ping flood. yamux answers each ping SYN in a new goroutine that waits up to ConnectionWriteTimeout (10 s). An agent-token holder that sends pings and never reads creates goroutines without limit; a scratch reproduction reached 640k goroutines / 2 GiB in 1 s. The control plane is OOM-killed, and the in-process Caddy, with it all app ingress, goes down. The same applies to any other session built on YamuxConfig. |
M1 (before M1 closes; it belongs to open item #4) | Wrap the hub-side net.Conn passed to yamux.Client (hub.go:228) in a small frame reader that tracks yamux headers (12 bytes; skip data payloads by length). Allow e.g. 4 ping SYNs/s, burst 16, and end the session past that (log once). Optionally also bound window-update and go-away frames. Lower ConnectionWriteTimeout for remote sessions (e.g. 5 s). Add a regression test: an agent that floods pings without reading leaves the hub's goroutine count bounded and the session closed. |
| G2 | Medium | The control plane trusts loopback. 127.0.0.1:7070 is plain HTTP and reachable by any local process. With ClientIP(r, true) that process can forge X-Forwarded-For and bypass per-IP back-off. --internal also accepts a non-loopback address, which would expose the panel over plain HTTP. |
M2 | Preferred: serve the control plane to the in-process Caddy over a unix socket in a 0700 directory (Caddy dials unix/…), and drop the TCP listener. Then trust XFF only on that socket. Otherwise refuse non-loopback --internal, and authenticate Caddy with a per-boot random header that Caddy sets and strips from client requests; trust XFF only when it matches. Test: a direct request with forged XFF is keyed by its real peer. Built (M2 step 2) as the preferred option: TestNoTCPControlListener, TestControlSocketModes, TestListenPrivateSocketRules, TestControlSocketConnectionCap, TestControlAndDebugPathsMustDiffer, TestForgedXFFOnSocketIgnoredByCaddy, TestXFFIgnoredWithoutSocketMark, TestMultipleXFFValuesRejected; the remote agent's Caddy config is pinned by TestAgentBuildConfigGolden. |
| G3 | Medium (the M1 part, "never evict a blocked bucket", is built) | TOTP and limiter strength. At the plan's example "10/min per account", an attacker who has the password wins in about 4% of days (14,400 tries × 3 valid codes / 10⁶). Per-IP back-off is defeated by rotating /64s from one /48. Keyed.evict (limits.go:95) can evict a bucket that is currently blocked. |
M2 | Per-account exponential back-off on TOTP and recovery codes: 5 free attempts, then doubling delays up to a 1 h cap, and the password must be entered again after every 5 TOTP failures. Notify the admin on "password correct, TOTP failed" and advise a password change. Add a second per-/48 bucket for IPv6. Never evict a blocked bucket; when the map is full of blocked keys, refuse new auth keys with 429 (an availability trade-off, recorded). |
| G4 | Medium | Auth state machine not specified. (a) The half-authenticated state between a correct password and TOTP. (b) Setup atomicity: two concurrent setup requests, or an admin committed before TOTP is confirmed. (c) What "an admin exists" means after admin reset (the setup endpoint must reopen only with the new token). (d) Session id rotation at login. |
M2 | (a) The password step returns a short-lived (5 min), single-use, hashed "pending-2FA" token with at most 5 TOTP tries. It is not a session. The session cookie is minted only after TOTP. (b) Setup verifies a TOTP code from the new seed, then commits admin, TOTP and recovery codes in one transaction, consuming the token in the same transaction (compare-and-delete). (c) Define "admin exists" as "an admin with a password and confirmed TOTP". (d) Always issue a new session id at login, and never accept a client-chosen id. |
| G5 | Medium | First-run MITM on the self-signed panel. Fingerprint comparison is the only defence, and few users do it. An on-path relay captures the setup token, password and TOTP seed, which means a lasting takeover. | M2 (ADR 0010) | Document an SSH-tunnel first run as the recommended path. After setup, show "admin created from |
| G6 | Medium | At-rest protection for M2 credentials. The plan doesn't say the TOTP seed (which must be reversible) is encrypted. The data directory is created 0750 (server.go:164), existing directories aren't checked, and SQLite files get the umask default (usually 0644). |
M2 | Store the TOTP seed in secretbox (AAD bound to the user row). Enforce DATA 0700, refusing a looser existing directory with a clear message as socket.go does. Set the process umask to 0077 at start. Test file modes after first run. Built (M2 step 1): internal/datadir (TestDataDirCreated0700, TestLooserDataDirRefused, TestForeignOwnedDataDirRefused), umask 0077 in serverMain (TestUmaskKeepsNewFilesPrivate, built binary), internal/secretbox with the master-key rules (TestSecretboxAADBinding, TestSecretboxRefusesBadKeyFile, TestMissingKeyWithCiphertextsRefusesStart, TestSecretboxWrongKeyIDRefused, TestKeyIDRecordedAndChecked: the key id is recorded in meta.secretbox_key_id, so a missing or swapped key file is refused at start; TestSecondServerCannotStealALiveControlSocket), the startup order with the lock before any write (TestSecondServerFailsOnLockAndFirstStillAnswers), TestAuditVerifyAsRootOnServiceOwnedData. Built (M2 step 5): the seed in secretbox (TestTOTPSeedNotInDBPlaintext), TestFileModesAfterFirstRun; (M2 step 10): the sentinel suite. |
| G7 | Low | Session table growth. Coolify #7394 grew a sessions table to 58 GB, and there is no scheduler until M3a. | M2 | Prune expired rows lazily on login and session insert (bounded batch). Cap active sessions per user (e.g. 20, revoking the oldest). Limit last-seen writes to once per minute, as for tokens. |
| G8 | Low | Auth precedence, CSRF and Host. The plan doesn't say what happens when a request has both a cookie and Authorization, and there is no Host allowlist (DNS rebinding hygiene). |
M2 | Decide the auth method first. A request with Authorization is token-only and its cookie is ignored. Any cookie-authenticated request needs the CSRF header; never skip CSRF just because some header is present. Accept only the configured Host values (server IPs, panel domain), else 421. The WebSocket Origin allowlist comes from the same list. |
| G9 | Low | Sentinel coverage for M2 secrets. Only the setup token is named in the plan's tests. | M2 | Add sentinels for the password, TOTP seed, recovery codes, API token, session id, and the raw Authorization and Cookie headers. Search the DB bytes, server logs and Caddy logs for them. |
| G10 | Low | Panel TLS key path is not named, and not in the doctor --bundle exclusions or the state-backup contents. |
M2 (ADR 0010), M7a, M7b | Put it under DATA/pki/panel/ or DATA/keys/ (0600). Add it to the M7a bundle exclusions and the M7b archive list. Decide whether a lost key is simply regenerated, which changes the fingerprint the console prints. Built (M2 step 3): DATA/pki/panel.pem (0600) and panel.fingerprint (also 0600: readable only by the owner; the value is public, but it lives under the secret pki/ tree), under pki/, which is in datadir.SecretPaths; a lost or invalid leaf is regenerated with a WARN showing the new fingerprint (TestPanelLeafPathAndModes, TestPanelLeafRegeneratedWithWarning, TestPanelLeafRenewedUnder60Days, TestPanelLeafRegeneratedWhenPanelHostsChange, TestPanelLeafNotFromHubCA, TestPanelFingerprintLoggedEveryStart). SNI: TestPanelSNIHandshakes (no SNI, localhost, an unknown name). :80 only redirects: TestPanelServedOnHTTPSAndHTTPOnlyRedirects, TestPanelConfig. |
| G11 | Low | Agent token in the environment. SD_AGENT_TOKEN in a systemd Environment= line is readable by any local user through systemctl show. The agent has no file option. |
M7a | Add --token-file to server and agent (refuse files readable by group or others), and use LoadCredential= or a 0600 EnvironmentFile= in the unit. Never use an Environment= line. |
| G12 | Low (built in M1) | The agent follows HTTP redirects during the WebSocket handshake (default CheckRedirect, client.go:200). That can move the bearer token past ValidateURL. It is not exploitable today, because only a holder of a pinned-CA leaf can answer. |
M1 (one line) or Phase 2 | Built in M1 (55b4807): the client refuses every redirect, with a test that the target is never contacted. |
| G13 | Low | Log content is attacker-controlled. Any container, or an agent-token holder, controls it. The debug route streams raw bytes to the operator's terminal; M8 renders logs in the browser; M9 sends them to MCP clients. | M8, M9 | Render logs as text only (no HTML injection). Neutralise control characters except a whitelisted SGR subset, or use xterm.js with OSC/DCS disabled. Cap line length. In MCP output, frame logs as untrusted data and run them through redaction. Optionally strip escape sequences from the debug route. Partly built (M3a steps 11 and 14): deploy logs are cleaned on the server (agent.CleanLogText: ESC, NUL, CR and every control character, bidi overrides and isolates, zero-width and format characters, line and paragraph separators; invalid UTF-8 becomes U+FFFD) and rendered by the SPA as text only with the header kept visually apart, capped at 1 MiB; TestDeploysLogOutputIsSanitised, TestCleanLogTextRemovesEveryControlAndBidiCharacter, TestDeployLogHeaderCannotForgeTheContainerOutputSeparator, Playwright deploy-detail-log.spec.ts. Still open: live logs in the browser (M8), the debug socket's raw bytes, MCP (M9). |
| G14 | Low | Supply-chain drift. Rule 10 and the roadmap say cosign + SBOM + provenance + Dependabot. Plan M7a / ADR 0017 use a stdlib-ECDSA signed manifest and don't mention SBOM or provenance. Before M1 step 10 there was no .github/dependabot.yml, so pinned Action SHAs and Go modules got no update PRs. |
Dependabot: built in M1 step 10 (.github/dependabot.yml, weekly and grouped for github-actions and gomod). SBOM and provenance: M7a (ADR 0017). |
Add a Dependabot config for github-actions and gomod (weekly, grouped). In ADR 0017, either add an SBOM (go version -m, or CycloneDX at build time) and GitHub artifact attestations, or record that they are dropped. Align the roadmap wording. |
| G15 | Low (closed in M4a step 10) | The IP panel stays open after M4. Once a panel domain has a valid certificate, the self-signed IP panel still works, which teaches users to click through warnings. | M4 | Once the domain certificate is valid, redirect IP access to the domain by default (break-glass opt-in to keep the IP panel). Add HSTS on the domain. Re-check Host and Origin lists (G8). |
Accepted risks (Phase 1)
- Shared agent token (open item #3): a token holder can replace another remote agent's session and read or fake its logs. Remote agents are off by default, experimental and logs-only. This is fixed in Phase 2.
- Botnet on the agent listener: many source IPs can hold the 128 connection slots with slow handshakes (open item #4). It doesn't reach the panel.
- User-name enumeration by a multi-IP attacker (accepted, M2 step 6b): every non-existent user name shares one account back-off bucket (
<unknown>), so spraying random names cannot fill the limiter maps (SEC3). The price: an attacker with many IPs first saturates<unknown>(11 wrong passwords for random names, each from another IP), then probes a name from a fresh IP; a name that does not exist is refused 429 while an existing one is still answered 401. A single client sees identical bodies, statuses and timing. The user name is not a secret, and the password plus TOTP still guard the account.TestUnknownBucketRevealsExistenceToAMultiIPAttackerpins it. - Host-scoped cookies on IP and tunnel access (SEC6, accepted): cookies are host-scoped, not port-scoped, so on IP and SSH-tunnel access another HTTPS service on the same host name could receive them.
SameSite=Strict,HttpOnlyand fresh 2FA limit the impact; M3a warns about services published on the panel IP; M4's panel domain removes the overlap. - A shown-once API token or recovery code stays on screen until the user hides it or leaves the page (accepted, maintainer decision 2026-11-21): the token is not cleared when the page is hidden or another action starts, because on a phone switching apps to paste it must not destroy a secret that cannot be shown again.
securitysuggested an automatic clear; the maintainer chose to keep it, andsecurityrated the remaining exposure (it lingers in the page's memory and DOM) as low.web/e2e/security.spec.tspins the behaviour. Recovery codes have a similar guard in the other direction: leaving before they are saved is blocked or confirmed. - A leaf can expire on a running server (accepted): it can serve an expired leaf after as little as about 60 days of uptime if it was last started with just over 60 days left; after a fresh leaf, about two years. The panel leaf (825-day validity) is renewed at start when fewer than 60 days remain, not while running (no timer, by the footprint rules). Mitigations: Settings › Security warns when fewer than 60 days remain (a status the user hears, not only a colour), the start-up log says when the leaf expires, and a restart renews it.
- The known-IP bypass of the per-account password back-off (accepted): an IP (IPv4, or an IPv6 /64) that completed a full sign-in in the last 30 days skips the per-account password back-off, and is still admitted to the hash when the back-off maps are full of blocked keys. Anyone who shares that NAT or /64 gets only the per-IP budget for password guesses. It is bounded by the per-account second-factor back-off (which that IP does not skip), the per-IP and per-/48 back-offs, and by the fact that a guess still needs the password before a session exists.
TestKnownIPExemptFromAccountBackoffandTestKnownIPReachesHashWhenMapsFullOfBlockedpin it. - Clipboard history can keep a copied seed or recovery codes (accepted): Copy key and Copy all use the clipboard, and clipboard-history apps or cloud clipboards may keep a copy. Both screens say so and offer Download (recovery codes) or typing the key; nothing is copied unless the user presses the button.
keep_tokensis an opt-out (accepted): a password or authenticator change revokes every API token by default, and the user can tick "Keep API tokens" for routine rotation. After a suspected compromise a user who ticks it keeps working tokens; the hint says not to, the default is unticked, the confirmation states the choice, and the choice is audited.- Login availability under a distributed attack: the single argon2 slot can be kept busy. Existing sessions keep working, and the console can recover.
- The control plane is root: the server process is in the
dockergroup, so any control-plane RCE means root on the host. systemd hardening (M7a) limits the filesystem but can't limit Docker. This is inherent to a Docker manager; we keep the attack surface small instead. - A compromised control plane compromises every agent. The agent trusts the hub by design.
- Data directory compromise gives the secretbox key, the hub CA key and the DB together. The key is "outside the DB" only to protect DB-only copies and bundles.
- First-run trust on a self-signed certificate (after G5 is applied): the remaining risk is a user who skips the fingerprint check on a hostile network.
- A public panel domain with phishable sign-in until M4b (accepted by the maintainer 2026-11-27; plan 0002 Revision 1): with the reordered milestones, the panel can sit on a public domain from M4a, and be used in real installs from M7a, while sign-in is still password + TOTP. Both can be phished by a relay page; passkeys, which bind sign-in to the panel's origin, only arrive in M4b (after M6). Mitigations: the panel domain is optional; the early-use guide recommends reaching the panel by IP over an SSH tunnel, or a firewall allowlist on 443; the G3 back-off limits guessing; dangerous actions need fresh 2FA.
- No out-of-band notice of sign-ins or brute-force back-off in Phase 1 (accepted by the maintainer 2026-11-27; plan 0002 Revision 1): sign-ins, failed second factors and back-off events are shown in the panel only (Security page, G3 admin notice). There is no email, webhook or Telegram notice until M8 adds notifications, and M8 itself plans no sign-in alerts, so an admin who doesn't open the panel won't learn of an attack. Mitigations: the panel domain is optional; the early-use guide recommends IP access over an SSH tunnel, or a firewall allowlist on 443; the G3 back-off; fresh 2FA for dangerous actions.
- BuildKit DNS rebinding between the URL pre-check and BuildKit's own fetch (M5, documented there).
curl | shinstall: the script is trusted through HTTPS; the binary it fetches is verified.
Added by M3a (plan 0004 step 15; each is a risk we know about and carry, in plain words):
- Limits are off by default, and there is no disk quota (M3a text, amended by M3b step 10: a service can now be given a memory limit, a CPU limit and no-new-privileges with
services.set_resources, but none is set unless an admin sets it). One app can use all of the host's RAM, CPU or disk; the kernel may then kill ServerDock, which takes every app's public port offline (QM3a-9). Give deploy rights only to people you trust with that (B10).CheckCreateallowsRestartPolicy,LogConfig,NetworkModeandPidsLimit, and since M3b, when set,Mounts(named volumes and binds only),Memory,MemorySwap,NanoCpusandSecurityOpt(internal/policy/create.go); a container's log files are capped (10 MiB x 3) but its writable layer and volumes are not. - B10: whoever may deploy can run code with this host's network reach. A deployed container is unprivileged and cannot touch the host's files (the create policy refuses privileged mode, host namespaces, devices, any mount type but a ServerDock-labelled named volume or a bind inside an operator-chosen
--bind-root(see the A5 row), and every other option outside the allowlist, and caps the PID count). But it can open network connections like any program on the host: the cloud metadata service (169.254.169.254, which on some clouds hands out credentials), private and LAN addresses, any machine the host can reach, and services on the host itself through the app network's gateway (for example the agent listener when--agent-listenis on, or anything bound to all interfaces). ServerDock does not firewall containers in Phase 1. So the permission to deploy (a session; a token withwritescope for any tag or digest of a repository an admin chose, so whoever controls that repository's tags controls the code that runs;adminfor a new repository) should be given only to people and systems you trust with that reach. If it matters, block the metadata service at the host or cloud firewall. Phase 1 adds no network control for containers; M3b's per-project networks narrow container-to-container reach but do not firewall the host. M3b's project network adds one path to the same reach: a container on a project's internal bridge has no default route and so reaches no outside address, but it reaches listeners on the host bound to all interfaces through that bridge's gateway (found in the Docker 29.10 record tests, plan 0005 Revision 3). ServerDock's own listeners are unaffected (the control socket is a unix socket and the agent listener uses mTLS); the real risk is a third-party host listener, such as a Docker TCP API on 0.0.0.0:2375, which any container could then reach. This is no more than B10's app-network gateway already gives. A host firewall rule that names the app network's bridge does not cover the per-project bridges (architecture.md, Project networks). - QM3a-9: apps are offline while ServerDock is down. The proxy that serves every app's public port is embedded in the ServerDock process, so while ServerDock restarts, crashes or is stopped, those ports do not answer. The containers keep running (
unless-stopped) but nothing routes to them. Measured (research 05 (on GitHub),kill -9at each deploy stage, then a fresh start on the same data), with one or two services: the outage, from the kill to the first answer from the app, was about 60 to 100 ms for a blue-green deploy at every stage (the server's own start and its first route apply). For a stop-first deploy killed atstart:beforeit was 0.23 to 0.35 s (the old version is started again), and inside the gap about 2.4 s with the tests' 2 s stop grace, and on a real service up to the 10 s cap on the candidate's stop plus the old version's start, because two versions never run at once. It grows with the install: before the first route apply the server makes one serial list and one inspect per container, then applies up to 100 ports in one load (plus bind isolation if a port is taken at boot: k taken ports cost k + 1 loads, and one-by-one probing happens only when a load error names no port; measured with 100 ports and 2 taken at boot: before commitd5f0327about 200 loads in 0.45 s, and 5 to 6 panel requests failed even after one retry; after it 3 loads in 7.7 ms with none failing); the 100-service figure is PENDING in research 05. While Docker does not answer at start, every app stays offline until the first list and inspect succeed: one inspect error aborts that pass and the watcher retries with a back-off of up to 30 s. A Docker daemon restart took 12.1 s in CI and 20.6 to 23.4 s locally to correct answers on both test ports (the bound is 30 s; it includes up to one back-off step). These figures are from a cloud container and CI, not a 1 GB VPS, and exclude the time a supervisor takes to restart a crashed process (the systemd unit is M7a). A downgrade is refused (newer schema), so apps stay offline until a matching binary runs. Revisited with M7b self-update. - N13: on Docker before 28.0.0, machines on the same local network may be able to reach app ports directly. On Docker Engine versions before 28.0.0 (ServerDock accepts 25 to 27), a machine on the same local network as the host can sometimes connect to an app container's ports directly, even though ServerDock never publishes them, by sending traffic for ServerDock's app subnet to the host. This may be possible when the host's firewall forwards traffic by default (the iptables
FORWARDpolicy isACCEPT), which is common when something other than Docker turned on IP forwarding, for example a VPN or router setup; since Docker 1.13 a default install sets the policy toDROPand is usually not exposed. ServerDock does not check the firewall and does not know whether a given host is affected.enable_icc=falseon the app network does not help: it limits traffic between containers, not traffic that arrives from outside. Docker Engine 28.0.0 and later block this by default (28.3.3 or later is best, because of an unrelated published-ports advisory, CVE-2025-54388). To fix it, upgrade Docker; if you cannot, set theFORWARDpolicy toDROPor add aDOCKER-USERrule that drops outside traffic to the app subnet, and do not share the host's local network with machines you do not trust. Sources, the exact conditions and what is unverified (the first affected version, IPv6, cloud VPS networks, the exactDOCKER-USERrule) are in research 06 (on GitHub). M3b builds the engine-version warning (worded "may be reachable", since ServerDock cannot see the firewall: the startup log,system.dockerand a standing line on the Overview Server card) and refuses to adopt a network whose gateway mode isnat-unprotected(and any driver option it does not set). ServerDock never setsgateway_mode_ipv4itself exceptnaton Docker 28 and later. The warning is not a fix and not a measurement: it is shown for every engine before 28.0.0 whether or not the host'sFORWARDpolicy isACCEPT. The daemon-wideallow-direct-routingoption (Docker 28.2.0 and later;daemon.json) turns off the filtering of packets from outside the host for published ports on every network. ServerDock publishes no app port on the host, so it does not change N13, but ServerDock cannot see the option and an operator who sets it for another service loses that protection on Docker 28 and later for whatever is published. system.exposureshows container names to anyreadcaller. It lists the names and published host ports of the containers on the host that ServerDock did not create, to anyreadtoken or session, and later to MCP. Areadtoken is already trusted with the service list, so this is accepted; it is the price of the SEC6 banner on Overview. It is a convenience, not a guarantee: anyone with Docker access can evade it (a foreign container carrying our instance label is left out), and when the panel listens on every interface it also names loopback- and private-address ports.- Deploy logs may hold app credentials (narrowed by M3b step 7). A deploy log is the tail of a container's output, kept for the last 10 deploys of a service. An app can print a generated admin password, a setup token or a connection string. ServerDock does not know which text is a secret, but since M3b it redacts every value it stores (the service's env secrets and the registry password) by exact match, in the forms listed in the A6 row, when a log is kept and again on every
deploys.logread; it cannot catch a transformed copy (base64, URL encoding, a short substring) or a secret the app generates itself, so the rest of this paragraph still holds for those. (M3a text, still true:) The output is cleaned for control and bidi characters and rendered as text, not hidden. It is inDATA/deploy-logs/(0600 in 0700, not indatadir.SecretPaths), is returned only bydeploys.log(session or awritetoken; neverread, never MCP). No backup covers it yet (the M7b state backup must decide). Anyone withwritescope, a session or access to the data directory can read it. M3b audits everydeploys.logread (AuditRead: an intent row before and an outcome row after; no log is returned if the intent cannot be written) and adds the sentinel test overdeploys.log,deploys.getreasons and stage details. Plan 0009'sdoctor --bundlemust still excludedeploy-logs/. - Registry hosts: closed by M3b step 6 for what ServerDock can check, with leftovers (see the A4 row on registry SSRF and "Added by M3b"). (M3a text, kept for history:) Registry hosts were only checked cosmetically (SSRF deferred to M3b). The Docker daemon, not ServerDock, fetches images, so ServerDock's dial-time checks (
internal/netpolicy, M5) cannot sit on that path. Refusing link-local and metadata IP literals, and loopback registries unless--allow-loopback-registryis set, stops mistakes and the plainest literals, but a registry can redirect, its tokenrealmcan point anywhere and a name can resolve to any address; pull error text can echo parts of a registry's answer (cleaned and capped, not hidden). It is acceptable for M3a for one reason: a deployer can already run a container with more reach than any pull has (B10). M3b, which sends registry credentials, applies the rule-10 checks to registry hosts. - Other costs M3a accepts:
- A Caddy reload (adding, changing or clearing a public port, deleting an exposed service, the first apply at boot, "Try again" for a failed port, bind isolation) can make a brand-new or reused connection get no response; it is expected never to have been processed (to be confirmed by the measurements), so safe to retry, and it closes open streams within 10 s. A switch, a revert, a restart, a rollback and the maintenance page never reload (an in-memory table swap). The measurements with 100 routes are in research 05 (on GitHub) (PENDING).
services.restartcauses a short outage (stated in the UI). Old images accumulate until M8 cleanup (anonymous volumes go with their container).- ServerDock must run on the host or with host networking to reach the app network (QM3a-7). No
no-new-privilegesby default (it breaks setuid images; M3b makes it per-service). - Two workers: a blue-green drain (up to 300 s) or a stop-first gap holds a worker and the service lock, so other services' jobs can wait up to about 10 minutes behind two of them, and a delete queued behind them may fail "confirm again".
- A silent Docker hang with the events stream still open is not noticed by the reconciler (a heartbeat would be a timer); the next job's own calls mark the service unknown.
Added by M4a (plan 0006 step 14; each is a risk we know about and carry, in plain words):
- Retired and removed keys stay in the write-ahead log until the next checkpoint (accepted, plan 0006 Revision 6).
PRAGMA secure_delete = ONoverwrites a replaced or deleted sealed key in the database file, but the copy in the write-ahead log stays until SQLite's next checkpoint (its automatic one at 1,000 pages, or a clean close), and in any backup or copy ofDATAtaken before. The key is still sealed under the master key in all of them.TestRetiredSealedKeysAreOverwrittenpins what is overwritten. - Managed keys and the ACME account key are unsealed in
DATA/caddy, and the certificates of removed domains stay there. certmagic writes them. The directory is 0700, its files 0600, it is a secret path, and a state backup must encrypt it (plan 0010). A restore without it re-issues every certificate (50 a week per registered domain) and under-counts the restart budget at the first boot; plan 0010 restores it with the database and warns when it is missing. - SNI with white space or control characters (accepted, Low). Caddy's
snimatcher does not trim, but certmagic's cache lookup does, so such an SNI can reach a different lookup than the matcher saw. A first connection policy that drops those SNIs was not practical in Caddy v2.11.9 (the matcher has no pattern form). The effect is a certificate for a name the admin already added, never an order (the deny permission holds) and never the control plane. - The restart budget is committed before a load, so a failed load over-counts, and Try again now is refused for up to 70 minutes for app domains too. A cancelled call can make 3 loads where 2 restarts are recorded (accepted edge). A name can also be paused before it was ever validated (three quick
domains.addcalls, boot plus one change, or about 100 failing names behind certmagic's limiter); its copy then says several attempts failed. Follow-ups are in plan 0006 Revision 12; the budget is never loosened from events. - Sibling subdomains. The panel and an untrusted same-site app are separated by the CSRF header, the exact
Origincheck and__Host-cookies, not by the domain. Use a panel domain whose parent hosts no apps of other people; Settings > Panel address says so. - A paused panel domain stays without a certificate until its resume job or "Try again now". The IP panel keeps working and nothing redirects meanwhile, the safe side; the domain is unavailable for up to the back-off (1 h, 4 h, then 24 h), and Try again is refused for up to 70 minutes while the restart window is full.
- The Host-based refusal and the re-secure checklist do not defend against an active man in the middle (I1). They protect an honest browser on a network that can only watch: whoever sits in the path controls the Host the client sends. The early-use guide still recommends an SSH tunnel.
- The diagnostics probe does not read routes (Revision 9 review fixes, item 2). The on-link prefix of every interface, this host's own addresses and the Docker and app networks are refused, but a static route, a WireGuard
AllowedIPsrange or another routed range is not read (that needs netlink), so an address reached through one can still be probed. The probe is one request with a random nonce, no redirect, and answers only whether the nonce came back (TestPrivateProbeResultIsNotAnOracle). The resolver asks at most three servers of/etc/resolv.conf, one second each, ignores its options and cannot see names onlynsswitchknows, so a locally resolved name can show as having no record. - For up to about 10 ms after a successful proxy load (
caddy.Load), a new connection can still be answered by the previous config, with its routes and certificates (accepted, Revision 10 review fixes, item 19; measured up to 9.5 ms). This is Caddy'sapp.stopbehaviour: it shuts the old servers down in goroutines the caller only waits to have started, soApplyDesiredreturns before the old servers stop accepting. The effect seen was the panel leaf instead of a newly uploaded certificate, for a name new to the config (or a closed connection); the previous config's routes and other certificates answer as they did. It never happens when the previous config already had that upload, and the new config never answers wrongly. A readiness probe would not close it, so none was added. - After a staging success certmagic tries production at once, outside the hard bound: up to 4 failed validations from restarts plus 2 retries of 2, so 8 in an hour for one name; Let's Encrypt then refuses that name for the hour and the back-off applies. A custom
--acme-directoryhas no staging, so every retry counts. - Every load restarts renewal attempts for trusted names that are failing renewal, and they are never paused (D10a). Repeated admin changes can use up that name's failed validations for the hour; there is no outage while the certificate is valid. There is no minimum interval between loads: it would delay a deliberate change with no outage to prevent.
- certmagic's
mailto:defaultaccount (E4). On a first start with several names and no e-mail, certmagic can register the contactdefault, which the CA rejects, and keeps it for the process. It shows asacme_contact_default("Set a contact email in Settings > HTTPS. A restart alone may not clear it."); at start an emptyusers/defaultfolder is removed (neverRemoveAll).account_keyis not set (it would put a private key in the config). Clearing the e-mail later does not remove it from the existing account. - Certificate events are best effort. Caddy delivers no event for an attempt that a later load cancelled, and such drops are invisible. No safety rule depends on an event: the redirect and the sign-in refusal read the served certificate's
NotBefore, the checklist is raised on any read, and the restart budget does not need events. - An upload expires unnoticed, and an expired upload keeps being served. Warnings at 30, 14 and 3 days and an Overview entry; Cloudflare sends no expiry notice; M8 notifies. Serving the expired certificate keeps the
:80redirect and is better than the panel leaf. - An Origin certificate does not hide the origin. A domain with a Cloudflare Origin certificate can still be reached directly, bypassing Cloudflare, with a certificate warning. Diagnostics flag an Origin certificate on a name that does not resolve to Cloudflare (
byo_origin_not_proxied). - Cloudflare's addresses are the client IPs of apps until Phase 2, and a panel domain behind Cloudflare's proxy keys the sign-in back-off on Cloudflare addresses. The panel domain behind the proxy is warned against, not refused (QM4a-4). Phase 2 must trust a client-IP header per route, never server-wide (no server sets
trusted_proxies). - An app domain shows a ServerDock "being set up" page over plain HTTP before its first certificate (QM4a-2), never the app over plain HTTP.
- ServerDock cannot see a cloud firewall from inside. A name that is not public always shows "unknown".
- An existing IP session keeps read access and non-Sensitive actions until it expires, after the panel domain becomes trusted. It cannot get fresh 2FA or change credentials on the IP.
- Superseded, not an accepted risk any more: "the old managed certificate can be served for a moment during a switch to an upload" (an upload always wins: a connection policy for the uploaded names never reads certmagic's cache), and "the panel name is outside the restart budget" (reversed in Revision 10; it is budgeted).
- A rule, not a risk: no server sets
trusted_proxies.
Lessons from competitors (see research (on GitHub))
- Coolify and Dokploy, 2026 CVEs: command injection through backups, build params, Traefik config, logs/terminal WebSockets, registry credentials and file mounts; unauthenticated RCE from public-repo PRs; a cross-org authz bypass. Coolify #7394: a 58 GB sessions table (G7).
- Portainer: privileged plugin ops; file read through git symlinks; unauthenticated init through restore; first-admin creation by whoever reaches a fresh instance first (setup token, M2).
- 1Panel: RCE through agent certificate verification (CVE-2025-54424; our pinned-CA check and role SAN); an X-Forwarded-For allow-list bypass (CVE-2025-66508; G2); a CSRF series; XSS (CVE-2026-23525).
- CapRover: a well-known default password (we have none; console setup token).
Disclosure
SECURITY.md with GitHub private vulnerability reporting, from the first public commit. (Built.)
Open items from the Phase 0 review
These were found in the systems/security review of plan 0001 (2026-11-20). The status is as of Phase 1 M1 (plan 0002 (on GitHub)). Rows 1–2 and 4–6 are closed in code, tests and the bench. Row 4 has a follow-up, G1 (yamux ping flood), found in this review.
Scroll sideways for more columns
| # | Item | Phase | Status |
|---|---|---|---|
| 1 | The agent bearer token travelled over plain ws:// on :80. |
1 | Closed (M1 step 5). Agents connect over wss (TLS 1.3) to the hub's own listener (--agent-listen, off by default), pinning the hub CA by fingerprint (ADR 0009). ws:// is loopback-only. The token is 43+ characters or generated into a 0600 file. |
| 2 | Caddy reloads dropped every remote agent after stream_close_delay. |
1 | Closed (M1 step 5). /agent/connect is served by the hub's own listener. The Caddy route and StreamCloseDelay are gone, and :80/agent/connect answers 404. A test shows that a Caddy reload keeps the session. |
| 3 | The shared token gives no per-agent identity: any token holder can claim any non-reserved id and replace that agent. Enrollment + mTLS must bind the id to the credential (ADR 0003). The local agent's id is already reserved. | 2 | Open. Phase 1 mitigation: remote agents are experimental, off by default and read-only. Only hello and logs are RemoteOK, an op missing from the table is refused, and this is enforced in the hub for every op. The token is at least 43 characters with at least 16 distinct ones (a generated token is 256-bit; a hand-made one is only screened). A failed-auth limiter bounds guessing. A token holder can still replace another agent's session and read logs. |
| 4 | No session cap, per-IP limit, per-agent stream cap or auth-failure rate limit. | 1 | Closed (M1 step 6), except the yamux window bound below. The ping-flood follow-up (G1, High) is built too: agent.GuardPings ends a session past 4 pings/s. The limits in place: 16 sessions (--agent-max-sessions, 503 before the upgrade); 4 TCP connections per IP and 128 in total on the agent listener (closed in Accept, before any TLS work); 5 auth failures/min per IP with burst 10 (429, checked before the token compare); 8 hub-opened streams per remote session (32 for the local one); an agent-opened stream ends that agent's session (yamux would keep an accepted-then-closed stream buffered for up to its close timeout); 32 streams per agent, with one error frame when over; header 64 KiB, body 1 MiB, 10 s header timeout (5 s, no keep-alives, on the agent listener); Caddy public server header and idle limits. Remaining risk: an attacker with many source IPs (4 connections each, 128 in total) can hold the agent listener's slots with slow handshakes, each dropped after 5 s and replaced by a new one. This blocks legitimate agents while it lasts. It needs a botnet and doesn't touch the control plane or the panel (separate listeners). |
| 5 | Non-streaming Docker API calls (inspect) had no timeout. | 1 | Closed (M1 step 4). Per-call deadlines: 30 s, and stop?t=N gets N + 15 s. Log follow is bounded by its context only. API negotiation refuses Docker older than Engine 25 (API 1.44). |
| 6 | No goroutine-leak tests. | 1 | Closed (M1 step 3). goleak runs in the hub, agent, api and cmd/serverdock test mains (and dockerapi). |
| 7 | The bench mounts docker.sock into the agent container (root-equivalent); keep it confined to the bench. |
ongoing | Open. |
| 8 | yamux can't bound a stream's receive window below 256 KiB (the library rejects any MaxStreamWindowSize under its initial window), so the plan's 64 KiB bound can't be expressed. |
1 | Resolved (maintainer-delegated decision, 2026-11-20). Keep the 256 KiB window (pinned by a test) and cap the hub at 8 streams per remote session (the local in-process session keeps 32). Steady-state worst case for hub-opened streams: 16 sessions × 8 × 256 KiB = 32 MiB, reached only if the hub's reader stalls. The bound holds because an agent-opened stream ends the session (agents never open streams). Closed hub streams can linger up to yamux's 10 s close timeout, bounded by how fast operators open them. A violating agent can briefly pin about 2 MiB per connection (8-stream backlog × 256 KiB) before its session is closed. Remote agents are logs-only in Phase 1, so 8 is enough. Control frames (pings) are not covered by this bound: see G1. |
Added by M3b (plan 0005 step 15; each is a risk we know about and carry, in plain words):
- Limits are off by default and there is no disk quota (QM3b-2, QM3b-3). No memory, CPU or no-new-privileges setting exists until an admin sets it, so one app can still use the whole host and the kernel may kill ServerDock (QM3a-9: every app's public port goes offline). Docker cannot enforce a per-container disk limit on overlay2 over ext4, so a container's writable layer and its volumes are not capped (a container's own log files still are). The UI shows a hint and OOM kills are reported; M8 adds disk alerts.
- Deploy logs are narrowed, not clean (above), and kept log files are sensitive in backups. Redaction is exact-match, so a transformed copy of a secret stays in the log and in the kept file, which is mode 0600 under a 0700 directory and not encrypted. A control-character copy of a secret can stay on disk: at the cut that keeps the newest 1 MiB, only the last (longest form minus 1) bytes are held back, so a copy made longer by control characters than that may have its leading part written raw, and a prefix of it can show on read when the copy straddles the cap. Read-time redaction does not cover env versions that were pruned: a log kept before a secret was replaced is redacted at write time with the versions then known, and the read uses only the deploy's own version and the service's current one, so an older log relies on the write-time pass. A multi-line secret's lines are hidden one by one only when each line is at least 8 bytes (
internal/redact/secrets.go); a shorter line of such a secret is not matched on its own. The agent's own scrubber skips env values under 4 bytes (minScrubLen,internal/agent/dockerapi/containers.go; secrets are 8 bytes or more by input rule, so this matters only together with the 512-byte cut). The agent cutsOpError.Msgto 512 bytes and has no secret list, so a secret split by that cut leaves its start in the message the server receives (the agent scrubs env values incontainer_createerrors and the auth value in pull and registry errors; nothing else). The M7b state backup must decide whether to includedeploy-logs/. - Docker holds env in clear.
docker inspectand anyone in thedockergroup, or root, read every container's environment, secrets included. ServerDock's ops never returnEnv, and the values are encrypted at rest in ServerDock's database, but a container's environment cannot be hidden from the Docker daemon. - An admin reads every secret.
services.env_revealshows one secret to a signed-in admin with a fresh second factor (audited,no-store, never to a token or MCP); an admin can also set any env, change a service's image and run any container the policy allows. Env secrets protect against a stolen database or backup, awritetoken and the logs, not against an admin. - Env and registry ciphertexts are only as safe as the master key.
DATA/keys/master.keydecrypts every env version and registry password; it is kept with the database (the data-directory compromise risk above), and a restore with a different key loses them (plan 0010:--forget-app-secrets). - The bind swap window and its actor. Docker mounts a bind by path at every start of the container, so a directory swapped for a symlink after the agent's re-resolve is followed at any later start (a restart included). The actors are a host user who can write inside a bind root (the owner, mode and group rules limit who that is) and a container with a writable bind covering that path (the overlap rule removes the second). On kernels before 5.12
read_onlyis not recursive for a bind, so a submount inside is writable. The group warning at start reads only/etc/groupmember lists (it misses primary-gid members and NSS sources such as LDAP or sssd). Roots on a network filesystem can make the checks slow. A container whose deploy row is gone is skipped by the overlap rule (relevant to M6 restores). - QM3b-11 does not cover everything that changes what a bind mount exposes. A mutable tag that is re-pushed and then redeployed (the same reference, no image change), an admin
env_setofLD_PRELOADand its kin, and a token'sservices.set_sourcebefore a bind mount exists are not gated. Thenosuid,nodevcheck warns and does not refuse (deviation 2 of plan 0005 step 8). - Registry leftovers (A4 row on registry SSRF): DNS rebinding after the check, the token
realm, blob redirects, a daemon-sideHTTPS_PROXYorregistry-mirrors, and a name that only the daemon resolves. Credentials are per install and per exact host key. The Docker Hubserveraddresswas not verified with real Hub credentials. The registry, or whoever answers for its name where TLS is not verified, can make the daemon send the stored password to another host (the token realm). Store a pull-only, least-privilege token, not an account password, and do not pair credentials withinsecure-registries. - Project-network reach (B10, above): a container on a project's internal network reaches host listeners on all interfaces through the gateway (for example a Docker TCP API), and a host firewall rule naming the app bridge does not cover the project bridges. A manual
docker network rmof a project network ends withprevious_version_downuntil a redeploy. Two ServerDock installs on one Docker host that deploy their first service at the same moment can pick the same /25; the loser's range is cleared and chosen again once if its network was never created (Revision 8 fix H), but a second race inside that window is not closed (--project-pooland--app-subnetare the answer). - B1: a blue-green candidate answers its service name before its health gate passes (R3, accepted by the maintainer 2026-11-28). The candidate joins the project network at create, with its service alias, so an app that connects to its database at start passes its gate; the price is that from the moment the new version starts until the old one stops, the name resolves to both versions (Docker's DNS returns both, in varying order), so a peer may reach an unhealthy candidate. Stop-first never overlaps, and an unhealthy candidate is removed within
health_timeout_s. - OOM reports can be missed or hidden. They come from Docker's event stream, so a kill during a gap in the stream is missed; the per-minute coalescing hides a second OOM inside the minute (a candidate OOM right after a live-version OOM can be hidden for up to a minute). Likewise, if the first-run write of the engine-version baseline fails, a version change at that same connection is absorbed as the baseline (the write is retried at the next connection; only that one notice is lost).
- Volumes are not backed up until M6, and an interrupted stop-first candidate has at most 10 s to stop. A stateful app that needs longer to stop after an interrupted stop-first deploy is killed, so plan a migration accordingly.
Unattended destructive actions
The complete list of destructive entries is three, and with the system-only mutates it is eight: auth.admin_reset (console recovery), reconciler.remove_container and reconciler.finish_deploy (the reconciler, M3a), reconciler.remove_network (the reconciler, M3b step 9), and four system-only mutates that M4a adds and lists here for review: domains.record_cert_event, domains.pause_acme, domains.resume_acme and panel.record_keep_ip_flag. (reconciler.finish_deploy and the four M4a actions are mutates, not destructive; they are listed because they run with no human at the keyboard.) Not on the list, on purpose: jobs.run_service_delete, jobs.run_deploy and jobs.run_restart run as the actor that queued them (with the policy re-checked at run time), never as system; the boot pass changes only database state (it settles interrupted deploys and writes one outcome row for each interrupted job intent), so it is not a destructive action. A future scheduled cleanup (M6, M8) must be added here first.
These are destructive actions that the SystemInvoker may run (System != ""). TestEveryUnattendedDestructiveActionIsListedInTheThreatModel (in internal/actions) fails when a destructive action with a System reason is not listed here by name, in backticks, with its reason, for security to review.
-
auth.admin_reset(M2 step 7): console recovery, not a scheduled job. It runs only in theserverdock admin resetprocess, as the system actor, because the operator at the console started it as the owner ofDATAwith the server stopped. It isConsoleOnly: every other actor (user, token, MCP, webhook) is denied, REST answers 404 and OpenAPI omits it, and the server's registry never contains it (TestServerRegistryHasNoAdminReset). It clears the password, TOTP, recovery codes, sessions, pending sign-ins, known IPs, the setup state and the key id, and revokes every API token, in one transaction; it keeps the user row, the panel leaf, the hub CA, the agent token and the master key. Docker form:docker run --rm -v <volume>:/data <image> admin reset --data /data --yes(stop the server container first;/datais the data path the image'sserver --data /datauses, so the command must name it, because the default--datais/var/lib/serverdock; the image runs as the uid that owns the volume, and the volume must be 0700). It opens the store like a server start, so pending migrations run (with the pre-migration backup). -
reconciler.remove_container(M3a step 10): unattended, system-only, no human at the keyboard. It isConsoleOnly(every actor except theSystemInvokeris denied, REST answers 404, OpenAPI omits it) and only the reconciler calls it, as the system actor, with the audit intent first and the outcome after (two rows per removal; a pass that removes nothing writes none). It removes one container of this install (the agent refuses any container that is not ours: the instance label and exactly our six labels) that no deploy owns: its service no longer exists, or its deploy is not the service's active one (the candidate of an interrupted deploy, the old version of a deploy that committed before a crash, a kept candidate). It stops it with the service's grace (10 s if the service is gone), capped at 10 s for a container of a deploy that never committed when its removal is what keeps the stopped active container from starting (the stop-first gap, an interrupted candidate: the outage lasts as long as that stop; the cap is the stop call's own grace parameter, no timer), keeps the log tail when the deploy's log exists (the hook is wired since step 11:log_keptis true only when a tail was kept,TestOrphanRemovalReportsLogKeptHonestly), and removes it with its anonymous volumes only; a named volume attached by hand survives (TestOrphanRemovalRemovesOnlyAnonymousVolumes). Guards: the reconciler never touches a service whose lock a job holds (it takes service locks withTryLockonly), never the current attempt of a deploy whose job is running, and removes a container whose address a stale proxy could still route to only after an apply that does not name it has succeeded, confirmed again under the service's lock right before the removal (the override is dropped and the route list applied; a job may have switched, failed its revert and kept its candidate since the pass's own apply) (otherwise the address could be handed to another service while a route still points at it). The container id is validated as 64 hex characters, so nothing else reaches Docker. Inside the action it also refuses a container whose deploy is the service's active one, whatever called it. -
reconciler.remove_network(M3b step 9): unattended, system-only, no human at the keyboard. The reason on the action is "crash reconciliation: remove a project network labelled with this install whose project no longer exists (never forced)". It isConsoleOnly(every actor except theSystemInvokeris denied, REST answers 404, OpenAPI omits it) and only the reconciler's full resync calls it, as the system actor, with the audit intent first and the outcome after (two rows per removal; a pass that finds no orphan writes none). It removes one network of this install: the name must be exactlyserverdock-<install id[:8]>-p<N>, the network must carryserverdock.managed=1, this install'sserverdock.instanceandserverdock.projectequal to the canonical decimal N, and the project N must have no row (checked in the resync and again inside the action). The agent checks the labels again on its own single inspect and deletes by the id it inspected; the network is never forced and is kept while any container labelled with the project exists, in any state (a stopped container cannot start on a network that was removed and made again), and while an endpoint of anything else is connected. Guards: the networks are listed before the project rows are read, so a project created during the pass is never an orphan; if the Docker list or the project query fails the rule is skipped; the resync takes the project's lock exclusively withTryLockonly (lock order: project, service, allocator, route) and skips a project that a deploy (which holds it shared until its container exists) or a service delete is using, so a create cannot land between the agent's container check and its delete. Anot_foundcounts as done only while that lock is held. Tests:TestResyncRemovesAnOrphanProjectNetworkWithoutForce,TestOrphanNetworkRuleSkipsABusyProjectAndAFailedProjectQuery,TestRemoveNetworkActionRechecksTheProjectAndReportsAConflict,TestRemoveNetworkIsSystemOnlyAndListed,TestDeleteOfLastServiceRacesANewServiceDeploy. -
reconciler.finish_deploy(M3a step 10, a mutate, listed here with its destructive sibling): the same system-only, audited form. It starts the stopped container of a service's active deploy (after a crash during a stop-first deploy, a Docker restart or a manual stop) and refuses unless the deploy is still the service's active one and the service is not flaggeddelete_interrupted(the check is inside the action, whatever called it). Inside the action it refuses while any container of another deploy of the service runs (two versions never run, whatever called it). The resync removes every container of another deploy first, after the apply that never names it, and only then asks for the start; there is no health gate of its own: the service's flags (previous_version_down,versions_kept) are cleared when the container is seen running andprevious_version_downis set when it does not come up. A service whose delete failed (delete_interrupted, or the same fact kept in memory if the flag could not be written) is never started. -
domains.record_cert_event(M4a step 6): unattended, system-only; a mutate.ConsoleOnly(every other actor is denied, REST answers 404, OpenAPI omits it). The embedded proxy'scert_obtainedandcert_failedevents call it through a 2 s writer adapter (a 64-entry buffer holds events that arrive before the registry is wired). It changes one existingdomainsrow (the classified problem, the CA text with tokens and e-mail addresses masked, the failure and obtained times) and, for a rate-limit problem, queues the one debounced pause job in the same transaction. It touches no certificate, key or proxy, ignores a name with no row (counted), and never queues a pause for the panel row. Tests:TestCertEventWritesTheRowAndIsSystemOnly,TestEventsBeforeRegistryAreBufferedThenWritten,TestPausedJWTNeverReachesAnAuditRowOrTheRow,TestPanelDomainEventsNeverQueueAPause. -
domains.pause_acme(M4a step 7): unattended, system-only; a mutate. Reason: "pause failing names to stay under Let's Encrypt's rate limits (plan 0006, D10a)".ConsoleOnly; only the server's job runner calls it, for the install-wide jobdomains_pause(a row of the existing jobs table, one queued at most, debounced 2 minutes, run by the scheduler's one timer). It takes every eligible app name (an automatic app domain with no present certificate that failed repeatedly; never an upload, a name with a trusted certificate or the panel row) out of the proxy'sautomatelist in one load; the row and the stored files stay, so no data is deleted. It re-checks each name when it runs, and pauses nothing and queues itself again whencert_statuscannot be read. Tests:TestOnePauseJobPausesAllEligibleNamesInOneLoad,TestPauseJobSkipsANameThatGotACertificate,TestPauseJobStatusErrorPausesNothingAndRequeues,TestNameWithTrustedCertNeverPaused. -
domains.resume_acme(M4a step 7): unattended, system-only; a mutate. Reason: "resume paused names when their pause has ended (plan 0006, D10a)".ConsoleOnly; run by the jobdomains_resumeon 15-minute boundaries. It puts every name whosepaused_untilhas passed back intoautomatein one load, skips a name that is gone, an upload or already served, and never resumes a Let's Encrypt "paused identifier" name (only an admin's Try again now does). Tests:TestResumesBatched,TestLetsEncryptPausedIdentifierIsNeverAutoResumed,TestResumeJobUsesTheSchedulerTimer. -
panel.record_keep_ip_flag(M4a step 10): system-only at start; a mutate. Reason: "record at start that the --panel-keep-ip flag changed (plan 0006, D14)".ConsoleOnly;runServercalls it once at start, only when the flag differs from the last recorded value, so an unchanged start writes nothing. It writes one meta key. Tests:TestKeepIPFlagIsRecordedBySystemOnly,TestKeepIPFlagAuditedAtStartWhenItChanges.
M1 close-out status
Recorded at the end of M1 (2026-11-20). Evidence is the tests named in plan 0002 (on GitHub) step by step and the commits in its M1 section.
Built in M1 (each with tests, go test -race ./... green):
- CI: the fail-closed
bench-gate, the docs-only reuse rule (pathspec allowlist), CODEOWNERS and Dependabot. - goroutine-leak tests in every package that starts goroutines.
- Docker: per-call deadlines, API negotiation, Engine 25+ required.
- The agent channel (ADR 0009): its own TLS 1.3 listener, a pinned hub CA, a role marker, lazy renewal, token rules, read-only remote agents (
RemoteOK), the per-session stream caps, the agent-opened-stream rule, and the yamux ping guard (G1). - Limits: per-IP auth-failure limiter before the token compare, session cap, per-IP connection caps in
Accept, header and body limits; limiters never evict a blocked key (G3, M1 part). - The debug socket (0600 in a 0700 directory) replaces the TCP debug listener.
- Store: forward-only migrations with a pre-migrate backup, foreign-key-safe table rebuilds, the one-server lock (a 0600 file), and a read-only open that works next to a live server as another user.
- The audit log: a hash chain with boot ids,
audit verify, redacted rows, rate-limited denied rows.audit verifyruns as root on a service-owned data dir (production,TestAuditVerifyAsRootOnServiceOwnedData) and as a non-owner uid on a test-built permissive tree (TestAuditVerifyAsAnotherUser); it creates no files. - The action registry: risk tiers, the per-actor policy table, the one-time
SystemInvoker, and the three built-in read actions. No HTTP route reaches it yet.
Still open, with an owner:
- Open item #3 (no per-agent identity) and #7 (bench mounts
docker.sock): Phase 2 and ongoing. - G2, G4–G11, G13 and the rest of G3 (per-account TOTP back-off, a per-/48 bucket): M2 or later, as the gap table says.
- Not detectable by design: truncating the tail of the audit log, or someone who can write the file rebuilding the whole chain. Compare the head hash and row count (logged at start, returned by
system.info) with an older copy; M7b stores them in state backups. - In the audit chain, NULL and an empty string hash the same for
executorandapprover.Appendnever writes an empty string, so switching between them takes direct file access and changes no meaning. - A denied-row window dropped while its table is full of in-progress windows loses its "suppressed" count. That needs thousands of distinct actor+action pairs denied inside one minute.
- The
update.jsonskip of the pre-migrate backup is M7b, written together with the file. - A local user who can already read the service user's files can do far more than anything here; the 0600 lock file and the 0700 debug directory only close the cheap local-denial cases.
M2 close-out status
Recorded at the end of M2 (2026-11-21). Evidence is the tests named above and in plan 0003 (on GitHub) step by step, and the commits in its step list. security approved the design (ADR 0010, now accepted) and each step, 1 to 13.
Built in M2 (each with tests; go test -race ./... green on macOS and in Linux as root and non-root; the Playwright and axe suite green in eight projects):
- G2 (control plane on a unix socket, XFF only from it), G3 (limiter wiring: four back-offs, one hash at a time), G4 (the auth state machine,
admin reset), G5 (first-run token, tunnel hint, no fingerprint on an unauthenticated page, "Admin created fromat - Panel TLS on
:443with a leaf of its own,:80redirect (M4a adds challenges), the setup token, admin and TOTP, recovery codes, sessions, API tokens, the REST API generated from the action registry with an OpenAPI 3.1 golden, the SPA embedded with a hash-based CSP, and the first-run, sign-in and Security screens (WCAG 2.2 AA checked by axe in eight Playwright projects; manual screen-reader passes for steps 12 and 13 are still the maintainer's). - The database upgrade path:
testdata/v2.dbandtestdata/v3.dbopen with the real migration list and the audit chain verifies (TestV2FixtureOpensAndMigrates,TestV3FixtureOpensMigratesAndTheAuditChainVerifies).
Found by the tests, fixed: Caddy's DEBUG log printed the X-SD-CSRF header (a log encoder now redacts it); SvelteKit's route announcer carried an inline style the CSP blocks (a build plugin swaps it for a class).
Still open, with an owner:
- WebSocket routes do not exist yet: when they arrive (logs, terminal) they must pass the same session and exact-
Originrules and join the route matrix. - G11 (agent token file), G13 (log rendering), G14 (SBOM and provenance), G15 (IP panel after M4) and open items #3 and #7: unchanged, owned as the gap table says.
- Accepted risks added in M2: host-scoped cookies (SEC6), user-name enumeration by a multi-IP attacker, a shown-once token or recovery codes staying on screen until hidden or the page is left, an expired leaf (after as little as about 60 days of uptime if last started with just over 60 days left; about two years after a fresh leaf), the known-IP bypass of the per-account password back-off, clipboard history keeping a copied seed or codes, and the
keep_tokensopt-out (see Accepted risks). - The maintainer's manual screen-reader passes for steps 12 and 13 (checklists in plan 0003) and the CI bench numbers for the PR.
M3a close-out status
Recorded at the end of M3a (2026-11-27). Evidence is the tests named in the rows above and in plan 0004 (on GitHub) step by step (Revisions 5 to 20), and the commits in its step list. Each step 1 to 14 was reviewed by security where the plan required it. security reviewed this close-out (plan 0004 step 15) and approved it after one revision (container resource limits added as an accepted risk); ADR 0012 is accepted.
Built in M3a (each with tests):
- The op protocol v1 and the typed Docker client (ADR 0012), with ownership by label enforced in the agent, the create policy checked in both processes on the exact bytes, and
hello/logsas the only remote ops. - Jobs and the scheduler (one "next due" timer, two workers, one running job per service), actors stored in jobs and re-checked at run time,
JobOnlyactions. - The app network, static addresses and the allocator; app routes in the embedded Caddy with per-port bind isolation, and switches that never reload.
- Blue-green and stop-first deploys with the commit order, restart, redeploy, rollback, cancel and delete; the reconciler (boot pass, events watcher, resync rules) and its two system-only actions.
- Deploy logs, and the Services, Service and Deploy screens (WCAG 2.2 AA checked by axe in eight Playwright projects; manual screen-reader pass pending).
- G13 partly (deploy logs); the A4 rows for the policy, ownership, addresses, jobs, routes, logs and delete.
Still open, with an owner:
- ADR 0012: accepted (2026-11-27).
- The maintainer's manual screen-reader pass for steps 12 to 14: PENDING (M3a screen-reader checklist (on GitHub)).
- Measurements: PENDING (research 05 (on GitHub)): the CI "S2 live watcher" number (the release gate; the bench job does not run on a draft PR), full S4, S2 with one and with ten exposed services, RSS after a deploy, and the reload cases with 100 routes.
- Accepted risks B10, QM3a-9, N13,
system.exposure, deploy logs holding app credentials and the registry-host deferral (see Accepted risks). N13 has no engine-version warning. - Carried to later plans: the sentinel test over deploy output and
doctor --bundleexclusion (plans 0005, 0009); registry-host rule-10 checks,no-new-privilegesper service and automatic stop-first for writable volumes (plan 0005); adoctorcheck of the app subnet (plan 0009); a negativeOOMScoreAdjustfor ServerDock in the unit (plan 0009); revisit QM3a-9 and pause the scheduler for the trial boot (plan 0010). - Optional follow-ups from the reviews, with what they leave open:
expect_liveonservices.redeploy: until it exists, a redeploy confirmed from a stale page runs the version that is live when the action arrives, which may not be the one the page showed (a refresh-to-confirm gap; it needs a signed-in session orwritescope).- A minimum interval between reconciler
Kick()calls: until it exists, repeated service actions while Docker is down can reconnect the events stream faster than the back-off. - Sending agent errors out of band: until then a container can stop its own log from being kept by starting its output with the error prefix.
- The e2e test teardown sweeps
sdpw-*directories in the shared/tmpon developer and CI machines (a test-tooling side effect, not a server one).
- G11, G13 (live logs and MCP), G14, G15 and open items #3 and #7: unchanged, owned as the gap table says. WebSocket routes still do not exist.
M3b close-out status
Recorded at the end of M3b (2026-12-02; plan 0005 step 15). Evidence is the tests named in the rows above and in plan 0005 (on GitHub) step by step (Revisions 2 to 11). security reviewed steps 1 to 14 where the plan required it (steps 13 and 14: approved after their fix round, CI green at d3f4ed7) and this close-out, after a fix round (plan 0005 Revision 11). The maintainer's confirmation of this AI-written draft is still open.
Built in M3b (each with tests): env vars and secrets with audited reveal, rollback that restores the env version, deploy context variables, the redactor and the sentinel suite, registry credentials with rule-10 checks, volumes (stop-first when writable) and bind mounts behind --bind-root, per-project networks with service DNS, memory and CPU limits with no-new-privileges and OOM reports, the Docker version check with the pre-28 warning and the nat-unprotected refusal, the Docker RC CI job, and the screens.
Hand-offs to later plans (also in plan 0005, "Notes this plan hands to later plans"):
- Plan 0009 (M7a):
doctor --bundleexcludesdeploy-logs/and never holds decrypted env;doctorchecks the project subnets and the gateway mode; the install docs cover--bind-root(nosuid,nodev, a private group) and the pre-28 warning; systemd hardening must not give ServerDock a mount view of the bind roots that differs from dockerd's (noProtectSystem,PrivateMounts,ReadOnlyPathsor a mount namespace of its own), and under a mount namespace thenosuid,nodevwarning should read/proc/1/mountinfo. - Plan 0010 (M7b): backups hold env and registry ciphertexts and need the key; a restore with a wrong key goes through
--forget-app-secrets; the backup decides aboutdeploy-logs/; volumes are not in the state backup. - Plan 0011 (M8): cleanup lists detached and unattached volumes; OOM may feed notifications; disk alerts.
- Plan 0012 (M9, MCP): MCP never gets
env_get,env_revealordeploys.log. Today MCP is denied all three only because MCP is read-scope and they needwrite(internal/actions/policy.go, theKindMCPcase:act.scope > ScopeRead). If plan 0012 widens MCP beyond read, it must name all three in the MCP denial test and in the policy. - Plan 0007 (M5):
SD_COMMITis set by the git flow;netpolicymay reuse the registry address classes. Plan 0008 (M6): Compose maps onto env versions, volumes (the bind rules apply) and project networks.
Still open, with an owner:
- The maintainer's manual screen-reader pass for the steps 13 and 14 screens: PENDING (plan 0005 test plan; the M3a checklist is in
docs/accessibility/). - The manual 1 GB VPS check (plan 0005 test plan) is informational and was not run (no 1 GB host here).
- The maintainer's confirmation of this AI-written draft.
- Carried: G11, G13 (live logs and MCP), G14, G15 and open items #3 and #7: unchanged.
M4a close-out status
Recorded at the end of M4a (2026-12-02; plan 0006 step 14). Evidence is the tests named in the rows above and in plan 0006 (on GitHub) step by step (Revisions 6 to 12). security reviewed steps 1 to 10 where the plan required it; steps 11 to 13 had their review rounds in Revisions 10 and 11. This close-out is for security to review, and the maintainer's confirmation of this AI-written draft is open. M4a is implemented on branch m4a (PR #35, merge pending); it is not "built" until it merges.
Built in M4a (each with tests): domains with automatic Let's Encrypt HTTPS and per-domain diagnostics, certificates you upload (Cloudflare Origin recognised by signature), the restart budget with pauses and resumes, the panel domain with its redirect, sign-in refusal, HSTS and re-secure checklist, ACME settings and flags, IPv6 ingress, SD_FQDN, the Pebble integration suite, and the screens (Service > Domains, Domain details, Upload certificate, Settings > HTTPS, Settings > Panel address, the Overview entries, the refused sign-in page). G15 is closed and G5's M4 part is built; rule 12 is restated for explicit names with a global deny.
Hand-offs to later plans are in plan 0006 ("Notes this plan hands to later plans"): netpolicy for M5 (0007); no server-wide trusted_proxies and per-route client IPs for Phase 2; doctor checks and the doctor --bundle exclusion of DATA/caddy for M7a (0009); DATA/caddy inside the encrypted state archive, restored with the database and warned about when missing, for M7b (0010); notifications for failed certificates, pauses and expiring uploads for M8 (0011); MCP sees domains.list, panel.status and acme.get only (0012); the panel domain as the passkey RP ID for M4b (0013).
Still open, with an owner:
- The manual real-domain check: BLOCKED, not run (it needs a real domain and a host, which the build environment does not have). The exact checklist is in plan 0006 Revision 12. It is a required exit item; the maintainer runs it.
- The maintainer's manual screen-reader pass for the steps 12 and 13 screens: PENDING (checklist (on GitHub)).
- The Let's Encrypt paused-identifier sample is confirmed against Boulder's source and many real production reports, which were pasted by users, not recorded by ServerDock, and show no JSON bytes. Let's Encrypt staging uses another portal host (
portal-staging.letsencrypt.org), which is not on the allowlist, so a staging pause is classified as an ordinary rate limit; adding it is the maintainer's decision (plan 0006 Revision 12, open question 1). - Release numbers (the full S4 and S2 medians, the sentinel suite on CI): PENDING. The one-off 200-name lag run did not complete: 9 of 200 names were never tried, probably paused untried (an inference, rows not inspected); open question 5 in plan 0006 Revision 12 is for
systems. - Three upstream reports are drafted and not posted (plan 0006 Revision 12); the maintainer decides.
- Departure 2 of plan 0006 Revision 11 (the SPA fallback for domain pages,
isDomainRoute) is forsecurityto confirm. - The Caddy upgrade checklist in architecture.md must be walked at every Caddy or certmagic bump.
- Carried: G11, G13 (live logs and MCP), G14 and open items #3 and #7: unchanged.
Debug access
--debug-listen and --debug-allow-remote are removed. --debug-socket PATH serves /debug/* (memory, agent list, log proxy) on a unix socket created 0600 inside a directory that must be 0700 and owned by the service user; the server refuses a looser directory. There is no TCP debug listener. The log proxy can stream any container's logs, local or remote, so the socket counts as service-user-level access. It joins the M2 route matrix.