Repository navigation
fix(server): require a GHP-issued token on the management host API paths - #312
Merged
Merged
Conversation
Contributor
✅ E2E Test Results — Passed
Test Details
📸 Screenshots & report: Download artifacts Run #825 · 2026-11-06 08:15:04 UTC |
goodtune
marked this pull request as ready for review
November 6, 2026 07:20
goodtune
force-pushed
the
fix-296-management-host
branch
2 times, most recently
from
November 6, 2026 07:40
170b7fc to
9af1a4f
Compare
…ths (#296) Anonymous requests to /api/v3/ and /api/graphql on the management host now get 401 and native GitHub tokens get 403, instead of being forwarded to api.github.com. Adds ghp_management_host_rejected_total{reason}.
…, extra header cases)
goodtune
force-pushed
the
fix-296-management-host
branch
from
November 6, 2026 07:50
9af1a4f to
1e9a329
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The management host serves GHES-style paths (
/api/v3/and/api/graphql) through the API proxy handler. Requests without aghx_/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:401,WWW-Authenticate: Bearer realm="ghp", message "Authentication with a GHP-issued token (ghx_ or gha_) is required".gho_,ghp_,ghs_,github_pat_, unknown strings, basic auth with a non-ghp password):403, whatever theblock.*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 theborder_policy_checkandtotaldecision 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/userwith 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— fakegho_token on/api/v3/user, expect 403 (message not asserted, as it depends onblock.gho).tools/scoperig/expectadds both new messages to the GHP denial prefixes soghp_denial: trueholds.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 TestManagementHostRejectedTotalmake check,go test ./tools/scoperig/...,make scoperig-validate,go test ./internal/proxy -run GHCorpusgolangci-lint run ./internal/... ./tools/scoperig/...: no findings in changed filesPart of #329