fix: block direct IP address HTTPS connections to prevent domain filtering bypass#142
fix: block direct IP address HTTPS connections to prevent domain filtering bypass#142
Conversation
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
|
💥 WHOOSH! Smoke Claude springs into action on this pull request! [Panel 1 begins...] |
Smoke Test ResultsLast 2 Merged PRs:
Test Results:
Overall Status: PASS
|
Smoke Test ResultsLast 2 merged PRs:
Test Results:
Overall: FAIL
|
✅ Coverage Check PassedOverall Coverage
Coverage comparison generated by |
|
@copilot merge main and fix PR title check CI failure |
There was a problem hiding this comment.
Pull request overview
This PR adds security controls to prevent bypass of domain-based filtering through direct IP address HTTPS connections. When clients connect via raw IP addresses (e.g., CONNECT 140.82.114.4:443), Squid cannot perform SNI extraction, allowing potential circumvention of domain filtering rules.
Changes:
- Added Squid ACL rules to block direct IPv4 and IPv6 address connections before domain filtering
- Updated test suite to verify IP blocking ACLs are present and correctly ordered
- Modified backward compatibility test comment to clarify IP blocking ACLs use
dstdom_regex
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/squid-config.ts | Added two ACL rules (ip_dst_ipv4 and ip_dst_ipv6) with corresponding deny rules to block direct IP connections |
| src/squid-config.test.ts | Added test suite for IP blocking feature and updated backward compatibility test clarification |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/squid-config.ts
Outdated
| # Security: Block direct IP address connections (bypass prevention) | ||
| # Clients must use domain names, not raw IP addresses | ||
| # This prevents bypassing domain-based filtering via direct IP HTTPS connections | ||
| acl ip_dst_ipv4 dstdom_regex ^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$ |
There was a problem hiding this comment.
The IPv4 regex pattern is too permissive and will match invalid IP addresses. The pattern [0-9]+ matches one or more digits without bounds, allowing invalid IPs like 999.999.999.999 or 1.2.3.4567. Consider using a more restrictive pattern that validates each octet is between 0-255, such as ^([0-9]{1,3}\\.){3}[0-9]{1,3}$ or the more precise ^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$. While the overly permissive pattern will still block most IP-based bypass attempts (since real IPs will match), it may also accidentally match malformed strings that resemble IPs.
| acl ip_dst_ipv4 dstdom_regex ^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$ | |
| acl ip_dst_ipv4 dstdom_regex ^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$ |
src/squid-config.ts
Outdated
| acl ip_dst_ipv4 dstdom_regex ^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$ | ||
| # IPv6: Must contain at least one colon (distinguishes from domain names) | ||
| # Matches: ::1, fe80::1, 2001:db8::1, [::1] (bracket notation for URLs) | ||
| acl ip_dst_ipv6 dstdom_regex ^\\[?[0-9a-fA-F]*:[0-9a-fA-F:]*\\]?$ |
There was a problem hiding this comment.
The IPv6 regex pattern is overly permissive and will match invalid or malformed IPv6 addresses. The pattern [0-9a-fA-F]* allows zero or more hex digits, which means it would match strings like : (just a colon), ::::::: (multiple colons without hex digits), or [:] (brackets with just a colon). While the requirement of at least one colon helps distinguish from domain names, consider a more restrictive pattern that validates proper IPv6 structure, such as requiring at least one hex digit between colons: ^\\[?([0-9a-fA-F]{1,4}:)+[0-9a-fA-F:]*\\]?$ or using a more complete IPv6 validation regex.
| acl ip_dst_ipv6 dstdom_regex ^\\[?[0-9a-fA-F]*:[0-9a-fA-F:]*\\]?$ | |
| acl ip_dst_ipv6 dstdom_regex ^\\[?([0-9a-fA-F]{1,4}:)+[0-9a-fA-F:]*\\]?$ |
src/squid-config.test.ts
Outdated
| const result = generateSquidConfig(config); | ||
| // Should contain IPv4 address blocking ACL | ||
| expect(result).toContain('acl ip_dst_ipv4 dstdom_regex'); | ||
| expect(result).toMatch(/\^\\?\[0-9\]\+/); // Should match IP pattern |
There was a problem hiding this comment.
This regex test pattern is imprecise and may not accurately validate the IPv4 ACL pattern. The test regex /\^\\?\[0-9\]\+/ checks for an optional backslash (\\?) which shouldn't be optional - the actual pattern should have \\. (escaped dot) between octets. Consider testing for the complete pattern or at least a more representative substring like /\^\\[0-9\\]\+\\\\\\.\\[0-9\\]/ to verify the pattern includes escaped dots between digit groups.
| expect(result).toMatch(/\^\\?\[0-9\]\+/); // Should match IP pattern | |
| expect(result).toMatch(/\^\[0-9]\+\\\.\[0-9]\+\\\.\[0-9]\+\\\.\[0-9]\+\$/); // Should match full IPv4 regex pattern |
src/squid-config.test.ts
Outdated
| // Should not have domain pattern regex (allowed_domains_regex) for plain domains | ||
| // Note: IP blocking ACLs (ip_dst_ipv4, ip_dst_ipv6) use dstdom_regex but are separate | ||
| expect(result).not.toContain('allowed_domains_regex'); |
There was a problem hiding this comment.
The comment clarification about IP blocking ACLs is helpful, but the test name 'should handle only plain domains (backward compatibility)' could be clearer. Consider updating the test description to explicitly mention that it tests backward compatibility while allowing the new IP blocking ACLs, e.g., 'should handle only plain domains without pattern ACLs (backward compatibility, IP blocking ACLs are separate)'.
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
Merged main branch and resolved the conflict in |
|
@copilot address comments and merge main |
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
Addressed all code review comments and merged main. Changes in commits
|
Merge latest changes from main branch, resolving conflicts by accepting main branch versions which include: - allowHostPorts feature for fine-grained port control - Enhanced security with DANGEROUS_PORTS blocklist - Updated documentation and workflows - New smoke tests and CI improvements Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation... |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
Smoke Test ResultsLast 2 merged PRs:
Tests:
Status: PASS
|
🚨 CRITICAL Security Issues FoundThis PR introduces changes that significantly weaken the firewall's security model. Please review the following concerns before merging. 1. 🔴 CRITICAL: Docker Socket Mounting (Container Escape Risk)File: Code: // Mount Docker socket for MCP servers that need to run containers
'/var/run/docker.sock:/var/run/docker.sock:rw',Security Impact: Mounting the Docker socket ( Attack Vectors:
Recommendation:
2.
|
Smoke Test ResultsLast 2 Merged PRs:
Test Results:
Status: FAIL (Playwright test blocked) cc: @Mossaka (author/assignee)
|
Changes in this PR:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.