Skip to content

Commit 5ac0ce5

Browse files
committed
Added missing mitigated tag for log4j1 and logback detection.
1 parent 4a4d034 commit 5ac0ce5

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
log4j2-scan is a single binary command-line tool for CVE-2021-44228 vulnerability scanning and mitigation patch. It also supports nested JAR file scanning and patch. It also detects CVE-2021-45046 (log4j 2.15.0), CVE-2021-45105 (log4j 2.16.0), CVE-2021-4104 (log4j 1.x), and CVE-2021-42550 (logback 0.9-1.2.7) vulnerabilities.
44

55
### Download
6-
* [log4j2-scan 2.3.0 (Windows x64, 7z)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.3.0/logpresso-log4j2-scan-2.3.0-win64.7z)
7-
* [log4j2-scan 2.3.0 (Windows x64, zip)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.3.0/logpresso-log4j2-scan-2.3.0-win64.zip)
6+
* [log4j2-scan 2.3.1 (Windows x64, 7z)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.3.1/logpresso-log4j2-scan-2.3.1-win64.7z)
7+
* [log4j2-scan 2.3.1 (Windows x64, zip)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.3.1/logpresso-log4j2-scan-2.3.1-win64.zip)
88
* If you get `VCRUNTIME140.dll not found` error, install [Visual C++ Redistributable](https://docs.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170).
99
* If native executable doesn't work, use the JAR instead. 32bit is not supported.
1010
* 7zip is available from www.7zip.org, and is open source and free.
11-
* [log4j2-scan 2.3.0 (Linux x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.3.0/logpresso-log4j2-scan-2.3.0-linux.tar.gz)
11+
* [log4j2-scan 2.3.1 (Linux x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.3.1/logpresso-log4j2-scan-2.3.1-linux.tar.gz)
1212
* If native executable doesn't work, use the JAR instead. 32bit is not supported.
13-
* [log4j2-scan 2.3.0 (Any OS, 20KB)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.3.0/logpresso-log4j2-scan-2.3.0.jar)
13+
* [log4j2-scan 2.3.1 (Any OS, 20KB)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.3.1/logpresso-log4j2-scan-2.3.1.jar)
1414

1515
### Build
1616
* [How to build Native Image](https://github.com/logpresso/CVE-2021-44228-Scanner/wiki/FAQ#how-to-build-native-image)
@@ -20,7 +20,7 @@ Just run log4j2-scan.exe or log4j2-scan with target directory path. The logpress
2020

2121
Usage
2222
```
23-
Logpresso CVE-2021-44228 Vulnerability Scanner 2.3.0 (2021-12-18)
23+
Logpresso CVE-2021-44228 Vulnerability Scanner 2.3.1 (2021-12-18)
2424
Usage: log4j2-scan [--fix] target_path1 target_path2
2525
2626
-f [config_file_path]
@@ -81,7 +81,7 @@ On Linux
8181
```
8282
On UNIX (AIX, Solaris, and so on)
8383
```
84-
java -jar logpresso-log4j2-scan-2.3.0.jar [--fix] target_path
84+
java -jar logpresso-log4j2-scan-2.3.1.jar [--fix] target_path
8585
```
8686

8787
If you add `--fix` option, this program will copy vulnerable original JAR file to .bak file, and create new JAR file without `org/apache/logging/log4j/core/lookup/JndiLookup.class` entry. In most environments, JNDI lookup feature will not be used. However, you must use this option at your own risk. Depending the Operating System:

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<modelVersion>4.0.0</modelVersion>
77
<groupId>com.logpresso</groupId>
88
<artifactId>log4j2-scanner</artifactId>
9-
<version>2.3.0</version>
9+
<version>2.3.1</version>
1010
<packaging>jar</packaging>
1111
<name>Logpresso Log4j2 Scanner</name>
1212

src/main/java/com/logpresso/scanner/Detector.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -223,23 +223,23 @@ private DetectResult scanStream(File jarFile, InputStream is, List<String> pathC
223223
}
224224

225225
if (log4j1Version != null) {
226-
printDetectionForLog4j1(jarFile, pathChain, log4j1Version);
226+
printDetectionForLog4j1(jarFile, pathChain, log4j1Version, !foundJmsAppender);
227227
if (foundJmsAppender)
228228
result.setPotentiallyVulnerableLog4j1();
229229
else
230230
result.setMitigated();
231231
} else if (foundJmsAppender) {
232-
printDetectionForLog4j1(jarFile, pathChain, POTENTIALLY_VULNERABLE);
232+
printDetectionForLog4j1(jarFile, pathChain, POTENTIALLY_VULNERABLE, false);
233233
}
234234

235235
if (logbackVersion != null) {
236-
printDetectionForLogback(jarFile, pathChain, logbackVersion);
236+
printDetectionForLogback(jarFile, pathChain, logbackVersion, !foundJndiUtil);
237237
if (foundJndiUtil)
238238
result.setPotentiallyVulnerableLogback();
239239
else
240240
result.setMitigated();
241241
} else if (foundJndiUtil) {
242-
printDetectionForLogback(jarFile, pathChain, POTENTIALLY_VULNERABLE);
242+
printDetectionForLogback(jarFile, pathChain, POTENTIALLY_VULNERABLE, false);
243243
}
244244

245245
return result;
@@ -328,23 +328,29 @@ else if (version.startsWith("2.16.") || version.equals("2.12.2"))
328328
addReport(jarFile, pathChain, version, mitigated, potential);
329329
}
330330

331-
private void printDetectionForLog4j1(File jarFile, List<String> pathChain, String version) {
331+
private void printDetectionForLog4j1(File jarFile, List<String> pathChain, String version, boolean mitigated) {
332332
String path = jarFile.getAbsolutePath();
333333
if (pathChain != null && !pathChain.isEmpty())
334334
path += " (" + StringUtils.toString(pathChain) + ")";
335335

336336
String msg = "[?] Found CVE-2021-4104 (log4j 1.2) vulnerability in " + path + ", log4j " + version;
337+
if (mitigated)
338+
msg += " (mitigated)";
339+
337340
System.out.println(msg);
338341

339342
addReport(jarFile, pathChain, version, false, true);
340343
}
341344

342-
private void printDetectionForLogback(File jarFile, List<String> pathChain, String version) {
345+
private void printDetectionForLogback(File jarFile, List<String> pathChain, String version, boolean mitigated) {
343346
String path = jarFile.getAbsolutePath();
344347
if (pathChain != null && !pathChain.isEmpty())
345348
path += " (" + StringUtils.toString(pathChain) + ")";
346349

347350
String msg = "[?] Found CVE-2021-42550 (logback 1.2.7) vulnerability in " + path + ", logback " + version;
351+
if (mitigated)
352+
msg += " (mitigated)";
353+
348354
System.out.println(msg);
349355

350356
addReport(jarFile, pathChain, version, false, true);

src/main/java/com/logpresso/scanner/Log4j2Scanner.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import com.logpresso.scanner.utils.ZipUtils;
1616

1717
public class Log4j2Scanner {
18-
private static final String BANNER = "Logpresso CVE-2021-44228 Vulnerability Scanner 2.3.0 (2021-12-19)";
18+
private static final String BANNER = "Logpresso CVE-2021-44228 Vulnerability Scanner 2.3.1 (2021-12-19)";
1919

2020
private static final boolean isWindows = File.separatorChar == '\\';
2121

0 commit comments

Comments
 (0)