Skip to content

Commit 42d70ad

Browse files
committed
Prevent invalid uuids
1 parent 5708ab3 commit 42d70ad

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

api/src/main/java/com/ruinscraft/panilla/api/nbt/checks/NbtCheck_EntityTag.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import com.ruinscraft.panilla.api.nbt.INbtTagList;
88
import com.ruinscraft.panilla.api.nbt.NbtDataType;
99

10+
import java.util.UUID;
11+
1012
public class NbtCheck_EntityTag extends NbtCheck {
1113

1214
private static final String[] ARMOR_STAND_TAGS = new String[]{"NoGravity", "ShowArms", "NoBasePlate", "Small", "Rotation", "Marker", "Pose", "Invisible"};
@@ -52,6 +54,16 @@ public NbtCheckResult check(INbtTagCompound tag, String itemName, IPanilla panil
5254
}
5355
}
5456

57+
if (entityTag.hasKey("UUID")) {
58+
String uuid = entityTag.getString("UUID");
59+
60+
try {
61+
UUID.fromString(uuid);
62+
} catch (Exception e) {
63+
return NbtCheckResult.CRITICAL;
64+
}
65+
}
66+
5567
if (entityTag.hasKey("ExplosionPower")) {
5668
return NbtCheckResult.FAIL;
5769
}
@@ -95,6 +107,13 @@ public NbtCheckResult check(INbtTagCompound tag, String itemName, IPanilla panil
95107
return NbtCheckResult.FAIL;
96108
}
97109

110+
String id = entityTag.getString("id");
111+
112+
// prevent lightning bolt eggs
113+
if (id.toLowerCase().contains("lightning")) {
114+
return NbtCheckResult.FAIL;
115+
}
116+
98117
// check for massive slime spawn eggs
99118
if (entityTag.hasKey("Size")) {
100119
if (entityTag.getInt("Size") > panilla.getProtocolConstants().maxSlimeSize()) {

api/src/main/java/com/ruinscraft/panilla/api/nbt/checks/NbtCheck_SkullOwner.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.ruinscraft.panilla.api.nbt.NbtDataType;
88

99
import java.util.Base64;
10+
import java.util.UUID;
1011
import java.util.regex.Matcher;
1112
import java.util.regex.Pattern;
1213

@@ -23,6 +24,28 @@ public NbtCheckResult check(INbtTagCompound tag, String itemName, IPanilla panil
2324
if (panilla.getPConfig().preventMinecraftEducationSkulls) {
2425
INbtTagCompound skullOwner = tag.getCompound("SkullOwner");
2526

27+
if (skullOwner.hasKey("Id")) {
28+
String idString = skullOwner.getString("Id");
29+
30+
try {
31+
// Ensure valid UUID
32+
UUID.fromString(idString);
33+
} catch (Exception e) {
34+
return NbtCheckResult.CRITICAL;
35+
}
36+
}
37+
38+
if (skullOwner.hasKey("UUID")) {
39+
String uuidString = skullOwner.getString("UUID");
40+
41+
try {
42+
// Ensure valid UUID
43+
UUID.fromString(uuidString);
44+
} catch (Exception e) {
45+
return NbtCheckResult.CRITICAL;
46+
}
47+
}
48+
2649
if (skullOwner.hasKey("Properties")) {
2750
INbtTagCompound properties = skullOwner.getCompound("Properties");
2851

0 commit comments

Comments
 (0)