security: harden the pre-authentication request surface - #333
Conversation
…ed host header - middleware: the pre-setup wizard window passed ALL /setup-api/* with no auth; narrow it so desktop/agent backends (files, browser, code workspace, remote desktop, and the gateway-token endpoints) stay gated even during onboarding, while the wizard's own routes — incl. gateway/health — keep working. They fall through to the normal session / MCP-bearer checks, so authed callers are unaffected. - gateway proxy: validate the Host header to hostname/IP chars and JSON-encode it before embedding in the injected <script> (reflected-XSS hardening). - add middleware coverage for the gate (sensitive blocked, health open, session allowed).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe gateway setup route validates host values and safely serializes WebSocket URLs. Middleware now requires authentication for sensitive setup APIs during setup. Tests cover denied, allowed, and authenticated access paths. ChangesSetup API security hardening
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant middleware
participant RouteClassifier
participant AuthChecks
Client->>middleware: Request setup API route
middleware->>RouteClassifier: Classify route sensitivity
RouteClassifier-->>middleware: Sensitive or non-sensitive
middleware->>AuthChecks: Check MCP bearer or session
AuthChecks-->>middleware: Authentication result
middleware-->>Client: JSON 401 or continue to route
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🦀 ClawReviewYour friendly reef crab, here with the lay of the land. Tightens the pre-authentication surface during the first-boot setup window: a list of sensitive desktop/agent backends (file access, browser automation, code workspace, VNC, tunnels, and the gateway token endpoint) are now gated behind a session or MCP bearer even before setup completes, closing a window where those routes were reachable unauthenticated over the open At a glance
Good to know
— ClawReview 🦀, your resident reef crab. Just orientation — CodeRabbit does the line-by-line, humans do the merge. Conventions: docs. |
…ackup restore, tunnel enable, app install/uninstall) + normalize trailing slash
Part of the ongoing security-hardening sweep (targeting
beta).What this does — narrows what is reachable before a session exists: several privileged
/setup-api/*surfaces that play no part in first-boot onboarding are no longer served during the pre-setup window, while the wizard's own routes (including the gateway readiness check) keep working. Also hardens a reflected request-header sink by validating and encoding it before it reaches an inline script.Authenticated callers and the MCP bearer path are unaffected — the gated routes simply fall through to the normal session checks.
Validation — build + full unit suite on the Jetson; new middleware coverage for the gate (sensitive routes blocked pre-setup, readiness route still open, valid session allowed) passes 59/59 in isolation. The one unrelated failure in the full run is the known
updatertiming flake (fixed separately in #332).Vulnerability specifics intentionally omitted from this public description.
Summary by CodeRabbit