This Spigot plugin fixes several minecraft server crashing exploits related to books.
- Book Sign Crasher
- Book Edit Crasher
- SetCreativeSlot Crasher
- WindowClick Crasher
- BlockPlace Crasher
- Lag Books
- Shulker box overflow (1.16 only)
A few minecraft packets (SetCreativeSlot, WindowClick, BlockPlace and CustomPayload when used for books / replaced by BookEdit in 1.16) can contain Slot-data, also called an ItemStack, which is a full "description" of an item, containing its type, amount, and nbt data such as the displayname or the lore, but also a large array of strings, when sent within a written/writable book itemstack. When these packets are sent very often in a short amount of time, the thread where the packets are decoded on is getting blocked by all these packets (one book itemstack with 50 pages full of random characters takes about 2 seconds to decode), and because minecraft is using one networking thread for multiple players, all players connected over this thread are going to time out.
These packets can also contain text components in the book's pages, which can push the time to deserialize one itemstack up to 17 seconds.
There are two different fixing techniques, which are used by this plugin:
This technique processes incoming packets asynchronously, and only one at the time per player, so if a player sends a book edit/sign packet which contains so many data that the deserializing and parsing of the nbt data takes longer than a few milliseconds, the following book edit/sign packets are ignored until the server is done processing the last packet. The deserialization and parsing of these packets is completely asynchronous, so that the server does not receive any lag while doing so.
This technique does simply ignore the nbt data of books. All three packets (SetCreativeSlot, WindowClick and BlockPlace) dont really need to know the clientside itemstack, they are just sent for synchronizing purpose (except SetCreativeSlot, more about that later). This is how I fixed everyone of these three:
-
SetCreativeSlot: This one could easily be fixed by ignoring the packet, when the player is not in creative mode. The crasher just works, because the default minecraft packet decoder does simply decode the packet (and parse nbt data) without event checking if the player is able to send this packet.
-
WindowClick: This one could be fixed by ignoring the nbt data which is being sent by the client when clicking on a book item, because the server doesnt need it, it just needs the item type and amount.
-
BlockPlace: This one could also be fixed by ignoring the nbt data which is being sent by the client when right-clicking a book item, because the server only checks the itemstack sent by the client when the right-clicked item is a placeable block.
-
Lag Books: This one could be fixed by concatenating all sibling component's text to the text of the main component sent by the client, because this crashing/lag exploit relies on sending chat components with many sibling components, which firstly, freeze the client who opens the book for ~10-15+ seconds, and, secondly, can cause lag when the book gets dropped.
These two techniques fix all book-related crashing methods in version 1.8, but in 1.16 there are a few new exploits, using books together with shulker boxes:
This exploit is not really a crashing exploit, but it is an exploit which is caused by books, so it is fixed by this plugin. It works by writing 23 or more books full with data (100 pages which can contain up to 96KB in 1.16) and putting them into a shulker box. When someone breaks this shulkerbox, the server wants to send the player an entity metadata packet containing the slot data which is contained in the shulker box, but these books exceed the maximum size of the entity metadata packet. There is also another exploit with shulkers and books, by filling 54 shulker boxes full with 96kb books, and putting all of them into a doublechest, and then spamming rightclick on this chest, because the server will then try to send (96KB per book*27 slots in a shulkerbox*54 slots in a chest) ~140MB per rightclick, which causes it to lag/crash.
This exploits could both be fixed by preventing books from being put into shulker boxes.
This project depends on paperspigot 1.8, paperspigot 1.16 and teller to be contained in your local maven repository.
Clone
- https://github.com/PaperMC/Paper/tree/ver/1.8.8
- https://github.com/PaperMC/Paper/tree/ver/1.16.5
- https://github.com/zieserl/teller
and build them yourself, then publish them to maven local. After that you can clone and build this project.