/log4j-test

Demonstration of CVE-2021-44228 with a possible strategic fix.

Primary LanguageJava

Simple Example showing CVE-2021-44228 in action

Explanation

  • To reproduce this issue, I am removing the transitive dependency for logging from SpringBoot.
  • Instead, I am bringing in spring-boot-starter-log4j2
  • spring-boot-starter-log4j2 brings in log4j-core which has the remote code exploit (RCE) vulnerability.

Running API

  • Either run the command ./gradlew clean build bootRun in a terminal OR
  • Right click and click run in Log4TestApplication.java.

What happens when you pass in the JNDI value?

  • Because we are resolving to a non-existent site, we get a ConnectException.
  • But, imagine the possibilities if this was an actual malicious server!

img.png

Possible fix?

References: