Reject path traversal in savedata name fields

gameName/saveName/fileName and the saveNameList entries are
guest-controlled and get concatenated into host filesystem paths, so a
crafted request could escape the save directory with ../ sequences.

- PSPSaveDialog::Init rejects requests whose name fields contain a path
  separator ('/' or '\') or are bare dot components.
- SavedataParam::SetPspParam rejects saveNameList entries the same way.
This commit is contained in:
Henrik Rydgård committed 2026-08-01 13:16:21 +02:00
1 parent a67fc2300d
commit 779cae6232
2 files changed
+34

No files matched your search

+14
View File
@@ -1547,6 +1547,20 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param) {
// Get number of fileName in array
saveDataListCount = 0;
while (saveNameListData[saveDataListCount][0] != 0) {
// saveName entries become part of host filesystem paths; reject
// path separators and bare dot components (path traversal).
const std::string_view entry = StringViewFromFixedSizeField(saveNameListData[saveDataListCount]);
bool hasSeparator = false;
for (char c : entry) {
if (c == '/' || c == '\\') {
hasSeparator = true;
break;
}
}
if (hasSeparator || entry == "." || entry == "..") {
ERROR_LOG(Log::sceUtility, "SavedataParam: invalid saveName in list: %s", std::string(entry).c_str());
return SCE_ERROR_UTILITY_INVALID_PARAM_SIZE;
}
saveDataListCount++;
}