feat(libSceNKWebKit): implement WebCore::passesAccessControlCheck #26408
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/26408"
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 ToRaNek on 2026-11-23T22:26:17Z.
What
Resubmission of #24874, which was closed when my fork left the fork network (I switched it to private by mistake) and cannot be reopened. Same head commit
a3a5ea7dbe2; the reviews and the discussion are on #24874.Implements
WebCore::passesAccessControlCheck, the CORS check of a response, which was a stub.It follows the pinned source line by line (CrossOriginAccessControl.cpp L259-L286):
Access-Control-Allow-Origin: *, policyDoNotUse, or a disabler that says the check is off*otherwiseCannot use wildcard in Access-Control-Allow-Origin when credentials flag is true.Access-Control-Allow-Origin cannot contain more than one origin.Origin <origin> is not allowed by Access-Control-Allow-Origin. Status code: <code>Use,Access-Control-Allow-Credentialsnot exactlytrueCredentials flag is true, but Access-Control-Allow-Credentials is not "true".It uses three exports that are already implemented:
ResourceResponseBase::httpHeaderField(HTTPHeaderName),SecurityOrigin::toStringandWTF::equal(const StringImpl*, const StringImpl*). The disabler is asked through its virtual table, with the slot the library already uses, and only when the policy is notDoNotUse.Two layouts are new, both derived from the pinned source and not measured on a console:
Expected<void, String>, returned through the hidden pointer: the error string at offset 0, thehasflag at offset 8, 16 bytes (Expected.h L292-L304 and L378-L383).Box<NetworkLoadMetrics>(one pointer),std::optional<CertificateInfo>andshort m_httpStatusCode(ResourceResponseBase.h L316-L327). The curlCertificateInfois anint, aVectorand, on PlayStation, a secondVectorand aString: 48 bytes (CertificateInfo.h L94-L100), 56 with the flag of the optional. The code is only used in the text of the mismatch message.The rest of the family stays stubbed, because each one needs something
maindoes not have yet:validatePreflightResponse,validateCrossOriginResourcePolicy,createAccessControlPreflightRequestand three of theVaryhelpers are 3.20-era exports that take 3.20 layouts; the preflight cache holds guestHashMapandHashSettables;updateRedirectChainStatusneedscomputeFreshnessLifetimeForHTTPFamily. I did not implement any of them partially.Tested
Windows 11, MinGW GCC 15.2.
nkwebkit_crossoriginresponsecheck) and cannot be built onmain, where the export is an untyped stub; onmainthe function throws.DoNotUse(a call counter); the origin comparison for case, spaces, port, 8-bit against 16-bit strings, an empty header; an opaque origin and afileorigin; seven status codes written at offset 176 with0xFFaround them; the returned object (flag at offset 8, guard bytes on both sides intact, reference counts); null arguments.Use(line 183), the wildcard accepted without the condition (line 181), the comma test removed (line 299), the status code suffix removed (line 197), the credentials header required for every policy butDoNotUse(line 262), the disabler's answer inverted (line 222).nkwebkit_*tests andpatched_librariespass on the branch.python tools/check_conventions.py --base origin/mainandpython tools/debt_fold.py --checkpass.Not tested on a console.
Overlap (
python tools/pr_overlap.py --branch feat/nkwebkit-cors-response-checks):mainand shareExport.cpporInventoryExports.hpp, the two files every implementation edits. I searched each of their diffs for the symbol: none changes it (in #16510 it only appears as the context of a hunk header).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)Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-24T00:15:33Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
a3a5ea7dbe:tools/check_conventions.pypassed.nkwebkit_crossoriginresponsecheck_testsbuilt cleanly.nkwebkit_crossoriginresponsecheck):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/CrossOriginAccessControlExports.hpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/src/CrossOriginAccessControl.cpp,core/libs/prx/libSceNKWebKit/src/CrossOriginAccessControlAbi.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me