fix: Parse actual subnet from routing table instead of assuming /24#32856
Open
anshul-garg27 wants to merge 1 commit intoanthropics:mainfrom
Open
fix: Parse actual subnet from routing table instead of assuming /24#32856anshul-garg27 wants to merge 1 commit intoanthropics:mainfrom
anshul-garg27 wants to merge 1 commit intoanthropics:mainfrom
Conversation
The firewall init script hardcodes a /24 subnet mask for the host network, which fails on networks with different subnet configurations (e.g., /16, /20). Parse the actual subnet CIDR from the routing table, with a /24 fallback for compatibility.
This was referenced Mar 11, 2026
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.
Summary
/24subnet assumption with actual routing table parsing in.devcontainer/init-firewall.shProblem
Line 100:
HOST_NETWORK=$(echo "$HOST_IP" | sed "s/\.[0-9]*$/.0\/24/")assumes the host network is always a /24 subnet. This fails on networks with different configurations (e.g., /16, /20, /28), blocking container-to-host communication.Fix
Parse the actual subnet CIDR from
ip routeoutput using the host IP as a lookup key. Falls back to the original /24 assumption if route parsing fails, maintaining backward compatibility.Test plan
bash -n init-firewall.sh