fix(libSceHttp): reject malformed escapes and accept port 65536 as a PS5 does #5475

Closed
hugodearaujo wants to merge 1 commit from upstream-pr/5475 into main
hugodearaujo commented 2026-10-13 20:46:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-13T20:46:45Z.


What

Two URI functions of libSceHttp disagreed with a PS5 (firmware 13.60). I measured them through the console's libSceHttp.sprx from a payload, and ran the same program against AnyPS5:

  • sceHttpUriUnescape copied a malformed escape through unchanged and returned 0 (the behaviour the debt entry took from shadPS4). The console returns ERROR_INVALID_URL (0x80433060) for any % that is not followed by two hexadecimal digits, wherever it is in the input, and writes neither the output nor the required size:

    input PS5 main
    %4, %zz, %, abc%, %G1, %-1, % 1, %1 0x80433060, nothing written 0, copied unchanged
    %%41 0x80433060 0, %A
    a%41b%, ok%20then%2, %41% 0x80433060 0, partly decoded
    %4a%4A, %7e%7E, %ff, a%25b, %00x decoded decoded (same)
  • sceHttpUriParse rejected port 65536. The console accepts it as port 0, and rejects 65537, 70000, 131072 and larger values. 65535 and 00080 are accepted on both.

The same run found no difference for sceHttpUriSweepPath (20 paths), sceHttpUriEscape (10 inputs), sceHttpUriMerge (87 base and reference pairs) or sceHttpParseStatusLine (20 lines), so they are unchanged. One difference is left and documented in the debt: when the console rejects a port, it has already written the scheme, user name, password and host to the element and pool; AnyPS5 writes nothing on any failure.

Probe output for the changed cases (PS5 13.60)
UNESC|3|rc0=80433060|req0=30583|rc1=80433060|req1=30583|in="%4"|out="~~~~~~~~~~~~~~~~"
UNESC|8|rc0=80433060|req0=30583|rc1=80433060|req1=30583|in="%%41"|out="~~~~~~~~~~~~~~~~"
UNESC|2|rc0=00000000|req0=3|rc1=00000000|req1=3|in="%4a%4A"|out="JJ\x00"
PARSE|3|rc0=00000000|req0=16|rc1=00000000|req1=16|opaque=0|port=65535|scheme="http"|user=""|pass=""|host="host"|path="/"|query=""|frag=""
PARSE|4|rc0=00000000|req0=16|rc1=00000000|req1=16|opaque=0|port=0|scheme="http"|user=""|pass=""|host="host"|path="/"|query=""|frag=""
PARSE|0|rc0=80433060|req0=30583|rc1=80433060|req1=30583|opaque=0|port=0|scheme="http"|user=""|pass=""|host="host"|path=null|query=null|frag=null

The last PARSE line is http://host:65537/. 30583 (0x7777) and ~ are the probe's untouched fill values.

