From b0d780b91e6160d21f2ad7eff84b3d62023b3f13 Mon Sep 17 00:00:00 2001 From: Slendy Date: Sat, 5 Nov 2022 22:37:16 -0500 Subject: [PATCH] Fix score uploading exploit --- .../Controllers/Slots/ScoreController.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs index 8d737c5d..1a335872 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs @@ -4,6 +4,7 @@ using System.Xml.Serialization; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Levels; using LBPUnion.ProjectLighthouse.Logging; +using LBPUnion.ProjectLighthouse.Match.MatchCommands; using LBPUnion.ProjectLighthouse.PlayerData; using LBPUnion.ProjectLighthouse.PlayerData.Profiles; using LBPUnion.ProjectLighthouse.Serialization; @@ -74,6 +75,13 @@ public class ScoreController : ControllerBase return this.BadRequest(); } + if (!score.PlayerIds.Contains(username)) + { + Logger.Warn("Rejecting score upload, requester username is not present in playerIds" + + $" (user={username}, playerIds={string.Join(",", score.PlayerIds)}", LogArea.Score); + return this.BadRequest(); + } + SanitizationHelper.SanitizeStringsInClass(score); if (slotType == "developer") id = await SlotHelper.GetPlaceholderSlotId(this.database, id, SlotType.Developer);