feat(net): add TCP-level allowlist filtering with SNI/Host inspection#411
Merged
Conversation
Complements the DNS sinkhole from #410 with transport-layer filtering. Guests can no longer bypass the allowlist by connecting to raw IPs. For port 443: extracts hostname from TLS ClientHello SNI extension. For port 80: extracts hostname from HTTP Host header. Other ports: filters by IP/CIDR rules only. Zero overhead when no allowlist is configured (filter=nil). Uses bufio.Reader.Peek() + crypto/tls.Server.GetConfigForClient for non-consuming SNI extraction (same technique as inet.af/tcpproxy). Overrides gvproxy's TCP handler via reflect to inject the filter after virtualnetwork.New() — guarded by structural test. Go: 25 unit tests (filter, SNI peek, structural guard) Rust: 2 new ignored VM integration tests Python: 21 end-to-end integration tests across 7 categories Also fixes pre-existing boxlite-server test that used wrong serde format for network field (JSON object instead of string).
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
Complements the DNS sinkhole from #410 with transport-layer filtering. Guests can no longer bypass the allowlist by connecting to raw IPs.
Uses
bufio.Reader.Peek()+crypto/tls.Server.GetConfigForClientfor non-consuming SNI extraction (same technique asinet.af/tcpproxy). Overrides gvproxy's TCP handler via reflect to inject the filter aftervirtualnetwork.New()— guarded by structural test.Behavior by port
Files
New Go files (7):
tcp_filter.go— AllowNet matcher (IP/CIDR/hostname/wildcard)tcp_filter_test.go— 12 unit testssni_peek.go— TLS SNI + HTTP Host extraction viabufio.Peek()sni_peek_test.go— 10 unit testsforked_tcp.go— TCP forwarder with filter + SNI inspectionforked_network.go— Override TCP handler via reflectforked_network_test.go— Structural guard testModified:
main.go— Wire filter aftervirtualnetwork.New()network_spec.rs— 2 new ignored VM integration teststypes.rs— Fix pre-existing server test (wrong serde format)New Python tests:
test_tcp_filter.py— 21 end-to-end VM integration tests across 7 categoriesTest plan
make test:integration:rust FILTER=network_specfor VM tests