Skip to content

Commit

Permalink
Merge pull request #593 from Pietrodjaowjao/master
Browse files Browse the repository at this point in the history
Patch game-breaking exploits
  • Loading branch information
miniduikboot committed Apr 28, 2024
2 parents 414303b + 0ba700e commit f1f5185
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/Impostor.Server/Net/State/Game.Data.cs
Expand Up @@ -230,6 +230,8 @@ public async ValueTask<bool> HandleGameDataAsync(IMessageReader parent, ClientPl
{
// Sender is only allowed to change his own scene.
var clientId = reader.ReadPackedInt32();
var scene = reader.ReadString();

if (clientId != sender.Client.Id)
{
_logger.LogWarning(
Expand All @@ -239,7 +241,17 @@ public async ValueTask<bool> HandleGameDataAsync(IMessageReader parent, ClientPl
return false;
}

sender.Scene = reader.ReadString();
// According to game assembly, sender is only allowed to send OnlineGame.
if (scene != "OnlineGame")
{
_logger.LogWarning(
"Player {0} ({1}) tried to send SceneChangeFlag with disallowed scene.",
sender.Client.Name,
sender.Client.Id);
return false;
}

sender.Scene = scene;

_logger.LogTrace("> Scene {0} to {1}", clientId, sender.Scene);
break;
Expand All @@ -248,6 +260,16 @@ public async ValueTask<bool> HandleGameDataAsync(IMessageReader parent, ClientPl
case GameDataTag.ReadyFlag:
{
var clientId = reader.ReadPackedInt32();

if (clientId != sender.Client.Id)
{
_logger.LogWarning(
"Player {0} ({1}) tried to send ReadyFlag for another player.",
sender.Client.Name,
sender.Client.Id);
return false;
}

_logger.LogTrace("> IsReady {0}", clientId);
break;
}
Expand Down

0 comments on commit f1f5185

Please sign in to comment.