fix(libSceNKWebKit): validate guest pointers in CrossOriginPreflightResultCache exports #27958
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27958"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-27T22:36:13Z.
What
Validate guest pointers in
WebCore::CrossOriginPreflightResultCache::appendEntryandcanSkipPreflight(core/libs/prx/libSceNKWebKit/src/CrossOriginPreflightResultCache.cpp):std::invalid_argumentchecks for non-singletonself, null arguments, empty-cache null-string queries, invalidHTTPHeaderMapvector bounds, unknownHTTPHeaderNamevalues, and null lookup strings in populated tables.GuestArenaPrepareHostRead_nid_no_patch+GuestReadable_nid_no_patch) and copy nestedWTF::String,WTF::URL,HTTPHeaderMap,CrossOriginPreflightResultCacheItem, and guestWTF::HashTablemetadata/slot/string storage viaGuestCopyIn_nid_no_patch, callingNotImplementedAt_nid_no_patchon invalid guest memory without mutating or evicting cached entries.appendEntry, validate writablepreflightResultand releasableWTF::StringImplentries (including terminating flags and cycle/truncatedSharedSubstringchains) under activeGuestArena::HostWriteguards before publishing and clearing*preflightResultviaGuestCopyOut_nid_no_patch.core/libs/prx/libSceNKWebKit/tests/CrossOriginPreflight.cppand record the technical debt fragment indocs/dev/debt/changes/fix-libSceNKWebKit-cross-origin-preflight-cache-guest-pointers.md.Tested
2b61df882da2. All three focused Linux CTests passed (cross-origin preflight, preflight request and header map). The guard-page cases check arrays whose first entry is readable and whose tail crosses into a protected page./usr/local/bin/cmake --build /mnt/sas-ssd/AnyPS5-work/agy/build-spec --target nkwebkit_crossoriginpreflight_tests nkwebkit_crossoriginpreflightrequest_tests):CrossOriginPreflightResultCache.cpp):ctest -R '^nkwebkit_crossoriginpreflight$' --output-on-failurefailed (***Exception: SegFault, 0/1 passed).d89d144a1fc):ctest -R '^nkwebkit_crossoriginpreflight(request)?$' --output-on-failurepassed (2/2,nkwebkit_crossoriginpreflight0.07 sec,nkwebkit_crossoriginpreflightrequest0.03 sec).python3 tools/guest_pointer_audit.py libSceNKWebKit: 0 hits inCrossOriginPreflightResultCache.cpp.python3 tools/check_conventions.py --base origin/main: All conventions checks passed.python3 tools/pr_overlap.py --branch fix/libSceNKWebKit-cross-origin-preflight-cache-guest-pointers: No overlap with open pull requests.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-27T22:39:33Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
d89d144a1f:tools/check_conventions.pypassed.nkwebkit_crossoriginpreflight_testsbuilt cleanly.nkwebkit_crossoriginpreflight):core/libs/prx/libSceNKWebKit/src/CrossOriginPreflightResultCache.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T22:45:17Z.
Review: COMMENTED
ad17ad0b-c993-45cd-813d-3efacfc2cdbdReviewing files that changed from the base of the PR and between
073e0313f3andd89d144a1f.core/libs/prx/libSceNKWebKit/src/CrossOriginPreflightResultCache.cppcore/libs/prx/libSceNKWebKit/tests/CrossOriginPreflight.cppdocs/dev/debt/changes/fix-libSceNKWebKit-cross-origin-preflight-cache-guest-pointers.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-11-28T05:39:25Z.
Review: APPROVED
Checked head
d89d144a1f. All on Windows 11 with WinLibs GCC 15.2 (Release), applied tomain4c7578e0a4together with #27997, #27996, #27978, #27975, #27973, #27971, #27969, #27967, #27964, #27950, #27949, #27946, #27945, #27943, #27938, #27936.tools/check_conventions.py --headandtools/debt_fold.py --checkpassed and the full build succeeded.nkwebkit_crossoriginpreflightpasses. In the full CPU suite (5,131 tests) the only failures are unrelated:windows_read_trap_unknownfails onmaintoo (fixed in #28028), andframe_capture_minimizeis a timeout under load that passes on its own.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T08:18:05Z.
Review: APPROVED
Reviewed — looks good
The inspected changes validate and copy guest data before using it, and I found no verified blocking defect in the three changed files.
What I ran
Read the prepared diff and the changed files at head
d89d144a1fcaf1cf5a698d7d193fbb00f5a26c4fusing the pinnedrepo_read.pyreader. No commands or tests were run in this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The Linux build and test results, negative control, audit scripts, and convention checks were reported by the author and were not independently run. Console behavior remains unmeasured, as recorded in the debt entry.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T08:12:44Z.
Review: COMMENTED
The CORS preflight fixture passed its ordinary cache decisions and invalid argument checks. The valid cached PUT entry still worked after the rejected operations.
I ran the exact fixture and changed translation unit in a focused Linux build linked against the project’s guest libraries.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T15:14:41Z.
Review: COMMENTED
Actionable comments
Deallocatewithout validation.core/libs/prx/libSceNKWebKit/tests/CrossOriginPreflight.cpp, lines948–949· 📐 Maintainability & Code Quality · ⚡ Quick winNotImplemented, retained append pointers, and a successful lookup of the existing cache entry. These cases would specifically detect regression of the allocation-order fix.e7cea70a-d0cd-4de4-babd-5832883243cbReviewing files that changed from the base of the PR and between
d89d144a1fand2b61df882d.core/libs/prx/libSceNKWebKit/src/CrossOriginPreflightResultCache.cppcore/libs/prx/libSceNKWebKit/tests/CrossOriginPreflight.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T15:16:04Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: prevent
appendEntryfrom freeing an unverified guest string buffer when its ownership flag is 1.What I ran
Reviewed head
2b61df882da2f3e81294004dee22c415bbb09457usingrepo_read.pyand the prepared review files. No tests or build commands were run.Results
Negative control
Not run; no tests were executed.
Findings
Blocking
core/libs/prx/libSceNKWebKit/src/CrossOriginPreflightResultCache.cpp:317rejects ownership flag3but permits flag1. For a guestStringImplwithrefCount == 2and flag1,appendEntryreachesWtfAbi::Release, which deallocatesimpl->datafor that flag. A zero-length string skips data readability validation, so a readable but non-allocator-owneddatapointer can be passed to the deallocator. Reject this case or establish that the buffer is safe to deallocate before publishing the entry. Changed check, release behaviorNon-blocking
None.
Sources
Behavior was checked against the pinned source links in the blocking finding. The prepared diff and description were also reviewed.
Not verified
No tests, build, merged-preview check, or console behavior were run. The reported Linux CTest results are author-reported.
manifest.jsonlists three changed files, all included infiles/;files.jsonlists no excluded files. I inspected the cache implementation in targeted ranges and reviewed the test and debt-file changes in the prepared diff.To get this to a good state
Reject ownership flag
1for guest strings that will be released, or validate safe allocator ownership before release. Rerun the focused cross-origin preflight CTests on the corrected head.Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T21:08:44Z.
Review: COMMENTED
The revised code computes the byte spans, validates both header buffers, and then allocates the host copies. Empty spans still take the zero-byte path in
RequireReadableGuestBytes. The revised cache fixture compiled and passed on Linux against the guest libraries, including ordinary cache behavior and the input-validation checks. The revision trial-merges onto6ef4f2f73b.Source review at
2b61df882d.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-04T16:13:52Z.
Review: APPROVED
Re-verified head
2b61df882don Windows 11 with WinLibs GCC 15.2 (Release), applied alone to main484b0368d3. The new commit checks the preflight buffers before allocating.nkwebkit_crossoriginpreflightpasses, as on main.CrossOriginPreflightResultCache.cppreverted to main and the tests kept: the test crashes on a read of an unmapped guest page (0x923000).Not run: Linux and macOS.
AI-assisted: yes (Claude Code)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.