The vulnerability lies in a desynchronization issue between the visual inventory presented to the player and the actual backing inventory storage, specifically when using GuiStorageElement. The analysis of the patch commit 690fc91d137c6cc04f6ed3a89449050964dd8cb9 reveals the root cause and the affected functions.
The core of the vulnerability is in the click and drag handling logic. The original code had several weaknesses:
- In the
GuiStorageElement constructor, the click handler (setAction) did not adequately verify that the item displayed in the GUI (slotItem) matched the item in the backing storage (storageItem) before performing an action. This allowed a player to get the GUI into an inconsistent state that could be exploited.
- The
InventoryGui.onInventoryDrag method used an insufficient validation function (validateItemPlace), which could be bypassed to create duplicated items.
- A central flawed mechanism was the
InventoryGui.storeItems method. This method, called on inventory close or page change, would save the (potentially manipulated) state of the visual GUI back to the storage, making the item duplication permanent. The patch completely removes this method.
The fix involves three main changes:
- Adding strict consistency checks in the
GuiStorageElement click handler to detect and correct any desynchronization between the visual slot and the backing storage before any click action is processed.
- Replacing the weak validation in
onInventoryDrag with a direct and safer update to the storage.
- Removing the
storeItems method entirely, thus eliminating the flawed synchronization trigger.
Therefore, the vulnerable functions are the GuiStorageElement constructor where the faulty click handler is defined, the onInventoryDrag event handler, and the now-removed storeItems method which finalized the duplication.