feat(libSceNKWebKit): implement SecurityOrigin canAccess, canRequest and canDisplay and the SecurityPolicy origin access allowlist #23772
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23772"
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 opxdelwin on 2026-11-19T16:14:36Z.
What
Implements the same-origin checks WebKit runs before a page reads another frame, fetches a resource or displays one, plus the per-origin allowlist an embedder uses to grant cross-origin access:
WebCore::SecurityOrigin::canAccess(const SecurityOrigin&),canRequest(const URL&)andcanDisplay(const URL&)(newsrc/SecurityOriginAccess.cpp). These are 3.20 exports (LegacyExports.hpp) whose single-argument signatures predate the 11.x tree, so they follow WebKitSecurityOrigin.cpp@7dba47c08160(Feb 2021, the parent of thecanAccess->isSameOriginDomainrename, after the Whitelist -> Allowlist rename). They read the 11.xSecurityOriginAbi.hpplayout from #22751, withisUnique()taken as the opaqueSecurityOriginDataindex.WebCore::SecurityPolicy::addOriginAccessAllowlistEntry,removeOriginAccessAllowlistEntryandresetOriginAccessAllowlists(src/SecurityPolicy.cpp). These are 11.x inventory exports, so they follow the pinned 11.xSecurityPolicy.cppandOriginAccessEntry.cpp: a host-side, process-wide list keyed by the sourceSecurityOriginData, matched withOriginAccessEntrysemantics (exact host, subdomains, IP addresses never subdomain-matched, empty host with subdomains = every host of that scheme).canRequestandcanDisplayread it.src/Mime.cppgetsCanDisplayOnlyIfCanRequestandShouldTreatURLSchemeAsDisplayIsolatedaccessors over the existing scheme lists (built-in lists checked against WebKit'sLegacySchemeRegistry.cpp).Export.cpp; declarations moved fromLegacyExports.hpp/InventoryExports.hpptoSecurityOriginExports.hpp/SecurityPolicyExports.hpp.Still throwing (
NotImplemented_nid_no_patch), listed in the debt fragment:canRequest/canDisplayforblob:URLs (no blob origin cache), andcanDisplayfor afileorigin with afile:URL (FileSystem::filesHaveSameVolumeis a stub).canAccessStoragestays a stub (the 11.x layout has nom_storageBlockingPolicy).allowAccessTopatterns are not modelled because that export still throws, so the pattern list it would fill is always empty. TheWKBundleallowlist exports are untouched.Each ported function was compared line by line with the pinned source; the feed prefix list and
maximumURLSizewere diffed by script, and every licence notice is copied verbatim with a// Derived fromline. The ported functions are identical to WebKite12a212a531aapart from thecanAccessname.Tested
Linux (Docker, Ubuntu 24.04 image), Release,
BUILD_TESTING=ON, on this branch rebased ontomainc144015083:ctest -R '^(nkwebkit_securityoriginaccess|nkwebkit_securityorigin|nkwebkit_securitypolicy|nkwebkit_mimetyperegistry|nkwebkit_contexturlschemes|nkwebkit_legacyschemeregistryqueries|nkwebkit_forwarding|nkwebkit_symbolset|public_headers.*)$'public_headers_compile_13/29/44/55) are-Winvalid-offsetofonRegioninRegionExports.hppand fail identically onmainb8be4de452with Clang (61/65); everynkwebkit_*test passes.nkwebkit_securityoriginaccesscovers:canAccess(universal access, same object, opaque on either side, scheme/host/port,document.domainset on one or both sides, file origins with and without path separation);canRequest(default-port normalisation, different scheme/host/port, opaque self and target,document.domainignored, file origins,blob:throws, universal access); the allowlist (case-insensitive entries, exact host, subdomains with and without the flag, IP addresses, empty host, duplicate add, remove of missing or differently-flagged entries, source origin with an equal tuple shares the list, opaque source ignored, reset);canDisplay(pathEndat and above 0x04000000, local file path match,canLoadLocalResources, allowlist, each local load policy,fileorigin +file:URL throws, nested feed URLs, can-display-only-if-can-request and display-isolated schemes, local schemes); null pointers throwstd::invalid_argument; origin refcounts unchanged.tools/check_conventions.py --base upstream/mainandtools/debt_fold.py --checkpass.3rdparty/ffmpeg-core, unrelated), macOS, any title; not compared with a console module.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-19T16:30:40Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
5ce70803d5:tools/check_conventions.pypassed.nkwebkit_securityoriginaccess_testsbuilt cleanly.nkwebkit_securityoriginaccess):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp,core/libs/prx/libSceNKWebKit/include/SecurityOriginExports.hpp,core/libs/prx/libSceNKWebKit/include/SecurityPolicyExports.hpp,core/libs/prx/libSceNKWebKit/src/Mime.cpp,core/libs/prx/libSceNKWebKit/src/MimeAbi.hpp,core/libs/prx/libSceNKWebKit/src/SecurityPolicy.cpp,core/libs/prx/libSceNKWebKit/src/SecurityOriginAccess.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T16:35:35Z.
Review: COMMENTED
Reviewed — no blocking findings
The core origin checks and allowlist implementation were reviewed at head
5ce70803d56af25a68f19bb470043531f7548c17; no checks were run in this review, and two changed files were unavailable for full-text inspection.What I ran
No commands or tests were run. I inspected the prepared diff and targeted source ranges using
repo_read.py.Results
Findings
Blocking
None identified in the code inspected.
Non-blocking
None.
Not verified
Could not read the full text of
core/libs/prx/libSceNKWebKit/Export.cpporcore/libs/prx/libSceNKWebKit/include/InventoryExports.hpp; the diff showed their removed stubs and declarations. No tests were run. Other changed files were read only at changed lines or targeted ranges, rather than in full. The author reports GCC and Clang test results, but those were not independently verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T06:24:13Z.
Review: DISMISSED
Reviewed — changes requested
Changes are required before merge: correct allowlist matching so destination protocol and host comparisons follow WebKit’s ASCII case insensitive semantics for the origin tuple.
What I ran
Reviewed head
4e288faa63abc493c597c967c94cc9118f4b0516using the prepared diff andrepo_read.py; no commands or tests were run during this review. The author reports Linux GCC tests passing, with four Clang header test failures also present on main.Results
Findings
Blocking
core/libs/prx/libSceNKWebKit/src/SecurityPolicy.cpp:271:SameTuplecompares the source protocol and host withWTF::equal, which is case sensitive. WebKit origin tuple matching is ASCII case insensitive; consequently allowlist entries added for an origin may not be found when the equivalent origin tuple has different ASCII casing, despite the description claiming equal tuples share the list. Use the case insensitive comparison for both tuple fields.Non-blocking
None.
Not verified
The complete file texts in the review bundle were available for all changed files except
Export.cppandInventoryExports.hpp, excluded as too large. Their removals were inspected in the diff. No tests were run. Windows, macOS, and console behavior were not verified.To get this to a good state
Fix the source tuple comparison and add or adjust a regression test showing case-insensitive equivalent origins find the same allowlist; rerun the reported targeted checks on the updated head.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-29T23:26:14Z.
Review: COMMENTED
Architecture findings (3)
Advisory architecture findings (2)
4bb0807a-042f-4b7e-81b8-f8d37ab57bc4Reviewing files that changed from the base of the PR and between
97319cf0b9and3772f1f35a.core/libs/prx/libSceNKWebKit/Export.cppcore/libs/prx/libSceNKWebKit/include/InventoryExports.hppcore/libs/prx/libSceNKWebKit/include/LegacyExports.hppcore/libs/prx/libSceNKWebKit/include/SecurityOriginExports.hppcore/libs/prx/libSceNKWebKit/include/SecurityPolicyExports.hppcore/libs/prx/libSceNKWebKit/src/Mime.cppcore/libs/prx/libSceNKWebKit/src/MimeAbi.hppcore/libs/prx/libSceNKWebKit/src/SecurityOriginAccess.cppcore/libs/prx/libSceNKWebKit/src/SecurityPolicy.cppcore/libs/prx/libSceNKWebKit/tests/SecurityOriginAccess.cppdocs/dev/debt/changes/feat-libscenkwebkit-origin-access-checks.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-29T23:31:27Z.
Review: COMMENTED
Reviewed — comments
The implementation covers the requested origin checks and allowlist, but I could not verify all changed files or the claimed test results in this review session.
What I ran
Reviewed head
3772f1f35aa708174a23ce024d6b589ba70a8317using the prepared diff and the pinned repository reader. No tests or build commands were run.Results
Findings
Blocking
None verified in the code read.
Non-blocking
core/libs/prx/libSceNKWebKit/src/SecurityOriginAccess.cpp:87treats the opaqueSecurityOriginDataindex as the unique-origin marker. The debt note says the 3.20 object layout has not been compared with a console module. Verify this layout against the target module before relying on these checks for security decisions.core/libs/prx/libSceNKWebKit/src/SecurityPolicy.cpp:364appends every allowlist entry, including duplicates. This matches the exercised add/remove behavior, but repeated additions can grow the process-wide list until each matching removal; consider deduplicating if callers may add entries repeatedly.Not verified
Export.cppwas excluded from the review folder because it was too large, so its full text was not read. All other files listed as included in the manifest were available, but not every included file was read in full; in particular, large export headers and the complete 389-line test file were inspected only through their changes and relevant ranges. No tests were run, and console behavior and the ABI layout remain unconfirmed. The description reports Linux test outcomes, convention checks, and debt checks; those results were not independently verified.To get this to a good state
Nothing is required. Optional follow-up: compare the origin layout against a 3.20 console module and consider deduplicating repeated allowlist entries.