Repository navigation
fix(security): Unauthenticated unrestricted postgres-mcp and pgweb published on public sandbox tunnels - #863
scale-avr[bot] wants to merge 5 commits into
Conversation
…s and off every VM interface
|
🤖 Automated Claude routine — Env Pod PR Context Review. This is a bot, not Edgar Arakelyan; not a human review. Context from outside this diff: an open PR already makes most of this change, and it is deliberately being held back. The overlap. #823 ("reach pgweb and db-mcp only through the gateway's
The last row is a direct contradiction, and both PRs encode it as an assertion in the same test file: this PR's The hold. #823 carries an explicit "DO NOT MERGE" and a merge-order note: it is meant to merge last, after consumers of Not a view on which version is right — the two differ in real ways (this PR also covers Generated by Claude Code |
| vm_kwargs["memory"] = memory_mb | ||
| # The SQL consoles are never tunnelled: the gateway serves them behind its control token. Only the local | ||
| # provider gets a host port for them (its own free port, published on 127.0.0.1), so two local envs don't clash. | ||
| console_ports = [DB_WEB_PORT, DB_MCP_PORT] if sandbox_provider.ON_THIS_MACHINE else [] |
There was a problem hiding this comment.
The new ON_THIS_MACHINE check breaks test_deploy_via_vm_asks_for_no_tunnel_to_the_sql_consoles. That test creates an unconfigured MagicMock, whose ON_THIS_MACHINE attribute is truthy. Both console ports therefore enter exposed_ports, and the assertions excluding them fail. Set ON_THIS_MACHINE=False on the test's provider mock so it represents a remote provider.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/providers/env_providers/env_gateway_provider.py
Line: 891
Comment:
**Remote provider test fails**
The new `ON_THIS_MACHINE` check breaks `test_deploy_via_vm_asks_for_no_tunnel_to_the_sql_consoles`. That test creates an unconfigured `MagicMock`, whose `ON_THIS_MACHINE` attribute is truthy. Both console ports therefore enter `exposed_ports`, and the assertions excluding them fail. Set `ON_THIS_MACHINE=False` on the test's provider mock so it represents a remote provider.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
Superseded by #823 (released in v0.9.1624), which makes the same fix: pgweb and db-mcp get no public tunnel or published port on any provider, the container sidecars are created with expose_externally=False, and deploys no longer record the tunnel URLs. Both consoles are served only through the gateway's /svc routes behind the control token. |
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: High · CWE-306 ·
src/agent_env/providers/env_state/local_postgres.py:287-303Root cause: One failing check is caused by this PR, and I fixed it. A source-scan test (provider_capabilities_test) bans isinstance checks on the sandbox provider class. The PR's deploy code used one to choose local console host ports. It now reads the provider's declared ON_THIS_MACHINE flag, and the matching…
Details: proof ladder, not fixed, files
How sure is this fix?
.avr/tests/sql_console_binding.pywritten by AVR's accepted proof. Before the fix it ran src/agent_env/providers/env_state/local_postgres.py:263-276, 280-285, 287-302, 304 (the finding's code: src/agent_env/providers/env_state/local_postgres.py….python3 -m py_compile src/agent_env/providers/env_providers/env_gateway_provider.pyuv run --offline pytest tst/unit/providers/compose_host_port_publish_test.py tst/unit/providers/env_providers/env_gateway_provider_test.py tst/unit/providers/enNot fixed by this PR
Files changed (2)
src/agent_env/providers/env_providers/env_gateway_provider.pytst/unit/providers/env_providers/env_gateway_provider_test.pyFix the remote-provider test before merging.
Fix with agent prompt
Summary
The PR removes public SQL-console tunnels and keeps direct VM console bindings on loopback.
Reviews (4) · Last reviewed commit: "test(gateway): expect the ON_THIS_MACHIN..." · Reviewed by Greptile