|
| 1 | +# |
| 2 | +# Test vectors for DHCPv6 error conditions |
| 3 | +# |
| 4 | +proto dhcpv6 |
| 5 | +proto-dictionary dhcpv6 |
| 6 | +fuzzer-out dhcpv6 |
| 7 | + |
| 8 | +# |
| 9 | +# ---- Pair-level decode tests (decode_option) ---- |
| 10 | +# |
| 11 | + |
| 12 | +# |
| 13 | +# Insufficient data - 1 byte (need at least 4 for option header) |
| 14 | +# |
| 15 | +decode-pair 00 |
| 16 | +match decode_option: Insufficient data |
| 17 | + |
| 18 | +# |
| 19 | +# Insufficient data - 3 bytes (need at least 4 for option header) |
| 20 | +# |
| 21 | +decode-pair 00 01 00 |
| 22 | +match decode_option: Insufficient data |
| 23 | + |
| 24 | +# |
| 25 | +# Option overflows input - option header says length 10, but only 2 bytes follow |
| 26 | +# |
| 27 | +decode-pair 00 01 00 0a 01 02 |
| 28 | +match decode_option: Option overflows input. Optional length must be less than 2 bytes, got 10 bytes |
| 29 | + |
| 30 | +# |
| 31 | +# ---- Packet-level validation tests (fr_dhcpv6_ok) ---- |
| 32 | +# |
| 33 | + |
| 34 | +# |
| 35 | +# Packet too small for DHCPv6 header - 1 byte |
| 36 | +# |
| 37 | +decode-proto 01 |
| 38 | +match Packet is too small for DHCPv6 header: Invalid DHCPv6 packet starting at offset 0 |
| 39 | + |
| 40 | +# |
| 41 | +# Packet too small for DHCPv6 header - 3 bytes |
| 42 | +# |
| 43 | +decode-proto 01 00 00 |
| 44 | +match Packet is too small for DHCPv6 header: Invalid DHCPv6 packet starting at offset 0 |
| 45 | + |
| 46 | +# |
| 47 | +# Relay Forward too small - need 34 bytes, only have 10 |
| 48 | +# Type 12 = Relay-Forward |
| 49 | +# |
| 50 | +decode-proto 0c 00 00 00 00 00 00 00 00 00 |
| 51 | +match Packet is too small for relay header: Invalid DHCPv6 packet starting at offset 0 |
| 52 | + |
| 53 | +# |
| 54 | +# Relay Reply too small - need 34 bytes, only have 5 |
| 55 | +# Type 13 = Relay-Reply |
| 56 | +# |
| 57 | +decode-proto 0d 00 00 00 00 |
| 58 | +match Packet is too small for relay header: Invalid DHCPv6 packet starting at offset 0 |
| 59 | + |
| 60 | +# |
| 61 | +# Not enough room for option header - normal packet with 2 trailing bytes |
| 62 | +# Solicit (type 1) + txn_id + 2 bytes (need 4 for option header) |
| 63 | +# |
| 64 | +decode-proto 01 00 00 00 00 01 |
| 65 | +match Not enough room for option header: Invalid DHCPv6 packet starting at offset 0 |
| 66 | + |
| 67 | +# |
| 68 | +# Not enough room for option header - normal packet with 1 trailing byte |
| 69 | +# |
| 70 | +decode-proto 01 00 00 00 ff |
| 71 | +match Not enough room for option header: Invalid DHCPv6 packet starting at offset 0 |
| 72 | + |
| 73 | +# |
| 74 | +# Option length overflows the packet - option says length 10, only 4 bytes of data |
| 75 | +# Solicit + txn_id + option_num(0x0001) + option_len(0x000a) + 4 bytes |
| 76 | +# |
| 77 | +decode-proto 01 00 00 00 00 01 00 0a 01 02 03 04 |
| 78 | +match Option length overflows the packet: Invalid DHCPv6 packet starting at offset 0 |
| 79 | + |
| 80 | +# |
| 81 | +# Not enough room for option header in relay packet |
| 82 | +# Relay Forward (12) + hop_count + 16-byte link addr + 16-byte peer addr + 2 bytes |
| 83 | +# |
| 84 | +decode-proto 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 |
| 85 | +match Not enough room for option header: Invalid DHCPv6 packet starting at offset 0 |
| 86 | + |
| 87 | +# |
| 88 | +# Option length overflows in relay packet |
| 89 | +# Relay Forward + hop_count + link_addr(16) + peer_addr(16) + option(0001) + len(00ff) + 2 bytes |
| 90 | +# |
| 91 | +decode-proto 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 ff 01 02 |
| 92 | +match Option length overflows the packet: Invalid DHCPv6 packet starting at offset 0 |
| 93 | + |
| 94 | +# |
| 95 | +# Not enough room for second option header - valid first option (8 bytes), |
| 96 | +# then 2 trailing bytes. Offset in options = 8, plus 4-byte normal header = 12. |
| 97 | +# But offset calculation returns 8 (relative to options start) via fr_dhcpv6_options_ok, |
| 98 | +# then fr_dhcpv6_ok_internal adds 4 for the header -> final offset = 8 in the stacked message. |
| 99 | +# Solicit + txn_id + option(0x0001, len=4, data=01020304) + 2 bytes |
| 100 | +# |
| 101 | +decode-proto 01 00 00 00 00 01 00 04 01 02 03 04 00 01 |
| 102 | +match Not enough room for option header: Invalid DHCPv6 packet starting at offset 12 |
| 103 | + |
| 104 | +# |
| 105 | +# Second option overflows the packet - valid first option (8 bytes), |
| 106 | +# second option claims length 20 but only 2 bytes available |
| 107 | +# Solicit + txn_id + option(0x0001, len=4, data=01020304) + option(0x0002, len=0x0014) + 2 bytes |
| 108 | +# |
| 109 | +decode-proto 01 00 00 00 00 01 00 04 01 02 03 04 00 02 00 14 01 02 |
| 110 | +match Option length overflows the packet: Invalid DHCPv6 packet starting at offset 12 |
| 111 | + |
| 112 | +# |
| 113 | +# Relay Forward with valid header but relay-message containing too-small packet |
| 114 | +# Relay Forward + hop=0 + link(16 zeros) + peer(16 zeros) + |
| 115 | +# Relay-Message option (type 9, 0x0009) with length 2 containing a 2-byte inner packet |
| 116 | +# Inner packet: type 1 (Solicit) + 1 byte (too small for 4-byte header) |
| 117 | +# |
| 118 | +decode-proto 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 00 02 01 00 |
| 119 | +match Packet is too small for DHCPv6 header: Invalid DHCPv6 packet starting at offset 38 |
| 120 | + |
| 121 | +# |
| 122 | +# Relay Forward with empty relay-message |
| 123 | +# Relay-Message option (type 9) with length 0 |
| 124 | +# |
| 125 | +decode-proto 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 00 00 |
| 126 | +match Packet is empty: Invalid DHCPv6 packet starting at offset 38 |
| 127 | + |
| 128 | +count |
| 129 | +match 35 |
0 commit comments