Repository navigation
fix(security): Older REST data routes behind the gateway proxy (/api/reset, /export-state, /export-snapshot) take no control token - #776
scale-avr[bot] wants to merge 4 commits into
Conversation
…hind /svc/mcp-<name>/
…xport-state calls
|
🤖 Automated Claude routine — Env Pod PR Context Review. This is a bot, not Edgar Arakelyan; not a human review. Context from outside this diff: two other open PRs are already guarding these same routes, so whoever reviews this probably wants to decide which version is the one to keep.
One concrete gap inside this PR, independent of which list wins: Both of those are still drafts, so this PR may simply be ahead of them; flagging it only because the overlap isn't visible from this diff alone. Generated by Claude Code |
…stubs An env outcome verifier can take a control_headers argument, so a check that reads a server's REST data routes through the gateway sends the deployment's control token. The composed-universe test verifier and the snapshot state test stubs now match the guarded routes.
|
Superseded by #820 (released in v0.9.1639) and #822 (v0.9.1642, now the default gateway in dev and prod). #820 makes every agent-env caller of the older REST state routes send the deploy's control token, and #822 makes the gateway require it on those routes (/api/reset, /api/add, /api/bridge/apply, /export-state, /export-snapshot, /snapshot-dirty, /reset-memory, /validate-rows, /api/_state, /api/_reset, /api/debug/seed). The optional control_headers argument this PR adds for verify() scripts isn't needed: verify runs under Task.run's grant of each deployed env's token, so a script's calls through the protocol client or request_headers() already send it. |
Merge risk: High. Review impact before merge.
Not checked: The reproduction of an earlier fix reproduces on the new code and on the code before this change. This change did not undo that fix. Review must confirm that the earlier fix still holds.
Finding:
src/agent_env/env/gateway/gateway.pyRoot cause: Fixed the CI failures on this PR. The "unit" and "integration-local-slow" jobs failed for two causes. First, three snapshot_agent_state unit tests used export_state stubs that did not take the new headers argument. They now do. Second, the composed-universe integration test has a verifier that read…
Before merge:
Details: proof ladder, not fixed, files
How sure is this fix?
.avr/tests/legacy_data_routes_poc.pywritten by AVR's accepted proof. Before the fix it coverage not checked: the finding names no file and line.python3 -m py_compile src/agent_env/task_step/task_steps/verifiers/env_outcome_verifier.py tst/unit/task_step/verifiers/test_env_outcome_verifier_step.pycd src/agent_env/utils/egress_proxy && go vet .cd src/agent_env/utils/egress_proxy && go test .cd packages/agentenv-protocol && uv run --frozen --no-sync python -m pytest -q -rfE -p no:cacheprovider tests/test_a2a_agent.py tests/test_a2a_agent_clock.py tetest_a_control_headers_parameter_gets_the_deployments_control_token in tst/unit/task_step/verifiers/test_env_outcome_verifier_step.pyNot fixed by this PR
Files changed (4)
src/agent_env/task_step/task_steps/verifiers/env_outcome_verifier.pytst/integration/cli/run_bundle_built_envs_test.pytst/unit/task_step/verifiers/test_env_outcome_verifier_step.pytst/unit/task_step/test_snapshot_agent_state.pyOther findings this PR fixes
an earlier finding
Merge risk: Medium. Review verification before merge.
Not checked: The reproduction of an earlier fix reproduces on the new code and on the code before this change. This change did not undo that fix. Review must confirm that the earlier fix still holds.
Finding:
src/agent_env/env/gateway/gateway.pyRoot cause: The REST helpers reset_via_rest, add_via_rest and _export_state_at in legacy_protocol.py now pass their final URL through protocol_v1.request_headers. A call that names no headers takes the token granted to its env. This fixes shared-name loads, where MultiEnv grants the token through protocol_v1.a…
Details: proof ladder, not fixed, files
How sure is this fix?
.avr/tests/legacy_data_routes_poc.pywritten by AVR's accepted proof. Before the fix it coverage not checked: the finding names no file and line.tst/unit/env/test_legacy_protocol.py::test_a_rest_call_without_headers_takes_the_token_its_env_was_grantedNot fixed by this PR
Files changed (3)
src/agent_env/env/legacy_protocol.pytst/unit/env/test_legacy_protocol.pytst/integration/env/envs/multi_env_local_test.pyan earlier finding
Merge risk: Medium. Review verification before merge.
Not checked: The reproduction of an earlier fix reproduces on the new code and on the code before this change. This change did not undo that fix. Review must confirm that the earlier fix still holds.
Finding:
src/agent_env/env/gateway/gateway.pyRoot cause: The gateway now takes its control token on the older REST routes behind /svc/mcp-<name>/: api/reset, export-state, export-snapshot, snapshot-dirty, reset-memory and validate-rows. It matches them with the same dot-segment normalisation, case folding and encoding rules as the MCP endpoint. A gateway…
Before merge:
Details: proof ladder, not fixed, files
How sure is this fix?
.avr/tests/legacy_data_routes_poc.pywritten by fireworks_ai/deepseek-v4p1-flash-1017. Before the fix it coverage not checked: the finding names no file and line.python -m py_compile <changed files>python -m pytest tst/unit/env/test_legacy_protocol.py tst/unit/env/gateway/control_token_test.pycontrol_token_test.py: legacy routes (plain, dot-segment, encoded, mixed case) get 401 without a token and pass with it; no token means no guard; website routestest_legacy_protocol.py: reset, add and export send the Bearer token; legacy service_state sends itNot fixed by this PR
Files changed (8)
src/agent_env/env/gateway/gateway.pysrc/agent_env/env/legacy_protocol.pysrc/agent_env/env/envs/_deployment.pysrc/agent_env/env/envs/website.pysrc/agent_env/env/envs/mcp_server.pysrc/agent_env/task_step/task_steps/snapshot_env.pytst/unit/env/gateway/control_token_test.pytst/unit/env/test_legacy_protocol.py

Confidence Score: 5/5
The reviewed changes appear safe to merge, pending the required CI checks.Summary
The PR guards older REST data routes with the deployment’s control token and updates framework callers to send it. The latest changes let verifier scripts request those headers and repair affected tests.
The earlier shared-name authentication issue is fixed. No new actionable issues were found. CI still needs to confirm the unit and slow integration jobs pass.
Reviews (3) · Last reviewed commit: "test(snapshot): let the export_state stu..." · Reviewed by Greptile