TExcelTAD

UDP and Amplification Attacks

UDP is the simplest transport there is: eight bytes of header, no handshake, no state. That makes it ideal for DNS lookups, voice, games and QUIC, and it makes one attack very cheap. Because no handshake proves the source address, an attacker can send a small UDP request with the victim's address as the source to a server that answers with a large response. The server "reflects" the traffic to the victim and multiplies it. Thousands of such servers turn a modest upload into a flood of hundreds of gigabits. This is reflection and amplification, the method behind most of the largest DDoS attacks on record. The UDP header itself is covered in UDP; DDoS in general is introduced in Denial of Service and DDoS; this lesson treats the attack as a concept, measures amplification from the sample DNS capture, and covers detection and the fixes.

Nothing here sends traffic anywhere: the numbers come from a sample capture and arithmetic.

The UDP header

Bytes Field
2 source port
2 destination port
2 length (header + data)
2 checksum (pseudo-header + header + data; optional in IPv4, mandatory in IPv6)
python · try it yourself
import struct

# UDP header of the first query in $SAMPLES/pcap/dns.pcap
sport, dport, length, csum = struct.unpack("!HHHH", bytes.fromhex("9c4100350026760b"))
print(f"source port {sport}, destination port {dport} (DNS), length {length} = 8 header + {length - 8} data, checksum 0x{csum:04x}")
source port 40001, destination port 53 (DNS), length 38 = 8 header + 30 data, checksum 0x760b

There is nothing else: no sequence numbers, no acknowledgement, no connection. A server that receives this packet has no way to know whether 10.10.0.5 really sent it.

The mechanism

attackersrc = victim reflector 1 reflector 2 reflector n victim small spoofed requestslarge responses

Three ingredients are needed: source spoofing (the attacker's network doesn't apply BCP 38), a protocol where a small request triggers a large response without a handshake, and many open reflectors that answer anyone.

The bandwidth amplification factor (BAF) is the ratio of the response's UDP payload size to the request's.

Measuring it in the sample capture

The sample DNS capture has two small queries. The session prints the sizes; the program after it turns them into factors and a back-of-the-envelope attack estimate.

bash · try it yourself
tshark -r $SAMPLES/pcap/dns.pcap -T fields -e frame.number -e dns.flags.response -e dns.qry.name -e udp.length -e frame.len
1	False	www.lab.test	38	72
2	True	www.lab.test	66	100
3	False	nope.lab.test	39	73
4	True	nope.lab.test	113	147
python · try it yourself
pairs = {"A www.lab.test": (38, 66), "A nope.lab.test (NXDOMAIN)": (39, 113)}   # UDP lengths from the capture
for name, (q, r) in pairs.items():
    print(f"{name:<27} request {q - 8:>3} B  response {r - 8:>3} B  factor {(r - 8) / (q - 8):.1f}")

# A thought experiment, not a measurement: how much traffic reaches the victim?
upload_mbps = 100                  # the attacker's spoofed request traffic
for proto, baf in [("DNS, small answers like above", 2), ("DNS ANY / large DNSSEC answers", 50),
                   ("protocol with BAF 500", 500)]:
    print(f"{proto:<32} {upload_mbps} Mbit/s of requests -> about {upload_mbps * baf / 1000:g} Gbit/s at the victim")
A www.lab.test              request  30 B  response  58 B  factor 1.9
A nope.lab.test (NXDOMAIN)  request  31 B  response 105 B  factor 3.4
DNS, small answers like above    100 Mbit/s of requests -> about 0.2 Gbit/s at the victim
DNS ANY / large DNSSEC answers   100 Mbit/s of requests -> about 5 Gbit/s at the victim
protocol with BAF 500            100 Mbit/s of requests -> about 50 Gbit/s at the victim

