Skip to content

Commit

Permalink
Fix Exploits (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
IPECTER authored Dec 30, 2023
1 parent 8c5f28b commit 7183552
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 207 deletions.
126 changes: 97 additions & 29 deletions patches/server/0009-Optimize-Default-Configurations.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ From: IPECTER <[email protected]>
Date: Tue, 7 Mar 2023 12:28:34 +0900
Subject: [PATCH] Optimize Default Configurations

Original: YouHaveTrouble/minecraft-optimization, AkiraDevelopment/SimplyMC
Original: YouHaveTrouble/minecraft-optimization, YouHaveTrouble/minecraft-exploits-and-how-to-fix-them, AkiraDevelopment/SimplyMC
Copyright (C) 2023 YouHaveTrouble, AkiraDevelopment

diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
index 3e36958365bc136516bafbaad0c168f7956406f1..b5eca4a809d5e7c77de9737941f3f6c35e4fc796 100644
index 3e36958365bc136516bafbaad0c168f7956406f1..47e96912f8cde6e6988b5d609a4fbd8e00b126cb 100644
--- a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
@@ -211,8 +211,8 @@ public class PufferfishConfig {
Expand All @@ -18,12 +18,12 @@ index 3e36958365bc136516bafbaad0c168f7956406f1..b5eca4a809d5e7c77de9737941f3f6c3
- maxProjectileLoadsPerProjectile = getInt("projectile.max-loads-per-projectile", 10, "Controls how many chunks a projectile", "can load in its lifetime before it gets", "automatically removed.");
+ maxProjectileLoadsPerTick = getInt("projectile.max-loads-per-tick", Boolean.getBoolean("Plazma.disableConfigOptimization") ? 10 : 8, "Controls how many chunks are allowed", "to be sync loaded by projectiles in a tick."); // Plazma
+ maxProjectileLoadsPerProjectile = getInt("projectile.max-loads-per-projectile", 10, "Controls how many chunks a projectile", "can load in its lifetime before it gets", "automatically removed.");

setComment("projectile", "Optimizes projectile settings");
}
@@ -225,16 +225,16 @@ public class PufferfishConfig {
public static int activationDistanceMod;

private static void dynamicActivationOfBrains() throws IOException {
- dearEnabled = getBoolean("dab.enabled", "activation-range.enabled", false); // Purpur
- startDistance = getInt("dab.start-distance", "activation-range.start-distance", 12,
Expand All @@ -42,25 +42,81 @@ index 3e36958365bc136516bafbaad0c168f7956406f1..b5eca4a809d5e7c77de9737941f3f6c3
"tick frequency. freq = (distanceToPlayer^2) / (2^value)",
"If you want further away entities to tick less often, use 7.",
"If you want further away entities to tick more often, try 9.");
@@ -253,8 +253,18 @@ public class PufferfishConfig {
public static Map<String, Integer> projectileTimeouts;
private static void projectileTimeouts() {
// Set some defaults
- getInt("entity_timeouts.SNOWBALL", -1);
- getInt("entity_timeouts.LLAMA_SPIT", -1);
+ // Plazma start - Optimize Default Configurations
+ if (!Boolean.getBoolean("Plazma.disableConfigOptimization")) {
+ getInt("entity_timeouts.ARROW", 200);
+ getInt("entity_timeouts.EGG", 200);
+ getInt("entity_timeouts.ENDER_PEARL", 200);
+ getInt("entity_timeouts.SNOWBALL", 200);
+ getInt("entity_timeouts.LLAMA_SPIT", 200);
+ } else {
+ // Plazma end
+ getInt("entity_timeouts.SNOWBALL", -1);
+ getInt("entity_timeouts.LLAMA_SPIT", -1);
+ } // Plazma
setComment("entity_timeouts",
"These values define a entity's maximum lifespan. If an",
"entity is in this list and it has survived for longer than",
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
index 3bc7230ca62ebe3426da293e436a962bb0134f85..1a4b5dc4c5340de66553936bbbc074d1654a3ef8 100644
index 3bc7230ca62ebe3426da293e436a962bb0134f85..766e518c6a3b3e684f5fda65a680b5378c9c0479 100644
--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
@@ -143,7 +143,7 @@ public class GlobalConfiguration extends ConfigurationPart {

public class Watchdog extends ConfigurationPart {
public int earlyWarningEvery = 5000;
- public int earlyWarningDelay = 10000;
+ public int earlyWarningDelay = Boolean.getBoolean("Plazma.disableConfigOptimization") ? 10000 : 180000; // Plazma - Optimize Default Configurations
}

public SpamLimiter spamLimiter;
@@ -230,7 +230,7 @@ public class GlobalConfiguration extends ConfigurationPart {
public BookSize bookSize;

public class BookSize extends ConfigurationPart {
- public int pageMax = 2560; // TODO this appears to be a duplicate setting with one above
+ public int pageMax = !Boolean.getBoolean("Plazma.disableConfigOptimization") ? 1024 : 2560; // TODO this appears to be a duplicate setting with one above // Plazma - Optimize Default Configurations
public double totalMultiplier = 0.98D; // TODO this should probably be merged into the above inner class
}
public boolean resolveSelectorsInBooks = false;
@@ -241,7 +241,15 @@ public class GlobalConfiguration extends ConfigurationPart {
public class PacketLimiter extends ConfigurationPart {
public Component kickMessage = Component.translatable("disconnect.exceeded_packet_rate", NamedTextColor.RED);
public PacketLimit allPackets = new PacketLimit(7.0, 500.0, PacketLimit.ViolateAction.KICK);
- public Map<Class<? extends Packet<?>>, PacketLimit> overrides = Map.of(ServerboundPlaceRecipePacket.class, new PacketLimit(4.0, 5.0, PacketLimit.ViolateAction.DROP));
+ // Plazma start - Optimize Default Configurations
+ public Map<Class<? extends Packet<?>>, PacketLimit> overrides = new java.util.HashMap<>() {{
+ put(ServerboundPlaceRecipePacket.class, new PacketLimit(4.0, 5.0, PacketLimit.ViolateAction.DROP));
+ if (!Boolean.getBoolean("Plazma.disableConfigOptimization")) {
+ put(net.minecraft.network.protocol.game.ServerboundCommandSuggestionPacket.class, new PacketLimit(1.0, 15.0, PacketLimit.ViolateAction.DROP));
+ put(net.minecraft.network.protocol.game.ServerboundPlaceRecipePacket.class, new PacketLimit(4.0, 5.0, PacketLimit.ViolateAction.DROP));
+ }
+ }};
+ // Plazma end

@ConfigSerializable
public record PacketLimit(@Required double interval, @Required double maxPacketRate, ViolateAction action) {
@@ -308,7 +316,7 @@ public class GlobalConfiguration extends ConfigurationPart {
executor.setMaximumPoolSize(_chatExecutorMaxSize);
}
}
- public int maxJoinsPerTick = 5;
+ public int maxJoinsPerTick = !Boolean.getBoolean("Plazma.disableConfigOptimization") ? 3 : 5; // Plazma - Optimize Default Configurations
public boolean fixEntityPositionDesync = true;
public boolean loadPermissionsYmlBeforePlugins = true;
@Constraints.Min(4)
diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
index f45afb7e2607617d1239abeca13a9002dd9a3a18..844ecc2a6d6677742e87ef22dede28867892a301 100644
index f45afb7e2607617d1239abeca13a9002dd9a3a18..3f7868dbc4b5b7cf665e9d60b146374f79481e42 100644
--- a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
+++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
@@ -88,15 +88,15 @@ public class WorldConfiguration extends ConfigurationPart {

public class AntiXray extends ConfigurationPart {
public boolean enabled = false;
- public EngineMode engineMode = EngineMode.HIDE;
Expand All @@ -79,14 +135,25 @@ index f45afb7e2607617d1239abeca13a9002dd9a3a18..844ecc2a6d6677742e87ef22dede2886
+ // Plazma end
}
}


@@ -120,8 +120,8 @@ public class WorldConfiguration extends ConfigurationPart {
public ArmorStands armorStands;

public class ArmorStands extends ConfigurationPart {
- public boolean doCollisionEntityLookups = true;
- public boolean tick = true;
+ public boolean doCollisionEntityLookups = Boolean.getBoolean("Plazma.disableConfigOptimization"); // Plazma - Optimize Default Configurations
+ public boolean tick = Boolean.getBoolean("Plazma.disableConfigOptimization");; // Plazma - Optimize Default Configurations
}

public Markers markers;
@@ -150,7 +150,7 @@ public class WorldConfiguration extends ConfigurationPart {
@MergeMap
public Reference2IntMap<MobCategory> spawnLimits = Util.make(new Reference2IntOpenHashMap<>(NaturalSpawner.SPAWNING_CATEGORIES.length), map -> Arrays.stream(NaturalSpawner.SPAWNING_CATEGORIES).forEach(mobCategory -> map.put(mobCategory, -1)));
@MergeMap
- public Map<MobCategory, DespawnRange> despawnRanges = Arrays.stream(MobCategory.values()).collect(Collectors.toMap(Function.identity(), category -> new DespawnRange(category.getNoDespawnDistance(), category.getDespawnDistance())));
+ public Map<MobCategory, DespawnRange> despawnRanges = Arrays.stream(MobCategory.values()).collect(Collectors.toMap(Function.identity(), category -> new DespawnRange(category.getNoDespawnDistance(), Boolean.getBoolean("Plazma.disableConfigOptimization") ? category.getDespawnDistance() : (net.minecraft.server.MinecraftServer.getServer().server.getSimulationDistance() * 16) + 8))); // Plazma - Optimize Default Configurations

@ConfigSerializable
public record DespawnRange(@Required int soft, @Required int hard) {
@@ -372,7 +372,7 @@ public class WorldConfiguration extends ConfigurationPart {
Expand All @@ -109,9 +176,9 @@ index f45afb7e2607617d1239abeca13a9002dd9a3a18..844ecc2a6d6677742e87ef22dede2886
+ public int maxEntityCollisions = Boolean.getBoolean("Plazma.disableConfigOptimization") ? 8 : 2; // Plazma - Optimize Default Configurations
public boolean allowPlayerCrammingDamage = false;
}

@@ -462,18 +462,40 @@ public class WorldConfiguration extends ConfigurationPart {

public class Chunks extends ConfigurationPart {
public AutosavePeriod autoSaveInterval = AutosavePeriod.def();
- public int maxAutoSaveChunksPerTick = 24;
Expand Down Expand Up @@ -162,7 +229,7 @@ index f45afb7e2607617d1239abeca13a9002dd9a3a18..844ecc2a6d6677742e87ef22dede2886
}
@@ -488,9 +510,9 @@ public class WorldConfiguration extends ConfigurationPart {
public TickRates tickRates;

public class TickRates extends ConfigurationPart {
- public int grassSpread = 1;
+ public int grassSpread = Boolean.getBoolean("Plazma.disableConfigOptimization") ? 1 : 4; // Plazma - Optimize Default Configurations
Expand All @@ -173,7 +240,7 @@ index f45afb7e2607617d1239abeca13a9002dd9a3a18..844ecc2a6d6677742e87ef22dede2886
public Table<EntityType<?>, String, Integer> behavior = Util.make(HashBasedTable.create(), table -> table.put(EntityType.VILLAGER, "validatenearbypoi", -1));
}
@@ -514,9 +536,9 @@ public class WorldConfiguration extends ConfigurationPart {

public class Misc extends ConfigurationPart {
public int lightQueueSize = 20;
- public boolean updatePathfindingOnBlockUpdate = true;
Expand All @@ -189,13 +256,13 @@ index 24763d3d270c29c95e0b3e85111145234f660a62..18bc271a34ffba8c83743fef7eaf4a2c
--- a/src/main/java/io/papermc/paper/configuration/type/fallback/ArrowDespawnRate.java
+++ b/src/main/java/io/papermc/paper/configuration/type/fallback/ArrowDespawnRate.java
@@ -29,6 +29,7 @@ public class ArrowDespawnRate extends FallbackValue.Int {

@Override
protected int fallback() {
+ if (!Boolean.getBoolean("Plazma.disableConfigOptimization")) return 100; // Plazma - Optimize Default Configurations
return this.get(FallbackValue.SPIGOT_WORLD_CONFIG).arrowDespawnRate;
}

diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
index ed7bcd832340a7a46897f0275c99e72b7247a5de..65e0a4c04b91e6fd6d2959927bdb75a4fcf8f86b 100644
--- a/src/main/java/net/minecraft/server/Main.java
Expand All @@ -207,10 +274,10 @@ index ed7bcd832340a7a46897f0275c99e72b7247a5de..65e0a4c04b91e6fd6d2959927bdb75a4
- configuration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(Main.class.getClassLoader().getResourceAsStream("configurations/bukkit.yml"), Charsets.UTF_8)));
+ configuration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(Main.class.getClassLoader().getResourceAsStream(Boolean.getBoolean("Plazma.disableConfigOptimization") ? "configurations/bukkit.yml" : "configurations/bukkit_optimized.yml"), Charsets.UTF_8))); // Plazma - Optimize Default Configurations
configuration.save(configFile);

File commandFile = (File) optionset.valueOf("commands-settings");
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
index 1ea3012995c738c67b31e997c138f824f9e69ba1..8ed00a650b712cbf4bc8796165a539d76d390d0f 100644
index 1ea3012995c738c67b31e997c138f824f9e69ba1..aa37c7a7bfe75064db9cf78e967a6644f61b0e09 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
@@ -120,7 +120,7 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
Expand All @@ -233,7 +300,8 @@ index 1ea3012995c738c67b31e997c138f824f9e69ba1..8ed00a650b712cbf4bc8796165a539d7
this.opPermissionLevel = this.get("op-permission-level", 4);
this.functionPermissionLevel = this.get("function-permission-level", 2);
this.maxTickTime = this.get("max-tick-time", TimeUnit.MINUTES.toMillis(1L));
this.maxChainedNeighborUpdates = this.get("max-chained-neighbor-updates", 1000000);
- this.maxChainedNeighborUpdates = this.get("max-chained-neighbor-updates", 1000000);
+ this.maxChainedNeighborUpdates = this.get("max-chained-neighbor-updates", !Boolean.getBoolean("Plazma.disableConfigOptimization") ? 10000 : 1000000); // Plazma - Optimize Default Configurations
this.rateLimitPacketsPerSecond = this.get("rate-limit", 0);
- this.viewDistance = this.get("view-distance", 10);
- this.simulationDistance = this.get("simulation-distance", 10);
Expand All @@ -256,7 +324,7 @@ index c43023fecf0882101248f625a28975586da05071..6b092fec6e8c468f3ecd2fc150f54634
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -429,7 +429,7 @@ public final class CraftServer implements Server {

this.configuration = YamlConfiguration.loadConfiguration(this.getConfigFile());
this.configuration.options().copyDefaults(true);
- this.configuration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("configurations/bukkit.yml"), Charsets.UTF_8)));
Expand All @@ -279,11 +347,11 @@ index d0d31002562e728fa1a6c9bc81baa4534f11d365..d0968eeb0f9edeee43394da8a32d3ee8
+ // Plazma end
private static File CONFIG_FILE;
public static YamlConfiguration config;

@@ -241,7 +244,7 @@ public class PurpurConfig {
laggingThreshold = getDouble("settings.lagging-threshold", laggingThreshold);
}

- public static boolean useAlternateKeepAlive = false;
+ public static boolean useAlternateKeepAlive = !Boolean.getBoolean("Plazma.disableConfigOptimization"); // Plazma - Optimize Default Configurations
private static void useAlternateKeepAlive() {
Expand Down Expand Up @@ -323,15 +391,15 @@ index 5b5109e942b18418b3a3a0e2109fe4ef15045fe5..e24106f0d936375f200cb82339dc03f8
+ this.itemMerge = this.getDouble("merge-radius.item", Boolean.getBoolean("Plazma.disableConfigOptimization") ? 2.5 : 3.5 ); // Plazma - Optimize Default Configurations
this.log( "Item Merge Radius: " + this.itemMerge );
}

public double expMerge;
private void expMerge()
{
- this.expMerge = this.getDouble("merge-radius.exp", 3.0 );
+ this.expMerge = this.getDouble("merge-radius.exp", Boolean.getBoolean("Plazma.disableConfigOptimization") ? 3.0 : 4.0 ); // Plazma - Optimize Default Configurations
this.log( "Experience Merge Radius: " + this.expMerge );
}

@@ -196,7 +196,7 @@ public class SpigotWorldConfig
public byte mobSpawnRange;
private void mobSpawnRange()
Expand All @@ -340,11 +408,11 @@ index 5b5109e942b18418b3a3a0e2109fe4ef15045fe5..e24106f0d936375f200cb82339dc03f8
+ this.mobSpawnRange = (byte) getInt( "mob-spawn-range", Boolean.getBoolean("Plazma.disableConfigOptimization") ? 8 : 3 ); // Paper - Vanilla // Plazma - Optimize Default Configurations
this.log( "Mob Spawn Range: " + this.mobSpawnRange );
}

@@ -207,26 +207,26 @@ public class SpigotWorldConfig
this.log( "Item Despawn Rate: " + this.itemDespawnRate );
}

- public int animalActivationRange = 32;
- public int monsterActivationRange = 32;
+ public int animalActivationRange = Boolean.getBoolean("Plazma.disableConfigOptimization") ? 32 : 16; // Plazma - Optimize Default Configurations
Expand Down Expand Up @@ -409,10 +477,10 @@ index 0000000000000000000000000000000000000000..eb33b0a19d6060f78d7ead7a2ad63b1b
+# As you can see, there's actually not that much to configure without any plugins.
+# For a reference for any variable inside this file, check out the Bukkit Wiki at
+# https://www.spigotmc.org/go/bukkit-yml
+#
+#
+# If you need help on this file, feel free to join us on Discord or leave a message
+# on the forums asking for advice.
+#
+#
+# Discord: https://www.spigotmc.org/go/discord
+# Forums: https://www.spigotmc.org/
+# Bug tracker: https://www.spigotmc.org/go/bugs
Expand Down
20 changes: 20 additions & 0 deletions patches/server/0046-Paper-Add-another-slot-sanity-check.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: IPECTER <[email protected]>
Date: Sat, 30 Dec 2023 21:50:18 +0900
Subject: [PATCH] Paper-Add-another-slot-sanity-check

Backport of Paper ver/1.20.2 8493340

diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
index 38d47fbcd49cc291040ea00470abeb982fe2714c..662f3eee6ff17e0b0191b1c59066465db818ed2b 100644
--- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
@@ -600,7 +600,7 @@ public abstract class AbstractContainerMenu {
int j2;

if (actionType == ClickType.SWAP) {
- if (slotIndex < 0) return; // Paper
+ if (slotIndex < 0 || button < 0) return; // Paper
slot2 = (Slot) this.slots.get(slotIndex);
itemstack1 = playerinventory.getItem(button);
itemstack = slot2.getItem();
Loading

0 comments on commit 7183552

Please sign in to comment.