Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Dlog4j2.formatMsgNoLookups=true in JVM?

In one of my computers, there is JRE 1.8.0_45 and in another machine there is OpenJDK.

I want to set the JVM flag Dlog4j2.formatMsgNoLookups=true, but where can I write this piece of configuration?

like image 612
Simant Avatar asked Dec 11 '21 09:12

Simant


People also ask

What does formatMsgNoLookups true do?

formatMsgNoLookups=true that can mitigate the issue after a restart, which is the default behavior in the patched Log4j 2.15. 0 version. You want this setting to stop your log messages from being evaluated to block this attack.


1 Answers

If possible, upgrade to Log4j version 2.15.0.

If upgrading is not possible, then ensure the -Dlog4j2.formatMsgNoLookups=true system property is set. Use the this command:

java -Dlog4j2.formatMsgNoLookups=true -jar myapp.jar

Also worth reading on mitigation:

  • Log4J2 Vulnerability and Spring Boot
  • Inside the Log4j2 vulnerability (CVE-2021-44228)
like image 76
Raghu Reddy Avatar answered Oct 17 '22 09:10

Raghu Reddy