[Exploit] Exiting a world while holding an item duplicates it
Partner Rank:
1
Partner Team Reporting:
Everbloom Games
Verification builds:
1.20.80.24_rc0
Summary:
Exiting a world while holding an item in the mainhand and re-entering it creates a copy of the held item stack in a strange inventory slot that has a couple properties:
- The item can be found via the hasitem={} selector, without a "location" field. It cannot be found in any specific location field.
- Removing or modifying the original held item from the inventory does not remove or modify the copy.
- /clear can never remove that item.
- The item drops on death.
Impact:
The most obvious impact of this is an item duplication exploit that's easy to do in survival - simply log out with the item you want to duplicate in your hand, log back in and die to duplicate that item stack.
In our own content, it makes the hasitem={} selector argument unreliable unless location fields are specified. This results in pretty high server time in two of our upcoming maps, due to a command system attempting to replace an item in an inaccessible container slot every tick.
Repro Steps:
- Open a flat world, and clear your inventory.
- Make sure the keepinventory gamerule is false.
- Give yourself a diamond and hold it in your mainhand.
- Save & Quit out of the world, and re-enter it.
- Drop the diamond on the ground
- Run /say @a[hasitem=\{item=diamond}] (JIRA won't let me remove the backslash, just don't include it)
- Run /kill (you must not be in creative mode)
Observed Results:
Step 6 shows your name in chat, even though you've dropped the diamond and no longer have diamonds in your inventory.
Step 7 drops an extra diamond (or however many diamonds you were holding when you entered the world.
Expected Results:
Step 6 should print no players.
Step 7 should not drop an item, when your inventory is supposedly empty.
Regression Build:
Does not occur in 1.20.70
Screenshots / Videos Attached:
Yes. Shows the observed behavior after re-entering the world.{}