The lab answers are small, so the factors are only about 2 and 3. Attackers choose queries that produce huge answers (for DNS: ANY queries, or records signed with DNSSEC, sent over UDP with EDNS0 allowing 4 KB responses) and protocols with even bigger ratios. Public advisories have reported factors in the tens for DNS, in the hundreds for older NTP monlist and chargen, and in the tens of thousands for memcached exposed over UDP. Exact numbers depend on server configuration; what matters is that the victim receives many times the attacker's own bandwidth, from thousands of innocent-looking servers.

How it is detected

At the victim: a sudden volume of UDP responses (source port 53, 123, 1900, 11211, 389, …) that match no request the victim ever sent, from many sources, often fragmented because the responses are large. Flow data (NetFlow/IPFIX) shows it first: bytes per second by source port. For DNS, the giveaway is responses arriving for queries with IDs and names you never asked about.

At a reflector (your server being abused): many requests from one "source" (the victim) for the same large answer, especially ANY or very large TXT records, at a rate no real client sends. DNS servers log this; response-rate-limiting statistics show it.

At the attacker's network: packets leaving with source addresses that don't belong to it, which egress filtering would have dropped.

How it is fixed or prevented

Where Control
every network edge BCP 38 / BCP 84 ingress and egress filtering: no spoofed sources leave, so no reflection is possible from there
DNS servers don't run open resolvers (recursion only for your own clients); response rate limiting (RRL); minimal answers to ANY (RFC 8482)
other UDP services disable legacy features (NTP monlist, chargen, SSDP on WAN, memcached UDP), bind internal services to internal interfaces, firewall them from the Internet
protocol design handshake or address validation before large responses; QUIC (RFC 9000) limits a server to 3× the bytes received until the client's address is validated
the victim upstream DDoS scrubbing and filtering by source port; an attack that fills the link has to be stopped before the link

Pitfalls

  • Blocking UDP 53 to "stop DNS amplification" and breaking your own name resolution. Filter responses you didn't ask for (stateful) and rate-limit, don't block the protocol.
  • Thinking "our server is only one of thousands, it doesn't matter". Each reflector is part of the attack; open resolvers and exposed services get abuse reports for good reason.
  • Ignoring fragmented UDP: large responses arrive as fragments, and only the first carries the port numbers, so port-based filters miss the rest unless they reassemble or drop fragments under attack.

Practice

1. From the capture: why does the NXDOMAIN answer have a bigger factor than the positive answer?

It carries the zone's SOA record in the authority section (for negative caching), 105 bytes against a 31-byte query, while the positive answer adds only one 28-byte A record to the question (58 bytes; the lab server doesn't compress the name). Negative answers can be larger than positive ones.

2. Why is TCP not used for reflection attacks in the same way?

A spoofed SYN gets only a SYN-ACK of similar size (factor about 1, plus a few retransmissions), and no data is sent before the handshake completes, which the spoofer can't do. Some middleboxes that answer before a handshake were found to amplify, which is the exception that proves the rule.

3. A DNS server answers 900 ANY queries per second from 203.0.113.50, each 3,000 bytes. What do you do?

It is almost certainly a reflection attack against 203.0.113.50. Turn on (or tighten) response rate limiting, answer ANY minimally (RFC 8482), make sure recursion is only offered to your own clients, and report the traffic if needed; don't block 203.0.113.50 permanently, it is the victim.

Test yourself

Which property of UDP makes reflection attacks possible?

  1. Its checksum
  2. No handshake, so the source address is never verified
  3. Its 8-byte header
  4. Port numbers above 1024

What is the bandwidth amplification factor of a 30-byte request with a 1,500-byte response?

  1. 5
  2. 15
  3. 50
  4. 1470

Which measure removes the root cause of reflection from a network?

  1. Bigger links
  2. BCP 38 source address filtering
  3. Blocking all UDP
  4. Using IPv6

How does QUIC protect against being used as an amplifier?

  1. It uses TCP
  2. Servers send at most 3 times the bytes received until the client's address is validated
  3. It disables UDP checksums
  4. It requires DNSSEC