Skip to content

fix(server): require a GHP-issued token on the management host API paths - #312

Merged
goodtune merged 8 commits into
mainfrom
fix-296-management-host
Nov 6, 2026
Merged

goodtune merged 8 commits into
mainfrom
fix-296-management-host

Conversation

@goodtune

@goodtune goodtune commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

The management host serves GHES-style paths (/api/v3/ and /api/graphql) through the API proxy handler. Requests without a ghx_/gha_ token were forwarded to api.github.com unchanged, so the instance was an open, anonymous GitHub proxy that shared its egress rate limit (seen live: 403 "API rate limit exceeded" for the egress IP).

A new middleware, proxy.RequireGHPToken, now wraps these two routes only.

Fixes #296

Behaviour change

On the management host's /api/v3/ and /api/graphql:

  • No credential (or an Authorization header that does not parse): 401, WWW-Authenticate: Bearer realm="ghp", message "Authentication with a GHP-issued token (ghx_ or gha_) is required".
  • Any other credential (gho_, ghp_, ghs_, github_pat_, unknown strings, basic auth with a non-ghp password): 403, whatever the block.* settings are. If the border policy blocks that token type, the body keeps "Token type is not permitted by the border policy" (no change for existing clients or BORDER-C43); otherwise it is "Native GitHub tokens are not accepted on the GHP management host; use a GHP-issued token (ghx_ or gha_)".
  • ghx_/gha_ requests are unchanged.

The api.github.com virtual host is unchanged; the border policy still governs it. There is no config option: no documented client needs anonymous or native access to the GHES-style paths, and raw pass-through stays available on the api.github.com virtual host.

New metric ghp_management_host_rejected_total{reason="anonymous"|"native_token"}. Rejections are timed under the border_policy_check and total decision stages.

Docs: docs/how-it-works.md (security model), docs/features/border-policy.md (note), docs/admin/monitoring.md (metric). Design note: docs/superpowers/specs/2026-11-06-296-design.md.

Rig

New scenarios under the existing claim GAP-A8:

  • GAP-A8.anonymous-rest — GET /api/v3/user with an empty Authorization header, expect 401 + message.
  • GAP-A8.anonymous-graphql — anonymous { viewer { login } } on /api/graphql, expect 401 + message.
  • GAP-A8.native-token-rest — fake gho_ token on /api/v3/user, expect 403 (message not asserted, as it depends on block.gho).

tools/scoperig/expect adds both new messages to the GHP denial prefixes so ghp_denial: true holds.

Test plan

  • go test ./internal/proxy -run TestRequireGHPToken (anonymous, unparseable, native blocked/unblocked, basic auth, ghx_/gha_ on both paths; counter deltas)
  • go test ./internal/server -run TestManagementProxyHandler (mux wiring on both paths)
  • go test ./internal/metrics -run TestManagementHostRejectedTotal
  • make check, go test ./tools/scoperig/..., make scoperig-validate, go test ./internal/proxy -run GHCorpus
  • golangci-lint run ./internal/... ./tools/scoperig/...: no findings in changed files
  • Live rig run: GAP-A8.* pass; BORDER-C43/C44 still pass

Part of #329

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

✅ E2E Test Results — Passed

