Commit 1935700
feat: implement comprehensive TCP jailing with host-side PREROUTING
Replaced port-specific OUTPUT rules with comprehensive TCP interception
using host-side PREROUTING rules. This closes all potential bypass routes
for applications using non-standard ports.
Key Changes:
## Traffic Interception Strategy
- **Before**: Namespace OUTPUT rules for ports 80 and 443 only
- **After**: Host PREROUTING rules for ALL TCP traffic from namespace
## Security Improvements
- ✅ Blocks ALL TCP traffic (not just HTTP/HTTPS)
- ✅ Prevents bypass via custom ports (8080, 3306, 22, etc.)
- ✅ Ensures complete network isolation
- ✅ Provides comprehensive audit trail
## Technical Implementation
- Added vethHost field to LinuxJail struct for interface tracking
- Changed from namespace 'ip netns exec iptables OUTPUT' rules
- To host 'iptables PREROUTING -i veth_interface' rules
- All TCP traffic redirected to HTTPS proxy port for handling
## Bypass Prevention
Applications can no longer escape jail by using:
- HTTP on non-standard ports (8080, 3000, etc.)
- Database connections (3306, 5432, 27017)
- SSH connections (22)
- Custom API ports
- Any other TCP-based protocols
This provides true network jailing instead of just HTTP/HTTPS proxying.
Tested: Build succeeds, all tests pass.
Co-authored-by: f0ssel <[email protected]>1 parent 602dd2f commit 1935700
1 file changed
+17
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
221 | 222 | | |
222 | 223 | | |
223 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
224 | 228 | | |
225 | 229 | | |
226 | 230 | | |
| |||
306 | 310 | | |
307 | 311 | | |
308 | 312 | | |
309 | | - | |
| 313 | + | |
310 | 314 | | |
311 | 315 | | |
312 | 316 | | |
313 | 317 | | |
314 | 318 | | |
315 | | - | |
| 319 | + | |
316 | 320 | | |
317 | 321 | | |
318 | 322 | | |
319 | 323 | | |
320 | 324 | | |
321 | 325 | | |
322 | | - | |
323 | | - | |
324 | | - | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
325 | 330 | | |
326 | 331 | | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
| 332 | + | |
336 | 333 | | |
337 | 334 | | |
| 335 | + | |
338 | 336 | | |
339 | 337 | | |
340 | 338 | | |
341 | 339 | | |
342 | 340 | | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
343 | 345 | | |
344 | | - | |
| 346 | + | |
345 | 347 | | |
346 | 348 | | |
347 | 349 | | |
| |||
0 commit comments