WireGuard has a habit I really like. Send it a packet it can't authenticate and it says nothing at all: no error, no hint, nothing an attacker could learn from.
But silence doesn't mean the packet went nowhere. Before WireGuard gets to ignore a datagram, the kernel has already accepted it, a socket has handed it to userspace, and a handful of tasks have passed it around through buffers and channels, all before a single byte of cryptography runs.
That stretch of code is where I spent my time in gotatun, Mullvad's userspace WireGuard implementation written in Rust. I found three bugs there.
None of them touch WireGuard's cryptography. Two could make a device stop receiving packets entirely, and the third let handshake rate-limiter entries pile up in memory long after they should have been cleared.
TL;DR
- Linux: one empty UDP datagram could panic the shared receive task.
- Windows: one oversized UDP datagram could stop reception for good.
- Rate limiter: source-IP counters never got cleared while no peer had a known endpoint.
All three are fixed. Update to gotatun 0.10.1 or later.
| Finding | Affected path | Severity | Fixed in |
|---|---|---|---|
| Empty datagram causes a panic | Linux batched/GRO receive path | High, CVSS 7.5 | 0.10.1 |
| Oversized datagram stops reception | Windows transport without windows-gro
|
High, CVSS 7.5 | 0.10.0 |
| Source-IP counters accumulate | Device with no known peer endpoints | Moderate | 0.10.1 |
The advisories list 0.9.2 as affected by the Linux and rate-limiter issues, and versions through 0.9.2 for the Windows one. I didn't test every older release, so I can't tell you exactly how far back each bug goes.
The part before authentication
Receiving a packet and authenticating a peer are two very different things. In gotatun, a platform-specific socket receives the datagram, a buffered receive task pushes it through a channel, and only then does the device handler verify the packet and process handshakes.
So untrusted input gets handled before WireGuard ever has a say.
For the first two bugs, that was enough. Neither needed a valid handshake or any secret key, and the sender only had to get the packet length right.
The rate limiter was a little different. Packets had to pass MAC1 validation first, but MAC1 doesn't authenticate a configured peer: its key is derived from the receiving device's public key, so anyone who knows that public key can build a packet with a valid MAC1 without holding any peer's private key.
Keep that in mind. It comes back later.
None of this gave me a way to decrypt traffic, extract keys or run code. These are availability bugs, and what they have in common is that unauthenticated traffic could reach resources the whole device depends on.
Bug 1: Zero bytes, one dead receiver
Linux · GHSA-6gxq-8xp9-742r · High, CVSS 7.5 · fixed in 0.10.1
On Linux, gotatun reads UDP packets in batches with recvmmsg. That saves a syscall per packet, which is exactly what you want on a hot path like this.
In gotatun/src/udp/socket/linux.rs I found this line:
result.iovs().next().expect("we create exactly one IoSlice")
It looks harmless. The code creates exactly one IoSlice per receive, so it expects to get exactly one back.
It doesn't always. With the nix 0.31.2 behavior described in the advisory, a UDP datagram with an empty payload can make result.iovs().next() return None, and expect() then does precisely what it was written to do: it panics.
An empty UDP datagram is perfectly legal. UDP allows zero-length payloads, and unlike a zero-length read on a TCP stream it doesn't mean EOF; it's a complete datagram that just happens to contain nothing, and the receiver has to cope with it.
WireGuard could simply have thrown it away. It never got the chance.
Why one packet was enough
The expect() sat inside gotatun's shared UDP receive task. That single task receives traffic for every peer on the device.
When the empty datagram arrived, the iterator returned None, the task panicked, and the channel feeding packets to the device handler closed behind it. Every packet after that had nowhere to go, and reception for the whole device stayed gone until someone restarted or reconfigured it.
One empty datagram. That's all it took.
I want to be precise about the scope, though. What I showed is that the device's receive path dies; I didn't show that every application embedding gotatun crashes, and I wouldn't claim that without testing the embedding process separately.
Reproducing it
The Linux loopback reproduction in the report sends two things. First an empty datagram, then a normal control message.
The second message is the real test. In the vulnerable version the producer task panics, the buffered receiver eventually reports a broken pipe because its channel has closed, and the control message never makes it through.
No configured peer is needed. No key either, because the bug fires long before any of that matters.
The fix
Mullvad fixed it in pull request #204. The unconditional expect() is gone, replaced with a check that handles an empty iterator:
let Some(iov) = result.iovs().next() else {
cold_path();
if cfg!(debug_assertions) {
tracing::trace!("Received empty datagram from IoSlice");
}
continue;
};
If there's no I/O slice, gotatun skips the result and moves on, and debug builds log what happened. That's really all a receiver needs to do with an empty datagram: no rebuilding the device, no touching peer state, no effect on whatever arrives next.
The patch also adds a regression test. That matters more than it sounds, because "the panic is gone" is only half the story.
The receiver has to survive the empty datagram and deliver the next normal one.
Bug 2: A packet Windows forgave and gotatun didn't
Windows · GHSA-fc57-wfhg-7c2w · High, CVSS 7.5 · fixed in 0.10.0
The Windows bug looked nothing like the Linux one. There was no panic and no empty iterator, just a socket error that gotatun took far more seriously than Windows did.
It affects the built-in Windows transport without the optional windows-gro feature. In that path, the buffered receiver uses a default packet buffer of 4,096 bytes.
When a UDP datagram is bigger than the buffer passed to recvfrom, Windows returns WSAEMSGSIZE, error 10040. According to Microsoft's recvfrom documentation, the data gets truncated and the excess is discarded.
The socket itself is fine. I checked that on native Windows: after an oversized datagram produced the expected error, a direct receive on the same socket returned the next, shorter message without complaint.
Windows had moved on. Gotatun hadn't.
Following the error
I traced the error into BufferedUdpReceive::new, where a producer task receives packets and sends them through a channel to a consumer:
let Ok(()) = udp_rx
.recv_many_from(&mut recv_many_buf, &mut recv_pool, &mut packet_bufs)
.await
else {
// TODO
return;
};
That return is the bug. The // TODO right above it says a lot.
Any error from recv_many_from() made the producer exit, whether the socket was truly broken or Windows had just dropped one datagram that didn't fit. Exiting dropped the sending side of the channel, and once the consumer had drained whatever was already queued, the device's receive loop ended.
It ended quietly, too. DeviceState::handle_incoming finished with Ok(()), so nothing reported a fatal error and nothing restarted the receiver.
The operating system hadn't disabled the socket. The library had simply stopped asking it for packets.
Two devices, one big packet
I tested this on native Windows 11. First at the socket and buffered-receiver layers, then with two peered gotatun devices talking to each other.
For the device test I used real loopback UDP sockets and in-process TUN channels, so traffic went through gotatun's actual data path. Before the trigger, ordinary traffic flowed in both directions on both the patched and the unpatched build.
Then I sent one 8,192-byte UDP datagram to the listening port of one device.
On the unpatched build, the next packet didn't reach that device within five seconds. With only the Windows receive patch applied, the exact same test kept passing traffic both ways.
That was the comparison I wanted. Same devices, same traffic, and the only thing that changed the outcome was the receive error hitting the vulnerable code.
This result has limits. I didn't test a complete VPN product or every recovery path, so it covers the gotatun data path I exercised and not how a particular application behaves after rebuilding its device. The optional Windows GRO path uses a larger batch buffer and different code, and Linux is another implementation entirely, so I wouldn't stretch this finding to either one without separate evidence.
The fix
The patch I sent with the report handles the error where it's actually understood: inside the Windows socket's own receive method. Here's UdpSocket::recv_datagram as it shipped in 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),
}
}
}
A successful receive returns the packet as before. On WSAEMSGSIZE the method knows Windows has already thrown the datagram away, so it yields to the executor with tokio::task::yield_now().await and tries again.
Every other error still propagates. I wanted to keep it that way, because some receive errors really do mean the socket or transport is broken, and swallowing those would only hide a different problem.
WSAEMSGSIZE isn't one of them. Now one oversized datagram gets dropped, and reception carries on.
Bug 3: The cleanup nobody called
Rate limiter · GHSA-m2rr-7rr7-vmp7 · Moderate · fixed in 0.10.1
The third bug lives in gotatun's handshake rate limiter. It counts handshake packets per source IP address and uses those counters to decide whether a source has gone over the configured threshold.
The counting happens after MAC1 validation. That sounds sensible at first, since at least something has been checked before the code starts creating state.
But remember what MAC1 is. Its key comes from the device's public key, so a sender who has never authenticated as a peer can still push a packet far enough into handshake processing to reach the rate limiter.
Here's the counter update from gotatun 0.9.2:
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
}
Lock the map, find or create the entry for the source IP, increment, compare. Simple enough.
The catch is the difference between many packets from one address and packets from many addresses. The first case keeps updating a single entry, while the second adds a fresh counter for every new IP, and the per-IP threshold does nothing to cap how many IPs end up in the map.
So the obvious next question was how entries ever leave it.
A reset that existed but never ran
There was a reset method, and it looked fine:
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 checks how long it's been since the last reset. If the interval has passed, it clears the map and updates the timestamp.
A reset only helps if something calls it. I followed the call path and found that the usual reset ran through the peer timer logic, and that logic skipped every peer without an endpoint.
That's an awkward combination. A gotatun device can listen for handshakes while none of its configured peers has a known endpoint, so incoming packets keep creating source-IP entries while the code that's supposed to clear them skips every peer and never gets there.
The map keeps growing, long after the reset interval has passed.
The counters belonged to the device. Their cleanup depended on peer state that might not exist.
What the test shows, and what it doesn't
The public advisory includes a reproduction that doesn't even need sockets. It builds handshake packets with valid MAC1 values for 2,048 synthetic source IP addresses, splits them into two groups and processes them across the normal reset interval.
The entries stay in the map until the reset is called by hand.
Together with the device timer's control flow, that demonstrates the missing cleanup: time passes, new entries arrive, and the reset still doesn't happen when no peer has a known endpoint.
I'm not going to turn that into "an attacker can exhaust memory on any affected machine." Filling the map takes traffic from many distinct source IPs, and whether someone can produce that depends on the network, on filtering and on anti-spoofing protections, so the test proves that entries survive when they shouldn't, not how fast memory would run out in a real deployment.
A side note on clear()
While reading the reset code I noticed one more thing. Rust's HashMap::clear() removes every entry but keeps the allocated capacity.
So even after a successful reset, an empty map can still hold on to memory from when it was full.
That isn't necessarily wrong. Reusing capacity is often faster than freeing and reallocating, and for a map that gets cleared and refilled on a schedule it can be the right call; it just means entry count and retained capacity are two separate things to measure if you care about resource exhaustion.
The bug I reported was about the reset not running. Whether the map should also shrink is a different decision.
The fix
Mullvad fixed this in pull request #205 by attempting the reset during the device's periodic maintenance:
if let Some(rate_limiter) = device.rate_limiter.as_ref() {
rate_limiter.try_reset_count();
}
The device can now clear the counters even when no peer has a known endpoint. The peer-side reset is still there, but cleanup no longer depends on it alone.
The patch doesn't touch HashMap::clear() or add a shrinking policy. It makes sure the reset finally gets a chance to run.
Test the packet after the bad one
Working through these bugs changed how I think about tests for receive paths. Checking that an invalid packet gets rejected tells you surprisingly little about whether the service survives it.
On Linux, the empty datagram should be dropped and the receiver must still be alive afterward. On Windows, the OS is allowed to report an oversized datagram, but that's no reason for gotatun to stop receiving altogether.
For both receive-path bugs, the most useful regression test is almost boring. Send the bad datagram, then send a normal one, and if the normal one arrives you've confirmed that the receive task is still running, the channel still works and packets still make it through the device.
The rate limiter needs a different kind of test. Its failure depends on time and device state, so I'd set up a listening device with no known peer endpoints, create source-IP entries with qualifying handshake traffic, move past the reset interval and check that the entries are gone, and I'd measure retained capacity separately if memory was what I cared about.
And test on every platform. A Linux test says nothing about how the Windows socket wrapper handles WSAEMSGSIZE, and a passing test on the Windows non-GRO path says nothing about the GRO one.
In both receive-path bugs, the platform-specific code is exactly where things went wrong.
If you use gotatun
Update to 0.10.1 or later. Version 0.10.0 already contains the Windows fix, but 0.10.1 is the first release with all three.
If you're checking an application that embeds gotatun, look at the resolved dependency version and the build you actually ship, not just what the manifest says. Check the target OS and which transport features are enabled too, because an advisory proves that a vulnerable code path exists, not that every application exposes it in its own configuration.
What I look for now
When I review UDP code these days, I start right at the receive boundary. Can an empty datagram reach an expect() or an assertion? Does the code assume a buffer holds data just because it handed one to the operating system? How are receive errors classified, and can one unexpected result make a shared producer task exit?
If the producer does exit, what then? Does the consumer notice, does the device restart reception, or does the task end quietly while the rest of the application carries on as if nothing happened?
And when unauthenticated traffic can create state, I want to know what bounds it and what cleans it up, especially when the device has no active peers or known endpoints. The rate limiter is a good reminder to follow the call to a cleanup function instead of only reading the function itself. Its logic was fine, but the path that called it depended on peer state that could be missing.
Final thoughts
I went into gotatun to see what happens around WireGuard's authentication boundary. I came out with three different ways unauthenticated input could take availability away from an otherwise healthy device: an empty datagram that panicked a shared task, an oversized one that made a producer give up on a socket that still worked, and a cleanup that waited for peers who weren't there.
None of them needed to break any cryptography. The fixes were small as well: skip the empty result, handle WSAEMSGSIZE where it's understood, and give the rate limiter a cleanup path that doesn't need a peer endpoint.
A packet doesn't have to pass authentication to cause trouble. It only has to reach code that makes the wrong assumption about its input, about a socket error, or about the state of the device.
So don't stop at asking whether the bad packet gets rejected. Ask whether the next good one still gets through.
Thanks to the Mullvad team for fixing these, shipping the patches and publishing the advisories.
Top comments (0)