test(libSceSaveData): audit container slot limits and path traversal defenses #15650
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15650"
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 slopgobblercobbler on 2026-11-03T23:46:53Z.
What
Audit container slot limits (16 slots maximum) and path traversal defenses across SaveData subsystems (
GuestSaveDataMountStatus,GuestSaveDataPs4, andGuestSaveDataSearch).Tested
Windows 11, libSceSaveData native unit tests (
guest_savedata_mount_status,guest_savedata_ps4,guest_savedata_search). Verified slot reclamation, overflow rejection withSAVE_DATA_ERROR_MOUNT_FULL, unterminated pattern handling, and traversal pattern rejection ("../","..\\","../victim","..\\victim","../../escape","dir/../dir").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 XairRrR on 2026-11-03T23:57:10Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The merged tree does not build:
GuestSaveDataPs4.cppis missing#include <array>. The changedguest_savedata_mount_statustest fails against the PR's own code. Two production changes have no source: an unknown-mode throw now returns an error code, and names containing..are rejected.What I ran
Head
acc1a6a2eea5c35548f465b80dfd8c6b5c8b0294,main1c8c0efc8c41314402e6966da5bef6ea3d639d10, merged tree53c2b67d88e3303db7ec363f4a1afbf6137b68f2. Debian 13 VM, GCC 14.2.0, Release, Ninja.Results
git diff --checkcheck_conventions.pyguest_savedata_ps4_testsstd::arrayused without<array>guest_savedata_searchguest_savedata_mount_statusguest_savedata_ps4(with#include <array>added locally)Build error
guest_savedata_mount_status on the merged tree
Negative control
I restored
Export.cppandSaveData.hppfrommain, rebuilt and ran the tests:guest_savedata_searchfails as expected (unterminated pattern returns PARAMETER in sceSaveDataDirNameSearch). The test covers the new pattern bound check.guest_savedata_mount_status, only"..escape"and"escape.."fail onmain.mainalready rejected every name that contains/,\,:,.or... So the separator-based traversal cases such as"../victim"and"dir/../dir"are not new defenses: they were already blocked. The only new behaviour is rejecting..inside a name that has no separator.main, so they come from the test, not the production code.I then restored the merged files and rebuilt. The worktree is clean.
Findings
Blocking
The merged tree does not build.
core/libs/tests/GuestSaveDataPs4.cpp:250usesstd::arraywithout including<array>. With GCC 14 / libstdc++ the header is not pulled in by anything else. The description says this was tested on Windows 11, which cannot be reproduced on Linux. Fix: add#include <array>. With that include added locally,guest_savedata_ps4passes.guest_savedata_mount_statusfails on the PR's own capacity test. The loop atcore/libs/tests/GuestSaveDataMountStatus.cpp:843tries a plainMountReadWriteopen ofcapacity-overflow. That directory does not exist, andmount3checksopen && !exists(NOT_FOUND,Export.cpp:1121) beforefind_free_slot(MOUNT_FULL,Export.cpp:1124). So the call returns NOT_FOUND.overflow.mount_modeis stillMountReadWriteafter the loop, so the check atGuestSaveDataMountStatus.cpp:861fails the same way. Fix: either create the directory before the open-mode attempt or expect NOT_FOUND for it, and resetmount_modeto a create mode before line 861. If the order of the two checks is meant to change, that needs a source.An unknown
mount_modeno longer throws. Atcore/libs/prx/libSceSaveData.native/Export.cpp:1103-1105,throw std::runtime_error("sceSaveDataMount3: unknown mount_mode")becomesreturn SAVE_DATA_ERROR_PARAMETER. CONTRIBUTING.md says cases whose behaviour is not established throw. The PR gives no source for the console returning PARAMETER here, adds no test for it, and has no debt entry. It is also unrelated to a "test" PR. Fix: keep the throw, or cite where PARAMETER comes from and test it, in a separate PR.Non-blocking
..anywhere in a name has no source and does not block any traversal.Export.cpp:651rejects names such asa..b,..escapeandescape... Separators are already rejected atExport.cpp:654, so these names stay inside the save root. Valid console save names containing..would become unmountable, and existing saves with such names would no longer open. Please cite the console's dir-name rule, or drop the check and the"..escape"/"escape.."cases.test(...)but also changes production behaviour (items 3 and 1 above) and deletes explanatory comments inExport.cppandSaveData.hpp. Removing non-debt comments is allowed, but CONTRIBUTING.md asks for one topic per PR.mainalready rejected every name with a separator.Not verified
guest_savedata_ps4run on the PR as submitted, since it does not compile. I only ran it with a local include fix, which I then reverted.To get this to a good state
#include <array>toGuestSaveDataPs4.cpp.mount_modereset inCheckMountCapacityAndLifecyclesoguest_savedata_mount_statuspasses.mount_mode, or source and test the new return value...rejection.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-07T18:56:31Z.
Review: CHANGES_REQUESTED
Thanks for the update; the
<array>include is fixed. Two earlier points from XairRrR are still open, plus one new one:core/libs/prx/libSceSaveData.native/Export.cpp:651rejects every directory name containing..(a..b,escape..,..escape). Path separators and:are already rejected at :654 and./..at :648, so../victimand friends were rejected on main already; the only names this changes are ones that cannot traverse. Please cite a reference (KytyPS5, shadPS4, prosper or measured PS5 behaviour) showing the console rejects them, or drop the check and the..escape,escape..and.../testrows inGuestSaveDataMountStatus.cpp:331-333.Export.cpp:898-901makesdirNameSearchreturnSAVE_DATA_ERROR_PARAMETERfor an unterminated pattern. Same ask: source for that error code, or leave the behaviour as it was and note it indocs/dev/debt/if unknown.Export.cppandSaveData.hpp(e.g. the error-table note atSaveData.hpp:9). That is unrelated to a test PR; please move it to its own PR or drop it. The title andWhatalso describe tests only, while production behaviour changes.Please split the tests that pass on current
main(slot limit and traversal rows with separators) from the behaviour changes, and keep only the changes that have a source.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T11:14:45Z.
Review: COMMENTED
Reviewed — no blocking findings
The two changed test files add mount-capacity, slot-reclamation, and invalid-directory-name coverage; I could not run the tests in this review.
What I ran
Reviewed head
2c1b2f73256b2dc94d9fde1a6bc25a56b7985df4usingrepo_read.py. No test commands were run.Results
Negative control
Not run; no test execution was available.
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author reports Windows 11 test runs, but I did not independently verify them. No files were excluded by the review manifest; both changed files were read.
To get this to a good state
Nothing is required. Optional: run the three reported native tests in CI and confirm they pass on this head.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:49:21Z.
Review: COMMENTED
The Linux integration build passed both registered SaveData tests covering mount status and PS4 behavior.
AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.