You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(docker): simplify to localhost+Squid-only iptables (#1270)
* fix(security): simplify to localhost+Squid-only iptables
Simplify iptables to a minimal security model:
- ALLOW: localhost (127.0.0.0/8) for MCP servers + Docker DNS
- ALLOW: Squid proxy IP — single egress point for HTTP/HTTPS
- REJECT: everything else
Remove DNS server exception rules from container and host iptables.
Docker embedded DNS (127.0.0.11) handles name resolution via
localhost. Squid resolves DNS internally via dns_nameservers.
Remove AWF_DNS_SERVERS env var. Keep --dns-servers for Docker
embedded DNS upstream forwarding and Squid config.
Prevents DNS-based data exfiltration.
Fixes#11
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add host-iptables coverage for uncovered paths
Adds tests for untested code paths to fix coverage regression:
- API proxy sidecar rule generation
- Bridge name not found error path
- DOCKER-USER chain creation fallback
- Skip duplicate DOCKER-USER jump rule insertion
- IPv6 cleanup with ip6tables available
- IPv6 cleanup skip when ip6tables unavailable
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add hasRateLimitOptions test to fix function coverage regression
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: save and restore Docker DNS DNAT rules across NAT flush
Docker's embedded DNS (127.0.0.11) works by redirecting port 53 queries
to its internal DNS server on a random high port via iptables DNAT rules.
When setup-iptables.sh flushes the NAT OUTPUT chain, these rules are
destroyed, causing DNS resolution via 127.0.0.11 to fail silently.
Save Docker's DNS DNAT rules before flushing and restore them after,
so Docker embedded DNS continues to work.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: restore DNS forwarding rules in DOCKER-USER chain
Docker's embedded DNS (127.0.0.11) forwards queries to upstream servers
through the container's network interface, which traverses the Docker
bridge and DOCKER-USER chain. The previous commit incorrectly assumed
Docker DNS bypasses container iptables entirely, but the DNS proxy
runs within the container's network namespace. Without DNS ACCEPT rules
in DOCKER-USER, forwarded queries are blocked, causing SERVFAIL.
Add UDP/TCP port 53 ACCEPT rules for configured upstream DNS servers
in the AWF_EGRESS chain, while keeping the simplified model where
containers can only use Docker embedded DNS (no direct external DNS).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add unmountSslTmpfs tests to restore function coverage
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: add UDP DROP rule to prevent DNS exfiltration
The OUTPUT filter chain only dropped TCP traffic, leaving UDP
unfiltered. This allowed direct DNS queries to external servers
(e.g., dig @8.8.8.8) to succeed, defeating the DNS exfiltration
prevention. Add iptables -A OUTPUT -p udp -j DROP alongside the
existing TCP DROP rule.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(action): use GITHUB_TOKEN for API calls to avoid 403
The curl call to api.github.com/repos/.../releases/latest was
unauthenticated, causing intermittent 403 rate limit errors in CI.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: restore explicit DNS ACCEPT rules for Docker DNS forwarding
The blanket `iptables -A OUTPUT -p udp -j DROP` blocked Docker embedded
DNS forwarding to upstream servers, causing SERVFAIL for nslookup.
Changes:
- Restore AWF_DNS_SERVERS env var so setup-iptables.sh knows which
upstream DNS servers Docker embedded DNS forwards to
- Add explicit iptables ACCEPT rules for configured upstream DNS servers
(UDP/TCP port 53) before the DROP rules in the container OUTPUT chain
- Fix host-iptables.ts to use ip6tables for IPv6 DNS servers instead of
iptables (which rejects IPv6 addresses with exit code 2)
- Update DNS exfiltration tests to use non-configured DNS servers
(Quad9 9.9.9.9, OpenDNS 208.67.222.222, Cloudflare 1.1.1.1) since
the default upstream (8.8.8.8) must be allowed for DNS forwarding
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: resolve rebase conflicts with DoH support from main
Merge PR #1270's simplified DNS model with DoH support from main:
- DoH mode: route DNS through DoH proxy (from main)
- Non-DoH mode: Docker embedded DNS with upstream forwarding only
- Fix test calls to include required dnsServers parameter
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: create FW_WRAPPER_V6 chain before adding IPv6 DNS rules
When IPv6 DNS servers are configured, the code tried to append rules
to the FW_WRAPPER_V6 chain without creating it first, causing
"No chain/target/match by that name" error from ip6tables.
Create the chain lazily when IPv6 DNS servers are present and
ip6tables is available.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0 commit comments