fix: bypass Squid for network gateway to fix MCP SSE crash#553
Conversation
Squid crashes with a segfault (comm.cc:1583 assertion failure) when proxying concurrent MCP Streamable HTTP (SSE) connections from Codex to the MCP gateway. Root cause: Codex resolves host.docker.internal to 172.30.0.1 (the AWF network gateway) instead of 172.17.0.1 (Docker bridge). The existing iptables bypass only covers 172.17.0.1, so traffic to 172.30.0.1:80 gets DNAT-redirected to Squid, which crashes on concurrent SSE streams. Fix: Dynamically detect the container's default network gateway via `route -n` and add it to the iptables bypass list alongside host.docker.internal, so MCP gateway traffic goes directly to the host. Locally reproduced: before fix Squid crashes with the exact CI error; after fix all SSE+POST traffic bypasses Squid and Squid stays alive. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded. |
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
✅ Coverage Check PassedOverall Coverage
Coverage comparison generated by |
C++ Build Test Results
Overall: PASS ✅ All C++ projects built successfully.
|
Deno Build Test Results
Overall: ✅ PASS All Deno tests passed successfully.
|
✅ Smoke Test ResultsLast 2 Merged PRs:
Tests:
Status: PASS 🎉 cc @Mossaka
|
Smoke Test Results (Claude)✅ GitHub MCP: Retrieved last 2 merged PRs
✅ Playwright: Navigated to https://github.com, title contains "GitHub" ✅ File Writing: Created ✅ Bash Tool: Verified file content Status: PASS
|
Go Build Test Results
Overall: PASS ✅ All Go projects successfully downloaded dependencies and passed tests.
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical Squid proxy crash that occurs when concurrent MCP Server-Sent Events (SSE) connections are proxied through Squid. The fix adds the container's network gateway IP (172.30.0.1) to the iptables bypass list, preventing MCP traffic destined for host.docker.internal from being redirected through Squid.
Changes:
- Adds automatic detection of the container's default network gateway using
route -n - Bypasses Squid for the network gateway IP when it differs from the Docker bridge gateway
- Prevents Squid assertion failures (
comm.cc:1583) caused by SSE connection handling
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🧪 Bun Build Test ResultsStatus: ❌ FAILED Bun test runner crashed in both projects due to containerized environment limitations.
Error Details: Root Cause: Bun's test runner requires kernel capabilities not available in GitHub Actions containers. This is a known limitation when running Bun in restricted environments. Overall: ❌ FAIL
|
Node.js Build Test Results
Overall: PASS ✅ All projects installed successfully and passed their test suites.
|
Security Review: Network Gateway BypassI've reviewed this PR and identified a security concern that should be addressed before merging. Issue: Overly Permissive Gateway BypassThe new bypass rules for the network gateway (172.30.0.1) create an unfiltered egress path when Location: echo "[iptables] Allow direct traffic to network gateway (${NETWORK_GATEWAY_IP}) - bypassing Squid..."
iptables -t nat -A OUTPUT -d "$NETWORK_GATEWAY_IP" -j RETURN
iptables -A OUTPUT -d "$NETWORK_GATEWAY_IP" -j ACCEPT # ⚠️ Allows ALL ports/protocolsSecurity Impact
This means malicious code in the agent container can connect to any service running on the Docker host (SSH on 22, databases on 3306/5432, etc.) by targeting 172.30.0.1, completely bypassing the firewall's protection. Root Cause AnalysisThe issue stems from needing to bypass Squid for MCP SSE traffic while maintaining security boundaries. The current implementation is too broad. Recommended MitigationsOption 1: Port-specific bypass (Recommended) # Replace line 145 with port-specific rule
iptables -A OUTPUT -p tcp -d "$NETWORK_GATEWAY_IP" --dport 80 -j ACCEPTOption 2: Restrict to HTTP/HTTPS only # Replace line 145 with protocol-specific rules
iptables -A OUTPUT -p tcp -d "$NETWORK_GATEWAY_IP" --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp -d "$NETWORK_GATEWAY_IP" --dport 443 -j ACCEPTOption 3: Explicit port configuration MCP_GATEWAY_PORT="${AWF_MCP_GATEWAY_PORT:-80}"
iptables -A OUTPUT -p tcp -d "$NETWORK_GATEWAY_IP" --dport "$MCP_GATEWAY_PORT" -j ACCEPTQuestions for Discussion
Recommendation: Please update the bypass rule to be port-specific rather than allowing all traffic to the gateway IP. This maintains security while fixing the Squid SSE crash issue.
|
Chroot Runtime Version Test Results
Overall Status: ❌ FAILED Some runtime versions differ between host and chroot environments. Go matches successfully, but Python and Node.js versions don't align.
|
❌ Rust Build Test FailedStatus: FAILED - Unable to execute Rust toolchain in AWF container environment Error DetailsThe Rust toolchain (cargo/rustup) cannot be executed within the AWF firewall container. All attempts to run Projects Not Tested
Overall: FAILED Technical Details
Root CauseWhen attempting to execute This occurs even when:
RecommendationThe Rust toolchain needs to be pre-installed on the host system before the AWF container starts, or the test should run outside the AWF container environment. The issue appears to be related to how binaries are executed within the chroot-enabled AWF container.
|
Address security review: narrow the OUTPUT ACCEPT rule from all ports/protocols to only TCP port 80 (where MCP gateway runs). The NAT RETURN rule remains broad since DNAT only catches 80/443. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
|
Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded. |
Claude Smoke Test ResultsLast 2 merged PRs:
✅ GitHub MCP test Status: PASS
|
Deno Build Test Results
Overall: ✅ PASS All Deno tests completed successfully.
|
Node.js Build Test Results
Overall: PASS ✅ All Node.js projects successfully installed dependencies and passed their test suites.
|
Go Build Test Results
Overall: PASS ✅ All Go projects successfully downloaded dependencies and passed tests.
|
Smoke Test ResultsLast 2 Merged PRs:
Test Results:
Status: PASS cc @Mossaka
|
Build Test: Bun - FAILEDStatus: ❌ FAIL Results
Overall: FAIL - Test runner crashes in GitHub Actions environment Error DetailsIssue: Bun test runner (v1.3.8) crashes with core dump on both projects: Environment: GitHub Actions runner
* RecommendationThis appears to be a compatibility issue between Bun v1.3.8 and the GitHub Actions runner environment. Consider:
|
Build Test: Java - FAILED ❌Status: Unable to execute Java tests due to environment configuration issue. Error DetailsThe Java runtime environment is not functioning correctly in the GitHub Actions runner:
Investigation Results
Next StepsThis appears to be a GitHub Actions runner or shell environment configuration issue rather than a code problem. The workflow may need:
|
Chroot Version Comparison Test Results
Overall Status: ❌ Tests FAILED - Not all runtime versions match between host and chroot environments. The chroot mode successfully uses host binaries, but Python and Node.js versions differ. This is expected behavior when the host and container have different installations.
|
Build Test: Rust - FAILED ❌Unable to execute Rust build tests due to missing Rust toolchain. IssueThe Rust toolchain (cargo/rustc) is not available in the GitHub Actions runner environment, and installation via Root CauseWhen attempting to install Rust via the official rustup installer (
Attempted Solutions
RecommendationTo run Rust build tests, one of the following is needed:
Test Results
Overall: FAIL ❌
|
Fixes Squid crash on MCP Streamable HTTP (SSE) traffic from Codex. See github/gh-aw-firewall#553 for details. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
comm.cc:1583assertion failure / segfault) when proxying concurrent MCP Streamable HTTP (SSE) connections from Codex to the MCP gatewayhost.docker.internal(172.17.0.1)Root Cause
Codex resolves
host.docker.internalto172.30.0.1(AWF network gateway) instead of172.17.0.1(Docker bridge). The existing iptables bypass only covers172.17.0.1, so MCP traffic to172.30.0.1:80gets DNAT-redirected to Squid. Concurrent SSE connections through Squid trigger the assertion failure and Squid segfaults, severing all proxied connections.Local Reproduction
Before fix — Squid crashes:
Test C:
curl: (7) Failed to connect to 172.30.0.10 port 3128: Connection refused— Squid is dead.After fix — Squid survives:
172.30.0.1reaches host SSE server (Server: BaseHTTP/0.6 Python)172.30.0.1entries (fully bypassed)example.comTest plan
🤖 Generated with Claude Code