From 82a095f3cf8bd66d30c727d242c79edc98be8561 Mon Sep 17 00:00:00 2001 From: punchready Date: Tue, 26 Jul 2022 08:58:56 +0200 Subject: [PATCH] fix a region bypass exploit using the ice rod --- TShockAPI/Bouncer.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index dae66461..736fc6d7 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -401,6 +401,18 @@ namespace TShockAPI return; } + // i do not understand the ice tile check enough to be able to modify it, however i do know that it can be used to completely bypass region protection + // this check ensures that build permission is always checked no matter what + if (!args.Player.HasBuildPermission(tileX, tileY)) + { + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from build from {0} {1} {2}", args.Player.Name, action, editData); + + GetRollbackRectSize(tileX, tileY, out byte width, out byte length, out int offsetY); + args.Player.SendTileRect((short)(tileX - width), (short)(tileY + offsetY), (byte)(width * 2), (byte)(length + 1)); + args.Handled = true; + return; + } + if (editData < 0 || ((action == EditAction.PlaceTile || action == EditAction.ReplaceTile) && editData >= Main.maxTileSets) || ((action == EditAction.PlaceWall || action == EditAction.ReplaceWall) && editData >= Main.maxWallTypes))