Path traversal in player stats file allows an attacker to delete arbitrary JSON files on offline-mode servers
Description
Due to improper sanitization of player name, an attacker is able to delete arbitrary JSON files on offline-mode servers.
In net.minecraft.server.management.PlayerList.java, there is a function called getPlayerStats.
This function returns player stats by reading stats/UUID.json of world folder, and if there is no matching files for the UUID, it tries to migrate stats by using stats/PLAYER_NAME.json.
As migration codes don't sanitize player name, it's possible to perform path traversal by adding ../ into player name.
While ../ can't be added to player names normally, it's possible to use crafted name in offline-mode servers, allowing an attacker to exploit this vulnerability.
Steps to reproduce
For 1.16.5
- Download server.jar: https://www.minecraft.net/ja-jp/article/minecraft-java-edition-1-16-5
- Run server.jar once, and agree to EULA by modifying eula.txt.
- Set online-mode to false in server.properties.
- Download poc.js from this ticket.
- Run "npm install mineflayer" (to install a library used by poc.js)
- Run server.jar and wait for startup.
- Run "node poc.js".
- ops.json will be deleted.
For 1.17 (As mineflayer doesn't support 1.17 yet, you need to run Minecraft client.)
- Run Minecraft 1.17 from Minecraft Launcher.
- While running Minecraft, open %appdata%/.minecraft/bin
- Find newly created directory with random hex characters.
- Create a directory named test under %appdata%/.minecraft
- Copy files inside the directory you found in step3 into %appdata%/.minecraft/test
- Download cmd.txt from this ticket, and open it in text editor.
- Replace all RyotaK to your PC's username.
- Paste it into command prompt, and execute it.
- Download server.jar: https://launcher.mojang.com/v1/objects/0a269b5f2c5b93b1712d0f5dc43b6182b9ab254e/server.jar
- Run server.jar once, and agree to EULA by modifying eula.txt.
- Set online-mode to false in server.properties.
- Run server.jar and wait for startup.
- Join the server with Minecraft client that you started in step 8.
- ops.json will be deleted.
2021-06-08, 09:29 AM
2021-07-27, 04:49 AM
2021-06-15, 06:03 PM
0
1