Extension headers and fragmentation attacks
Explain attacks that use header chains, routing headers, and overlapping and atomic fragments. Configure extension-header and fragmentation filtering policy. Weigh the operational cost of dropping extension headers (RFC 7872, RFC 9288).
Take the quiz · pass mark 70% · 9 questions
Explanation
IPv6 (RFC 8200) replaced IPv4 options with a chain of extension headers between the main header and the payload: Hop-by-Hop, Destination Options, Routing, Fragment, and the authentication/ESP headers. Each has a Next Header field pointing to the next. The design is clean, but it creates parsing problems that attackers exploit and firewalls struggle with.
The attacks
Long header chains (RFC 7112). A firewall must walk the whole chain to find the transport header and ports. An attacker can build a chain so long, or so fragmented, that the first fragment does not contain the full header chain. A stateless filter then cannot see the TCP/UDP ports and may fail open or closed. RFC 7112 requires the first fragment to contain the entire header chain and lets routers drop packets that violate this. Drop first fragments without a complete header chain.
Overlapping fragments (RFC 5722). If two fragments claim overlapping offsets with different contents, different reassembly implementations keep different bytes, so an attacker can show the firewall one packet and the host another (evasion). RFC 5722 requires that any IPv6 datagram with overlapping fragments be discarded entirely. Ensure your stack and firewall do this.
Atomic fragments (RFC 8021). An "atomic" fragment is a Fragment header with offset 0 and the M (more) flag 0: a single, complete packet that is nonetheless marked fragmented. They are usually triggered by a forged ICMPv6 Packet Too Big claiming an MTU below 1280. RFC 8021 concludes they are harmful and should not be generated; treat each atomic fragment as a whole packet and consider dropping them at the edge.
Routing Header type 0 (RFC 5095). RH0 let the sender list intermediate hops the packet must visit. An attacker could bounce a packet between two routers repeatedly for traffic amplification. RFC 5095 deprecated RH0; drop it. (Type 2 is used by Mobile IPv6 and type 4 is the Segment Routing Header; treat other routing-header types by policy.)
Hop-by-Hop abuse. The Hop-by-Hop Options header is examined by every router on the path and historically punted packets to the slow control-plane path, so it can be a denial-of-service vector. Modern guidance (RFC 9673) improves processing, but many networks still drop or limit Hop-by-Hop.
Fragmented ND (RFC 6980). Neighbor Discovery must never be fragmented; fragmenting ND was a way to evade RA-Guard (L5.03). Drop fragmented ND messages.
The policy
RFC 9098 (operational implications) and RFC 9288 (filtering recommendations at transit routers) are the current guidance. A workable edge policy:
- Drop Routing Header type 0 (deprecated) and unknown/unused routing-header types by policy.
- Drop packets whose first fragment does not contain the full header chain (RFC 7112), and any packet with overlapping fragments (RFC 5722).
- Drop fragmented ND (RFC 6980) and consider dropping atomic fragments.
- Decide on Hop-by-Hop and Destination Options: drop or rate-limit at the edge if you do not need them.
- Permit the Fragment header for normal traffic (DNS over UDP and other large responses still fragment), and permit ESP/AH for your VPNs.
The operational cost
Dropping extension headers is not free. RFC 7872 measured the real Internet and found that a significant fraction of paths already drop packets with extension headers, especially Hop-by-Hop and large header chains, which breaks legitimate uses. So:
- Dropping Hop-by-Hop or Destination Options wholesale can break things that use them.
- Dropping all fragments breaks large DNS-over-UDP responses and some tunnels. Prefer the targeted rules above.
- RFC 9288 stresses: filter at transit routers only for traffic not addressed to them, and distinguish "drop the header" from "drop the packet".
Measure what your traffic actually uses before you drop a header class, and document the decision.
nftables building blocks
nftables can match extension-header presence and fragment fields:
# drop deprecated routing header type 0 and segment-left routing-header abuse
ip6 nexthdr ipv6-route rt type 0 drop
# drop fragmented Neighbor Discovery (RFC 6980): fragment header + ND type
exthdr frag exists icmpv6 type { nd-router-advert, nd-router-solicit,
nd-neighbor-solicit, nd-neighbor-advert, nd-redirect } drop
# drop first fragment with offset 0 and more-fragments that is too small to hold the chain (heuristic)
frag frag-off 0 frag more-fragments 1 meta length 0-68 drop
# optionally drop Hop-by-Hop at the edge
exthdr hbh exists drop
Matching the "first fragment lacks the full chain" condition exactly is hard in a stateless filter; many operators approximate it or rely on the host stacks (which, per RFC 7112, discard such packets) plus dropping overlaps. rt type 0 and fragmented-ND rules are exact. Keywords and capabilities differ between nftables versions and other firewalls, so test on your platform.
ictNetworks scenario
ictNetworks' edge policy drops RH0 and fragmented ND everywhere, discards overlapping fragments (the host stacks do too), and drops Hop-by-Hop on transit for traffic not destined to its routers, having measured that none of its services use it. It deliberately permits the Fragment header, because its authoritative DNS sends large signed responses over UDP, and it monitors the drop counters so a new legitimate use of extension headers is noticed rather than silently broken.
Drawing diagram…
Worked examples
Example 1: Identifying an atomic fragment
A packet has a Fragment header with Fragment Offset 0 and the M flag 0. That is an atomic fragment: a complete packet marked as fragmented, usually the result of a forged Packet Too Big below 1280. RFC 8021 says not to generate these.
Example 2: Why overlaps are banned
Fragment A covers bytes 0–47 with a benign port; fragment B claims bytes 24–71 overwriting the port with a blocked one. A firewall that reassembles one way and the host another disagree on the packet. RFC 5722 removes the ambiguity: discard the whole datagram.
Example 3: The first-fragment rule
The IPv6 header is 40 bytes. With a Hop-by-Hop (8), a Destination Options (8) and a Fragment header (8), the chain before the transport header is 40 + 8 + 8 + 8 = 64 bytes. RFC 7112 requires the first fragment to include all of it (plus the transport header); a first fragment shorter than that must be dropped.
Lab
Goal: Send crafted extension-header and fragment packets through a firewall and record which are dropped.
You need: a namespace lab with a client, an nftables firewall/router and a server; Scapy on the client; tshark on the firewall and server.
- Baseline: send normal TCP and a legitimately fragmented large UDP (DNS) packet through the firewall and confirm both pass.
- Craft and send, with Scapy: (a) a packet with Routing Header type 0 (
IPv6ExtHdrRouting(type=0)), (b) overlapping fragments with conflicting payloads, (c) an atomic fragment (IPv6ExtHdrFragment(offset=0, m=0)), (d) a Router Advertisement in a fragment (fragmented ND), (e) a long header chain whose first fragment omits the transport header. For each, record whether it reaches the server with no firewall rules. - Apply the policy: drop RH0, drop fragmented ND, drop overlapping fragments (or confirm the host discards them), drop the tiny-first-fragment case, and (optionally) drop Hop-by-Hop. Re-send each packet and record the result.
- Confirm the baseline traffic (normal TCP and legitimate fragmented DNS) still passes with the policy on.
- Read
/proc/net/snmp6or nft counters to show the drop counts, and write up the operational trade-off (RFC 7872/9288): which header you would and would not drop in production and why.
What to submit: the Scapy scripts, the nftables policy, a table of packet → dropped/passed before and after, and the trade-off write-up.
Summary
- Attacks use long/fragmented header chains (RFC 7112), overlapping fragments (RFC 5722), atomic fragments (RFC 8021) and RH0 (RFC 5095).
- Drop RH0, fragmented ND (RFC 6980), overlapping fragments and first fragments lacking the full header chain.
- Permit the Fragment header for legitimate large traffic; do not drop all fragments.
- Dropping Hop-by-Hop or Destination Options can break real traffic (RFC 7872); filter at transit per RFC 9288 and measure first.
- Verify nftables keywords and capabilities on your version.
- Next lesson (L5.05): stateful firewalls and perimeter policy.
Quiz imported · 9 questions · pass mark 70%. Lab questions are not auto-marked.