Tested

  • PS5 (firmware 13.60): the payload resolves sceHttpUriUnescape, sceHttpUriParse, sceHttpUriEscape, sceHttpUriMerge, sceHttpUriSweepPath, sceHttpParseStatusLine and sceHttpParseResponseHeader by NID in libSceHttp.sprx and runs 178 cases, then 31 more for the edges above. A host build of the same case list against AnyPS5's libSceHttp gives the comparison.
  • Linux: full CTest 1070/1071. guest_http now checks the malformed escapes (error, output and required size untouched) and ports 65535, 65536, 65537 and 70000; it fails with this PR's Uri.cpp reverted. agc_driver_tessellation segfaults the same way on main.
  • Windows Server 2025 VM, WinLibs GCC 15.2, CI configure flags: CTest 1097 tests with no failures (the GPU tests skip in this VM).
  • No title I have calls these functions, so this is console evidence only.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4849266186 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5475). Originally posted by [hugodearaujo](https://github.com/hugodearaujo) on 2026-10-13T20:46:45Z. --- ### What Two URI functions of libSceHttp disagreed with a PS5 (firmware 13.60). I measured them through the console's `libSceHttp.sprx` from a payload, and ran the same program against AnyPS5: - `sceHttpUriUnescape` copied a malformed escape through unchanged and returned 0 (the behaviour the debt entry took from shadPS4). The console returns `ERROR_INVALID_URL` (`0x80433060`) for any `%` that is not followed by two hexadecimal digits, wherever it is in the input, and writes neither the output nor the required size: | input | PS5 | `main` | |---|---|---| | `%4`, `%zz`, `%`, `abc%`, `%G1`, `%-1`, `% 1`, `%1 ` | `0x80433060`, nothing written | 0, copied unchanged | | `%%41` | `0x80433060` | 0, `%A` | | `a%41b%`, `ok%20then%2`, `%41%` | `0x80433060` | 0, partly decoded | | `%4a%4A`, `%7e%7E`, `%ff`, `a%25b`, `%00x` | decoded | decoded (same) | - `sceHttpUriParse` rejected port 65536. The console accepts it as port 0, and rejects 65537, 70000, 131072 and larger values. 65535 and `00080` are accepted on both. The same run found no difference for `sceHttpUriSweepPath` (20 paths), `sceHttpUriEscape` (10 inputs), `sceHttpUriMerge` (87 base and reference pairs) or `sceHttpParseStatusLine` (20 lines), so they are unchanged. One difference is left and documented in the debt: when the console rejects a port, it has already written the scheme, user name, password and host to the element and pool; AnyPS5 writes nothing on any failure. <details><summary>Probe output for the changed cases (PS5 13.60)</summary> ``` UNESC|3|rc0=80433060|req0=30583|rc1=80433060|req1=30583|in="%4"|out="~~~~~~~~~~~~~~~~" UNESC|8|rc0=80433060|req0=30583|rc1=80433060|req1=30583|in="%%41"|out="~~~~~~~~~~~~~~~~" UNESC|2|rc0=00000000|req0=3|rc1=00000000|req1=3|in="%4a%4A"|out="JJ\x00" PARSE|3|rc0=00000000|req0=16|rc1=00000000|req1=16|opaque=0|port=65535|scheme="http"|user=""|pass=""|host="host"|path="/"|query=""|frag="" PARSE|4|rc0=00000000|req0=16|rc1=00000000|req1=16|opaque=0|port=0|scheme="http"|user=""|pass=""|host="host"|path="/"|query=""|frag="" PARSE|0|rc0=80433060|req0=30583|rc1=80433060|req1=30583|opaque=0|port=0|scheme="http"|user=""|pass=""|host="host"|path=null|query=null|frag=null ``` The last `PARSE` line is `http://host:65537/`. `30583` (`0x7777`) and `~` are the probe's untouched fill values. </details> ### Tested - PS5 (firmware 13.60): the payload resolves `sceHttpUriUnescape`, `sceHttpUriParse`, `sceHttpUriEscape`, `sceHttpUriMerge`, `sceHttpUriSweepPath`, `sceHttpParseStatusLine` and `sceHttpParseResponseHeader` by NID in `libSceHttp.sprx` and runs 178 cases, then 31 more for the edges above. A host build of the same case list against AnyPS5's `libSceHttp` gives the comparison. - Linux: full CTest 1070/1071. `guest_http` now checks the malformed escapes (error, output and required size untouched) and ports 65535, 65536, 65537 and 70000; it fails with this PR's `Uri.cpp` reverted. `agc_driver_tessellation` segfaults the same way on `main`. - Windows Server 2025 VM, WinLibs GCC 15.2, CI configure flags: CTest 1097 tests with no failures (the GPU tests skip in this VM). - No title I have calls these functions, so this is console evidence only. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
oneandonlydean commented 2026-10-14 02:26:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:26:08Z.


Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159509641 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5475#issuecomment-6159509641). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T02:26:08Z. --- Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!5475
No description provided.