Repository navigation
fix(http): safely parse guest response headers - #22415
oneandonlydean merged 1 commit into
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
5594f44 to
f5ee1bf
Compare
3eb1acc to
e002fe8
Compare
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — changes requested
Changes are required before merge: avoid unchecked pointer arithmetic and define allocation failure behavior for guest-sized header lengths.
What I ran
Reviewed head e002fe8688ec2cda61752259f0912d778f318b43. I read the prepared description, commits, manifest, diff, all three changed files, and the HttpGuest copy helpers. I did not run commands or tests.
Results
| Check | Result | Note |
|---|---|---|
| Diff and changed code | passed | All changed files read |
| Tests and build | not run | Author reports pre-rebase Windows tests only |
| Console behavior | not run | Unmapped-memory behavior unmeasured |
Findings
Blocking
-
core/libs/prx/libSceHttp/Export.cpp:509constructs astd::stringofheaderLenbefore validating or copying guest memory. A guest-controlled length can request an enormous host allocation, and allocation failure can throw through the exported C API instead of returning a parser error. Bound or safely handle staging allocation so malformed lengths cannot escape as host exceptions. -
core/libs/prx/libSceHttp/Export.cpp:505incrementsfieldStr + fieldLenup to 4095 bytes. For a short valid C string near the end of an addressable object, forming pointers beyond that object is undefined behavior even if the guest-copy helper safely rejects the resulting address. Read the field name using an access method that does not form out-of-object pointers, or establish a safe bounded input contract.
Non-blocking
None.
Not verified
No local build or tests were run. The author reports Windows tests against pre-rebase commit 3d6ad153ef; current-head CI is pending. Linux, title, network and console behavior were not tested. files.json was not available through the reader; manifest lists three changed files, all included, and each was read. No excluded paths were listed in the manifest.
To get this to a good state
Handle guest-controlled allocation size and field-name reads without host exceptions or undefined pointer arithmetic. Then rerun the parser tests and checks on the updated head.
e002fe8 to
1ec2058
Compare
1ec2058 to
8a427ab
Compare
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the reviewed implementation and test updates support merging, with console behavior still unmeasured.
What I ran
Reviewed head 8a427abfb4a7102f4a4a32197e84fa5709c418da. No commands or tests were run in this review. Read review/description.md, review/commits.md, review/manifest.json, review/diff.patch, core/libs/prx/libSceHttp/Export.cpp, core/libs/tests/GuestHttpResponseHeader.cpp, core/libs/prx/libSceHttp/src/GuestAccess.hpp, and docs/dev/debt/changes/http-response-header-guest-access.md. All three changed files listed in the manifest were read; none were excluded.
Results
| Check | Result | Note |
|---|---|---|
| Changed code review | passed | Inspected all changed files |
| Tests in this review | not run | No test command run |
| Console behavior | not run | Unmeasured per description |
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author reports Windows syntax-only compilation, a parser test run, allocation fault injection, and convention checks; these were not independently run in this review. Full local rebuild and title or PS5 behavior, especially invalid-memory and allocation-failure behavior on console, remain unverified.
To get this to a good state
Nothing is required.
ligmaSec
left a comment
There was a problem hiding this comment.
The branch's GuestHttpResponseHeader fixture passed when compiled and run on Linux against the existing runtime libraries. It covers the parser's guest output and field validation and verifies the caller's errno in the rejection cases.
AI-assisted: yes.
Plyxen
left a comment
There was a problem hiding this comment.
I read the diff at 8a427abfb4. Windows 11 with GCC 15.2 and Linux (Ubuntu 24.04 in WSL2, GCC 13.3), merged into main at c1593e4e1dd together with other open PRs (so not an isolated build).
guest_http_response_header: pass on both.- Control (the same tree and tests, with the sources of this PR and of the other CPU PRs in the batch put back to
main's): it fails with "HTTP response header check failed".
Not checked: a title.
AI-assisted: yes (Claude Code)
What
sceHttpParseResponseHeadernow reads the field name and header through checked guest copies. The parser calculates guest addresses with checked integer offsets and returns a successful value pointer into the original header. It copies the header in blocks and only grows the staging buffer after each successful read. The buffer uses realloc so an allocation failure does not rely on catching a libstdc++ exception on Windows (see #25728). Invalid ranges, failed staging allocations and offsets too large for the return type returnINVALID_RESPONSE. The 4095-byte field name limit, folded lines and missing-field outputs keep their existing behavior. Console behavior for invalid memory and allocation failure is unmeasured.Tested
On Windows, MinGW compiled Export.cpp in syntax-only mode. The complete GuestHttpResponseHeader test passed with the extracted parser linked against the existing guest-copy library. It covers oversized inputs, a header spanning several copy blocks and guard-page cases. A local fault injection probe forced the first allocation and the first resize to fail. Both returned INVALID_RESPONSE and preserved errno and the outputs. Conventions and whitespace checks passed. No full local rebuild, title or PS5 run.
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)