Skip to content

s1: request-level identity gate + read-only MCP proxy allowlist - #90

Open
jasandroidx wants to merge 1 commit into
ravenstackfrom
s1-lock-doors
Open

jasandroidx wants to merge 1 commit into
ravenstackfrom
s1-lock-doors

Conversation

@jasandroidx

Copy link
Copy Markdown
Owner

s1-lock-doors: every request into the Keep now carries a provable identity, and the browser proxy can only reach read-only MCP tools.

What changed

Request-level identity gate (all SSR page loads + server functions)

  • New src/start.ts registers createKeepGateRequestMiddleware() — it runs before every SSR render and server function (and /api/auth/*). Returns 401 unless the request clears:
    1. VERCEL runtime → skipped (preview only)
    2. VITE_AUTH_ENABLED=false and a loopback Host — the dev override, which can never fire through Tailscale serve
    3. Tailscale-User-Login ∈ KEEP_ALLOWED_LOGINS (defaults to the operator login; explicit empty value locks the Tailscale path to nobody)
    4. x-keep-internal === KEEP_INTERNAL_TOKEN (tagged-device bearer)
  • createCsrfMiddleware is restored explicitly so CSRF protection survives replacing the framework's default middleware array.
  • SSE/build assets (/assets/, /hall/, /__grok/, common extensions) are exempt; everything else — including SSR HTML — is gated.
  • Pure gate logic lives in src/lib/auth/tailscale-gate.ts (no React imports, unit-tested 1:1).

Read-only proxy allowlist

  • callFastMCP (the browser's POST proxy) now refuses any tool outside KEEP_READONLY_TOOLS — exactly 12 read-only tools — and strips confirm from params. Refusals return blocked: true.
  • audit_county_budget and oracle_verify stay refused: the audit pipeline is frozen, and oracle_verify has no registered implementation on the fortress MCP surface (see follow-up below). The Sentinel panels now render an explicit "🛑 Tool blocked by the Keep allowlist" box for these, never a fake bridge error.
  • Human gate decisions still travel only through the dedicated decideGate server function (unchanged).

Auth header hardening

  • The preview-session bearer moved out of GET-query sendContext (which TanStack serializes into the URL) into the Authorization request header; the server hook reads it back via getRequest() from @tanstack/react-start/server.

Honest gateway + model display

  • tail_gateway_logs proxy path replaced by a normalized getGatewayLogs server function ({ ok, lines[], error? }, execFile fixed args, fail-closed) — the Mechanic streamer renders exactly that shape, "UNREACHABLE" when unreadable.
  • Raziel only names the gateway's primary model when it observes it live (openclaw_models, 3s timeout race) — otherwise he says he cannot see it, never invents one.
  • The header identity chip now shows the request's actual gate identity (Tailscale login / BOT · internal / DEV · local) via getKeepIdentity.

Tests

  • New: src/lib/auth/tailscale-gate.test.ts + src/lib/keep/fastmcp-allowlist.test.ts (allowlist refusals incl. county_queue_approve, write_repo_file, service_restart, audit_county_budget, oracle_verify; stripConfirm).

Validation

  • npm run typecheck ✅
  • npm test ✅ 84/84 (requires a Node build with the TS type-stripping engine — the box's distro /usr/bin/node v22.22.1 is compiled without it; tests run under official Node 22.23.2 at /opt/node-v22.23.2-linux-x64, repo untouched)
  • npm run build:box ✅

Deploy notes (box, after merge)

  • Pull + npm run build:box + systemctl restart ravenstack-keep-ui (token/env lives in gitignored ui-v2/.env; already present — the service restart loads it).
  • KEEP_INTERNAL_TOKEN was generated on the box and appended to ui-v2/.env (chmod 600); it is not in this PR, tests, or logs.

Follow-up (labeled jules)

  • oracle_verify remains blocked pending a real implementation on the fortress MCP; re-review once one exists.

- new request middleware (src/start.ts) runs before every SSR page load and
  server function; 401 unless Tailscale-User-Login is allowlisted (operator
  default) or a tagged device carries KEEP_INTERNAL_TOKEN; loopback dev
  override only with VITE_AUTH_ENABLED=false; Vercel previews skipped
- callFastMCP browser proxy refuses anything outside KEEP_READONLY_TOOLS (12
  read-only tools); county audit + Oracle verify + every write/human-gate
  tool stays blocked, surfaced as blocked:true in the Sentinel panels
- preview bearer auth moved from GET-query context into the Authorization
  request header so the token never lands in URLs or logs
- gateway log tail normalized to {ok, lines[], error?} via getGatewayLogs
  (execFile, fixed args, authMiddleware); Raziel names the gateway model only
  when observed live (openclaw_models, 3s race) or says it is unknown
- header identity badge (getKeepIdentity) replaces the dev-build chip
- unit tests for both pure modules; parseAllowedLogins(undefined) keeps the
  default, explicit empty string locks the tailscale path to nobody
@vercel

vercel Bot commented Sep 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ravenstack-keep Ready Ready Preview Sep 23, 2026 2:33am UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview — 4915e03e Deployed Sep 23, 2026 by vercel[bot]
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