Software Composition Analysis (SCA) tools are notoriously unopinionated: if a vulnerable package exists inside your build artifact, you get a critical alert regardless of whether the flawed path can ever be executed. During high-profile disclosures like Log4Shell (CVE-2021-44228), this lack of context creates operational panic. Security teams scramble to patch thousands of microservices, many of which only include the vulnerable library as an unused transitive dependency or invoke safe sub-components.
Triaging a critical dependency CVE requires moving beyond bill-of-materials scanning to reachability analysis. To determine if an application is exposed, you must answer three core questions: Is the vulnerable library loaded at runtime? Does application code pass user-controlled input into the affected module? And can protocol-level side effects be safely verified without deploying dangerous payloads?
Reading the Advisory and Patch Diff
When analyzing a critical dependency flaw, vendor advisories provide context, but the git commit diff reveals the actual mechanical vulnerability. In CVE-2021-44228, the core vulnerability exists in Apache Log4j2’s log4j-core library, where string message formatters recursively evaluate nested expressions, including Java Naming and Directory Interface (JNDI) lookups.
Comparing log4j-core version 2.14.1 with 2.15.0 shows where the underlying control failed:
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/JndiManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/JndiManager.java
public synchronized Context getContext() {
- return this.context;
+ if (context == null) {
+ return null;
+ }
+ // Restrictions added to limit allowed protocols and host destinations
+ return context;
}
public synchronized Object lookup(final String name) throws NamingException {
+ String lowerName = name.toLowerCase(Locale.ENGLISH);
+ if (!lowerName.startsWith("java:")) {
+ // Log warning and reject protocol if not explicitly allowed
+ LOGGER.warn("JNDI lookup disallowed for protocol: {}", name);
+ return null;
+ }
return this.context.lookup(name);
}
The diff highlights two structural failures:
- Unrestricted Evaluation: The message lookup parser inside
StrSubstitutorautomatically resolved expressions like${jndi:ldap://...}without validating the URI protocol or target host destination. - Implicit Reachability: Any application path logging user input via methods like
logger.info(userInput)orlogger.error("Failed login for header: {}", requestHeader)passed untrusted strings directly into the substitution engine.
To confirm if your application artifact includes the affected component, inspect the dependency graph using native build tooling rather than relying solely on file-path searches:
# For Maven projects: Check transitive inclusion of log4j-core
mvn dependency:tree -Dincludes=org.apache.logging.log4j:log4j-core
# For Gradle projects: Inspect runtime classpath configurations
./gradlew dependencies --configuration runtimeClasspath | grep log4j-core
If the project uses log4j-api without log4j-core (or routes logging to Simple Logging Facade for Java [SLF4J] backends like Logback), the application is not vulnerable to CVE-2021-44228 because the string substitution engine resides strictly within log4j-core.
Building a Safe Lab Harness for Reachability Testing
Once dependency inclusion is confirmed, verify whether user input reaches the logger without triggering remote code execution. Never test exposure by pointing JNDI strings to external public callback infrastructure or deploying weaponized Java object payloads. Instead, construct a local isolated lab harness to measure protocol interaction safely.
Set up a test container running a minimal Java Spring Boot application that logs an incoming HTTP header:
@RestController
public class VulnerableController {
private static final Logger logger = LogManager.getLogger(VulnerableController.class);
@GetMapping("/api/v1/resource")
public ResponseEntity<String> handleRequest(@RequestHeader("X-Api-Version") String apiVersion) {
// Direct injection point: User header logged directly via Log4j2
logger.info("Processing API request version: {}", apiVersion);
return ResponseEntity.ok("Request processed");
}
}
To validate reachability safely:
- Run a local packet capture tool (
tcpdumpor Wireshark) on the container’s loopback interface, listening for DNS (port 53) or TCP connection attempts on an unassigned port (e.g., port 1389). - Execute a non-destructive curl request carrying a JNDI syntax string targeted strictly at
127.0.0.1:
curl -H "X-Api-Version: \${jndi:ldap://127.0.0.1:1389/a}" http://localhost:8080/api/v1/resource
- Observe loopback telemetry. If the application attempts an outbound TCP SYN packet to
127.0.0.1:1389immediately upon processing the request, the execution path is confirmed reachable. This proves that untrusted data reaches the vulnerable JNDI lookup routine without needing to execute a payload or contact external hosts.
Telemetry, Detection, and Threat Hunting
Detecting reachability probes and exploitation attempts requires correlated monitoring across web access logs, application execution logs, and network egress telemetry.
Log Sources and Fields
- Web Application Logs / WAF Logs: Look at
cs-method,cs-uri-stem,cs(User-Agent), and custom header fields. - Java Application Logs: Standard stdout/stderr streams displaying unparsed JNDI string exceptions or lookup errors.
- Network Egress Telemetry: Firewall and DNS logs tracking outbound connections from application subnets to non-standard ports.
Detection Queries
Splunk SPL (Web Request Header Probe Detection):
index=web_logs OR index=waf
| eval raw_payload=urldecode(_raw)
| search raw_payload="*${jndi:*" OR raw_payload="*${${lower:*"
| stats count by src_ip, uri_path, http_user_agent, raw_payload
KQL (Azure Sentinel / Defender for Endpoint - Outbound JNDI Egress):
NetworkCommunicationEvents
| where InitiatingProcessFileName in~ ("java.exe", "java")
| where RemotePort in (389, 636, 1099, 1389)
| project Timestamp, DeviceName, InitiatingProcessCommandLine, RemoteIP, RemotePort
Sigma Rule Fragment (JNDI Expansion Pattern):
title: Log4j JNDI Lookup Attempt
status: stable
logsource:
category: webserver
detection:
selection:
c-uri|contains: '${jndi:'
c-useragent|contains: '${jndi:'
condition: selection
falsepositives:
- Internal vulnerability scanners or authorized reachability tests.
Note on False Positives: Security scanners and automated canary tokens will trigger string-matching rules frequently. Correlate raw string matches in web logs with outbound network egress events from the JVM process to isolate true positive exposures from superficial probes.
Remediating the Vulnerability: Evaluating Strategy Options
When a critical dependency vulnerability hits production systems, choose a mitigation strategy based on deployment speed and operational risk.
+-------------------------------------------------------------------+
| Remediation Strategy |
+-------------------------------------------------------------------+
| Option 1: Direct Dependency Upgrade (Gold Standard) |
| -> Bump log4j-core to >= 2.17.1 |
| |
| Option 2: Class Removal / Environment Mitigation (Stopgap) |
| -> Set LOG4J_FORMAT_MSG_NO_LOOKUPS=true (2.10 - 2.14.1) |
| -> Strip org/apache/logging/log4j/core/lookup/JndiLookup.class |
| |
| Option 3: WAF / Edge Filtering (Defense-in-Depth Only) |
| -> Block requests containing '${jndi:' |
| * Warning: Easily bypassed via nested string evaluation |
+-------------------------------------------------------------------+
1. Direct Dependency Upgrade (Recommended)
Update the build manifest (pom.xml or build.gradle) to target a patched version (2.17.1 or later for Log4j2). This permanently replaces the vulnerable lookup engine.
2. Runtime & Class Mitigation
If an immediate rebuild is blocked by release cycles, apply environment or artifact modifications:
- System Property / Environment Flag: For Log4j versions
2.10.0to2.14.1, set JVM flag-Dlog4j2.formatMsgNoLookups=trueor set environment variableLOG4J_FORMAT_MSG_NO_LOOKUPS=true. - Bytecode / Archive Modification: Zip-delete the JNDI lookup class directly from the compiled JAR file:
zip -q -d log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class
3. WAF and Edge Inspection (Temporary Layer)
Deploying edge WAF rules to block ${jndi: strings buys time, but it must not be the sole control. Obfuscation techniques—such as ${${lower:j}ndi:...} or ${${env:BAR:-j}ndi:...}—easily bypass simple string-matching rules on unpatched backends. Treat edge filtering strictly as temporary defense-in-depth while executing class removal or dependency upgrades.
Related content
Auditing gRPC APIs: Schema Reflection, Fuzzing, and Auth Flaws
ResearchBreaking and Fixing LLM Integrations: Practical Injection and Defense
ResearchA Triage Framework for Dark Web Alerts That Won't Burn Out Your SOC
ResearchAnatomy of a Modern Supply Chain Attack — And Where Defenses Actually Break
Want a second set of eyes on your security posture?
Let's talk about where your real exposure is.
Book an advisory call