Skip to content

Instantly share code, notes, and snippets.

Last active December 14, 2021 11:23
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?

Log4Shell LDAP attack vectors on recent Java versions

This is simply wrong in the Lunasec Log4Shell blog post

JDK versions greater than 6u211, 7u201, 8u191, and 11.0.1 are not affected by the LDAP attack vector.

The LDAP attack vector exists. There are several forms of LDAP attack vectors:

  • leakage of system properties and environment properties with LDAP calls
  • possible DoS attacks with LDAP calls
  • LDAP deserialization attacks resulting to RCE

Using LDAP calls to leak information about environment variables and system properties



Notice, there are several evasion techniques, some examples:

  • ${${::-j}${::-n}${::-d}${::-i}:${::-l}${::-d}${::-a}${::-p}://}
  • ${${lower:-j}${lower:-n}${lower:-d}${lower:-i}:${lower:-l}${lower:-d}${lower:-a}${lower:-p}://}

Finding out what could have been leaked

  • Listing system properties of an active Java process

    • Use jinfo -sysprops <pid> to list system properties
  • Listing environment variables

    • On Linux, you can list environment variables available in a process with cat /proc/<pid>/environ | xargs -0 -n 1 echo

For docker / k8s containers without a shell or when jinfo doesn't exist, you can use with the properties command. jattach could be run on the docker host / k8s node. The cat /proc/<pid>/environ | xargs -0 -n 1 echo solution works also on the docker host / k8s node. The pid is the host pid in that case.

LDAP deserialization attacks resulting to RCE

This is one of the points of the blog post PSA: Log4Shell and the current state of JNDI injection , it contains references to other sources with more details (f.e. Exploiting JNDI injections in JDK 1.8.0_191+).

LDAP deserialization attacks are possible even on latest Java versions. Deserialization is enabled by default. It can be disabled on most recent Java versions. For example with system properties

"-Djdk.serialFilter=!*" "-Djdk.jndi.object.factoriesFilter=!*" "-Dcom.sun.jndi.ldap.object.trustSerialData=false"

could be used to disable remote object deserialization when using LDAP over JNDI. These settings could break applications depending on the serialization being enabled and using JNDI. The javadocs in JDK17 contain more information:

There's also Java Serialization Filtering documentation and JEPS-290 . The controls are featured at least in:

Other information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment