Commit bff230a
feat: transparent DNS interception via in-namespace server
Implements transparent DNS interception in Linux strong jails to prevent
DNS exfiltration via subdomain encoding attacks.
## Core Implementation
- **ForkedDnsProcess**: Manages child process running DummyDnsServer inside
network namespace with proper privilege dropping and cleanup
- **DummyDnsServer**: Returns 6.6.6.6 for all A record queries using
simple-dns library
- **DNS Redirection**: nftables rules redirect all UDP port 53 traffic to
in-namespace DNS server (6.6.6.6)
- **IPv6 Support**: Separate ip6 table with DNS DNAT to ::1 and blocks
other IPv6 egress
## Security Features
- DNS server drops privileges to nobody:nogroup (UID/GID 65534) after
binding port 53
- Uses PR_SET_PDEATHSIG(SIGTERM) to ensure DNS server terminates with parent
- Closes all inherited file descriptors (3-1024) to avoid tokio runtime issues
- Prevents DNS exfiltration - external DNS servers (1.1.1.1, 8.8.8.8) are
unreachable from jail
## Dependencies
- Added simple-dns = "0.7" for DNS packet parsing
- Added nix features: process, fs, sched, user, signal (Linux-only)
- Added command_utils module for command execution with timeout handling
## Testing
- Fixed #![allow(deprecated)] placement in test files (must be line 1)
- Fixed test_weak_mode_allows_localhost to accept exit code 28 (timeout)
in addition to 7 (connection refused) and 52 (empty reply) since the
proxy may timeout when trying to connect to localhost:80
## Platform Support
- Linux: Full DNS interception via network namespaces (strong jail)
- macOS: Weak mode only (no DNS changes needed)
Co-authored-by: Claude <assistant@anthropic.com>1 parent 574ca02 commit bff230a
18 files changed
Lines changed: 1354 additions & 890 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
135 | 180 | | |
136 | 181 | | |
137 | 182 | | |
| |||
0 commit comments