Skip to content

Fix NameConstraints minimum/maximum parsing for values >= 128#10660

Open
afldl wants to merge 1 commit into
wolfSSL:masterfrom
afldl:fix/nc-minmax-int8-overflow
Open

Fix NameConstraints minimum/maximum parsing for values >= 128#10660
afldl wants to merge 1 commit into
wolfSSL:masterfrom
afldl:fix/nc-minmax-int8-overflow

Conversation

@afldl

@afldl afldl commented Jun 11, 2026

Copy link
Copy Markdown

Closes #10659

DecodeSubtree() was using GetASN_Int8Bit() to decode the
GeneralSubtree minimum/maximum BaseDistance fields. That function
rejects any DER INTEGER longer than one byte, so values >= 128
(which need a two-byte encoding with leading zero sign octet)
caused ASN_PARSE_E and d2i_X509() to return NULL.

Switch to GetASN_Int16Bit() with word16 storage — same pattern
already used for BasicConstraints pathLength elsewhere in this
file. Four lines changed, no behavioral change beyond fixing the
parse failure.

Tested:

cert before after
NC minimum=1 ACCEPT ACCEPT
NC minimum=127 ACCEPT ACCEPT
NC minimum=128 REJECT ACCEPT
NC minimum=255 REJECT ACCEPT
NC maximum=128 REJECT ACCEPT

DecodeSubtree() used GetASN_Int8Bit() to decode GeneralSubtree
minimum/maximum BaseDistance fields.  This function enforces a strict
1-byte DER INTEGER length, so any value >= 128 (which needs 2 bytes
with leading-zero sign octet) caused ASN_PARSE_E and d2i_X509() to
return NULL.

Switch to GetASN_Int16Bit() with word16 variables, matching the
pattern already used for BasicConstraints pathLength elsewhere in
the same file.  The decoded values remain unused by NC matching
logic, so this is purely a parsing fix.
@wolfSSL-Bot

Copy link
Copy Markdown

Can one of the admins verify this patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

d2i_X509 rejects certificates with NameConstraints minimum/maximum >= 128

3 participants