Commit 12683ac
fix: restrict host gateway iptables bypass to allowed ports only
The --enable-host-access flag added an iptables ACCEPT rule for
host.docker.internal with no port restriction, allowing agent code
to reach ANY service on the host (databases, admin panels, etc.)
and bypassing the dangerous-ports blocklist entirely.
Changes:
- Restrict host gateway FILTER ACCEPT to ports 80, 443, and any
ports from --allow-host-ports (was: all ports)
- Apply same port restriction to network gateway bypass
- Add IPv4 format validation for dynamically resolved IPs before
using them in iptables rules
- Mount chroot-hosts as read-only (:ro) since host.docker.internal
is pre-injected by docker-manager.ts before mounting
The NAT RETURN rule (which prevents DNAT to Squid) is unchanged,
so MCP traffic still bypasses Squid correctly. Non-allowed port
traffic hits the final DROP rule in the FILTER chain.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 61432e3 commit 12683ac
3 files changed
Lines changed: 39 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
14 | 20 | | |
15 | 21 | | |
16 | 22 | | |
| |||
124 | 130 | | |
125 | 131 | | |
126 | 132 | | |
| 133 | + | |
| 134 | + | |
127 | 135 | | |
128 | 136 | | |
129 | | - | |
| 137 | + | |
130 | 138 | | |
| 139 | + | |
131 | 140 | | |
132 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
133 | 155 | | |
134 | 156 | | |
135 | 157 | | |
| |||
139 | 161 | | |
140 | 162 | | |
141 | 163 | | |
142 | | - | |
| 164 | + | |
143 | 165 | | |
144 | 166 | | |
145 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
146 | 178 | | |
147 | 179 | | |
148 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
774 | 774 | | |
775 | 775 | | |
776 | 776 | | |
777 | | - | |
| 777 | + | |
778 | 778 | | |
779 | 779 | | |
780 | 780 | | |
| |||
787 | 787 | | |
788 | 788 | | |
789 | 789 | | |
790 | | - | |
| 790 | + | |
791 | 791 | | |
792 | 792 | | |
793 | | - | |
794 | | - | |
| 793 | + | |
795 | 794 | | |
796 | 795 | | |
797 | 796 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
521 | 521 | | |
522 | 522 | | |
523 | 523 | | |
524 | | - | |
| 524 | + | |
525 | 525 | | |
526 | 526 | | |
527 | 527 | | |
| |||
0 commit comments