← Java / Spring · Contents

JAVA-039 / Advanced

Log4Shell (Log4j2 JNDI lookup)

A06:2021 Vulnerable and Outdated Components · CWE-917 / CWE-20 · CWE-502 related

Why is this a problem?

${jndi:ldap://...} in log messages leads to remote code execution.

How to fix it

xml
<!-- log4j-core 2.17.1 or later (Java 8); beware bypasses of JNDI lookup disabling in 2.16 and earlier -->
<dependency><groupId>org.apache.logging.log4j</groupId><artifactId>log4j-core</artifactId><version>2.17.1</version></dependency>

Further reading