Skip to content

fix: register TCPClientTunnel BindAddress as landlock.BindTCP, not ConnectTCP - #219

Open
bkmz wants to merge 1 commit into
windtf:masterfrom
bkmz:fix-tcpclienttunnel-landlock-bind
Open

fix: register TCPClientTunnel BindAddress as landlock.BindTCP, not ConnectTCP#219
bkmz wants to merge 1 commit into
windtf:masterfrom
bkmz:fix-tcpclienttunnel-landlock-bind

Conversation

@bkmz

@bkmz bkmz commented Jul 27, 2026

Copy link
Copy Markdown

What

TCPClientTunnel listens on BindAddress via net.ListenTCP (routine.go), but lockNetwork() in cmd/wireproxy/main.go registered its Landlock rule as landlock.ConnectTCP instead of landlock.BindTCP — the only listening routine type that got the wrong rule (HTTPConfig, Socks5Config, SNIConfig all correctly use BindTCP).

Why it matters

On kernels supporting Landlock network ABI v4 (Linux 6.7+, Jan 2024), landlock.V4.BestEffort().RestrictNet(rules...) actually enforces these rules. Since TCPClientTunnel's own bind was never allowlisted as a bind, the kernel denies wireproxy's own net.ListenTCP call on BindAddress:

listen tcp 0.0.0.0:5432: bind: permission denied

This reproduces on any host/platform once the kernel is new enough — independent of Docker, cloud platform, or any external sandboxing. Full writeup with reproduction and control test in #218.

Fix

One-line: swap ConnectTCP for BindTCP for the TCPClientTunnelConfig case, matching the pattern used by every other listening config type.

Verified go build ./... and go vet ./... pass. Manually verified TCPClientTunnel binds and accepts connections again after this change, on a host that previously reproduced the bug 100% of the time.

Fixes #218

…nnectTCP

TCPClientTunnel listens on BindAddress (net.ListenTCP), but lockNetwork()
registered it as a landlock.ConnectTCP rule instead of landlock.BindTCP.
On kernels supporting Landlock network ABI v4 (Linux 6.7+), this makes
wireproxy's own Landlock self-sandboxing deny its own bind() on
BindAddress, regardless of host environment.

Fixes windtf#218
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants