[H16] Relay server gob-decoded unauthenticated Hello handshake bytes before verifying the HMAC signature
Description
Advisory 19 — [H16] Relay HMAC unmarshalToken runs gob.Decoder on unauth bytes before signature check
- Severity: Medium (reassessed by NetBird; see Impact)
- CVSS 4.0 Base Score: 6.3 (reassessed by NetBird)
- CVSS 4.0 Vector:
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N - CWE: CWE-502 (CWE-502)
- Affected product:
github.com/netbirdio/netbird— relay server,>= 0.29.0, < 0.75.0(reported against v0.74.3) - Affected component(s): relay server pre-authentication handshake
- Reporter: @SecurinDisclose — Arjun Basnet · Securin Inc. —
arjun.basnet@securin.io
---
Overview
func unmarshalToken(raw []byte) (*Token, error) {
var t Token
if err := gob.NewDecoder(bytes.NewReader(raw)).Decode(&t); err != nil {
return nil, err
}
return &t, nil
}The relay accepts attacker-supplied bytes and hands them to gob.NewDecoder before any HMAC signature verification. Any future gob decoder CVE (or existing resource-exhaustion primitive) is directly reachable pre-auth by an anonymous network client.
The reachable path is the deprecated Hello handshake. handshakeReceive dispatched a MsgTypeHello message to handleHelloMsg, which called the validator's ValidateHelloMsgType — the gob path — before any peer was authenticated. The Auth handshake that every client has used since v0.29.1 never invoked gob.
---
Affected Location
Paths and line numbers as of v0.74.7, the last affected release:
shared/relay/auth/hmac/token.go:21—unmarshalTokenusesgob.Decoder.shared/relay/auth/hmac/validator.go:22-33— signature check runs AFTER decode.shared/relay/auth/validator.go—ValidateHelloMsgTypedelegates to the above.relay/server/handshake.go—handshakeReceiveacceptsMsgTypeHellopre-authentication and routes it tohandleHelloMsg.
---
Vulnerable Code
func unmarshalToken(raw []byte) (*Token, error) {
var t Token
if err := gob.NewDecoder(bytes.NewReader(raw)).Decode(&t); err != nil {
return nil, err
}
return &t, nil
}func (a *TimedHMACValidator) Validate(credentials any) error {
b, ok := credentials.([]byte)
if !ok {
return fmt.Errorf("invalid credentials type")
}
c, err := unmarshalToken(b) // gob decode of unauthenticated bytes
if err != nil {
return err
}
return a.TimedHMAC.Validate(sha256.New, c) // signature verified afterwards
}---
Reproduction
Sending a Hello handshake message to a relay server older than v0.75.0 reaches the gob decoder without credentials.
PoC output
=== RUN TestH16_GobDecoderSurface
poc_test.go:37: crafted payload 128MB nested slices -> peak alloc 1.9GB
poc_test.go:42: server accepted decode before signature check
--- PASS: TestH16_GobDecoderSurfaceThe reported allocation figure comes from calling unmarshalToken directly. Over the wire the payload is bounded — see Impact.
---
Impact
Reaching the decoder needs no credentials, but the achievable input is small. handshakeReceive reads into a buffer of messages.MaxHandshakeSize (212 bytes), and the pre-authentication phase is bounded by a 10-second timeout, so at most a couple of hundred attacker-controlled bytes ever reach gob.Decode. The 128 MB payload in the PoC is not reachable through the server, and there is no confidentiality or integrity impact.
What the path did expose is encoding/gob itself, which has had denial-of-service vulnerabilities — for example CVE-2024-34156, stack exhaustion on deeply nested input, fixed in Go 1.22.7 and 1.23.1. A relay server built with an affected Go toolchain would have reached that from an unauthenticated connection, before any signature check.
NetBird therefore rates this Medium (CVSS 4.0 base score 6.3) rather than the reported High (7.7). The difference is in the availability metrics: the report assumes a high availability impact on the relay and on subsequent systems, which the 212-byte handshake bound does not support. What remains is a low availability impact, contingent on a separate decoder vulnerability and so marked as attack requirements present. It stays network-reachable and pre-authentication, which is why it does not fall lower. CIA breakdown is captured in the reassessed CVSS 4.0 vector: CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N.
---
Fix
Fixed in v0.75.0 (#6783). The relay server no longer accepts the Hello message type, and the gob-based token and message decoding behind it was deleted along with the legacy validator wiring. Handshake authentication now runs only through the Auth message, whose token is parsed by v2.UnmarshalToken — a fixed-layout byte reader with explicit length checks — and whose signature is verified against the declared algorithm's digest size. No gob decoding remains on the relay server's handshake path.
The Hello handshake shipped in v0.29.0 and was superseded by the Auth handshake in v0.29.1. From v0.29.1 onward no NetBird client used it; the server kept the path solely for backwards compatibility with pre-v0.29.1 clients, which is why it could be removed outright rather than reordered.
Operators running a relay server older than v0.75.0 should upgrade. No configuration change is required, and no client action is needed.
---
Remediation
- HMAC-verify the raw bytes before ever calling
gob.Decode. - Prefer a length-bounded, schema-driven format (protobuf) over gob for network payloads.
- Cap decoder input size and nesting depth defensively.
---
References & Evidence
- CWE definitions: CWE-502
- CVSS 4.0 calculator: first.org/
cvss/ calculator/ 4-0 - Fix: #6783
---
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
Full reproduction bundle (labs, PoCs, live-target evidence, cross-referenced advisories) 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)