Skip to content

Commit 6e97dba

Browse files
committed
fixed broken directory traversal on windows, v1.2.5
1 parent 1a39e19 commit 6e97dba

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
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.
44

55
### Download
6-
* [log4j2-scan 1.2.4 (Windows x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v1.2.4/logpresso-log4j2-scan-1.2.4-win64.7z)
7-
* [log4j2-scan 1.2.4 (Linux x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v1.2.4/logpresso-log4j2-scan-1.2.4-linux.tar.gz)
8-
* [log4j2-scan 1.2.4 (Any OS, 10KB)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v1.2.4/logpresso-log4j2-scan-1.2.4.jar)
6+
* [log4j2-scan 1.2.5 (Windows x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v1.2.5/logpresso-log4j2-scan-1.2.5-win64.7z)
7+
* [log4j2-scan 1.2.5 (Linux x64)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v1.2.5/logpresso-log4j2-scan-1.2.5-linux.tar.gz)
8+
* [log4j2-scan 1.2.5 (Any OS, 10KB)](https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v1.2.5/logpresso-log4j2-scan-1.2.5.jar)
99

1010
### How to use
1111
Just run log4j2-scan.exe or log4j2-scan with target directory path.
@@ -20,7 +20,7 @@ On Linux
2020
```
2121
On UNIX (AIX, Solaris, and so on)
2222
```
23-
java -jar logpresso-log4j2-scan-1.2.4.jar [--fix] [--trace] target_path
23+
java -jar logpresso-log4j2-scan-1.2.5.jar [--fix] [--trace] target_path
2424
```
2525

2626
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. It is necessary to shutdown any running JVM process before applying patch. Start affected JVM process after fix.

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

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

+11-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public enum Status {
2525

2626
private static final String JNDI_LOOKUP_CLASS_PATH = "org/apache/logging/log4j/core/lookup/JndiLookup.class";
2727
private static final String LOG4j_CORE_POM_PROPS = "META-INF/maven/org.apache.logging.log4j/log4j-core/pom.properties";
28+
private static final boolean isWindows = File.separatorChar == '\\';
29+
2830
private long scanDirCount = 0;
2931
private long scanFileCount = 0;
3032
private long vulnerableFileCount = 0;
@@ -34,7 +36,7 @@ public enum Status {
3436

3537
public static void main(String[] args) {
3638
if (args.length < 1) {
37-
System.out.println("Logpresso CVE-2021-44228 Vulnerability Scanner 1.2.4 (2021-12-14)");
39+
System.out.println("Logpresso CVE-2021-44228 Vulnerability Scanner 1.2.5 (2021-12-14)");
3840
System.out.println("Usage: log4j2-scan [--fix] [--force-fix] [--trace] target_path");
3941
System.out.println(" Do not use --force-fix unless you know what you are doing");
4042
return;
@@ -315,7 +317,14 @@ private void traverse(File f, boolean fix, boolean trace) {
315317
private boolean isSymlink(File f) {
316318
try {
317319
String canonicalPath = f.getCanonicalPath();
318-
return f.isDirectory() && !canonicalPath.contains(f.getAbsolutePath());
320+
String absolutePath = f.getAbsolutePath();
321+
322+
if (isWindows) {
323+
canonicalPath = canonicalPath.toUpperCase();
324+
absolutePath = absolutePath.toUpperCase();
325+
}
326+
327+
return f.isDirectory() && !canonicalPath.contains(absolutePath);
319328
} catch (IOException e) {
320329
}
321330

0 commit comments

Comments
 (0)