Skip to content

feat(gateway): take the control token on the older /svc REST state routes - #740

Closed
andrewpark-scaleai wants to merge 1 commit into
andrewpark/vuln-5158-callers-send-control-tokenfrom
andrewpark/vuln-5158-gateway-guard
Closed

andrewpark-scaleai wants to merge 1 commit into
andrewpark/vuln-5158-callers-send-control-tokenfrom
andrewpark/vuln-5158-gateway-guard

Conversation

@andrewpark-scaleai

@andrewpark-scaleai andrewpark-scaleai commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

DO NOT MERGE until the scaleapi and synthetic-pipelines caller PRs are merged and deployed. Once this ships in a gateway image, a caller of these routes that does not send the control token gets a 401.

Why

The gateway's data plane routes take the control token. This PR applies the same rule to the older REST state routes behind /svc/<key>/, so every state-changing or state-reading route behind the gateway uses one auth scheme.

What changed

  • LEGACY_STATE_ROUTES in gateway/constants.py lists the older state routes: /api/reset, /api/add, /api/bridge/apply, /export-state, /export-snapshot, /snapshot-dirty, /reset-memory, /validate-rows, /api/_state, /api/_reset and /api/debug/seed.
  • token_paths adds them to every /svc/<key>/ route. Matching reuses reaches, so paths are normalized before the check.
  • A site's /website/<site>/ route serves none of these routes. The harness reaches sites through /svc/<site>/.
  • A gateway booted without a token behaves as before.
  • The verifier that run_bundle_built_envs_test.py embeds sends the run's grant to /export-state.

Rollout

Verification

  • tst/unit/env/gateway/control_token_test.py: 354 passed. tst/unit/env/gateway: 1356 passed. ruff check is clean.
  • Integration tests on local Docker through a token-booted gateway pass.

RetriggerView in GreptileConfidence Score: 5/5

No code issues found that block merging, but the external caller rollout must finish first.

Summary

The gateway now requires the control token for older state routes under /svc and blocks those routes under /website when a token is configured.

  • Legacy state routes behind /svc/ now require the control token.
  • Token-enabled website links no longer forward legacy state routes.

No new actionable issues found. Keep the stated rollout hold until the external callers are merged and deployed.

Reviews (2) · Last reviewed commit: "feat(gateway): take the control token on..." · Reviewed by Greptile

@andrewpark-scaleai
andrewpark-scaleai force-pushed the andrewpark/vuln-5158-gateway-guard branch from 6da03e2 to 0c48886 Compare November 17, 2026 18:39
@andrewpark-scaleai
andrewpark-scaleai force-pushed the andrewpark/vuln-5158-callers-send-control-token branch 2 times, most recently from 51545f0 to ffa4ca9 Compare November 18, 2026 18:55
@andrewpark-scaleai andrewpark-scaleai changed the title fix(gateway): refuse the legacy state routes behind /svc without the control token (VULN-5158) feat(gateway): take the control token on the older /svc REST state routes Nov 19, 2026
@andrewpark-scaleai
andrewpark-scaleai marked this pull request as ready for review November 19, 2026 18:26
@andrewpark-scaleai
andrewpark-scaleai requested a review from a team as a code owner November 19, 2026 18:26
…utes

LEGACY_STATE_ROUTES lists the older state routes a backing server serves
beside its data plane. On a gateway with a control token, every /svc/<key>/
route takes the token for each of them, after path normalization. A site's
/website route serves none of them. A gateway booted without a token behaves
as before.
@andrewpark-scaleai
andrewpark-scaleai force-pushed the andrewpark/vuln-5158-gateway-guard branch from 0c48886 to ab1fd64 Compare November 19, 2026 18:48
@andrewpark-scaleai
andrewpark-scaleai force-pushed the andrewpark/vuln-5158-callers-send-control-token branch from ffa4ca9 to 58f18f0 Compare November 19, 2026 18:48
@andrewpark-scaleai
andrewpark-scaleai deleted the andrewpark/vuln-5158-gateway-guard branch November 19, 2026 18:52
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