fix: close the 20 findings of the security and reliability audit #56
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/audit-fixes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes the 20 findings of the whole-app audit, one commit per finding (related ones share a commit).
The one change in shape is the sandbox network:
The NixOS module does the same on Docker 28+, creates the podman network with
--disable-dns(netavark then adds no gateway), and drops everything fromrunner.subnetin the host firewall (iptables or nftables).Runner homes follow the database by reconciliation, every 15 minutes and 10 s after an access, server or user change:
Evidence
--internalnetwork,connect 10.231.99.1:22(the host's sshd on the bridge gateway) ->open. The new VM test probe against the previous module:AssertionError: open 10.231.71.1.After: all seven VM tests pass (
nix build .#vm-test-docker,-podman,-docker-gvisor,-podman-gvisor,-docker-nftables,-podman-nftables,-docker25); each boots mcphub, the runner and the egress proxy and probes the sandbox. Each also removes the firewall rule and shows the probe then gets in, so the rule is what closes the host.docker25covers a Docker too old for the option, where only the rule protects.POST /%61pi/auth/loginwithOrigin: https://evil.examplereached the/api/auth/loginhandler while the hook sawrequest.url = /%61pi/auth/loginand returned early.After:
auth.test.ts"applies the CSRF check and session to a percent-encoded path": 403, no cookie set.GET /api/me/servers-> 500.After:
encryption-rotation.test.ts: 200 with the other servers listed;reencryptAllmoves values to the current key and reports the unreadable row.docs/deployment.mdcomes from running that engine in a throwaway VM: Docker 29.9.2 (no host address), 27.5.1 (upfails), 26.1.5 and 25.0.16 (option ignored, host keeps the address), Podman 6.1.4 with podman-compose 1.6.0 (upfails) and with docker-compose on its socket (option dropped silently, host keeps the address).nix flake checkpasses;nix develop -c ./scripts/ci.shpasses: lint, typecheck, tests (shared 7, api 366, runner 53 + 2 skipped, web 170), build,npm audit0 vulnerabilities.docker compose --profile prod config -qpasses, also withcompose.gvisor.yaml.mcphub:latestimages); the migrate guard's shell logic was run on its own. Docker 28.x and 24 or older were not run (not in the nixpkgs pin), nor Docker 25 together with nftables.trail checkreports two conflicts, both keyword matches on unrelated text: a comment ingovernance.ts("a deleted user's calls stay") against the tool-kinds learning, and the VM-test sentence indocs/deployment.mdagainst the "pure Nix base image" learning; neither decision is touched.Merge Danger
Door: one-way
Migration
0012_tool_calls_keep_historymakestool_calls.user_idnullable withSET NULLand adds a backfilleduser_email; rolling the code back needs the column changes undone by hand. The runner now deletes home directories: on uninstall, on user deletion, and for every key the reconciliation finds unbacked, which includes uninstalling a server whose row is gone or no longer stdio.Blast Radius: deployments
Compose installs must act before upgrading:
POSTGRES_PASSWORDstillmcphub: themigrateservice now refuses to run. Change the role's password first (steps indocs/deployment.md).up.MCPHUB_BINDnow defaults to127.0.0.1: a reverse proxy on another host needsMCPHUB_BIND=0.0.0.0.ISOLATE_UIDS=true), in compose and the NixOS module.Behaviour changes inside the app:
OIDC_AUTO_PROVISIONno longer creates an account for an unverified email unlessOIDC_ALLOW_UNVERIFIED_EMAIL=true(IdPs that never sendemail_verified, such as Entra by default, need it). Statements on the app pool are cancelled after 30 s. Retention is off by default (0keeps rows forever), so the two log tables keep growing until the settings are set; an old API talking to a new runner, or the reverse, only loses the home cleanup.🤖 Generated with Claude Code