Skip to content

fix(libSceHttp): copy URIs as measured on a PS5 - #9073

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
orezraey:fix/http-uri-copy-measured-ps5
Oct 23, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
orezraey:fix/http-uri-copy-measured-ps5

Conversation

@orezraey

Copy link
Copy Markdown
Contributor

What

sceHttpUriCopy was written from a reading of the libSceHttp.sprx disassembly, and its debt entry said it was not measured on a console. In a payload process on a PS5 (firmware 13.60) every ordinary input already matched:

  • the field order in the pool (scheme, hostname, path, username, password, each with its terminator);
  • a null field copied as an empty string;
  • the port copied, and the query, fragment and opaque flag left 0;
  • all prepare bytes cleared;
  • require on success, and left alone on a short pool;
  • the error codes for null arguments.

The one difference is the order of operations. The console clears the whole output element and all prepare pool bytes before it reads the source, so a source that is the output itself, or that lies inside the pool, is read after it was cleared:

Case Payload process, firmware 13.60 main before this PR here now
out == src 0, require 5: all five strings empty, port 0 a full copy of the source as on the console
source element stored inside the pool 0, require 5: all five strings empty, port 0 a full copy of the source as on the console
source hostname stored inside the pool the hostname reads as empty (require 0x12, while sizing only counts the real string: 0x1c) the full hostname copied as on the console
fault while clearing the pool (prepare past a guard page) the output was already cleared, so the output is cleared first not determined output first, as on the console

This PR clears out and the pool first, then reads the source pointers and the port, computes the size and copies. A short pool returns ERROR_OUT_OF_MEMORY with both already cleared, as before.

Not measured: whether the console writes the strings before it checks the size. A short pool always ends up cleared, so the order can't be seen. The debt entry says so.

Tests: guest_http checks, inside the existing sceHttpUriCopy block:

  • the pool layout and offsets;
  • the zeroed bytes after require, the padding and the reserved bytes;
  • short and zero-size pools, and the null-argument combinations;
  • opaque 7 and mixed null and empty fields;
  • out == src, and a source element or a source string inside the pool.

The new checks fail on main and pass here.

Debt: the sceHttpUriCopy entry in docs/dev/debt/libSceHttp.md now describes the measured behaviour and the one unmeasured point.

How the console was measured

  • Setup:
    • The console runs firmware 13.60 and is jailbroken.
    • The probes are ELF payloads built with ps5-payload-dev/sdk v0.44 and clang 18.1.8 and started through elfldr, so they ran in a payload process, not in a title.
    • sceHttpInit was not needed and not called.
  • Provenance: libSceHttp.sprx was loaded with dlopen, and sceHttpUriCopy and sceHttpUriParse were taken from it with dlsym.
  • Method:
    • Sources come from sceHttpUriParse and from hand-built elements.
    • Pools are filled with ~, outputs with 0x5a, and require is preset to 0xabcd; every output pointer is logged as an offset into the pool.
    • Each source runs sizing only, with a 256-byte pool, with the exact size and one byte short.
    • uricopy2 and uricopy3 put the pool before a guard page to see the clearing, and alias the source with the output and the pool.
  • Files: the probe sources and full logs are in this gist.
