Summary
TrustTunnel versions prior to 0.9.114 contain a server-side request forgery (SSRF) flaw in the TCP forwarding logic that bypasses private network restrictions when a numeric IP is used.
An attacker who can influence the VPN's destination endpoint may reach loopback or private network services despite allow_private_network_connections = false, enabling unauthorized access to internal systems.
Affected context
This vulnerability affects TrustTunnel deployments that:
- Rely on the VPN's
allow_private_network_connections = falsesetting to block access to loopback or private IP ranges, and - Allow clients or upstream components to specify arbitrary TCP destinations, including numeric IP addresses.
The flaw resides in the TCP forwarder (tcp_forwarder.rs), where hostname-based destinations are filtered for private ranges but numeric IP destinations are connected without equivalent checks.
Environments that expose TrustTunnel as a gateway toward internal services or cloud metadata endpoints are particularly at risk.
Exploit preconditions
- Attack surface: The TrustTunnel TCP forwarding interface that accepts user-controlled or proxy-controlled destination endpoints.
- Required access: Ability to establish a TrustTunnel connection and influence the requested TCP destination (e.g., hostname or IP address) within the protocol or configuration used by the server.
- Trigger point: Supplying a numeric IP address (e.g.,
127.0.0.1,10.x.x.x,192.168.x.x) as the destination whenallow_private_network_connections = falseis configured. - Why exploitation is possible: The private network checks (such as
is_global_ipand loopback checks) were only applied to theTcpDestination::HostName(peer)path. TheTcpDestination::Address(peer)path for numeric IPs proceeded directly toTcpStream::connect()without equivalent validation, allowing connections to loopback and private IP ranges.
Why this happens
The root cause is an incomplete enforcement of network access controls based on how the destination is represented in code.
The private network restriction logic was implemented only for hostnames (e.g., performing checks after DNS resolution), and was not mirrored for numeric IP addresses handled via TcpDestination::Address(peer).
This design creates a discrepancy in trust enforcement: the same logical "destination" is treated differently depending on whether it is given as a name or as an IP literal.
Conceptually, this maps to CWE-918: Server-Side Request Forgery (SSRF), where an attacker leverages a server-side component to initiate unauthorized connections to internal resources, often by bypassing incomplete or inconsistent validation of outbound targets.
Potential impact
- Access to loopback services (
127.0.0.1) exposed only on the TrustTunnel server host. - Unauthorized connections to private network services (e.g.,
10.0.0.0/8,192.168.0.0/16,172.16.0.0/12) that administrators expected to be blocked by configuration. - Potential interaction with sensitive internal APIs, databases, or administrative interfaces not directly reachable from the attacker's network.
- Use of the TrustTunnel server as an SSRF pivot to discover internal network topology and probe additional internal hosts.
- Possible access to cloud provider metadata endpoints or other local infrastructure services if reachable via private ranges.
General mitigation guidance
Effective mitigation centers on making the outbound connection policy uniform and destination-agnostic, and on minimizing trust in client-controlled routing data.
Common defensive patterns include:
- Applying identical private-network and loopback checks to all outbound connection paths, regardless of whether the destination is a hostname or a numeric IP.
- Implementing a centralized, reusable network access control layer (e.g., a "safe connect" helper) that enforces allowlists/denylists and is used by all code that creates outbound TCP connections.
- Treating both resolved addresses and literal IPs as untrusted and validating them against explicit policies (e.g., block RFC1918 ranges, link-local, loopback, and other restricted segments when such access is disabled).
- Designing configuration flags like
allow_private_network_connectionsso they are enforced close to the networking layer, reducing the chance of bypass through alternative code paths. - Running the VPN and its forwarder components under least-privilege network conditions, such as using firewall rules or container/network namespaces to prevent access to highly sensitive internal endpoints by default.
How teams detect issues like this
Detection typically involves a mix of code-level and runtime approaches:
- Static analysis and code review:
- Search for direct
TcpStream::connect()(or equivalent) calls and verify that all paths go through a common validation routine for destination addresses. - Look for branching logic that treats hostnames and numeric IP addresses differently, especially around network filtering or private-range checks.
- Enforce policies in code review templates requiring that new outbound network code use shared, policy-enforcing helpers.
- Automated scanning:
- Configure SAST tools to flag outbound connection calls that bypass central network policy functions.
- Use configuration-as-code checks to ensure that SSRF protections are not conditional on representation (hostname vs IP).
- Runtime monitoring:
- Log outbound connection attempts with resolved destination IPs and compare them against allowed ranges.
- Alert on attempted connections to loopback or private IP ranges from the VPN server when such access is nominally disabled.

