fix: enforce TCP isolation on --internal networks by dropping default gateway - #2072
Open
am-saksham wants to merge 1 commit into
Open
fix: enforce TCP isolation on --internal networks by dropping default gateway#2072am-saksham wants to merge 1 commit into
am-saksham wants to merge 1 commit into
Conversation
Drops the default gateway allocation for hostOnly networks to prevent TCP egress, and updates the isolation integration test to verify against a raw IP.
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.
Fixes #2062
Description
This PR addresses the isolation leak reported in #2062, where containers on
--internal(hostOnly) networks were still able to make outbound TCP connections to the public internet by using raw IP addresses.The root cause was that
vmnetinVMNET_HOST_MODEdoes not prevent the macOS host from NAT-ing and forwarding outbound TCP packets if IP forwarding is enabled. Furthermore, a default gateway was being unconditionally assigned to the guest OS. The integration test previously missed this because it tested a hostname (http://google.com), which failed due to UDP/DNS being blocked, creating a false positive for network isolation.Changes Made
ReservedVmnetNetwork.swift: Modified the network provisioning to conditionally assignipv4Gateway = nilwhen the network mode ishostOnly.NetworkStatus&Attachment: Updated the structs across the networking stack to support an optionalipv4Gateway.RuntimeService.swift: Safely unwraps the gateway when generating the container's DNS configuration, gracefully skipping it if the gateway isnil.TestCLINetwork.swift: UpdatedtestIsolatedNetworkto verify isolation using a raw IP (https://1.1.1.1/) rather than a hostname. This ensures the test validates the actual TCP egress path rather than just DNS failure.Testing
make testlocally. The updatedtestIsolatedNetworkpasses, confirming TCP egress is successfully blocked.