Repository navigation
Description
What happens
A box that uses the Box Egress Proxy loses every proxy-served host after the proxy restarts. The box keeps running, and its declared egress is unchanged, but each request to a credentialed upstream host is refused:
$ min box exec <box> -- curl -sS https://api.github.com/zen
{"message":"The Box Egress Proxy refused the request to api.github.com:443, because this box is not allowed to reach api.github.com:443."}
$ min box exec <box> -- git ls-remote https://github.com/<owner>/<repo> HEAD
remote: The Box Egress Proxy refused the request to github.com:443, because this box is not allowed to reach github.com:443.
The message is wrong for this case. min box spec <box> and min box show <box> --network both list github.com and api.github.com under allow_dns_hosts. Hosts that do not go through the proxy still work from the same box.
The proxy restarts whenever minvmd or the VM restarts. An upgrade restarts both, so every box kept across an upgrade to 0.8.0 that holds a GitHub grant or a store secret is affected. A reboot has the same effect.
Observed
- Host: macOS arm64, VM provider, upgraded in place from a 0.8.0 dev build to
0.8.0-rc1. - Box: a session box created under the dev build, with
mode = "own_ip",[defaults.network.bep] steering = "dns", aGH_TOKENsecret withsource = "broker", and eight hosts inallow_dns_hosts. - The proxy's audit log holds about 4,690
admitdecisions for the box before the restart. After the restart it holds only"decision":"refuse","marker":"outside_declared_egress"for the same box. - At the restart
minvmdlogged that it reloaded the box's row and named the live boxes to the proxy. It did not send the box's egress. - DNS steering still works:
github.comresolves to the proxy address inside the box.
Cause
The proxy keeps each box's declared egress in memory only, and only box creation registers it. Citations are from main at cc059f7.
crates/bep/src/boxes.rs:41: the registry is an in-memoryRwLock<HashMap<String, BoxEgress>>.crates/bep/src/boxes.rs:6: a box id that is not registered has no declared egress, so the proxy refuses every request from it asoutside_declared_egress.crates/bep/src/main.rs:1273:bep servestarts withBoxRegistry::default(), which is empty.register_boxis sent only on the creation path:crates/minimal/src/mint.rs:1663andcrates/minimal/src/cmd/boxes/create.rs:4496and:4510. Attach and resume do not send it.crates/minvmd/src/box_registry.rs:4041: after a restartsend_live_boxessends the box ids only.
The proxy already keeps client keys in a file across restarts (crates/bep/src/control.rs:108, from #2288). Box registrations have no equivalent. #2483 introduced the in-memory registry.
crates/bep/src/boxes.rs is the same in the earlier dev build, so this is not new in rc1. The upgrade was the first proxy restart in the box's life.
Expected
A kept box reaches the same proxy-served hosts after a proxy restart as before it, with no action from the user.
Possible fixes
minvmdre-registers each live box's egress when it starts the proxy. Itsbox-registry.jsonrow already holds each box's egress and credentialed upstream settings.- Or the proxy persists registrations beside the client keys and reloads them at start.
Either way, a test should restart bep serve under a running box that holds a GitHub grant and assert that a request to a declared host is still admitted.
Workaround
None that keeps the box. No command re-registers an existing box. A new box created from the same project is registered with the running proxy, and it loses its hosts the same way at the next restart.
This is a residual of epic #1501 (BEP).
Activity