Skip to content

Fix: Fenrir F-10621 - #11905

Draft
ohki-saito wants to merge 1 commit into
wolfSSL:masterfrom
ohki-saito:fix/F10621
Draft

ohki-saito wants to merge 1 commit into
wolfSSL:masterfrom
ohki-saito:fix/F10621

Conversation

@ohki-saito

Copy link
Copy Markdown
Contributor

Description

Fenrir Finding F-10621

wolfSSL_OBJ_txt2nid() and wolfSSL_OBJ_obj2nid() identified an OID only by its 32-bit wc_oid_sum() value, without comparing the encoded OID bytes. OID sums are not unique: 2.5.29.19.1.1.1.1.1.1.1.1 has the same sum as 2.5.29.19, because the eight added bytes cancel out in the XOR lanes. Both functions therefore returned NID_basic_constraints for the longer OID.

Certificate parsing already checks the OID bytes in GetOID(), so this PR only changes the two OBJ functions, which match by sum alone.

Changes:

  • Add wolfssl_object_info_oid_match(), which compares the length and bytes of an OID with the encoding from OidFromId() for a candidate table entry.
  • Split oid2nid() into oid2nid_ex(oid, grp, der, derSz), which also checks the encoding when it is given, and keep oid2nid(oid, grp) as a sum-only wrapper. The existing callers of oid2nid() are unchanged; its comment now states that it is for OIDs whose encoding was already checked when parsed.
  • In wolfSSL_OBJ_obj2nid(), get the OID content bytes from the object and call oid2nid_ex().
  • In wolfSSL_OBJ_txt2nid(), check the encoding before returning a NID.

Remaining limitations

These are not addressed in this PR, and I would appreciate guidance on whether to handle them separately:

  • Table entries with no encoding in OidFromId() (38 of 143 with --enable-all, e.g. CN, O, some curves) are still matched by sum only, so OIDs colliding with them can still be misidentified.
  • oid2nid() is still sum-only. Its fallback search across all groups could map an unknown OID to an entry of another type

Testing

Added tests for OBJ_txt2nid() and OBJ_obj2nid():

  • 2.5.29.19 is still identified as NID_basic_constraints.
  • 2.5.29.19.1.1.1.1.1.1.1.1 is no longer identified as NID_basic_constraints.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

Copilot AI balanced review requested due to automatic review settings October 27, 2026 07:39
@wolfSSL-Bot

Copy link
Copy Markdown

Can one of the admins verify this patch?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The regression test covers only a different-length OID collision, so it would still pass if the byte comparison were removed and same-length collisions were accepted.

1 open issue
What changed in this PR

This PR addresses Fenrir F-10621 in wolfSSL’s OpenSSL-compatible object lookup functions by checking encoded OID bytes, rather than relying solely on OID sums, when a reference encoding is available.

Changes:

  • Add shared OID length-and-byte validation to OBJ_txt2nid() and OBJ_obj2nid().
  • Preserve the sum-only oid2nid() wrapper and document its intended use.
  • Add regression tests for basic constraints and a colliding longer OID.
File Description
tests/​api/​test_ossl_obj.c Adds valid-OID and collision regression tests for both OBJ lookup functions.
src/​ssl_asn1.c Adds encoding-aware lookup while preserving existing sum-only callers.

Review effort: Balanced

Comment thread tests/api/test_ossl_obj.c
Comment on lines +304 to +305
ExpectIntEQ(OBJ_txt2nid("2.5.29.19"), NID_basic_constraints);
ExpectIntEQ(OBJ_txt2nid("2.5.29.19.1.1.1.1.1.1.1.1"), NID_undef);
@philljj

philljj commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Okay to test.

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.

4 participants