aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorstonar96 <[email protected]>2021-10-21 11:15:18 +0200
committerGitHub <[email protected]>2021-10-21 02:15:18 -0700
commita1f49e4c600f2ada525171d969c893261088c155 (patch)
tree843684412fad49a93e83892ed6aadfd72e09c85d
parent5553432644a4606348d59e674b5ed1047ebdf25b (diff)
downloadPaper-a1f49e4c600f2ada525171d969c893261088c155.tar.gz
Paper-a1f49e4c600f2ada525171d969c893261088c155.zip
Fix command suggestion leak (#6592)
Co-authored-by: Jason Penilla <[email protected]>
-rw-r--r--patches/server/0833-Check-requirement-before-suggesting-root-nodes.patch31
-rw-r--r--patches/server/0834-Don-t-respond-to-ServerboundCommandSuggestionPacket-.patch23
2 files changed, 54 insertions, 0 deletions
diff --git a/patches/server/0833-Check-requirement-before-suggesting-root-nodes.patch b/patches/server/0833-Check-requirement-before-suggesting-root-nodes.patch
new file mode 100644
index 0000000000..da19d3f1ca
--- /dev/null
+++ b/patches/server/0833-Check-requirement-before-suggesting-root-nodes.patch
@@ -0,0 +1,31 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: stonar96 <[email protected]>
+Date: Sun, 12 Sep 2021 00:14:21 +0200
+Subject: [PATCH] Check requirement before suggesting root nodes
+
+Child nodes are handled by CommandDispatcher#parse checking
+requirements.
+
+Vanilla clients only send ServerboundCommandSuggestionPacket when
+encountering a command node with ASK_SERVER suggestions, however a
+modified client can send this packet whenever it wants.
+
+diff --git a/src/main/java/com/mojang/brigadier/CommandDispatcher.java b/src/main/java/com/mojang/brigadier/CommandDispatcher.java
+index ca24830bac1a04b798229d1946863429c7849495..5584040fe48c18aa809f5a1510157e735851df79 100644
+--- a/src/main/java/com/mojang/brigadier/CommandDispatcher.java
++++ b/src/main/java/com/mojang/brigadier/CommandDispatcher.java
+@@ -594,10 +594,14 @@ public class CommandDispatcher<S> {
+ int i = 0;
+ for (final CommandNode<S> node : parent.getChildren()) {
+ CompletableFuture<Suggestions> future = Suggestions.empty();
++ // Paper start - Don't suggest if the requirement isn't met
++ if (parent != this.root || node.canUse(context.getSource())) {
+ try {
+ future = node.listSuggestions(context.build(truncatedInput), new SuggestionsBuilder(truncatedInput, truncatedInputLowerCase, start));
+ } catch (final CommandSyntaxException ignored) {
+ }
++ }
++ // Paper end
+ futures[i++] = future;
+ }
+
diff --git a/patches/server/0834-Don-t-respond-to-ServerboundCommandSuggestionPacket-.patch b/patches/server/0834-Don-t-respond-to-ServerboundCommandSuggestionPacket-.patch
new file mode 100644
index 0000000000..61da4b8894
--- /dev/null
+++ b/patches/server/0834-Don-t-respond-to-ServerboundCommandSuggestionPacket-.patch
@@ -0,0 +1,23 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: stonar96 <[email protected]>
+Date: Sun, 12 Sep 2021 00:14:21 +0200
+Subject: [PATCH] Don't respond to ServerboundCommandSuggestionPacket when
+ tab-complete is disabled
+
+
+diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+index 5d7c47b0a302f7db95a0b2bb811c5656c6b02beb..7bf03b78a26b6a697a8d10e8832703421f96b2bb 100644
+--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+@@ -796,6 +796,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
+ }
+ // Paper end
+ // CraftBukkit end
++ // Paper start - Don't suggest if tab-complete is disabled
++ if (org.spigotmc.SpigotConfig.tabComplete < 0) {
++ return;
++ }
++ // Paper end
+ StringReader stringreader = new StringReader(packet.getCommand());
+
+ if (stringreader.canRead() && stringreader.peek() == '/') {