[G1] Relay WS handler trusts spoofable X-Real-IP / X-Real-Port from any peer
Description
Advisory 16 — [G1] Relay WS handler trusts spoofable X-Real-IP / X-Real-Port from any peer
- Severity: Medium
- CVSS 4.0 Base Score: 5.3
- CVSS 4.0 Vector:
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:N/SC:L/SI:L/SA:N - CWE: CWE-348, CWE-290 (CWE-348, CWE-290)
- Affected versions:
github.com/netbirdio/netbird>= 0.31.1, < 0.75.0 - Patched in: 0.75.0 — github.com/
netbirdio/ netbird/ pull/ 6833 - Affected component(s): relay xrealip
- Reporter: @SecurinDisclose — Arjun Basnet · Securin Inc. —
arjun.basnet@securin.io
---
Overview
if ip := r.Header.Get("X-Real-Ip"); ip != "" {
remoteAddr = net.JoinHostPort(ip, r.Header.Get("X-Real-Port"))
}Whatever the client sends in X-Real-Ip / X-Real-Port is used as the peer's observed source address — unconditionally, without verifying the request came from a trusted upstream proxy. Any WebSocket client can forge its IP.
---
Affected Location
relay/server/listener/ws/listener.go:105— remoteAddr overwrite from headers.
---
Vulnerable Code
if ip := r.Header.Get("X-Real-Ip"); ip != "" {
remoteAddr = net.JoinHostPort(ip, r.Header.Get("X-Real-Port"))
}---
Reproduction
A WebSocket client connecting to the relay from 127.0.0.1 with the header X-Real-Ip: 8.8.8.8 and X-Real-Port: 9999 is recorded by the server with the remote address 8.8.8.8:9999.
PoC output
=== RUN TestH12_RelayXRealIP
poc_test.go:39: connected from 127.0.0.1 with X-Real-Ip: 8.8.8.8
poc_test.go:44: server logged remoteAddr = 8.8.8.8:9999
--- PASS: TestH12_RelayXRealIP---
Impact
A WebSocket client that sends both headers makes the relay use an arbitrary address as the remote address of its connection, including in the relay's "WS client connected from" log line. A client can therefore hide its real address or attribute its connection to another host. See the CVSS 4.0 vector above for the scored impact.
---
Fix
Fixed in 0.75.0 (#6833).
The relay now honours X-Real-Ip and X-Real-Port only for requests whose direct connection address is inside a configured set of trusted proxies. Requests from any other address are served with their direct connection address. The set is configured with the --trusted-proxies flag, a comma-separated list of CIDRs or IPs. When it is empty, which is the default, the headers are ignored and the direct connection address is always used.
Operators who run the relay behind a reverse proxy and relied on the forwarded address must set --trusted-proxies to the proxy's address after upgrading.
Affected platforms
The relay server only. The NetBird client, including the Android and iOS apps, does not run the relay listener and is not affected.
---
Remediation
- Only trust
X-Real-Ipwhen the request came from a configured trusted proxy. - Ship without header trust by default; require explicit opt-in.
- Log both raw
RemoteAddrand any header-derived value to catch mismatches.
---
References & Evidence
- CWE definitions: CWE-348, CWE-290
- CVSS 4.0 calculator: first.org/
cvss/ calculator/ 4-0#CVSS:4.0/ AV:N/ AC:L/ AT:N/ PR:L/ UI:N/ VC:L/ VI:L/ VA:N/ SC:L/ SI:L/ SA:N - Fix: #6833
---
Credit
Reported by Arjun Basnet — Securin Inc. — via GitHub @SecurinDisclose. Coordinated disclosure timeline: 90 days — public disclosure on or after 2026-10-11 unless extended by mutual agreement.
---
Private Audit Bundle
The reporter's full reproduction bundle (labs, PoCs, live-target evidence) is available at github.com/arjun.basnet@securin.io).
Coordinated Disclosure
- Reporter: @SecurinDisclose — Arjun Basnet, Securin Inc.
- Contact:
arjun.basnet@securin.io - Public-disclosure deadline: 2026-10-11 (90 days from 2026-07-13)