Skip to content

Commit c0395e6

Browse files
committed
Do not remove JndiLookup.class for log4j 2.17.0 (CVE-2021-44832)
1 parent 12500cd commit c0395e6

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
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-44832 (log4j 2.17.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.6.4 (Windows x64, 7z)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.6.4/logpresso-log4j2-scan-2.6.4-win64.7z)
7-
* [log4j2-scan 2.6.4 (Windows x64, zip)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.6.4/logpresso-log4j2-scan-2.6.4-win64.zip)
6+
* [log4j2-scan 2.6.5 (Windows x64, 7z)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.6.5/logpresso-log4j2-scan-2.6.5-win64.7z)
7+
* [log4j2-scan 2.6.5 (Windows x64, zip)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.6.5/logpresso-log4j2-scan-2.6.5-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.6.4 (Linux x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.6.4/logpresso-log4j2-scan-2.6.4-linux.tar.gz)
12-
* [log4j2-scan 2.6.4 (Linux aarch64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.6.4/logpresso-log4j2-scan-2.6.4-linux-aarch64.tar.gz)
11+
* [log4j2-scan 2.6.5 (Linux x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.6.5/logpresso-log4j2-scan-2.6.5-linux.tar.gz)
12+
* [log4j2-scan 2.6.5 (Linux aarch64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.6.5/logpresso-log4j2-scan-2.6.5-linux-aarch64.tar.gz)
1313
* If native executable doesn't work, use the JAR instead. 32bit is not supported.
14-
* [log4j2-scan 2.6.4 (Mac OS)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.6.4/logpresso-log4j2-scan-2.6.4-darwin.zip)
15-
* [log4j2-scan 2.6.4 (Any OS, 620KB)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.6.4/logpresso-log4j2-scan-2.6.4.jar)
14+
* [log4j2-scan 2.6.5 (Mac OS)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.6.5/logpresso-log4j2-scan-2.6.5-darwin.zip)
15+
* [log4j2-scan 2.6.5 (Any OS, 620KB)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v2.6.5/logpresso-log4j2-scan-2.6.5.jar)
1616

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

2323
Usage
2424
```
25-
Logpresso CVE-2021-44228 Vulnerability Scanner 2.6.4 (2021-12-29)
25+
Logpresso CVE-2021-44228 Vulnerability Scanner 2.6.5 (2021-12-29)
2626
Usage: log4j2-scan [--scan-log4j1] [--fix] target_path1 target_path2
2727
2828
-f [config_file_path]
@@ -104,7 +104,7 @@ On Linux
104104
```
105105
On UNIX (AIX, Solaris, and so on)
106106
```
107-
java -jar logpresso-log4j2-scan-2.6.4.jar [--fix] target_path
107+
java -jar logpresso-log4j2-scan-2.6.5.jar [--fix] target_path
108108
```
109109

110110
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. All .bak files are archived into the single zip file which is named by `log4j2_scan_backup_yyyyMMdd_HHmmss.zip`, then deleted safely. In most environments, JNDI lookup feature will not be used. However, you must use this option at your own risk. You can easily restore original vulnerable JAR files using `--restore` option.

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.6.4</version>
9+
<version>2.6.5</version>
1010
<packaging>jar</packaging>
1111
<name>Logpresso Log4j2 Scanner</name>
1212

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

+11-6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.text.SimpleDateFormat;
1212
import java.util.ArrayList;
1313
import java.util.Date;
14+
import java.util.HashSet;
1415
import java.util.List;
1516
import java.util.Set;
1617
import java.util.zip.ZipEntry;
@@ -23,7 +24,7 @@
2324
import com.logpresso.scanner.utils.ZipUtils;
2425

2526
public class Log4j2Scanner {
26-
public static final String VERSION = "2.6.4";
27+
public static final String VERSION = "2.6.5";
2728
public static final String RELEASE_DATE = "2021-12-29";
2829
public static final String BANNER = "Logpresso CVE-2021-44228 Vulnerability Scanner " + VERSION + " (" + RELEASE_DATE + ")";
2930

@@ -309,21 +310,25 @@ private void fix() {
309310
continue;
310311
}
311312

312-
// do not patch if jar has only CVE-2021-45105 vulnerability
313-
String except = "";
313+
// do not patch if jar has only CVE-2021-45105 or CVE-2021-44832 vulnerability
314+
Set<String> exceptCves = new HashSet<String>();
314315
boolean needFix = false;
315316

316317
// report entries are added by original file. beware of symbolic link case
317318
List<ReportEntry> entries = detector.getReportEntries(vf.getFile());
318319
for (ReportEntry entry : entries) {
319-
if (entry.getCve().equals("CVE-2021-45105"))
320-
except = " (except CVE-2021-45105)";
320+
String cve = entry.getCve();
321+
if (cve.equals("CVE-2021-45105") || cve.equals("CVE-2021-44832"))
322+
exceptCves.add(cve);
321323
else
322324
needFix = true;
323325
}
324326

327+
String except = " (except " + StringUtils.join(exceptCves, ", ") + ")";
328+
325329
if (!needFix) {
326-
System.out.printf("Cannot fix CVE-2021-45105, Upgrade it: %s%s%n", f.getAbsolutePath(), symlinkMsg);
330+
System.out.printf("Cannot fix " + StringUtils.join(exceptCves, ", ") + ", Upgrade it: %s%s%n",
331+
f.getAbsolutePath(), symlinkMsg);
327332
continue;
328333
}
329334

src/main/java/com/logpresso/scanner/utils/StringUtils.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.logpresso.scanner.utils;
22

3+
import java.util.Collection;
34
import java.util.List;
45

56
public class StringUtils {
@@ -13,7 +14,7 @@ public static String toString(List<String> pathChain) {
1314
return join(pathChain, " > ");
1415
}
1516

16-
public static String join(List<String> tokens, String separator) {
17+
public static String join(Collection<String> tokens, String separator) {
1718
StringBuilder sb = new StringBuilder();
1819
int i = 0;
1920

0 commit comments

Comments
 (0)