fix(macos): honor -f/--forward port forwarding#99
Merged
Conversation
On macOS the -f/--forward flag (and forwardPorts config) was silently ignored: the forwarding logic only ran inside the Linux branch and WrapCommandMacOS never read cfg.Network.ForwardPorts. macOS shares the host network stack, so no socat bridge is needed. Emit a targeted Seatbelt rule per forwarded port: (allow network-outbound (remote ip "localhost:<port>")) skipped when allowLocalOutbound already opens all localhost ports. This is narrower than allowLocalOutbound, keeping deny-by-default intact. Adds TestMacOS_ProfileForwardPorts and updates docs that incorrectly described forwarding as Linux-only. Closes #98
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
On macOS,
-f/--forward(and theforwardPortsconfig field) was silently ignored. A sandboxed process could not reach a forwarded hostlocalhostport:The forwarding logic (
NewForwardBridge) lived entirely inside the Linux branch ofmanager.go, andWrapCommandMacOSnever readcfg.Network.ForwardPorts.Fix
Linux needs a
socatbridge because the sandbox runs in an isolated network namespace. macOS shares the host network stack, so forwarding just needs a Seatbelt allow rule. For each forwarded port we now emit:skipped when
allowLocalOutboundalready opens all localhost ports. This is narrower thanallowLocalOutbound(which opens all host localhost ports), preserving deny-by-default.Verification (real listener on macOS)
curl localhost:PORT(no-f)-f PORT -- curl localhost:PORT-f PORTthen curl a different portTestMacOS_ProfileForwardPorts.make fmt && make lintclean; sandbox/config/cmd tests pass.Closes #98