Feature #9439
openIPv6 decoder: no event for non-zero PadN data, and none at all when a Router Alert precedes it
Description
RFC 8200 section 4.2 requires PadN Option Data to be zero-valued octets, and non-zero PadN data is a documented covert channel (RFC 4942 section 2.1.9.5). Linux has dropped such packets since 2012 (net/ipv6/exthdrs.c, ip6_parse_tlv).
Current behavior (8.0.8 and 7.0.3, all IPv6 decoder rules enabled):
1. A Destination Options or Hop-by-Hop header holding only a PadN with non-zero data raises `ipv6.dstopts_only_padding` / `ipv6.hopopts_only_padding`, exactly as a conforming zero-filled PadN does, so the two cannot be told apart.
2. A Hop-by-Hop header with a Router Alert followed by an 8-octet PadN with non-zero data raises no event at all.
3. When a Router Alert, Jumbo or Home Address option is shorter than required, the decoder stops scanning the header, so later options are not inspected.
The attached patch (against 8.0.8, 133 added lines):
- adds `decoder.ipv6.nonzero_padn` and `decoder.ipv6.padding_too_long` (a Pad1/PadN run longer than 7 octets, the limit Linux enforces), with rules 2200131/2200132 (sids to be assigned as you prefer);
- keeps scanning past a too-short Router Alert / Jumbo / Home Address option (still flagged `exthdr_invalid_optlen`);
- adds unit test `DecodeIPV6PadNTest01` and schema entries.
Testing:
- all 158 decoder/defrag unit tests pass;
- on the IPv6 captures of the tcpdump, Wireshark, Zeek and suricata-verify test suites (207,800 whole extension-header packets) `nonzero_padn` never fires, and `padding_too_long` fires only on packets Linux also discards for an over-long padding run;
- on 200,000 fuzzed IPv6 records, every packet with non-zero PadN data that the new event misses already raises `ipv6.trunc_pkt` or `ipv6.exthdr_dupl_hh` / `ipv6.exthdr_dupl_dh` (duplicated header);
- ASan/UBSan build: no reports in decode-ipv6.c;
- no measurable decoder overhead (2.0M-packet extension-header-heavy pcap, single runmode, median of 5: 10.77 s patched vs 10.85 s stock with the stock rule set).
I can turn this into a GitHub PR and add a suricata-verify test if the approach is acceptable.
Files
DD Updated by Dang Truong Dinh 3 days ago
I have a patch against main with a unit test and a Suricata-verify test. Could I get the developer role so I can assign this ticket to myself and open a PR?