Patch 'sploits (1.17.1) (#33)

* Prevent invalid container events

* Do not attempt to cast items to recipes
This commit is contained in:
Allink 2022-07-10 03:21:35 +01:00 committed by GitHub
parent a877b648d5
commit c2b2427622
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 61 additions and 0 deletions

View file

@ -0,0 +1,37 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Allink <arclicious@vivaldi.net>
Date: Sun, 10 Jul 2022 02:20:16 +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 ca595abe940463a62da033c7082c868c4c4b28d8..6f43eec3490dd44d0f680977710f1d65dc6fc3b2 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -24,6 +24,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;
@@ -2782,6 +2784,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 {

View file

@ -0,0 +1,24 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Allink <arclicious@vivaldi.net>
Date: Sun, 10 Jul 2022 02:25:28 +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 73e95e631ac622de897775399d205de66c4d8ff8..c3fd536cebb2f8664f9bf86d322f88094677d2b5 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
@@ -629,6 +629,13 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
Entry<ResourceLocation> 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
});