WireGuard is known for staying silent towards packets it cannot authenticate. A userspace implementation still has to receive a UDP datagram, interpret the result of a socket call, and move bytes through its internal tasks before it can reject that packet. Bugs in those steps can stop a tunnel without breaking any cryptography.
I found three such bugs in gotatun, Mullvad's userspace WireGuard implementation in Rust. One empty datagram could terminate a Linux receive task. An oversized datagram could stop reception in the default Windows transport. A separate issue let handshake rate-limiter state accumulate when no peer had an endpoint.
All three are fixed. This post walks through the failure paths, the evidence behind them, and what the fixes change. The scope is gotatun and the configurations described below; these findings do not establish the exposure of a particular deployed VPN product.
| Finding | Relevant path or condition | Advisory severity | First patched release |
|---|---|---|---|
| Empty datagram causes a panic | Linux batched/GRO receive path | High, CVSS 7.5 | 0.10.1 |
| Oversized datagram stops reception | Windows built-in transport without windows-gro
|
High, CVSS 7.5 | 0.10.0 |
| Source-IP counters accumulate | Listening device with no known peer endpoints | Moderate | 0.10.1 |
The advisories identify 0.9.2 as affected for the Linux and rate-limiter findings, and versions through 0.9.2 for the Windows finding. The older-version coverage was not exhaustively established in the original reports. For the issues covered here, 0.10.1 is the first release containing all three fixes.
Where the authentication boundary actually sits
It helps to separate accepting a datagram from accepting a WireGuard peer. The implementation first receives the datagram through its platform-specific socket code. A buffered receive task passes it through a channel to the device handler, which then runs packet verification and handshake processing.
The first two findings interrupt this path before packet verification. A valid handshake is unnecessary: the trigger is a property of the UDP datagram itself.
The rate-limiter finding is slightly different. It requires a handshake-shaped packet with a valid MAC1, but that check does not authenticate a configured peer. The distinction matters because a public-key-derived MAC can protect a different boundary from one that requires a peer's secret key.
These are availability failures. Their mechanisms do not demonstrate decryption, key disclosure, or code execution. Their reach comes from putting device-wide resources on a path that processes untrusted input.
1. An empty datagram kills the Linux receive task
GHSA-6gxq-8xp9-742r · High, CVSS 7.5 · fixed in 0.10.1
The assumption behind the panic
The affected Linux implementation receives datagrams in batches using recvmmsg. In gotatun/src/udp/socket/linux.rs, it obtains the payload for each result through an iterator over the received I/O slices:
result.iovs().next().expect("we create exactly one IoSlice")
The comment embedded in the panic message explains the assumption: one slice was supplied, so one slice must be returned.
With the nix 0.31.2 behavior described in the advisory, an empty received datagram makes this iterator return None. The buffer arrangement used to request a receive does not guarantee a nonempty result iterator for every possible datagram. Calling expect turns that mismatch into a panic.
A zero-length UDP datagram is a valid message. It is different from a stream reaching EOF: the sender has sent a datagram whose payload length happens to be zero. There is no reason for a WireGuard implementation to accept it as a protocol packet, but receiving it must remain a normal, discardable event.
How a packet-level edge case becomes device-wide
The panic does not stay attached to the offending packet. It terminates the shared UDP receive task, which serves all peers on that gotatun device.
The resulting failure is therefore larger than a failed handshake:
- An unauthenticated sender delivers an empty datagram to the listening UDP port.
- The batched receiver reaches the
expectwhile extracting its payload. - The receive task panics and its channel closes.
- Further inbound traffic cannot reach the device's peers through that task.
Restarting or reconfiguring the device is required to restore reception. The demonstrated scope is the device's receive path; describing it as an inevitable crash of the entire embedding process would go beyond that evidence.
The report's Linux loopback reproduction queues an empty datagram followed by a nonempty control message. It observes the buffered receiver returning a broken-pipe error after its producer task panics. No configured tunnel peer or secret key is needed. The control message is important: it distinguishes losing one useless packet from losing the ability to receive the next useful one.
The upstream fix
The fixing pull request, #204, changes the empty iterator result into a skip instead of a panic. This is the replacement statement inside the loop over receive results:
let Some(iov) = result.iovs().next() else {
cold_path();
if cfg!(debug_assertions) {
tracing::trace!("Received empty datagram from IoSlice");
}
continue;
};
That is the right level at which to handle the condition: discard this receive result and continue processing the batch. There is no need to authenticate the empty packet, reconstruct the device, or make unrelated peers pay for it.
The PR also includes a regression test. For this kind of bug, a useful assertion is not merely that the receiver avoids panicking. It should verify that a normal message still gets through after the empty one.
2. An oversized datagram stops reception on Windows
GHSA-fc57-wfhg-7c2w · High, CVSS 7.5 · fixed in 0.10.0
This failure starts with a socket error rather than a panic. The affected configuration is the built-in Windows transport without the optional windows-gro feature. In the reviewed path, the device supplies a default 4096-byte packet buffer to the buffered receiver.
What Windows reports
When an incoming datagram is larger than the supplied buffer, Windows can return WSAEMSGSIZE, error 10040. Microsoft's recvfrom documentation describes the truncation and explains that excess UDP data is lost.
That describes a problem with this message. In the native reproduction, the socket remained usable: a subsequent direct receive obtained the next, shorter message.
Gotatun nevertheless propagated the first error out of the receive worker. A recoverable condition at the socket boundary became the end of the producer task.
Following the error through the task boundary
The receive producer in BufferedUdpReceive::new exits on a failed receive. This statement sits inside its packet-processing loop:
let Ok(()) = udp_rx
.recv_many_from(&mut recv_many_buf, &mut recv_pool, &mut packet_bufs)
.await
else {
// TODO
return;
};
That return drops the channel's sender. After already queued packets drain, the buffered consumer encounters the closed channel and the device's receive loop ends.
The last step made the problem harder to notice. DeviceState::handle_incoming ended with Ok(()), so that exit did not register as a fatal error and did not restart reception. The operating system had not permanently broken the socket; the library had stopped asking it for packets.
This also explains why a test that only checks the first receive error is incomplete. It proves that Windows reports an oversized datagram, but it does not establish what the application does after that error crosses its buffering and task boundaries.
What I tested
I tested this on native Windows 11, first at the socket and buffered-receiver layers, then with two peered gotatun devices using real loopback UDP sockets and in-process TUN channels.
Baseline traffic succeeded in both the patched and unpatched builds. After a single 8192-byte datagram was delivered to one device's UDP port, the unpatched build failed to deliver a subsequent packet to that device within five seconds. With only the Windows receive patch applied, traffic continued in both directions.
That comparison ties the observable outage to the receive error handling. It covers the library's device data path. A complete VPN product and recovery by rebuilding the device were not tested, so those remain separate deployment questions.
The configuration limit matters too. The optional Windows GRO path uses a different, larger batch buffer, and Linux has a different receive implementation. This finding should not be expanded into a claim that every platform or transport configuration stops on the same input.
Recover at the point where the error is understood
The patch I included with the report handles WSAEMSGSIZE locally, discards the offending message, and continues receiving. Here is the complete UdpSocket::recv_datagram method from gotatun 0.10.0:
async fn recv_datagram(&self, pool: &mut PacketBufPool) -> io::Result<(Packet, SocketAddr)> {
let mut buf = pool.get();
loop {
match self.socket().recv_from(&mut buf).await {
Ok((n, src)) => {
buf.truncate(n);
return Ok((buf, self.map_src(src)));
}
// Winsock discards the remainder of an oversized datagram. The socket
// remains usable; never pass its truncated contents to the protocol.
Err(err) if err.raw_os_error() == Some(WinSock::WSAEMSGSIZE) => {
tokio::task::yield_now().await;
}
Err(err) => return Err(err),
}
}
}
The yield gives the executor an opportunity to run other work between retries. Other receive errors still propagate. Treating one understood, message-local error as recoverable is different from swallowing every socket failure.
The broader lesson is about ownership of recovery. The socket layer knows what this platform-specific error means. If it lets that error terminate a shared task, every layer above it has to reconstruct context that was available at the original boundary.
3. A rate limiter that never forgets
GHSA-m2rr-7rr7-vmp7 · Moderate · fixed in 0.10.1
The third finding concerns memory retained while processing handshake traffic. Gotatun counts handshake packets per source IP to help protect against floods. The vulnerable lifecycle allowed entries to accumulate when the device had no known peer endpoints.
A valid MAC1 is not peer authentication
The counter insertion happens after MAC1 validation. At first glance, that can look like a useful barrier against untrusted senders allocating state.
But the MAC1 key is derived from the device's public key. A sender who knows that public key can construct a packet that passes MAC1 without possessing a configured peer's secret key. The packet can therefore reach the rate-limiter accounting before the sender has authenticated as a peer.
The resource that matters here is the number of distinct source IPs, because those addresses become map keys. The 0.9.2 rate-limiter implementation inserts or increments the entry before comparing its count to the per-IP limit:
fn is_under_load(&self, src_addr: IpAddr) -> bool {
let mut ip_counts = self.ip_counts.lock();
let count = ip_counts.counts.entry(src_addr).or_insert(0);
*count += 1;
*count > self.limit
}
Sending more packets from one address and sending packets from many addresses exercise different limits. A per-IP packet threshold does not by itself bound the number of IP entries stored.
Cleanup depended on peer activity
The reset method in that same file checks whether enough time has passed, clears the entries, and updates its timestamp:
pub fn try_reset_count(&self) {
let current_time = Instant::now();
let mut ip_counts = self.ip_counts.lock();
if current_time.duration_since(ip_counts.last_reset) >= RESET_PERIOD {
ip_counts.counts.clear();
ip_counts.last_reset = current_time;
}
}
It has to be called for any of that to happen. The caller was reached through the peer timer path, which skipped peers without an endpoint. If no peer had an endpoint, nothing reached the usual counter reset, even though the listening device could still process incoming handshake-shaped traffic.
The mismatch was between the lifecycle of the data and the lifecycle of its cleanup. The counters belonged to the device's exposed receive path, while their maintenance depended on the existence of a suitable peer.
The public advisory's test uses no sockets. It constructs packets with valid MAC1 values for 2,048 synthetic source IPs, separated into two groups across the normal reset interval. The entries remain until an explicit reset is invoked. Together with the device timer control flow, that demonstrates why elapsed time alone did not guarantee cleanup in the affected state.
This is evidence of retained growth, not a measurement of how quickly an attacker could exhaust a particular machine. A practical attack still requires traffic appearing from many distinct IPs. Filtering and anti-spoofing can limit that ability, which is one reason this finding needs more qualification than the single-datagram receive failures.
Emptying a map and releasing its allocation are different
There was another relevant detail: HashMap::clear() removes entries while retaining allocated memory for reuse.
That behavior is useful in a repeatedly reused collection. It also means that an empty map is not evidence that memory has returned to its earlier footprint. When reviewing a resource-exhaustion report, both entry count and retained capacity deserve attention.
Those are separate questions, though. Restoring periodic resets addresses the missing-cleanup lifecycle. Deciding whether and when to shrink an allocation is an additional resource-management policy, with its own allocation and performance tradeoffs.
What the fix changes
The upstream fix, #205, adds a reset attempt to the device's periodic maintenance, independently of the per-peer update path. The added call is straightforward:
if let Some(rate_limiter) = device.rate_limiter.as_ref() {
rate_limiter.try_reset_count();
}
The existing peer-side reset remains. The important change is that device-owned counters now have a cleanup opportunity even when peer state supplies none. This patch should not be described as a new shrinking policy: the published change fixes when resets run.
Testing the receive path after the bad input
These findings suggest a more useful test question than whether a malformed packet gets rejected: can the service still do useful work afterward?
For the Linux and Windows cases, a regression test should queue the trigger and then a normal control message. It should use a bounded wait and assert that the control message arrives. That exercises continuity across the receive loop, buffering, and task lifetime.
For the rate limiter, the relevant boundary is time and device state. Tests should cover a listening device without peer endpoints, advance beyond the reset interval, and inspect whether entries are actually removed. Retained allocation should be measured separately from logical entry count.
Platform coverage also needs to follow implementation paths. A passing Linux test cannot establish Windows receive behavior. A passing non-GRO test cannot establish what the batched/GRO implementation does. The operating-system wrapper is part of the behavior being tested.
Updating and reviewing downstream use
Update gotatun to 0.10.1 or a later release containing these fixes. Version 0.10.0 contains the Windows fix, but 0.10.1 is the first release that also covers the Linux panic and rate-limiter cleanup issue.
For an application embedding the library, inspect the resolved dependency and the deployed build, then check the actual target platform and transport features. A library advisory establishes a vulnerable path; determining whether a specific product exposes that path requires its own configuration and integration evidence.
When reviewing a similar UDP service, I would start with a few concrete questions:
- Can an empty datagram reach an
expect, an assertion, or an unchecked assumption about a returned buffer? - Which receive errors describe one bad message, and which require replacing the socket?
- If a producer task exits, does its consumer report a failure, restart, or quietly stop?
- How much state can an unauthenticated sender create by varying addresses?
- Does device-wide cleanup still run with zero peers or no known peer endpoints?
The cryptographic packet checks can be correct while these surrounding invariants fail. In gotatun, a handful of small control-flow changes restored the receive and cleanup behavior that those checks depended on.
Thanks to the Mullvad team for addressing the reports and publishing the advisories and fixes.
Top comments (0)