Repository navigation
feat(remote-worker/egress): allow-everything mode for MOCA_EGRESS_ALLOW=* - #886
Conversation
…OW=* A bare MOCA_EGRESS_ALLOW=* (nothing else on the line) is an explicit operator opt-in that removes every destination restriction: the hostname allowlist and the private/loopback-address refusal (CheckAddr) are both skipped, so a sandbox may reach any destination. For trusted research rigs whose sandboxes are deliberately unconstrained. Recognition happens in ConfigFromEnv before ParseAllow, which keeps refusing "*" as an ordinary list entry -- "*,example.com" and a list that is only separators remain errors, so the wildcard cannot smuggle itself into an ordinary allowlist. NewProxy accepts an empty Allow only when AllowAll is set (an allowlist Proxy is unchanged), and the handler skips the address refusal only in allow-all mode. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: George Almasi <[email protected]>
pdettori
left a comment
There was a problem hiding this comment.
Summary
This adds a narrowly recognised MOCA_EGRESS_ALLOW=* sentinel. The parsing guardrails hold: mixed lists, padded values and separator-only lists are still refused, and the default allowlist path is unchanged. The blocker is that allow-all also turns off the always-on refusal of link-local and cloud metadata addresses, which the egress design treats as fixed regardless of what the operator permits. Keeping that tier is a small change and costs nothing for a research rig.
Author: galmasi (MEMBER, maintainer)
Areas reviewed: Go (egress config/handler/proxy + tests), deploy docs/env
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, signed off: yes
CI status: all checks passing. Locally, go test ./internal/egress/... ./cmd/moca-egress/... passes at the PR head.
| } | ||
| // Allow-everything mode skips every address refusal, private and local | ||
| // included (Config.AllowAll). | ||
| if pc.p.cfg.AllowAll { |
There was a problem hiding this comment.
must-fix: This early return skips all of CheckAddr, not just the private/loopback refusal. addr.go says link-local (which includes 169.254.169.254), unspecified, multicast, broadcast and the cloud metadata endpoints (AWS IMDSv6 fd00:ec2::254, Azure WireServer, Alibaba) are "always refused, whatever the permit list". The cloudMetadata comment adds that permitting a range "must not thereby open the instance's credentials". With *, a sandbox on an AWS/Azure rig can fetch the host's instance-role credentials. Agent code runs on untrusted content (prompt injection), so "trusted rig" doesn't cover that.
Proposed fix: in allow-all mode, keep calling CheckAddr with an all-covering permit list and no local:
var allPrefixes = []netip.Prefix{netip.MustParsePrefix("0.0.0.0/0"), netip.MustParsePrefix("::/0")}
permit, local := pc.p.cfg.PermitCIDRs, ...
if pc.p.cfg.AllowAll {
permit, local = allPrefixes, nil
}Loopback, private, CGNAT, special-purpose and host-local addresses then pass, and only the always-refused tier stays refused. I checked locally against CheckAddr at this head: 127.0.0.1, 10.0.0.5, ::1, 100.64.1.1 and a local address pass; 169.254.169.254, fd00:ec2::254, 168.63.129.16, 0.0.0.0 and 224.0.0.1 are still refused. The doc on Config.AllowAll (proxy.go:25) and in egress-allow.env would need the same wording change.
| func TestAllowAllTunnelsOffAllowlistAndPrivate(t *testing.T) { | ||
| up := newTCPUpstream(t, echo) | ||
| h := newHarness(t, "up.test:443", func(c *Config) { | ||
| c.AllowAll = true |
There was a problem hiding this comment.
suggestion: (a) After the handler.go fix, add a check that allow-all still refuses 169.254.169.254 / fd00:ec2::254 with destination_private. (b) The harness still passes the up.test:443 allowlist, so the NewProxy change (empty Allow accepted only with AllowAll) has no test. Setting c.Allow = nil here, plus one NewProxy(Config{AllowAll: false}) empty-allowlist case, would cover both branches.
| // and a list that is only separators remain errors. | ||
| var err error | ||
| if allowRaw == "*" { | ||
| cfg.AllowAll = true |
There was a problem hiding this comment.
suggestion: cmd/moca-egress/main.go:80 logs serving %d allowlist entries, which reads serving 0 allowlist entries in this mode. For a mode that turns off the allowlist, the startup line should say so plainly (e.g. moca-egress: allow-all mode: every destination permitted (MOCA_EGRESS_ALLOW=*)), so an operator reading the journal can't miss it.
| # install-host.sh; it overrides this file for that run's seed only. | ||
| # Editing this file does not reach hosts that are already seeded (the seed is written only | ||
| # when absent); copy it to each host as above. | ||
| # A bare MOCA_EGRESS_ALLOW=* (nothing else on the line) is allow-everything mode: the |
There was a problem hiding this comment.
nit: The mode is only documented in this seed file. deploy/sbx/RUNBOOK.md (the allowlist bullet, ~L592) and deploy/microvm/P4-ON-P6.md (Guest egress → Allowlist, ~L709) describe MOCA_EGRESS_ALLOW but don't mention *. The PR says it is deployed on the P6 tier too, which the microVM doc covers.
… tier Review #886 must-fix: the early return skipped all of CheckAddr, not just the private/loopback refusal. Link-local (169.254.169.254 included), unspecified, multicast, broadcast and the cloud metadata endpoints (AWS IMDSv6 fd00:ec2::254, Azure WireServer, Alibaba) are always refused, whatever the permit list, and the cloudMetadata comment is explicit that permitting a range must not thereby open the instance's credentials. Agent code runs on untrusted content, so 'trusted rig' does not cover that. In allow-all mode, resolveAndCheck now calls CheckAddr with an all-covering permit list (0.0.0.0/0 and ::/0) and no local addresses: the always-refused tier still runs, everything else is permitted. Also from the review: tests that allow-all still refuses the cloud metadata endpoints and link-local with destination_private, and that NewProxy accepts an empty Allow only with AllowAll; the proxy's startup log says 'allow-all mode' plainly instead of 'serving 0 allowlist entries'; and the mode is documented beside MOCA_EGRESS_ALLOW in the RUNBOOK and P4-ON-P6. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: George Almasi <[email protected]>
|
All review points addressed in 002d60f:
Assisted-By: Claude Code |
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Summary
The previous must-fix is fixed and verified. In allow-all mode resolveAndCheck now calls CheckAddr with an all-covering permit list (0.0.0.0/0, ::/0) and no local addresses, so link-local, the cloud metadata endpoints, unspecified, multicast and broadcast are still refused while private/loopback pass; handle skips only the allowlist check (handler.go:224,282). Tests cover both the private-address tunnel and the metadata refusal, and NewProxy rejects an empty allowlist unless AllowAll is set. check (Go tests) is green at this head.
Remaining non-blocking items are wording: three comments still describe the pre-fix behavior (proxy.go:26, config.go:69, egress-allow.env:18) and understate the always-refused tier. Two required checks (deploy-scripts-bash32, k8s-kind-e2e) were still queued when this review was written.
Author: galmasi (MEMBER — maintainer)
Areas reviewed: Go (egress config/handler/proxy + tests), deploy docs/env
Agent/IDE config (.claude/.vscode): none
Commits: 2 commits, all signed-off: yes
CI status: green so far (check, lint, proto, microvm-gates, deploy-scripts pass); deploy-scripts-bash32 and k8s-kind-e2e pending
| Allow []AllowEntry | ||
| Allow []AllowEntry | ||
| // AllowAll removes every destination restriction: the hostname allowlist | ||
| // and the private/loopback-address refusal (CheckAddr) are both skipped. |
There was a problem hiding this comment.
suggestion: This is now stale after the handler fix: CheckAddr is not skipped in allow-all mode -- it runs with an all-covering permit list and no local addresses (handler.go:282). config.go:69 ("every destination restriction is off") and deploy/sbx/egress-allow.env:18 say the same thing. Consider matching the P4-ON-P6/RUNBOOK wording: every destination is permitted except the always-refused tier (cloud metadata endpoints, link-local, multicast).
| # Editing this file does not reach hosts that are already seeded (the seed is written only | ||
| # when absent); copy it to each host as above. | ||
| # A bare MOCA_EGRESS_ALLOW=* (nothing else on the line) is allow-everything mode: the | ||
| # allowlist and the private-address refusal are both off. For trusted research rigs only. |
There was a problem hiding this comment.
suggestion: As with the Config.AllowAll comment: the always-refused tier (cloud metadata, link-local, unspecified/broadcast, multicast) still applies, so "the private-address refusal is off" understates what is kept. The RUNBOOK / P4-ON-P6 wording is accurate; mirror it here.
Brings 15 upstream merges since 2eb0219, among them the R2 host sampler in its reviewed form (rossoctl#904), the workspace-reset marker (rossoctl#895), turn budgets and cancel (rossoctl#856), the egress allow-all option (rossoctl#886), the sbx installer token (rossoctl#888), and the docs site with the product-name prose (rossoctl#884, rossoctl#885, rossoctl#899). One conflict, deploy/sbx/template-onboarding/README.md: upstream's product-name wording for the deploy/sbx table, keeping the fork's mint-login.sh row. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
What
A bare
MOCA_EGRESS_ALLOW=*(nothing else on the line) is an explicit operator opt-in that removes every destination restriction from the egress proxy: the hostname allowlist and the private/loopback-address refusal are both skipped. For trusted research rigs whose sandboxes are deliberately unconstrained; the default allowlist behavior is unchanged.Guardrails
ConfigFromEnvbeforeParseAllow, which still refuses*as an ordinary list entry —*,example.comand a separator-only list remain errors, so the wildcard cannot smuggle itself into an ordinary allowlistNewProxyaccepts an emptyAllowonly whenAllowAllis set; a normal allowlist Proxy is unchangedAllowAllis setdeploy/sbx/egress-allow.envdocuments the mode where the seed allowlist livesTests
Unit tests on both paths (
config_test: the bare*accepted, mixed lists still refused;proxy_test: allow-all proxies to a private address that an allowlist proxy refuses).go test ./internal/egress/green.Deployed and running on two rigs (both tiers, P6 harness and SBX0) with
MOCA_EGRESS_ALLOW=*.Assisted-By: Claude Code