Skip to content

Commit 7a2bd2a

Browse files
committed
more corner cases for DER
1 parent 8314e00 commit 7a2bd2a

File tree

1 file changed

+149
-0
lines changed

1 file changed

+149
-0
lines changed
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# -*- text -*-
2+
# Copyright (C) 2025 The FreeRADIUS Server project and contributors
3+
# This work is licensed under CC-BY version 4.0 https://creativecommons.org/licenses/by/4.0
4+
5+
proto der
6+
proto-dictionary der
7+
8+
load-dictionary dictionary.test
9+
10+
fuzzer-out der
11+
12+
#
13+
# ---- Header-level errors (fr_der_decode_hdr / fr_der_decode_pair_dbuff) ----
14+
#
15+
16+
#
17+
# Truncated header - only 1 byte (need at least 2 for tag + length)
18+
#
19+
proto-dictionary-root Test-Boolean
20+
21+
decode-pair 01
22+
match Truncated header while trying to decode Test-Boolean
23+
24+
#
25+
# Multi-byte tags are not supported - tag byte 0x1f has lower 5 bits all set
26+
#
27+
decode-pair 1f 01 ff
28+
match Multi-byte tags are not supported: Failed decoding Test-Boolean header
29+
30+
#
31+
# Invalid tag 0 - tag number 0 is reserved/invalid in UNIVERSAL class
32+
#
33+
decode-pair 00 01 05
34+
match Invalid tag 0: Failed decoding Test-Boolean header
35+
36+
#
37+
# Tag mismatch - got INTEGER (0x02) when expecting BOOLEAN (0x01)
38+
#
39+
decode-pair 02 01 05
40+
match Failed decoding Test-Boolean - got tag 'integer', expected 'boolean'
41+
42+
#
43+
# Constructed flag mismatch - BOOLEAN is primitive but 0x21 = constructed BOOLEAN
44+
#
45+
decode-pair 21 01 ff
46+
match Constructed flag mismatch for tag 1: Failed decoding Test-Boolean header
47+
48+
#
49+
# Primitive with indefinite form length - INTEGER (0x02) with 0x80 length byte
50+
# Indefinite form is only valid for constructed types
51+
#
52+
proto-dictionary-root Test-Integer
53+
54+
decode-pair 02 80 02 01 05 00 00
55+
match Primitive data with indefinite form length field is invalid: Failed decoding Test-Integer header
56+
57+
#
58+
# ---- NULL errors ----
59+
#
60+
61+
#
62+
# NULL with non-zero length - NULL must have length 0
63+
#
64+
proto-dictionary-root Test-NULL
65+
66+
decode-pair 05 01 00
67+
match Null has non-zero length
68+
69+
#
70+
# NULL with length 2
71+
#
72+
decode-pair 05 02 00 00
73+
match Null has non-zero length
74+
75+
#
76+
# ---- Bitstring errors ----
77+
#
78+
79+
#
80+
# Invalid unused bits count - must be 0-7, got 8
81+
#
82+
proto-dictionary-root Test-Bitstring
83+
84+
decode-pair 03 02 08 aa
85+
match Invalid number of unused bits in 'bitstring'
86+
87+
#
88+
# Unused bits but no data bytes - claims 3 unused bits but only 1 byte (the count itself)
89+
#
90+
decode-pair 03 01 03
91+
match Insufficient data for 'bitstring'. Missing data bytes
92+
93+
#
94+
# ---- UTC Time errors ----
95+
#
96+
97+
#
98+
# UTC time contains null byte - "24010100\x0000000Z"
99+
#
100+
proto-dictionary-root Test-Date
101+
102+
decode-pair 17 0D 32 34 30 31 30 31 30 30 00 30 30 30 5A
103+
match UTC time contains null byte
104+
105+
#
106+
# Invalid UTC time format - month 13 is invalid: "241301000000Z"
107+
#
108+
decode-pair 17 0D 32 34 31 33 30 31 30 30 30 30 30 30 5A
109+
match Invalid UTC time format
110+
111+
#
112+
# ---- Generalized Time errors ----
113+
#
114+
115+
#
116+
# Missing timezone - 15 bytes ending with 'X' instead of 'Z' or '.'
117+
# "20240101000000X"
118+
#
119+
proto-dictionary-root Test-Generalized-Time
120+
121+
decode-pair 18 0F 32 30 32 34 30 31 30 31 30 30 30 30 30 30 58
122+
match Incorrect format for generalized time. Missing timezone
123+
124+
#
125+
# Invalid generalized time format - month 13: "20241301000000Z"
126+
#
127+
decode-pair 18 0F 32 30 32 34 31 33 30 31 30 30 30 30 30 30 5A
128+
match Invalid generalized time format (strptime)
129+
130+
#
131+
# ---- String character validation errors ----
132+
#
133+
134+
#
135+
# VisibleString with control character - 0x01 is not in range 0x20-0x7E
136+
#
137+
proto-dictionary-root Test-String-Visible
138+
139+
decode-pair 1a 01 01
140+
match Invalid character in a string (1)
141+
142+
#
143+
# VisibleString with DEL character (0x7f) - also outside 0x20-0x7E
144+
#
145+
decode-pair 1a 01 7f
146+
match Invalid character in a string (127)
147+
148+
count
149+
match 43

0 commit comments

Comments
 (0)