feat: implement comprehensive TCP jailing with host-side PREROUTING #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The current jail implementation only intercepts HTTP (port 80) and HTTPS (port 443) traffic, allowing applications to bypass the jail by using non-standard ports.
Applications that can currently escape the jail:
curl http://example.com:8080/api
mysql -h db.example.com -P 3306
ssh [email protected]
wget https://api.example.com:5000/data
Solution
Implemented comprehensive TCP jailing using the proven approach from the veth-pair branch:
Traffic Interception Strategy
Before (Limited):
After (Comprehensive):
# Catches ALL TCP traffic from namespace interface on host iptables -t nat -A PREROUTING -i veth_h_1234567 -p tcp -j REDIRECT --to-ports 8043
Key Changes
vethHost
field toLinuxJail
struct for interface trackingSecurity Improvements
Benefits
Technical Details
-i veth_h_*
ensures only namespace traffic is affectedTesting
This transforms jail from "HTTP/HTTPS proxy with some isolation" to "true network jail with comprehensive traffic control".