Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/API/CustomEmployeeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -891,10 +891,19 @@ private static void SetPortrait(Transform card, string employeeId)

string assetsDir = Path.Combine(MelonEnvironment.UserDataDirectory, "ModAssets");
string? imagePath = null;
foreach (var ext in new[] { ".jpg", ".png" })

// Validate employeeId to prevent path traversal
if (employeeId.IndexOfAny(Path.GetInvalidFileNameChars()) < 0 && !employeeId.Contains(".."))
{
foreach (var ext in new[] { ".jpg", ".png" })
{
string candidate = Path.Combine(assetsDir, employeeId + ext);
if (File.Exists(candidate)) { imagePath = candidate; break; }
}
}
else
{
string candidate = Path.Combine(assetsDir, employeeId + ext);
if (File.Exists(candidate)) { imagePath = candidate; break; }
CrashLog.Log($"[Security] CustomEmployee: Invalid characters in employeeId={employeeId} for portrait");
}

if (imagePath != null)
Expand Down
Loading