1.7-1.11.2 Log4j mitigation can be bypassed
The bug
The Log4j 2 RCE mitigation for Minecraft versions 1.7-1.11.2 can be bypassed. The issue is that the used regex pattern uses the dot (.), which by default does not match line breaks. Therefore when the log message contains line breaks it won't be discarded.
This can probably be solved by including the DOTALL flag (?s) at the beginning of the regex pattern. But please have a second look that this indeed solves the issue.
For whatever reason I was only able to reproduce this with the dedicated server. In singleplayer the pattern was logged as well, but was apparently not evaluated.
Reproduction steps
- Download the 1.11 dedicated server
- Download the mitigation log config log4j2_17-111.xml from https://www.minecraft.net/en-us/article/important-message--security-vulnerability-java-edition
- Start the dedicated server with the log config
java "-Dlog4j.configurationFile=log4j2_17-111.xml" -jar server.jar - Join the server
- Type the following in chat
test ${sys:java.home} - Check the log file / console
The text did not appear in the log, as expected. Note: In case it did appear in the log, make sure you correctly started the server with the log config. - Use the following command
/setblock ~ ~ ~ standing_sign default replace {Text1:"{\"text\":\"Click me\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"say ${sys:java.home} \na\"}}",Text2:"[\"\"]",Text3:"[\"\"]",Text4:"[\"\"]"}
- Right-click the sign
- Check the log file / console
The log cotains the substituted value, e.g. "C:\Program Files\..."
Note that this might not be limited to commands.
2021-12-11, 03:33 AM
2021-12-14, 07:55 PM
2021-12-14, 08:01 AM
2
4