Repository navigation
fix(env): send the control token to the REST routes behind the gateway - #728
Closed
andrewpark-scaleai wants to merge 1 commit into
Closed
andrewpark-scaleai wants to merge 1 commit into
andrewpark-scaleai wants to merge 1 commit into
Conversation
This was referenced Nov 17, 2026
andrewpark-scaleai
force-pushed
the
andrewpark/vuln-5158-callers-send-control-token
branch
2 times, most recently
from
November 18, 2026 18:55
51545f0 to
ffa4ca9
Compare
andrewpark-scaleai
marked this pull request as ready for review
November 18, 2026 19:23
The legacy REST helpers (reset_via_rest, add_via_rest, export_state, reset) take headers and default to the run's grant. Legacy loads, resets, state reads and streamed snapshots send the deployment's token. A grant covers a URL only when it resolves under the grant's address, by whole path segments. A legacy reset refused with 401 or 403 raises instead of falling back to the MCP tool.
andrewpark-scaleai
force-pushed
the
andrewpark/vuln-5158-callers-send-control-token
branch
from
November 19, 2026 18:48
ffa4ca9 to
58f18f0
Compare
andrewpark-scaleai
deleted the
andrewpark/vuln-5158-callers-send-control-token
branch
November 19, 2026 18:52
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.
Why
The gateway's data plane calls send the control token. This PR makes agent-env's calls to the older REST state routes send it too, so a later gateway change can require it there.
What changed
reset_via_rest,add_via_rest,export_stateandresetinlegacy_protocoltakeheaders. Without them, each call sends the run's grant (request_headers).data_plane_headers).service_stateand the snapshot step send the deployment's token to/export-stateand to a streamed/export-snapshot.granted_headersmatches a URL to a grant only when the URL resolves under the grant's address, by whole path segments.<name>_resetMCP tool.Scope
/api/reset,/api/add,/export-stateand/export-snapshot.Verification
Authorizationheader on each legacy route when a token exists, and its absence when none does.pytest packages/agentenv-protocol/tests tst/unit/env tst/unit/task_step -n 4: 7808 passed, 1 skipped, 0 failed.ruff checkis clean.tst/integration/env/envs/multi_env_local_test.pypassed on local Docker.

Confidence Score: 5/5
This PR appears safe to merge; no blocking issues were found.Summary
This PR adds control-token headers to legacy state calls and streamed snapshots, while keeping tokens scoped to the destination address.
No actionable issues found. Gateway enforcement remains separate in PR #740; its callers remain compatible with these changes.
Reviews (2) · Last reviewed commit: "fix(env): send the control token to the ..." · Reviewed by Greptile