Console output (excerpt, copied unchanged)
uricopy: meta fw=0x13600007 pid=148 sdk=v0.44 compiler=Clang 18.1.8 built=Oct 21 2026 08:18:56 log=/data/anyps5-probes/uricopy.log
uricopy: case parsed "https://user:secret@example.com:8443/a/./b/../c?x=1&y=2#top" exact out opaque=0x00000000 port=8443 scheme=@0"https" user=@23"user" pass=@28"secret" host=@6"example.com"
uricopy: case parsed "https://user:secret@example.com:8443/a/./b/../c?x=1&y=2#top" exact out path=@18"/a/c" query=(null) fragment=(null)
uricopy: case parsed "https://user:secret@example.com:8443/a/./b/../c?x=1&y=2#top" short ret=0x80431022 require=0xabcd
uricopy: case parsed "https://user:secret@example.com:8443/a/./b/../c?x=1&y=2#top" short out opaque=0x00000000 port=0 scheme=(null) user=(null) pass=(null) host=(null)
uricopy2: case out_equals_src ret=0x00000000 require=0x5
uricopy2: case out_equals_src out opaque=0x00000000 port=0 scheme=@0"" user=@3"" pass=@4"" host=@1""
uricopy3: case src_element_inside_pool ret=0x00000000 require=0x5
uricopy3: case src_strings_inside_pool ret=0x00000000 require=0x12
uricopy3: case src_strings_inside_pool out opaque=0x00000000 port=1234 scheme=@0"SCH" user=@10"usr" pass=@14"pwd" host=@4""
uricopy3: case src_strings_inside_pool_size_only ret=0x00000000 require=0x1c
uricopy3: case clear order fault signal=11
uricopy3: case clear_order_after_fault out opaque=0x00000000 port=0 scheme=(null) user=(null) pass=(null) host=(null)

Tested

Windows 11, WinLibs GCC 15.2.0, Release: guest_http, guest_http_response_header and guest_http2 pass. Not tested on Linux or with a title.

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
  • 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 (Claude Code)

A payload on a PS5 (firmware 13.60) shows sceHttpUriCopy clears the
whole output and all prepare bytes of the pool before it reads the
source, so a source that is the output or lies in the pool copies as
empty. Read the source after clearing, clear the output with its
padding, and test the measured layout, failures and aliasing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6044 core/libs/tests/GuestHttp.cpp
PR 8620 core/libs/tests/GuestHttp.cpp
docs/dev/debt/libSceHttp.md

@xXPBSXx

xXPBSXx commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Independent Windows run of this PR (data only).

Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against main is clean. I built only guest_http_tests; ctest -N -R guest_http lists exactly one test.

PR head tested: 19d7e29b3a8bcb215783f4480910fa2601237bd4.

Results (3 runs each):

  • PR head: guest_http passes 3/3.
  • Baseline: I kept the PR's test and replaced only core/libs/prx/libSceHttp/src/Uri.cpp with the version from the PR's merge base (3e91c8edf5), then rebuilt. The test fails 3/3 (exit 0xc0000409). I restored the PR's files afterwards.

GPU: the run output has no Selected GPU line; no GPU claim is made.

Not run: other platforms, the other tests in the same family, the full repository CTest, and any title or console run.

AI-assisted (Claude Code).

@github-actions github-actions Bot added docs prx needs rebase Conflicts with main, rebase needed labels Oct 21, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 22, 2026
@DoubleAAGuy

Copy link
Copy Markdown

My draft #9834 uses sceHttpUriMerge for automatic redirects and updates the adjacent libSceHttp debt entries; the overlap bot flags the debt hunk. I plan to sequence #9834 after #9073 and rebase so the measured URI semantics and your debt update land first. Please let me know if you prefer another order.

@DoubleAAGuy

Copy link
Copy Markdown

I moved the TLS test into guest_http_transport and changed the debt hunk so it no longer edits the sceHttpUriCopy entry flagged by #9073. The request path calls the existing sceHttpUriMerge; I removed #9073 from the dependency list. Please let me know if you still see an exact hunk overlap on the current draft #9834.

@orezraey

Copy link
Copy Markdown
Contributor Author

I see no exact hunk overlap now. tools/pr_overlap.py on this branch reports nothing against #9834. In libSceHttp.md, the changed lines of #9834 end at the sceHttpSetRequestStatusCallback entry, while this PR only rewrites the sceHttpUriCopy line, with three unchanged entries between them. In GuestHttp.cpp, this PR only appends after line 562, past the last hunk of #9834.

@oneandonlydean oneandonlydean self-assigned this Oct 22, 2026
@oneandonlydean
oneandonlydean merged commit b7a451d into boykopovar:main Oct 23, 2026
10 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.

4 participants