You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(seatbelt): let a sandbox listen without surrendering proxy confinement - #1166
A sandbox under a runtime proxy could not run a listener on macOS. python3 -m http.server 8080 --bind 127.0.0.1 failed with EPERM, and no
setting fixed it, because the two things a caller needs were welded together.
bind()/listen() require (allow network-inbound (local ip)), which only ingress.default: "allow" emits, and validate refused anyhostLoopback
differing from ingress.default. So asking for a listener also forced hostLoopback: "allow", which under a denied egress default emits (allow network-outbound (remote ip "localhost:*")) — every port on the host. A
client that ignores HTTP_PROXY then reaches host-local services directly,
which is precisely the confinement a proxy exists to provide. Callers had to
give one of the two up.
Only one of the two divergent ingress pairs is actually inexpressible, so validate now says that instead of rejecting both.
hostLoopback: "allow" under default: "deny" stays rejected. It promises
inbound host-loopback connectivity, and the only rule that could carry it is
the blanket inbound grant that default: "deny" withholds. Accepting it would
advertise a grant the profile never makes.
hostLoopback: "deny" under default: "allow" is now accepted:
(deny default)
(allow network-outbound (remote ip "localhost:9000")) ;; the proxy, only
(allow network-inbound (local ip)) ;; bind + listen
write_host_loopback_rules needed no change — it already emitted nothing when
loopback is denied under a denied egress default (the (deny default) baseline
carries it) and the explicit localhost:* deny when egress is allowed. Both
newly-reachable cells gained tests instead.
Limitations, stated up front
The container→host half of hostLoopback: "deny" is fully enforced. The
host→container half is not: (local ip) cannot exclude a loopback peer, so a
host process can connect to the sandbox's listeners, and a workload that binds 0.0.0.0 rather than 127.0.0.1 is reachable on that port from the LAN.
Seatbelt cannot express a local-address filter — a literal (local ip "127.0.0.1:8080") is a profile syntax error, host must be * or localhost, exactly as for remote. --bind 127.0.0.1 is a convention the
workload follows, not one the sandbox can enforce.
This is documented rather than implied, in both the backend doc and the 0.8
networking spec. It is strictly narrower than the alternative it replaces:
reaching a listener through hostLoopback: "allow" surrenders the
container→host direction as well.
Documentation
Also fixes the fact that made this look unfixable. Under a denied egress
default, bind() comes from ingress.default, not from the egress arm: (allow network-inbound (local ip)) grants bind()andlisten(), while (allow network-bind (local ip)) grants bind() but notlisten(). The
network policy table named network-bind only under egress.default: "allow",
which reads as "a denied egress default denies bind()" and invites widening
the deny posture to "fix" it.
🔗 References
Related to #1032 (not resolved here), and reviewers should know about one
interaction with it. This config was rejected before and is accepted
now:
An omitted hostLoopback parses as deny, so it is now a valid posture and
loopback is silently closed. Previously the symmetric check rejected it with a
message that said so explicitly ("an omitted hostLoopback is deny, not an
inherit of default"), which incidentally served as a diagnostic for the
ambiguity #1032 describes. That diagnostic is gone for this shape. Resolving #1032 (inherit vs. absolute deny) is the right place to decide whether an
omitted hostLoopback under default: "allow" should instead be refused as
under-specified.
New coverage: two profile_builder tests for the newly-reachable cells (denied
and allowed egress default), two seatbelt_runner tests (the rejected pair
keeps its message, the accepted pair validates), and two live-suite configs.
The pre-existing rejects_mismatched_ingress_default_and_host_loopback was
rewritten rather than deleted, so it now pins the narrower rejection.
The live suite also gains the egress deny + ingress allow cell, asserting
both the behavior and that no standalone network-bind rule is emitted —
without the second assertion, a change that re-granted bind() from the egress
side would keep the behavioral assertions green while widening the deny posture.
Manual, against real Seatbelt, with a loopback proxy and a separate host-local
origin listener, under egress: deny + ingress: {default: allow, hostLoopback: deny}:
Review-feedback commits on top of the original change, each re-validated with cargo fmt --all -- --check, cargo test -p seatbelt_common (133 passed), cargo check -p wxc_e2e_tests --tests, and shellcheck -S warning:
Commit
Change
40130b19
The rule-order assertion compared Option<usize> positions without first asserting the broad (allow network-outbound) exists, so Some(deny) > None kept it green if that rule disappeared.
3df4fa0a
The backend-guide rejection table and schema-updates.md still said every differing hostLoopback/ingress.default pair is rejected.
6374c499
Same stale claim in local_network_allowed's rustdoc, the rejections-suite case label, the e2e characterization comment, and the Copilot instructions. The rejection fixture itself was already the correct pair; only its label was wrong.
Schema 0.9.0-alpha
Since #1145 completed the directional cutover, both decisions were re-verified
against the exact v0.9 contract, end to end with a release mxc-exec-mac:
v0.9 config
Result
ingress: {default: allow, hostLoopback: deny}
runs; LISTEN_OK
ingress: {default: deny, hostLoopback: allow}
rejected, backend_error, exit 255
With a host listener on 127.0.0.1:8099 (reachable from the host, HTTP 200),
the accepted pair under egress.default: "deny" gives HOSTLOOPBACK_BLOCKED / EXTERNAL_BLOCKED / LISTEN_OK — identical to 0.8, so
the container-to-host confinement holds under v0.9.
Two seatbelt_runner tests now pin this through the real parser rather than a
hand-built ContainerPolicy. The rejection test is the guard: an adapter that
dropped ingress would make validate return Ok and fail it, while every
policy-level test in that module stayed green.
Not verified: only macOS 26.6.2 arm64 was exercised. hostLoopback validation
here is Seatbelt-specific, so other backends are untouched.
Updated Copilot instructions — no build, architecture, or convention change, but the Seatbelt row stated the old symmetric hostLoopback rejection and is corrected
If this PR changes Cargo.lock, the dependency-feed-check check passes — Cargo.lock is unchanged
The local_network_allowed rustdoc at lines 56-58 still states that hostLoopback must match default, which is no longer true after this validation change. Update it to explain that the inbound rule follows ingress.default and that only allow-under-deny remains rejected.
Correct the fixture-delta explanation
src/core/wxc_common/src/config_parser.rs:4484
These fixtures do not differ from seatbelt_net_egress_deny.json only by an ingress block: both also change the process probe, and the loopback-deny fixture changes its output markers and listener helper substantially. Clarify that those process differences do not affect parsing rather than claiming they do not exist.
These fixtures do not differ from seatbelt_net_egress_deny.json only by an ingress block: both also use different process.commandLine probes and marker names. The inventory conclusion is still valid, but this explanation should avoid asserting a comparison the files do not satisfy.
…ement
A sandbox under a runtime proxy could not run a listener on macOS.
`python3 -m http.server 8080 --bind 127.0.0.1` failed with EPERM, and no
setting fixed it, because the two things a caller needs were welded together.
`bind()`/`listen()` require `(allow network-inbound (local ip))`, which only
`ingress.default: "allow"` emits, and `validate` refused any `hostLoopback`
differing from `ingress.default`. So asking for a listener also forced
`hostLoopback: "allow"`, which under a denied egress default emits
`(allow network-outbound (remote ip "localhost:*"))` -- every port on the
host. A client that ignores HTTP_PROXY then reaches host-local services
directly, which is precisely the confinement a proxy exists to provide.
Only one of the two divergent ingress pairs is actually inexpressible, so
`validate` now says that instead of rejecting both:
- `hostLoopback: "allow"` under `default: "deny"` stays rejected; the only
rule that could carry it is the blanket inbound grant that `deny` withholds.
- `hostLoopback: "deny"` under `default: "allow"` is accepted, enforcing the
container-to-host half. The blanket inbound grant over-permits the
host-to-container half, which Seatbelt cannot express and which the backend
guide and the 0.8 networking spec now document.
`write_host_loopback_rules` needed no change. The docs also stop saying that a
denied egress default denies `bind()`: under `(deny default)`, `bind()` comes
from `ingress.default`, not from the egress arm.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fa9c67fe-4054-45cc-9901-da0b06ab7b5d
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
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
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.
📖 Description
A sandbox under a runtime proxy could not run a listener on macOS.
python3 -m http.server 8080 --bind 127.0.0.1failed withEPERM, and nosetting fixed it, because the two things a caller needs were welded together.
bind()/listen()require(allow network-inbound (local ip)), which onlyingress.default: "allow"emits, andvalidaterefused anyhostLoopbackdiffering from
ingress.default. So asking for a listener also forcedhostLoopback: "allow", which under a denied egress default emits(allow network-outbound (remote ip "localhost:*"))— every port on the host. Aclient that ignores
HTTP_PROXYthen reaches host-local services directly,which is precisely the confinement a proxy exists to provide. Callers had to
give one of the two up.
Only one of the two divergent ingress pairs is actually inexpressible, so
validatenow says that instead of rejecting both.hostLoopback: "allow"underdefault: "deny"stays rejected. It promisesinbound host-loopback connectivity, and the only rule that could carry it is
the blanket inbound grant that
default: "deny"withholds. Accepting it wouldadvertise a grant the profile never makes.
hostLoopback: "deny"underdefault: "allow"is now accepted:write_host_loopback_rulesneeded no change — it already emitted nothing whenloopback is denied under a denied egress default (the
(deny default)baselinecarries it) and the explicit
localhost:*deny when egress is allowed. Bothnewly-reachable cells gained tests instead.
Limitations, stated up front
The container→host half of
hostLoopback: "deny"is fully enforced. Thehost→container half is not:
(local ip)cannot exclude a loopback peer, so ahost process can connect to the sandbox's listeners, and a workload that binds
0.0.0.0rather than127.0.0.1is reachable on that port from the LAN.Seatbelt cannot express a local-address filter — a literal
(local ip "127.0.0.1:8080")is a profile syntax error,host must be * or localhost, exactly as forremote.--bind 127.0.0.1is a convention theworkload follows, not one the sandbox can enforce.
This is documented rather than implied, in both the backend doc and the 0.8
networking spec. It is strictly narrower than the alternative it replaces:
reaching a listener through
hostLoopback: "allow"surrenders thecontainer→host direction as well.
Documentation
Also fixes the fact that made this look unfixable. Under a denied egress
default,
bind()comes fromingress.default, not from the egress arm:(allow network-inbound (local ip))grantsbind()andlisten(), while(allow network-bind (local ip))grantsbind()but notlisten(). Thenetwork policy table named
network-bindonly underegress.default: "allow",which reads as "a denied egress default denies
bind()" and invites wideningthe deny posture to "fix" it.
🔗 References
Related to #1032 (not resolved here), and reviewers should know about one
interaction with it. This config was rejected before and is accepted
now:
{ "network": { "egress": { "default": "deny" }, "ingress": { "default": "allow" } } }An omitted
hostLoopbackparses asdeny, so it is now a valid posture andloopback is silently closed. Previously the symmetric check rejected it with a
message that said so explicitly ("an omitted
hostLoopbackisdeny, not aninherit of
default"), which incidentally served as a diagnostic for theambiguity #1032 describes. That diagnostic is gone for this shape. Resolving
#1032 (inherit vs. absolute deny) is the right place to decide whether an
omitted
hostLoopbackunderdefault: "allow"should instead be refused asunder-specified.
🔍 Validation
Automated, on macOS 26.6.2 (aarch64):
bash tests/scripts/run_seatbelt_network_test.shcargo test --locked --release --target aarch64-apple-darwin -p mxc_darwin -p seatbelt_common -p wxc_common -p wxc_e2e_tests -p mxc_enginecargo fmt --all -- --checkcargo clippy --target aarch64-apple-darwin --locked --release -p mxc_darwin -p seatbelt_common -- -D warningsshellcheck -S warning tests/scripts/run_seatbelt_network_test.shNew coverage: two
profile_buildertests for the newly-reachable cells (deniedand allowed egress default), two
seatbelt_runnertests (the rejected pairkeeps its message, the accepted pair validates), and two live-suite configs.
The pre-existing
rejects_mismatched_ingress_default_and_host_loopbackwasrewritten rather than deleted, so it now pins the narrower rejection.
The live suite also gains the
egress deny+ingress allowcell, assertingboth the behavior and that no standalone
network-bindrule is emitted —without the second assertion, a change that re-granted
bind()from the egressside would keep the behavioral assertions green while widening the deny posture.
Manual, against real Seatbelt, with a loopback proxy and a separate host-local
origin listener, under
egress: deny+ingress: {default: allow, hostLoopback: deny}:Review-feedback commits on top of the original change, each re-validated with
cargo fmt --all -- --check,cargo test -p seatbelt_common(133 passed),cargo check -p wxc_e2e_tests --tests, andshellcheck -S warning:40130b19Option<usize>positions without first asserting the broad(allow network-outbound)exists, soSome(deny) > Nonekept it green if that rule disappeared.3df4fa0aschema-updates.mdstill said every differinghostLoopback/ingress.defaultpair is rejected.6374c499local_network_allowed's rustdoc, the rejections-suite case label, the e2e characterization comment, and the Copilot instructions. The rejection fixture itself was already the correct pair; only its label was wrong.Schema
0.9.0-alphaSince #1145 completed the directional cutover, both decisions were re-verified
against the exact v0.9 contract, end to end with a release
mxc-exec-mac:ingress: {default: allow, hostLoopback: deny}LISTEN_OKingress: {default: deny, hostLoopback: allow}backend_error, exit 255With a host listener on
127.0.0.1:8099(reachable from the host,HTTP 200),the accepted pair under
egress.default: "deny"givesHOSTLOOPBACK_BLOCKED/EXTERNAL_BLOCKED/LISTEN_OK— identical to 0.8, sothe container-to-host confinement holds under v0.9.
Two
seatbelt_runnertests now pin this through the real parser rather than ahand-built
ContainerPolicy. The rejection test is the guard: an adapter thatdropped
ingresswould makevalidatereturnOkand fail it, while everypolicy-level test in that module stayed green.
Not verified: only macOS 26.6.2 arm64 was exercised.
hostLoopbackvalidationhere is Seatbelt-specific, so other backends are untouched.
✅ Checklist
hostLoopbackrejection and is correctedCargo.lock, thedependency-feed-checkcheck passes —Cargo.lockis unchanged📋 Issue Type
Microsoft Reviewers: Open in CodeFlow