From ce5f7210171c9b7c9481ea1b73d305437451099e Mon Sep 17 00:00:00 2001 From: Allink <44676012+allinkdev@users.noreply.github.com> Date: Sun, 10 Jul 2022 03:21:23 +0100 Subject: [PATCH] Patch 'sploits (1.19) (#35) * Prevent invalid container events * Do not attempt to cast items to recipes --- ...033-Prevent-invalid-container-events.patch | 37 +++++++++++++++++++ ...not-attempt-to-cast-items-to-recipes.patch | 24 ++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 patches/server/0033-Prevent-invalid-container-events.patch create mode 100644 patches/server/0034-Do-not-attempt-to-cast-items-to-recipes.patch diff --git a/patches/server/0033-Prevent-invalid-container-events.patch b/patches/server/0033-Prevent-invalid-container-events.patch new file mode 100644 index 0000000..98a81d2 --- /dev/null +++ b/patches/server/0033-Prevent-invalid-container-events.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Allink +Date: Sun, 10 Jul 2022 02:55:01 +0100 +Subject: [PATCH] Prevent invalid container events + + +diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index d053c7547db965cd103a6edf56916f3c6e98a673..1f5553977de20cc52ba654fbaf56c5002d561bb4 100644 +--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -31,6 +31,8 @@ import java.util.function.UnaryOperator; + import java.util.stream.Collectors; + import java.util.stream.Stream; + import javax.annotation.Nullable; ++ ++import net.kyori.adventure.text.format.NamedTextColor; + import net.minecraft.ChatFormatting; + import net.minecraft.CrashReport; + import net.minecraft.CrashReportCategory; +@@ -3034,6 +3036,17 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser + } + + if (packet.getClickType() != net.minecraft.world.inventory.ClickType.QUICK_CRAFT) { ++ // Scissors start - Do not call events when the slot/button number is invalid ++ if(packet.getSlotNum() > 45) ++ { ++ this.getCraftPlayer().kick( ++ net.kyori.adventure.text.Component.text("Invalid container click slot (Hacking?)") ++ .color(NamedTextColor.RED) ++ ); ++ return; ++ } ++ // Scissors end ++ + if (click == ClickType.NUMBER_KEY) { + event = new InventoryClickEvent(inventory, type, packet.getSlotNum(), click, action, packet.getButtonNum()); + } else { diff --git a/patches/server/0034-Do-not-attempt-to-cast-items-to-recipes.patch b/patches/server/0034-Do-not-attempt-to-cast-items-to-recipes.patch new file mode 100644 index 0000000..1f69062 --- /dev/null +++ b/patches/server/0034-Do-not-attempt-to-cast-items-to-recipes.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Allink +Date: Sun, 10 Jul 2022 02:55:33 +0100 +Subject: [PATCH] Do not attempt to cast items to recipes + + +diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +index 2a005e837108d1879da31e8054afbbd6bf7b175e..97bcfb36a37eb7d889d6233e7de9b7b53c8a8a5c 100644 +--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java ++++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +@@ -648,6 +648,13 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit + Entry entry = (Entry) objectiterator.next(); + + worldserver.getRecipeManager().byKey((ResourceLocation) entry.getKey()).ifPresent((irecipe) -> { ++ // Scissors start - Do not attempt to cast items to recipes ++ if (!(irecipe instanceof AbstractCookingRecipe)) ++ { ++ return; ++ } ++ // Scissors end ++ + list.add(irecipe); + AbstractFurnaceBlockEntity.createExperience(worldserver, vec3d, entry.getIntValue(), ((AbstractCookingRecipe) irecipe).getExperience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit + });