Skip to content

Commit

Permalink
fixed broken directory traversal on windows, v1.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
xeraph committed Dec 14, 2021
1 parent 1a39e19 commit 6e97dba
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
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.

### Download
* [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)
* [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)
* [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)
* [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)
* [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)
* [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)

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

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.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.logpresso</groupId>
<artifactId>log4j2-scanner</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
<packaging>jar</packaging>
<name>Logpresso Log4j2 Scanner</name>

Expand Down
13 changes: 11 additions & 2 deletions src/main/java/com/logpresso/scanner/Log4j2Scanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public enum Status {

private static final String JNDI_LOOKUP_CLASS_PATH = "org/apache/logging/log4j/core/lookup/JndiLookup.class";
private static final String LOG4j_CORE_POM_PROPS = "META-INF/maven/org.apache.logging.log4j/log4j-core/pom.properties";
private static final boolean isWindows = File.separatorChar == '\\';

private long scanDirCount = 0;
private long scanFileCount = 0;
private long vulnerableFileCount = 0;
Expand All @@ -34,7 +36,7 @@ public enum Status {

public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Logpresso CVE-2021-44228 Vulnerability Scanner 1.2.4 (2021-12-14)");
System.out.println("Logpresso CVE-2021-44228 Vulnerability Scanner 1.2.5 (2021-12-14)");
System.out.println("Usage: log4j2-scan [--fix] [--force-fix] [--trace] target_path");
System.out.println(" Do not use --force-fix unless you know what you are doing");
return;
Expand Down Expand Up @@ -315,7 +317,14 @@ private void traverse(File f, boolean fix, boolean trace) {
private boolean isSymlink(File f) {
try {
String canonicalPath = f.getCanonicalPath();
return f.isDirectory() && !canonicalPath.contains(f.getAbsolutePath());
String absolutePath = f.getAbsolutePath();

if (isWindows) {
canonicalPath = canonicalPath.toUpperCase();
absolutePath = absolutePath.toUpperCase();
}

return f.isDirectory() && !canonicalPath.contains(absolutePath);
} catch (IOException e) {
}

Expand Down

0 comments on commit 6e97dba

Please sign in to comment.