Total Passed Failed Skipped
144 144 0 0
Test Details
Test Browser Status Duration
admin-apps.spec.ts › Admin - Multi-App Management › admin page shows Apps section with empty state chromium ✅ Pass 0.8s
admin-apps.spec.ts › Admin - Multi-App Management › can create an app and form collapses after chromium ✅ Pass 1.1s
admin-apps.spec.ts › Admin - Multi-App Management › token sections appear after creating an app chromium ✅ Pass 0.7s
admin-apps.spec.ts › Admin - Multi-App Management › can edit an app via inline edit form chromium ✅ Pass 1.0s
admin-apps.spec.ts › Admin - Multi-App Management › edit form cancel closes without saving chromium ✅ Pass 0.8s
admin-apps.spec.ts › Admin - Multi-App Management › agent token fields hidden until app selected with multiple apps chromium ✅ Pass 0.8s
admin-apps.spec.ts › Admin - Multi-App Management › created app appears in the apps table with correct details chromium ✅ Pass 0.8s
admin-apps.spec.ts › Admin - Multi-App Management › can delete an app via the admin UI chromium ✅ Pass 0.9s
admin-apps.spec.ts › Admin - Multi-App Management › multiple apps appear in the apps table chromium ✅ Pass 0.7s
admin-apps.spec.ts › Admin - Multi-App Management › app selector is hidden when only one app exists chromium ✅ Pass 0.7s
admin-apps.spec.ts › Admin - Multi-App Management › app selector appears when multiple apps exist chromium ✅ Pass 0.7s
admin-apps.spec.ts › Admin - Multi-App Management › app selector auto-selects the default app chromium ✅ Pass 0.7s
admin-apps.spec.ts › Admin - Multi-App Management › admin page shows Apps section with empty state firefox ✅ Pass 1.9s
admin-apps.spec.ts › Admin - Multi-App Management › can create an app and form collapses after firefox ✅ Pass 1.4s
admin-apps.spec.ts › Admin - Multi-App Management › token sections appear after creating an app firefox ✅ Pass 0.9s
admin-apps.spec.ts › Admin - Multi-App Management › can edit an app via inline edit form firefox ✅ Pass 1.2s
admin-apps.spec.ts › Admin - Multi-App Management › edit form cancel closes without saving firefox ✅ Pass 1.1s
admin-apps.spec.ts › Admin - Multi-App Management › agent token fields hidden until app selected with multiple apps firefox ✅ Pass 1.0s
admin-apps.spec.ts › Admin - Multi-App Management › created app appears in the apps table with correct details firefox ✅ Pass 1.0s
admin-apps.spec.ts › Admin - Multi-App Management › can delete an app via the admin UI firefox ✅ Pass 1.1s
admin-apps.spec.ts › Admin - Multi-App Management › multiple apps appear in the apps table firefox ✅ Pass 1.0s
admin-apps.spec.ts › Admin - Multi-App Management › app selector is hidden when only one app exists firefox ✅ Pass 1.6s
admin-apps.spec.ts › Admin - Multi-App Management › app selector appears when multiple apps exist firefox ✅ Pass 1.0s
admin-apps.spec.ts › Admin - Multi-App Management › app selector auto-selects the default app firefox ✅ Pass 0.9s
admin-apps.spec.ts › Admin - Multi-App Management › admin page shows Apps section with empty state webkit ✅ Pass 5.0s
admin-apps.spec.ts › Admin - Multi-App Management › can create an app and form collapses after webkit ✅ Pass 3.0s
admin-apps.spec.ts › Admin - Multi-App Management › token sections appear after creating an app webkit ✅ Pass 1.2s
admin-apps.spec.ts › Admin - Multi-App Management › can edit an app via inline edit form webkit ✅ Pass 2.4s
admin-apps.spec.ts › Admin - Multi-App Management › edit form cancel closes without saving webkit ✅ Pass 1.3s
admin-apps.spec.ts › Admin - Multi-App Management › agent token fields hidden until app selected with multiple apps webkit ✅ Pass 1.2s
admin-apps.spec.ts › Admin - Multi-App Management › created app appears in the apps table with correct details webkit ✅ Pass 1.2s
admin-apps.spec.ts › Admin - Multi-App Management › can delete an app via the admin UI webkit ✅ Pass 1.7s
admin-apps.spec.ts › Admin - Multi-App Management › multiple apps appear in the apps table webkit ✅ Pass 1.2s
admin-apps.spec.ts › Admin - Multi-App Management › app selector is hidden when only one app exists webkit ✅ Pass 1.1s
admin-apps.spec.ts › Admin - Multi-App Management › app selector appears when multiple apps exist webkit ✅ Pass 1.2s
admin-apps.spec.ts › Admin - Multi-App Management › app selector auto-selects the default app webkit ✅ Pass 1.2s
admin-apps.spec.ts › Admin - App API endpoints › GET /api/apps returns empty array when no apps exist chromium ✅ Pass 0.0s
admin-apps.spec.ts › Admin - App API endpoints › POST /api/apps creates an app and returns it chromium ✅ Pass 0.0s
admin-apps.spec.ts › Admin - App API endpoints › GET /api/apps/{id} returns app details chromium ✅ Pass 0.0s
admin-apps.spec.ts › Admin - App API endpoints › DELETE /api/apps/{id} removes the app chromium ✅ Pass 0.1s
admin-apps.spec.ts › Admin - App API endpoints › POST /api/apps rejects missing required fields chromium ✅ Pass 0.1s
admin-apps.spec.ts › Admin - App API endpoints › app API endpoints require admin role chromium ✅ Pass 0.0s
admin-apps.spec.ts › Admin - App API endpoints › GET /api/apps returns empty array when no apps exist firefox ✅ Pass 0.1s
admin-apps.spec.ts › Admin - App API endpoints › POST /api/apps creates an app and returns it firefox ✅ Pass 0.0s
admin-apps.spec.ts › Admin - App API endpoints › GET /api/apps/{id} returns app details firefox ✅ Pass 0.1s
admin-apps.spec.ts › Admin - App API endpoints › DELETE /api/apps/{id} removes the app firefox ✅ Pass 0.1s
admin-apps.spec.ts › Admin - App API endpoints › POST /api/apps rejects missing required fields firefox ✅ Pass 0.0s
admin-apps.spec.ts › Admin - App API endpoints › app API endpoints require admin role firefox ✅ Pass 0.0s
admin-apps.spec.ts › Admin - App API endpoints › GET /api/apps returns empty array when no apps exist webkit ✅ Pass 0.1s
admin-apps.spec.ts › Admin - App API endpoints › POST /api/apps creates an app and returns it webkit ✅ Pass 0.1s
admin-apps.spec.ts › Admin - App API endpoints › GET /api/apps/{id} returns app details webkit ✅ Pass 0.1s
admin-apps.spec.ts › Admin - App API endpoints › DELETE /api/apps/{id} removes the app webkit ✅ Pass 0.1s
admin-apps.spec.ts › Admin - App API endpoints › POST /api/apps rejects missing required fields webkit ✅ Pass 0.1s
admin-apps.spec.ts › Admin - App API endpoints › app API endpoints require admin role webkit ✅ Pass 0.1s
auth-api.spec.ts › Auth API › GET /auth/status returns unauthenticated without session chromium ✅ Pass 0.0s
auth-api.spec.ts › Auth API › GET /auth/status returns authenticated with session chromium ✅ Pass 0.0s
auth-api.spec.ts › Auth API › GET /auth/github redirects to GitHub OAuth chromium ✅ Pass 0.0s
auth-api.spec.ts › Auth API › POST /auth/logout clears session chromium ✅ Pass 0.0s
auth-api.spec.ts › Auth API › API endpoints require authentication chromium ✅ Pass 0.0s
auth-api.spec.ts › Auth API › GET /auth/status returns unauthenticated without session firefox ✅ Pass 0.0s
auth-api.spec.ts › Auth API › GET /auth/status returns authenticated with session firefox ✅ Pass 0.0s
auth-api.spec.ts › Auth API › GET /auth/github redirects to GitHub OAuth firefox ✅ Pass 0.0s
auth-api.spec.ts › Auth API › POST /auth/logout clears session firefox ✅ Pass 0.4s
auth-api.spec.ts › Auth API › API endpoints require authentication firefox ✅ Pass 0.0s
auth-api.spec.ts › Auth API › GET /auth/status returns unauthenticated without session webkit ✅ Pass 0.0s
auth-api.spec.ts › Auth API › GET /auth/status returns authenticated with session webkit ✅ Pass 0.1s
auth-api.spec.ts › Auth API › GET /auth/github redirects to GitHub OAuth webkit ✅ Pass 0.0s
auth-api.spec.ts › Auth API › POST /auth/logout clears session webkit ✅ Pass 0.1s
auth-api.spec.ts › Auth API › API endpoints require authentication webkit ✅ Pass 0.0s
dashboard.spec.ts › Dashboard - no apps configured › hides token sections when no apps exist chromium ✅ Pass 0.7s
dashboard.spec.ts › Dashboard - no apps configured › hides token sections when no apps exist firefox ✅ Pass 0.9s
dashboard.spec.ts › Dashboard - no apps configured › hides token sections when no apps exist webkit ✅ Pass 1.0s
dashboard.spec.ts › Dashboard › renders dashboard with user info chromium ✅ Pass 0.3s
dashboard.spec.ts › Dashboard › shows Create Token section with form fields chromium ✅ Pass 0.2s
dashboard.spec.ts › Dashboard › shows Active Tokens section chromium ✅ Pass 0.2s
dashboard.spec.ts › Dashboard › duration dropdown has expected options chromium ✅ Pass 0.2s
dashboard.spec.ts › Dashboard › renders dashboard with user info firefox ✅ Pass 0.5s
dashboard.spec.ts › Dashboard › shows Create Token section with form fields firefox ✅ Pass 0.4s
dashboard.spec.ts › Dashboard › shows Active Tokens section firefox ✅ Pass 0.4s
dashboard.spec.ts › Dashboard › duration dropdown has expected options firefox ✅ Pass 0.4s
dashboard.spec.ts › Dashboard › renders dashboard with user info webkit ✅ Pass 1.4s
dashboard.spec.ts › Dashboard › shows Create Token section with form fields webkit ✅ Pass 0.7s
dashboard.spec.ts › Dashboard › shows Active Tokens section webkit ✅ Pass 0.7s
dashboard.spec.ts › Dashboard › duration dropdown has expected options webkit ✅ Pass 0.7s
dashboard.spec.ts › Dashboard - multi-app selection › requires app selection before showing token form with multiple apps chromium ✅ Pass 0.8s
dashboard.spec.ts › Dashboard - multi-app selection › auto-selects and shows form with single app chromium ✅ Pass 0.7s
dashboard.spec.ts › Dashboard - multi-app selection › requires app selection before showing token form with multiple apps firefox ✅ Pass 1.0s
dashboard.spec.ts › Dashboard - multi-app selection › auto-selects and shows form with single app firefox ✅ Pass 0.9s
dashboard.spec.ts › Dashboard - multi-app selection › requires app selection before showing token form with multiple apps webkit ✅ Pass 1.3s
dashboard.spec.ts › Dashboard - multi-app selection › auto-selects and shows form with single app webkit ✅ Pass 1.2s
login.spec.ts › Login page › renders the login page with branding chromium ✅ Pass 0.2s
login.spec.ts › Login page › displays the build version beneath the login form chromium ✅ Pass 0.1s
login.spec.ts › Login page › has a Sign in with GitHub button linking to OAuth chromium ✅ Pass 0.1s
login.spec.ts › Login page › unauthenticated root redirects to login chromium ✅ Pass 0.1s
login.spec.ts › Login page › renders the login page with branding firefox ✅ Pass 0.4s
login.spec.ts › Login page › displays the build version beneath the login form firefox ✅ Pass 0.3s
login.spec.ts › Login page › has a Sign in with GitHub button linking to OAuth firefox ✅ Pass 1.2s
login.spec.ts › Login page › unauthenticated root redirects to login firefox ✅ Pass 0.4s
login.spec.ts › Login page › renders the login page with branding webkit ✅ Pass 0.7s
login.spec.ts › Login page › displays the build version beneath the login form webkit ✅ Pass 0.5s
login.spec.ts › Login page › has a Sign in with GitHub button linking to OAuth webkit ✅ Pass 0.5s
login.spec.ts › Login page › unauthenticated root redirects to login webkit ✅ Pass 0.5s
logout.spec.ts › Logout › sign out button logs user out and redirects to login chromium ✅ Pass 0.4s
logout.spec.ts › Logout › sign out button logs user out and redirects to login firefox ✅ Pass 0.6s
logout.spec.ts › Logout › sign out button logs user out and redirects to login webkit ✅ Pass 1.6s
tokens.spec.ts › Token management › can create an open-scoped token (no repos, no permissions) chromium ✅ Pass 1.0s
tokens.spec.ts › Token management › can create a scoped token with repository and permissions chromium ✅ Pass 1.1s
tokens.spec.ts › Token management › can create a token with multiple repositories chromium ✅ Pass 0.9s
tokens.spec.ts › Token management › created token appears in the Active Tokens list chromium ✅ Pass 0.8s
tokens.spec.ts › Token management › can revoke a token chromium ✅ Pass 1.0s
tokens.spec.ts › Token management › repo select uses multi mode chromium ✅ Pass 0.6s
tokens.spec.ts › Token management › form labels indicate optional fields chromium ✅ Pass 0.2s
tokens.spec.ts › Token management › permission select loads from API and shows available scopes chromium ✅ Pass 0.7s
tokens.spec.ts › Token management › permission select respects API-returned scope restrictions chromium ✅ Pass 0.7s
tokens.spec.ts › Token management › can create a scoped token with pull_requests permission chromium ✅ Pass 0.9s
tokens.spec.ts › Token management › can create an open-scoped token (no repos, no permissions) firefox ✅ Pass 1.1s
tokens.spec.ts › Token management › can create a scoped token with repository and permissions firefox ✅ Pass 1.2s
tokens.spec.ts › Token management › can create a token with multiple repositories firefox ✅ Pass 1.1s
tokens.spec.ts › Token management › created token appears in the Active Tokens list firefox ✅ Pass 0.9s
tokens.spec.ts › Token management › can revoke a token firefox ✅ Pass 1.1s
tokens.spec.ts › Token management › repo select uses multi mode firefox ✅ Pass 0.9s
tokens.spec.ts › Token management › form labels indicate optional fields firefox ✅ Pass 0.4s
tokens.spec.ts › Token management › permission select loads from API and shows available scopes firefox ✅ Pass 1.7s
tokens.spec.ts › Token management › permission select respects API-returned scope restrictions firefox ✅ Pass 0.9s
tokens.spec.ts › Token management › can create a scoped token with pull_requests permission firefox ✅ Pass 1.1s
tokens.spec.ts › Token management › can create an open-scoped token (no repos, no permissions) webkit ✅ Pass 2.7s
tokens.spec.ts › Token management › can create a scoped token with repository and permissions webkit ✅ Pass 2.7s
tokens.spec.ts › Token management › can create a token with multiple repositories webkit ✅ Pass 2.0s
tokens.spec.ts › Token management › created token appears in the Active Tokens list webkit ✅ Pass 1.3s
tokens.spec.ts › Token management › can revoke a token webkit ✅ Pass 1.9s
tokens.spec.ts › Token management › repo select uses multi mode webkit ✅ Pass 1.0s
tokens.spec.ts › Token management › form labels indicate optional fields webkit ✅ Pass 0.7s
tokens.spec.ts › Token management › permission select loads from API and shows available scopes webkit ✅ Pass 1.1s
tokens.spec.ts › Token management › permission select respects API-returned scope restrictions webkit ✅ Pass 1.1s
tokens.spec.ts › Token management › can create a scoped token with pull_requests permission webkit ✅ Pass 2.1s
webhooks.spec.ts › Admin - Webhooks › app form takes a webhook secret and the table shows it chromium ✅ Pass 0.9s
webhooks.spec.ts › Admin - Webhooks › apps without a secret are marked and can be given one inline chromium ✅ Pass 0.9s
webhooks.spec.ts › Admin - Webhooks › webhooks panel reflects server state and shows deliveries chromium ✅ Pass 0.9s
webhooks.spec.ts › Admin - Webhooks › app form takes a webhook secret and the table shows it firefox ✅ Pass 1.1s
webhooks.spec.ts › Admin - Webhooks › apps without a secret are marked and can be given one inline firefox ✅ Pass 1.1s
webhooks.spec.ts › Admin - Webhooks › webhooks panel reflects server state and shows deliveries firefox ✅ Pass 1.0s
webhooks.spec.ts › Admin - Webhooks › app form takes a webhook secret and the table shows it webkit ✅ Pass 1.5s
webhooks.spec.ts › Admin - Webhooks › apps without a secret are marked and can be given one inline webkit ✅ Pass 1.4s
webhooks.spec.ts › Admin - Webhooks › webhooks panel reflects server state and shows deliveries webkit ✅ Pass 1.3s

📸 Screenshots & report: Download artifacts
📊 Workflow run: View details

Run #825 · 2026-11-06 08:15:04 UTC

@goodtune
goodtune marked this pull request as ready for review November 6, 2026 07:20
@goodtune
goodtune force-pushed the fix-296-management-host branch 2 times, most recently from 170b7fc to 9af1a4f Compare November 6, 2026 07:40
@goodtune
goodtune force-pushed the fix-296-management-host branch from 9af1a4f to 1e9a329 Compare November 6, 2026 07:50
@goodtune goodtune added bug Something isn't working security labels Nov 6, 2026
@goodtune
goodtune merged commit 320f917 into main Nov 6, 2026
6 of 7 checks passed
@goodtune
goodtune deleted the fix-296-management-host branch November 6, 2026 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scoping: management host is an open anonymous proxy to api.github.com via /api/v3 and /api/graphql

1 participant