9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 14:59:25 +00:00
Files
DivineMC/divinemc-server/minecraft-patches/features/0018-Block-Log4Shell-exploit.patch
NONPLAYT 624e45d701 Updated Upstream (Purpur)
Upstream has released updates that appear to apply and compile correctly

Purpur Changes:
PurpurMC/Purpur@09ea9cb9 fix mobs not burning in daylight (#1689)
PurpurMC/Purpur@4d5a8e6e Updated Upstream (Paper)
2025-07-07 03:11:24 +03:00

35 lines
1.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sat, 1 Feb 2025 19:28:34 +0300
Subject: [PATCH] Block Log4Shell exploit
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index b0bd45b8f53d4b9617680d7fb92d324c3713d960..89eddabc1a01f78b6945f1b8b8d32cede7e3cd9d 100644
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2525,6 +2525,7 @@ public class ServerGamePacketListenerImpl
}
private void tryHandleChat(String message, Runnable handler, boolean sync) { // CraftBukkit
+ if (ServerGamePacketListenerImpl.isLog4ShellExploit(message)) return; // DivineMC - Block Log4Shell exploit
if (isChatMessageIllegal(message)) {
this.disconnectAsync(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper - add proper async disconnect
} else if (this.player.isRemoved() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { // CraftBukkit - dead men tell no tales
@@ -2557,6 +2558,15 @@ public class ServerGamePacketListenerImpl
}
}
+ // DivineMC start - Block Log4Shell exploit
+ public static boolean isLog4ShellExploit(String message) {
+ java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(".*\\$\\{[^}]*}.*");
+ java.util.regex.Matcher matcher = pattern.matcher(message);
+
+ return matcher.find();
+ }
+ // DivineMC end - Block Log4Shell exploit
+
public static boolean isChatMessageIllegal(String message) {
for (int i = 0; i < message.length(); i++) {
if (!StringUtil.isAllowedChatCharacter(message.charAt(i))) {