Skip to content

fix(libSceLibreSsl3): use the X509v3 extension table of LibreSSL 4.0.0 - #25122

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
ToRaNek:fix/libressl3-x509v3-ext-method-table
Nov 21, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
ToRaNek:fix/libressl3-x509v3-ext-method-table

Conversation

@ToRaNek

@ToRaNek ToRaNek commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

What

X509V3_EXT_d2i and X509V3_EXT_conf_nid in libSceLibreSsl3 decide which extensions they know from a list of 42 NIDs. That list is the ext_dat.h table of the bundled 3.4.1 submodule. LibreSSL 4.0.0, the reference of this library, no longer has that file: the list is the switch of X509V3_EXT_get_nid, and it differs by six NIDs (I compared the two lists entry by entry against obj_mac.num; there is no other difference):

NID Extension 3.4.1 4.0.0
143 sxnet method none
369 id-pkix-OCSP-noCheck method none
663 proxyCertInfo method none
1018 CT precertificate SCTs none method (ct_x509v3.c)
1019 CT precertificate poison none method
1021 CT certificate SCTs none method

What a caller sees:

Call Before Now, as 4.0.0
X509V3_EXT_d2i on 143, 369, 663 throws NotImplemented null, no error (x509_lib.c: no method)
X509V3_EXT_conf_nid on 143, 369, 663 throws NotImplemented null, X509V3_R_UNKNOWN_EXTENSION (x509_conf.c L128-L131)
X509V3_EXT_d2i on 1019 with value 05 00 null the value 1 (ASN1_NULL_it)
X509V3_EXT_conf_nid on 1019 null, UNKNOWN_EXTENSION an extension whose value is 05 00, whatever the string (s2i_poison)
X509V3_EXT_conf_nid on 1018, 1021 null, UNKNOWN_EXTENSION null, X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED: these methods have no v2i, s2i or r2i (x509_conf.c L159-L163)
X509V3_EXT_d2i on 1018, 1021 null, silently throws NotImplemented: the source decodes an SCT list, which this library does not model

The poison decoder follows the NULL rules of tasn_dec.c: wrong tag, bad header and a length past the input fail with their reason and ERR_R_NESTED_ASN1_ERROR; a constructed form fails with ASN1_R_TYPE_NOT_PRIMITIVE; a content that is not empty fails with ASN1_R_NULL_IS_WRONG_LENGTH.

Both tables stay at 42 entries. The debt fragment records the change and the SCT gap.

Tested

Windows 11, MinGW GCC 15.2. Not tested on a console.

  • New TestMethodTable in guest_libressl3_x509v3_ext_d2i and in guest_libressl3_x509v3_ext_conf_nid: for each of the six NIDs, the return value and the whole error queue through both exports; for 1019, the value returned, each malformed NULL with its queue, and a round trip (the extension built by X509V3_EXT_conf_nid decodes to 1 through X509V3_EXT_d2i); an unchanged extension still works. One existing line that expected 369 to throw now uses 371.
  • With the two source files from main, both tests stop on the NotImplemented exception of the first 143 case; with the change they pass.
  • Negative controls: 38 mutations of the two source files, each rebuilt and run on its own, all make a test fail: each of the three removed NIDs put back and each of the three new ones removed, in both tables; the poison given another decoder; every check of the NULL decoder and its reason; the builder's reason changed or missing; the three new builder cases falling back to the default; the poison bytes changed.
  • python tools/check_conventions.py --base origin/main, python tools/debt_fold.py --check and python core/libs/tests/test_public_headers.py --audit-only pass.

Not verified. The expected queues come from reading the source, not from running a LibreSSL 4.0.0 binary.

Overlap (python tools/pr_overlap.py --branch fix/libressl3-x509v3-ext-method-table):

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

X509V3_EXT_d2i and X509V3_EXT_conf_nid carried the 42 extensions of the
3.4.1 ext_dat.h. The switch of X509V3_EXT_get_nid in 4.0.0 has no
method for sxnet, id-pkix-OCSP-noCheck and proxyCertInfo, and has the
three Certificate Transparency extensions.

The three removed NIDs now behave as extensions without a method. The
precertificate poison decodes NULL to the value 1 and is built as
05 00. The two SCT list extensions queue
X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED in the builder and throw in
the decoder, which does not model SCT lists.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@PrivacyOnion PrivacyOnion 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.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 4ce7c920b3:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_x509v3_ext_conf_nid_tests, guest_libressl3_x509v3_ext_d2i_tests built cleanly.
  • CTest (guest_libressl3_x509v3_ext_d2i, guest_libressl3_x509v3_ext_conf_nid):
    1/2 Test #4745: guest_libressl3_x509v3_ext_d2i ........   Passed    0.19 sec
    2/2 Test #4750: guest_libressl3_x509v3_ext_conf_nid ...   Passed    0.26 sec
    100% tests passed, 0 tests failed out of 2
    
  • Negative control: with core/libs/prx/libSceLibreSsl3/src/X509V3ExtConfNid.cpp, core/libs/prx/libSceLibreSsl3/src/X509V3ExtD2i.cpp reverted to main and the new tests kept, the suite fails:
    1/2 Test #4750: guest_libressl3_x509v3_ext_conf_nid ...Subprocess aborted***Exception:   0.49 sec
    2/2 Test #4745: guest_libressl3_x509v3_ext_d2i ........Subprocess aborted***Exception:   0.58 sec
    0% tests passed, 2 tests failed out of 2
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified IsStandardExtension and Methods arrays: both updated consistently to LibreSSL 4.0.0 NIDs (removed 143, 369, 663; added 1018, 1019, 1021) preserving table length 42 and static_assert.
    • Checked X509V3ExtConfNid.cpp: PlainExtension handles NID 1018 and 1021 by emitting ExtensionSettingNotSupported (103) and returning nullptr, and NID 1019 builds DER NULL tag (0x05, 0x00) matching OpenBSD/LibreSSL s2i_poison behavior.
    • Checked X509V3ExtD2i.cpp: NewNull safely checks ASN.1 header (tag class 0, NullTag 5, indefinite/constructed rules, primitive requirement, length 0 emitting NullIsWrongLength 144) and returns dummy non-null pointer (uintptr_t 1) without memory leak.
    • Verified AGENTS.md compliance: technical debt fragment docs/dev/debt/changes/fix-libressl3-x509v3-ext-method-table.md added, no code comments added, and unimplemented SCT list decoders correctly route to NotImplemented_nid_no_patch via Decoder::Unsupported.
    • Verified unit test coverage in X509V3ExtConfNid.cpp and X509V3ExtD2i.cpp: both success and error/malformed branches (constructed, non-zero length, truncated, invalid tag) are thoroughly asserted.

Looks Good To Me

@oneandonlydean
oneandonlydean merged commit 630d374 into boykopovar:main Nov 21, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants