Repository navigation
feat(egress,control-plane): an egress refusal says what it means, and the control plane's base URL says what it is - #864
Conversation
… base URL is
A sandbox that met moca-egress's allowlist read only
"destination_denied: <host>", and the control plane's own URL answered
{"error":"not_found"}. Neither told a user or an agent that the host is
not allowlisted, that a retry will not help, or whom to ask.
- moca-egress: a destination_denied refusal keeps its status, its
X-Moca-Egress-Error header and its first line, and adds fixed text
after it: the host is not on this sandbox's egress allowlist,
retrying will not help, ask the operator, and `mocactl sbx egress`
lists the hosts a sandbox was refused. The allowlist itself is not
echoed, and the proxy knows no user-facing URL to name. Other codes
keep their one-line body. The conformance suite now pins the first
line only, which every existing implementation still satisfies.
- control plane: GET / answers a short text/plain page on every profile
(what this is, the API under /v1 and /v1/discovery, how to install
mocactl and log in, and that the operator extends a sandbox's
egress), with no deployment URL and nothing echoed from the request.
OpenAPI 1.27.0.
- The sandbox rules tell the agent that a refused host stays refused:
name it to the user, who can ask the operator to allowlist it.
- User guide §5 and the RUNBOOK say the same.
Closes rossoctl#779
Assisted-By: Claude Code
Signed-off-by: Rong Chang <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Review at 2ac10b0
Adds a fixed hint to moca-egress's 403 destination_denied body (first line, status and X-Moca-Egress-Error unchanged; other codes keep one line), relaxes the conformance contract to a first-line match, adds an unauthenticated plain-text GET / page on every control-plane profile (OpenAPI 1.27.0), and tells the agent (sandboxRules) that a refused host stays refused. I verified that: only exact / matches (the regex is anchored; /index.html and POST / still return 404); the page echoes nothing of the request or the config URLs; BOTH mounts on combined via mountsOn; the install URL and both guide paths exist on main; Content-Length is computed from the longer body; and the conformance change is relax-only. One docs-accuracy suggestion: the hint is invisible to HTTPS clients, because the refusal is a CONNECT 403.
Author: webchang (MEMBER, maintainer)
Areas reviewed: Go (egress handler, conformance), TypeScript (control-plane routes/handlers, sandbox-client rules), tests, OpenAPI/CHANGELOG/change-policy, docs (user guide, RUNBOOK)
Agent/IDE config (.claude/.vscode): none
Commits: 1, all signed off: yes
CI status: all checks passing at submit time
Base: 1 commit behind main (#858, mocactl sbx only, no overlap); mergeable_state blocked (awaiting review)
Heads-up (not blocking): open #856 also bumps the control plane to 1.27.0 (CHANGELOG, openapi.yaml, change-policy). Whichever of the two merges second needs to become 1.28.0.
Drafted by an AI reviewer and approved by a human before posting.
| one carries the common registries (PyPI, npm, crates.io, the Go module proxy), but your operator | ||
| may have changed it. The templates carry the toolchains: `mocactl sbx templates` lists them, with | ||
| their tools, and `mocactl sbx policy` lists each profile's egress. | ||
| their tools, and `mocactl sbx policy` lists each profile's egress. A refused request's body says |
There was a problem hiding this comment.
suggestion: "A refused request's body says that the host is not on the sandbox's egress allowlist" holds for a plain http:// request only. For HTTPS, the case that matters for pip, npm, cargo, go get and git clone https://, the allowlist check in handle (handler.go:215) refuses the CONNECT itself before any interception. Clients do not show a failed CONNECT's body: curl/libcurl (so git) print CONNECT tunnel failed, response 403, Python's http.client raises Tunnel connection failed: 403 Forbidden, and Go's transport returns the status text. So in the usual case neither the user nor the agent sees the new hint, only the 403 (and with curl -v, the X-Moca-Egress-Error header). The sandboxRules text is what really reaches an agent here. Please say so here (for example: "an HTTPS client typically shows only 403 / CONNECT tunnel failed; the body is visible to plain-HTTP requests and to clients that print it"), and adjust the matching sentence in the RUNBOOK (deploy/sbx/RUNBOOK.md:586) the same way.
There was a problem hiding this comment.
Done in 9a4d559: the user guide and the RUNBOOK now say an HTTPS request is refused at its CONNECT, so most clients show only 403 / CONNECT tunnel failed (and X-Moca-Egress-Error under curl -v), and that for HTTPS the agent gets the rule from its sandbox instructions.
Review follow-up. The allowlist check refuses an HTTPS request at its CONNECT, and curl, git, pip and Go's transport don't show a failed CONNECT's body, so the hint reaches plain-HTTP requests and clients that print it; for HTTPS the agent learns the rule from sandboxRules. The user guide and the RUNBOOK now say so. Refs rossoctl#779 Assisted-By: Claude Code Signed-off-by: Rong Chang <[email protected]>
Main took 1.27.0 (rossoctl#864, the base URL's page), so this PR's contract version is 1.28.0, the next free one (it was 1.29.0 while rossoctl#874 held 1.28.0; whichever merges second renumbers). Its section goes above 1.27.0, and the change-policy list keeps both entries. rossoctl#863 made /turn a documented alias of POST /v1/turn, response by response, so the alias gets the new 422 too (the alias contract test caught it). Assisted-By: Claude Code Signed-off-by: Rong Chang <[email protected]>
Brings 25 upstream merges since 1aa8dd6, among them the sbx OIDC identity provider (rossoctl#851), the Redis schema-version key and config bundle format marker (rossoctl#868), the provisioner Redis ACL user (rossoctl#869), the relay keepalive env (rossoctl#866), the per-source OIDC pending bound with the forwarded-headers Route pin (rossoctl#874), the egress refusal hints and control-plane index (rossoctl#864), the empty-workspace sweep (rossoctl#872) and the orphan-sweep log split (rossoctl#849). No conflicts. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Closes #779
What changed and why
The docs part of #779 landed in #821: the user guide, the concepts pages, the MCP server's
instructions, the
bashtool descriptions andmocactl sbx's status text now say that a sandboxreaches the hosts on
moca-egress's allowlist, not that it has no network. What was still open iswhat a user or an agent learns when it meets the allowlist, and what the control plane's own URL says.
403 destination_deniedbody says what it means and what to do(
remote-worker/internal/egress/handler.go,refusalHints). The first line staysdestination_denied: <host>, and the status and theX-Moca-Egress-Errorheader are unchanged.After the first line, the body now says that the host is not on this sandbox's egress allowlist,
that retrying will not help, that the operator adds hosts, and that for the sandbox service
mocactl sbx egresslists the hosts a sandbox reached and was refused. The text is fixed. The proxydoes not know the deployment's user-facing URL (its credentials URL is the host's view of the
control plane), and it does not print the allowlist, because no API shows the allowlist to a
sandbox's user either. Other refusal codes keep their one-line body.
(
remote-worker/egress/conformance/conformance.gowantRefusal, and the package'sdoc.go). Itsfirst line must still be exactly
<code>: <host>. This only relaxes the check: an implementationwith a one-line body still conforms.
GET /on the control plane answers a page instead of404 not_found(
packages/control-plane/src/routes.ts,getIndex;indexPageinhandlers.ts). It isunauthenticated, mounted on every profile, and returns a short
text/plainpage. The page saysthat this is a Moca control plane (on the
sandboxprofile, the sandbox service), gives thedeployment's version if it has one, and says that the API is under
/v1, withGET /v1/discoverydescribing the deployment. It shows the install line for
mocactland the login command for eachprofile served, with a link to that profile's guide, and says that a sandbox's egress is an
allowlist that the operator extends. It names no URL of the deployment and echoes nothing from the
request (not the
Hostheader either), so it has nothing deployment-specific in it. The only URLsit names are the project's public ones. Only the exact path
/is routed.docs/api/openapi.yaml,CHANGELOG.md,change-policy.md): addsGET /. Thechange is additive, and the page's wording is documented as not a contract.
packages/sandbox-client/src/mcp-server.ts,sandboxRules, which alsowrites the
CLAUDE.md/AGENTS.mdblock): a refused host stays refused. The agent should neitherretry it nor look for another way to reach it, and should name the host to the user, who can ask
the operator to allowlist it. This is the behavior the issue reports: an agent that met the 403
went on probing, or set out to build the packages from source.
the operator;
mocactl sbx egressshows the refused ones), and that the service URL describesitself. The RUNBOOK's egress section tells the operator that users are sent to them, and where the
allowlist is.
Tests
Each new test was run before and after the fix.
remote-worker/internal/egress:TestOffAllowlistRefusalSaysWhatToDo(new) fails on main.The body is only
destination_denied: evil.test, and the test reports four missing phrases. Itpasses with the fix. The test also checks that no allowlisted host appears in the body and that
Content-Lengthmatches the longer body.TestOtherRefusalsKeepOneLine(new) pins the one-linebody for the other codes.
assertRefusalnow checks the first line instead of the whole body.packages/control-plane: the newGET / (#779)block indiscovery.test.ts(4 tests: harness,sandbox and combined pages, version, no deployment URL) and the server test in
server.test.ts(
200, no echo of aHost: cp.example.invalidheader,/index.htmlstill404) fail onmain. So do the updated route lists in
routes.test.tsandroute-profile.test.ts: 8 failuresin all. All of them pass with the fix.
packages/sandbox-client: the new test inmcp-server.test.tsthat checks, for all three modes,that the rules say a refused host stays refused fails on main and passes with the fix.
remote-worker:go vet ./...andgo test ./...pass. With-race: theinternal/egresstests, the
egress/conformancepackage andcmd/moca-egresspass.packages/control-plane: 1943 passed, 3 skipped.tsc --noEmitis clean, andopenapi-contract.test.ts(version, changelog and change-policy) passes.packages/sandbox-client: 271 passed, andtsc --noEmitis clean.packages/server: all but one test passed in the parallel run (585 tests). The one failure,workload-runs.test.ts("answers 404 for a deleted workload"), is in code this change does nottouch, and the file passes alone (26 tests, all passing).
packages/mocactl(--minWorkers=1 --maxWorkers=2): the full run on a heavily loaded machine had46 failures, all were 5000 ms timeouts, in five git-heavy files
(the push, up, up-cortex, templates and record suites under
test/). Those files, andsbx-agent-config.test.ts(which checks the rules' wording), were rerun with--testTimeout=60000: all 428 tests passed.prettier --checkpasses on the changed files, andpython3 scripts/check-doc-links.pyreports0 broken links.
Out of scope
mocactl sbx info: most of what it would print is already available. Thesandbox_infoMCPtool and
mocactl sbx getgive the sandbox's template, mode and state.mocactl sbx policygiveseach profile's egress, and
mocactl sbx egresslists the hosts a sandbox reached and was refused.The one new fact, the host's allowlist, is not exposed by any API, and adding one is a design
decision for the maintainers.
MOCA_EGRESS_ALLOW, but whether a sandbox may see the operator's whole allowlist is themaintainers' call.
proxy has a configured user-facing URL or contact today. An optional setting for it could follow.
Every commit is signed off (DCO).
Assisted-By: Claude Code