Repository navigation
fix(libSceLibreSsl3): decode constructed strings in X509V3_EXT_d2i - #24677
oneandonlydean merged 2 commits into
Conversation
Constructed BIT STRING, OCTET STRING, IA5String and GeneralizedTime extension values are joined as LibreSSL 4.0.0 asn1_collect does instead of failing with TYPE_NOT_PRIMITIVE, which stays for ENUMERATED and OBJECT. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The implementation and all three changed files were reviewed at head fbc8a1ed0a5d9697a6085942d150338f2db3f44a; no verified blocking defect was found, and the author reports successful tests that I did not run.
What I ran
No commands were run. I read the prepared description, commit list, diff, manifest, and every changed line in the three changed files. Targeted reader searches located the decoder caller and extension parsing code. The author-reported test results are not runs performed in this review.
Results
| Check | Result | Note |
|---|---|---|
| Changed code review | passed | All changed lines were read |
| Test suite | not run | Results in description are author-reported |
| Console comparison | not run | No console comparison reported |
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run tests, build the project, compare behavior against LibreSSL or a console, or inspect Windows and native x86-64 behavior. Excluded files: none; all three changed files were included and read. Repository context was limited to the decoder caller and extension struct.
To get this to a good state
Nothing is required.
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against fbc8a1ed0a:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_libressl3_x509v3_ext_d2i_testsbuilt cleanly. - CTest (
guest_libressl3_x509v3_ext_d2i):1/1 Test #4665: guest_libressl3_x509v3_ext_d2i ... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libSceLibreSsl3/src/X509V3ExtD2i.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/1 Test #4665: guest_libressl3_x509v3_ext_d2i ...Subprocess aborted***Exception: 0.89 sec 0% tests passed, 1 tests failed out of 1 - Code reading:
- X509V3ExtD2i.cpp: Collect(): Checked recursion depth limit (depth > MaxStringNesting), EOC handling (00 00), and missing/unexpected EOC error codes.
- X509V3ExtD2i.cpp: Content(): Checked tag, class, and constructed flags; verified delegation to Collect() when collected vector is provided, and TypeNotPrimitive when omitted for primitive-only decoders (Enumerated, Object).
- X509V3ExtD2i.cpp: Decode(): Verified BitString, OctetString, Ia5String, and GeneralizedTime decoders pass &collected while Enumerated and Object do not, preserving rejection for non-primitive types.
- X509V3ExtD2i.cpp: ReadCheckedLength(): Verified bounds checks against input.size() for definite length, tag limit checks against int::max(), and rejection of indefinite length on non-constructed elements.
- X509V3ExtD2i.cpp: Memory & lifetime: Verified vector collected remains valid for the duration of NewString/NewBitString/NewGeneralizedTime and does not leak or cause use-after-free.
- AGENTS.md & technical debt: Verified debt fragment docs/dev/debt/changes/fix-libscelibressl3-ext-d2i-constructed.md follows conventions and no prohibited comments were introduced in source files.
Looks Good To Me
|
On Windows the merge passes Existing runs.
What this run adds.
Merge. Code. I compared
Suggestion (non-blocking).
Negative control and mutations. Each change was made to
Tests.
On the merge, Host:
AI-assisted: yes |
…XT_d2i string Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
|
@Helldiverr Thanks for the mutation run. I added your pin as AI-assisted: yes (Claude Code). |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
Nothing blocks this change; the code and tests support the described constructed-string decoding behavior, but I did not run the checks needed for a formal approval.
What I ran
Reviewed head 39e8e6e88e30969f97e15d92a75d05f1a31a3210 using the prepared diff and repo_read.py. No build or test commands were run. The author reports passing tests and checks in the PR description; these were not run by me.
Results
| Check | Result | Note |
|---|---|---|
| Diff and changed code review | passed | All three changed files read |
| Build and tests | not run | Author reports passing checks |
| Console comparison | not run | Author reports no console comparison |
| Negative control | not run | Mutation checks not independently run |
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
I read the full text of core/libs/prx/libSceLibreSsl3/src/X509V3ExtD2i.cpp, core/libs/prx/libSceLibreSsl3/tests/X509V3ExtD2i.cpp, and docs/dev/debt/changes/fix-libscelibressl3-ext-d2i-constructed.md; all changed files were included and read. No changed files were excluded. Build/test results, mutation checks, and behavior on a physical console were not independently verified.
To get this to a good state
Nothing is required. Optionally, compare behavior with a console as recorded in the debt note.
ligmaSec
left a comment
There was a problem hiding this comment.
Built and ran the exact X509V3ExtD2i fixture and changed decode unit against the existing Linux runtime. The fixture passed its constructed-string cases, including flattened output and padding, exact error-queue contents, and freeing allocations on rejection.
AI-assisted: yes.
Main gained boykopovar#24677, which declares MissingEoc and NestedAsn1String in the same anonymous namespace of X509V3ExtD2i.cpp. This branch declared them too, with the same values, so the merged file stopped compiling. The branch's two copies are dropped and its code now uses main's. Nothing else changes; the decoder work is MarrasFederico's.
What
X509V3_EXT_d2i(libSceLibreSsl3) failed every constructed (BER) extension value withTYPE_NOT_PRIMITIVE(231). LibreSSL refuses a constructed encoding only for its primitive-only types. Constructed BIT STRING, OCTET STRING, IA5String and GeneralizedTime values are now joined fragment by fragment, as LibreSSL 4.0.0asn1_collectdoes (tasn_dec.c L180-L231, L452-L520). The joined content then goes through the existing decoders. This covers definite and indefinite lengths, nested fragments up to 5 levels (deeper givesNESTED_ASN1_STRING), fragments of any tag or class, empty fragments,UNEXPECTED_EOCandMISSING_EOC. ENUMERATED and OBJECT stay primitive-only (231), as in asn1_types.c.Examples (extension value → result):
24 06 04 01 41 04 01 42→ OCTET STRING "AB" (was NULL,0x0dfff0e7)24 80 04 01 41 00 00→ "A"24 00→ empty OCTET STRING36 05 16 03 61 62 63→ IA5String "abc"Compared with LibreSSL 3.4.1 from the submodule, run through
X509V3_EXT_d2ion an extension made byX509_EXTENSION_create_by_NID, on 72 inputs: 49 give the same result. Of the other 23, 21 follow 4.0.0 and 2 are still rejected because of the 8 length-octet limit, a gap already onmain. LibreSSL 3.7.3 (announced by firmware 11.60), 4.0.0 (announced by 13.40) and the LibreSSL main branch have the sametasn_dec.con this path; all three were read, none was run. Where 4.0.0 differs from 3.4.1:asn1_collectreads.24 03 04 01 41 04 01 42gives "AB" where 3.4.1 gives "A", and an end-of-contents after a definite fragment givesUNEXPECTED_EOC.The existing test that decodes the constructed BIT STRING
23 03 00 00 00now expectsUNEXPECTED_EOC(159) instead of 231. Both the measured 3.4.1 and the 4.0.0 source give 159.Overlap: #22890, which is open, changes the same file, but only its includes and the exported function. The two diffs do not touch the same lines, and its patch applies cleanly on this commit.
Tested
Ubuntu 26.04 x86-64 container under Rosetta 2 on Apple silicon (Colima VM, kernel 7.0), GCC 15.2. Not tested on Windows or on native x86-64.
guest_libressl3_x509v3_ext_d2ipasses. It adds 41 checks inTestConstructedStringsandTestConstructedLibreSsl4Rules. Every check fails onmainexcept two guards (ENUMERATED and OBJECT give 231 onmaintoo), and the test as a whole fails onmain.MISSING_EOCat the outer level only, which types may be constructed, depth increment, a bounding outer length and no tag limit on fragments. The test catches all 13.public_headers, registration and progress control tests.tools/check_conventions.py --base upstream/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Summary by CodeRabbit