Skip to content

security: fail-closed legacy policy, trusted proxy and defensive defaults (Track B) - #513

Merged
athNdev merged 3 commits into
mainfrom
codex/security-hardening-track
Nov 18, 2026
Merged

athNdev merged 3 commits into
mainfrom
codex/security-hardening-track

Conversation

@athNdev

@athNdev athNdev commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Summary

Defensive-only Track B hardening (plan reviewed READY_FOR_IMPLEMENTATION). No exploit code, no live probing, no deployment or release changes.

  • Fail-closed legacy HTTP policy (ADR 0027): one requireRequestObject helper in internal/rpc/handlers/policy.go; metrics, streaming upload, mod browse, staged config and Packwiz management now deny on nil enforcer/auth. Staged-config apply/rollback/discard resolve the staged record's real owning server before authorizing (cross-server IDOR refusal). ADR 0012 compatibility routes and explicit allow_no_auth remain supported.
  • Trusted proxy / headers (ADR 0029): HSTS, throttle client IP, Packwiz generated URL scheme and WS forwarded-host are gated on server.trust_proxy. New proxy.trusted_proxy_cidrs (default empty) means inbound PROXY v2 headers are trusted only from configured load balancer ranges; untrusted headers stay in the byte stream with the peer address retained. cmd/status binds loopback by default. New opt-in server.require_ws_origin strict mode (default false for CLI compatibility).
  • Credentials (ADR 0028): new servers get CSPRNG RCON passwords; legacy deterministic values are warned about, never silently rewritten; blank passwords keep RCON disabled per Minecraft semantics and are warned about. Custom roles with roles:create/roles:update can no longer assign built-in admin or grant wildcard resource/action without the new non-default roles/manage_wildcard capability.
  • WS lifecycle: failed AUTH now clears identity and drops log subscriptions; subscribe/command use RPC-parity object checks including subuser grants; command length and log-tail bounds.
  • Detection / egress / content: failed logins and recovery-key use are audited; log redaction covers Bearer/token/x-api-key; provider key validation no longer reflects upstream bodies; datapack install destinations are checked with files.WithinReal.
  • ADR bodies 0027-0032 added only (no knowledge/decisions/adrs.md edit - orchestrator owns the index).

Verification

  • go test ./... - all packages green (including new negative fixtures in internal/rpc/handlers/fail_closed_policy_test.go, proxy trusted-CIDR tests, RCON password tests, WS identity test, role escalation tests).
  • go vet ./... - clean.
  • go run ./cmd/knowledge-lint -root . before and after -fix: 38/38 queries, indexes current, no knowledge files changed.
  • No frontend files changed; no Bun/Chromium run required. Windows/UAC test flow unchanged; listeners in tests remain loopback/fixture-only.

Compatibility / migration

  • Reverse-proxy users should set server.trust_proxy: true; users with an upstream PROXY-protocol load balancer must set proxy.trusted_proxy_cidrs. Defaults fail closed for untrusted headers without breaking direct deployments.
  • Existing RCON credentials are never rotated silently; operators rotate via the existing server configuration path. Blank-password servers continue to boot with RCON disabled.
  • require_ws_origin is opt-in to preserve CLI/native WebSocket clients.

Deliberate limits / dependencies

  • B-00 shared contracts (auth.BootstrapAudit, auth.SessionValidator) remain Track A owned; no B-local auth hooks were created. First-admin claim atomicity across local+OIDC, API-token revocation on password change and open-socket session revocation are deferred to Track A.
  • Backup-encryption default change remains gated on the custody design (location outside data/backups, recovery, rotation, operator acknowledgement); plaintext archives are never silently re-encrypted.
  • Bounded Packwiz/ZIP import limits, image digest recording/strict mode and module sidecar confinement parity are documented as follow-ups (ADRs 0030/0031), not claimed here.
  • No live Docker daemon, Minecraft server, provider, remote node or public system was contacted. Evidence is static inspection, generated fixtures and the test suites above.

Draft PR: independent review and required CI must pass before merge; author will not merge.

@athNdev

athNdev commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Review fixes at 139759195cd3cfcbe93a619d45149ff54556a9d6

  • HIGH — role creation escalation: CreateRole now applies the same roles/manage_wildcard ceiling as UpdatePermissions/AssignRole, before any store write. Creating a default role is also gated (default roles are auto-granted to new users). Negative fixture in TestRoleService_WildcardGrantRequiresCapability proves refusal and that neither role is persisted; an admin can still deliberately create a wildcard role.
  • HIGH — status sidecar reachability: the built-in Status Panel template now sets HOST=0.0.0.0 in DefaultEnv, matching the module's published port and health check. TestBuiltinStatusPanelPublishesReachablePort pins the env/port/documentation contract; docs/deployment-modes.md documents that these endpoints are unauthenticated and that standalone cmd/status needs an explicit HOST.
  • MEDIUM — ADR/code reconciliation: ADR 0028 now states recovery-key auditing is implemented directly with auth.recovery_used/auth.denied activity events and that no B-00 hook was created; orchestrator should relay those event names to Track A. No duplicate hook.
  • LOW: staged-config authorizes the path server before looking up a staged ID (no existence oracle for unauthorized callers); login/recovery audit IPs use the same trust-aware realClientIP as the throttle key; RCON generation fails closed with an error and blank password (no predictable sentinel stored as a credential); import order fixed.

Verification: bounded tests for all touched packages, then full go test ./... and go vet ./... green; knowledge-lint 38/38 queries, indexes current. No new deployment, release or live probing. Draft retained for fresh exact-head review; author will not merge.

@athNdev
athNdev marked this pull request as ready for review November 18, 2026 03:41
@athNdev
athNdev merged commit 9150826 into main Nov 18, 2026
32 checks passed
@athNdev
athNdev deleted the codex/security-hardening-track branch November 18, 2026 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant