Skip to content

Commit 7b25634

Browse files
committed
dmg's toc pr (but squashed)
see: origin/dmg_toc
1 parent f325fca commit 7b25634

File tree

3 files changed

+75
-45
lines changed

3 files changed

+75
-45
lines changed

README.md

Lines changed: 75 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
1-
# log4j-detector
1+
<div style="text-align: right"><img src='mergebase-small.png'></div>
2+
3+
# Log4-detector
24

35
Detects Log4J versions on your file-system within any application that are vulnerable to [CVE-2021-44228](https://mergebase.com/vulnerability/CVE-2021-44228/) and [CVE-2021-45046](https://mergebase.com/vulnerability/CVE-2021-45046/). It is able to even find instances that are hidden several layers deep. Works on Linux, Windows, and Mac, and everywhere else Java runs, too!
46

5-
Currently reports `log4j-core` versions 2.12.2 and 2.17.0 as **\_SAFE\_**, 2.15.0 and 2.16.0 as **\_OKAY\_** and all other versions as **\_VULNERABLE\_**
7+
# Table of Contents
8+
- [Introduction](#itemdetector)
9+
- [Example Usage](#itemexample)
10+
- [More Example Usage](#itemmore)
11+
- [Understanding The Results](#itemresults)
12+
- [Usage](#itemusage)
13+
- [Build From Source ](#itembuild)
14+
- [Testing](#itemtesting)
15+
- [License](#itemlicense)
16+
- [Frequently Asked Questions](#faq)
17+
- [How Does It Work?](#itemwork)
18+
- [This Scanner Only Reports Hits Against The `log4j-core` Library. What About `log4j-api`? ](#itemapi)
19+
- [Why Report About 2.10.0, 2.15.0, and 2.16.0 ? ](#item2.10.0)
20+
- [What are those "file1.war!/path/to/file2.zip!/path/to/file3.jar!/path/to/log4j.jar" results about? ](#itemwar)
21+
- [What About Log4J 1.2.x ?](#item1.2.x)
22+
- [How Can I Be Sure This Isn't A Trojan Pretending To Be A Log4J Detector?](#itemtrojan)
23+
- [What Is MergeBase All About?](#item)
24+
25+
26+
27+
# Introduction <a name="itemdetector"></a>
28+
29+
Currently reports `log4j-core` versions 2.12.2 and 2.16.0 as **\_SAFE\_**, 2.15.0 as **\_OKAY\_** and all other versions as **\_VULNERABLE\_**
630
(although it does report pre-2.0-beta9 as "**\_POTENTIALLY_SAFE\_**").
731

832
Can correctly detect log4j inside executable spring-boot jars/wars, dependencies blended
@@ -11,13 +35,13 @@ exploded jar files just sitting uncompressed on the file-system (aka *.class).
1135

1236
We currently maintain a collection of [log4j-samples](https://github.com/mergebase/log4j-samples) we use for testing.
1337

14-
# Example Usage:
38+
# Example Usage: <a name="itemexample"></a>
1539

1640
java -jar log4j-detector-2021.12.20.jar [path-to-scan] > hits.txt
1741

1842
![Terminal output from running java -jar log4j-detector.jar in a terminal](./log4j-detector.png)
1943

20-
# More Example Usage:
44+
# More Example Usage: <a name="itemmore"></a>
2145

2246
```
2347
java -jar log4j-detector-2021.12.20.jar ./samples
@@ -37,52 +61,24 @@ java -jar log4j-detector-2021.12.20.jar ./samples
3761
/opt/mergebase/log4j-detector/samples/log4j-core-2.12.2.jar contains Log4J-2.x >= 2.12.2 _SAFE_ :-)
3862
/opt/mergebase/log4j-detector/samples/log4j-core-2.14.1.jar contains Log4J-2.x >= 2.10.0 _VULNERABLE_ :-(
3963
/opt/mergebase/log4j-detector/samples/log4j-core-2.15.0.jar contains Log4J-2.x >= 2.15.0 _OKAY_ :-|
40-
/opt/mergebase/log4j-detector/samples/log4j-core-2.16.0.jar contains Log4J-2.x >= 2.16.0 _OKAY_ :-)
41-
/opt/mergebase/log4j-detector/samples/log4j-core-2.17.0.jar contains Log4J-2.x >= 2.16.0 _SAFE_ :-)
64+
/opt/mergebase/log4j-detector/samples/log4j-core-2.16.0.jar contains Log4J-2.x >= 2.16.0 _SAFE_ :-)
4265
/opt/mergebase/log4j-detector/samples/log4j-core-2.4.1.jar contains Log4J-2.x >= 2.0-beta9 (< 2.10.0) _VULNERABLE_ :-(
4366
/opt/mergebase/log4j-detector/samples/log4j-core-2.9.1.jar contains Log4J-2.x >= 2.0-beta9 (< 2.10.0) _VULNERABLE_ :-(
4467
```
4568

46-
# Understanding The Results
69+
# Understanding The Results <a name="itemresults"></a>
4770

4871
**\_VULNERABLE\_** -> You need to upgrade or remove this file.
4972

50-
**\_OKAY\_** -> We only report this for Log4J versions 2.15.0 and 2.16.0. We recommend upgrading to 2.17.0.
73+
**\_OKAY\_** -> We only report this for Log4J version 2.15.0. We recommend upgrading to 2.16.0.
5174

52-
**\_SAFE\_** -> We currently only report this for Log4J versions 2.17.0 and 2.12.2.
75+
**\_SAFE\_** -> We currently only report this for Log4J versions 2.16.0 and 2.12.2.
5376

54-
**\_OLD\_** -> You are safe from CVE-2021-44228, but should plan to upgrade because Log4J 1.2.x has been EOL for 7 years and has several known-vulnerabilities.
77+
**\_OLD\_** -> You are safe from CVE-2021-44228, but should plan to upgrade because Log4J 1.2.x has been EOL for 10 years and has several known-vulnerabilities.
5578

5679
**\_POTENTIALLY_SAFE\_** -> The "JndiLookup.class" file is not present, either because your version of Log4J is very old (pre 2.0-beta9), or because someone already removed this file. Make sure it was someone in your team or company that removed "JndiLookup.class" if that's the case, because attackers have been known to remove this file themselves to prevent additional competing attackers from gaining access to compromised systems.
5780

58-
# This Scanner Only Reports Hits Against The `log4j-core` Library. What About `log4j-api`?
59-
60-
Many scanners (including GitHub's own [Dependabot](https://github.com/dependabot)) currently report both "`log4j-core`" and "`log4j-api`" libraries as vulnerable. These scanners are incorrect. There is currently no existing version of the "`log4j-api`" library that can be exploited by any of these vulnerabilities.
61-
62-
# Why Report About 2.10.0, 2.15.0, 2.16.0, and 2.17.0 ?
63-
64-
We consider version 2.10.0 important because that's the first version where Log4J's vulnerable "message lookup feature" can be disabled via Log4J configuration.
65-
66-
We consider versions 2.15.0 and 2.16.0 important because these are the first versions where Log4J's default out-of-the-box configuration is not vulnerable to CVE-2021-44228.
67-
68-
And version 2.17.0 is important because it's not vulnerable to CVE-2021-45046. Despite CVE-2021-45046 being much less serious,
69-
we anticipate everyone will want to patch to 2.17.0.
70-
71-
# What are those "file1.war!/path/to/file2.zip!/path/to/file3.jar!/path/to/log4j.jar" results about?
72-
73-
The "!" means the log4j-detector entered a zip archive (e.g., *.zip, *.ear, *.war, *.aar, *.jar). Since zip files can
74-
contain zip files, a single result might contain more than one "!" indicator in its result.
75-
76-
Note: the log4j-detector only recursively enters zip archives. It does not enter tar or gz or bz2, etc. The main reason
77-
being that Java systems are often configured to execute jars inside jars, but they are never configured to execute other
78-
file formats (that I know of!). And so a log4j copy inside a *.tar.gz is probably not reachable for a running Java
79-
system, and hence, not a vulnerability worth reporting.
80-
81-
2nd note: for zips-inside-zips our scanner does load the inner-zip completely into memory (using ByteArrayInputStream)
82-
before attempting to scan it. You might need to give Java some extra memory if you have extremely large inner-zips on
83-
your system (e.g., 1 GB or larger).
84-
85-
# Usage
81+
# Usage <a name="itemusage"></a>
8682

8783
```
8884
java -jar log4j-detector-2021.12.20.jar
@@ -98,42 +94,76 @@ Docs - https://github.com/mergebase/log4j-detector
9894
(C) Copyright 2021 Mergebase Software Inc. Licensed to you via GPLv3.
9995
```
10096

101-
# Build From Source:
97+
# Build From Source: <a name="itembuild"></a>
10298

10399
```
104100
git clone https://github.com/mergebase/log4j-detector.git
105101
cd log4j-detector/
106102
mvn install
107103
java -jar target/log4j-detector-2021.12.20.jar
108104
```
109-
# Testing:
105+
# Testing: <a name="itemtesting"></a>
110106

111107
We maintain a collection of log4j samples here: https://github.com/mergebase/log4j-samples
112108

113-
# License
109+
# License <a name="itemlicense"></a>
114110

115111
GPL version 3.0
116112

117-
# How Does It Work?
113+
# Frequently Asked Questions <a name="faq"></a>
114+
115+
# How Does It Work? <a name="itemwork"></a>
118116

119117
The Java compiler stores String literals directly in the compiled *.class files. If log4j-detector detects a file
120118
named "JndiManager.class"
121119
on your file-system, it then examines that file for this String: "Invalid JNDI URI - {}". Turns out that specific String
122120
literal is only present in the patched version of Log4J (version 2.15.0). Any versions of Log4J without that String are
123121
vulnerable.
124122

125-
# What About Log4J 1.2.x ?
123+
## This Scanner Only Reports Hits Against The `log4j-core` Library. What About `log4j-api`? <a name="itemapi"></a>
124+
125+
Many scanners (including GitHub's own [Dependabot](https://github.com/dependabot)) currently report both "`log4j-core`" and "`log4j-api`" libraries as vulnerable. These scanners are incorrect. There is currently no existing version of the "`log4j-api`" library that can be exploited by any of these vulnerabilities.
126+
127+
At [MergeBase](https://mergebase.com/) we pride ourselves on our scan accuracy. You're already busy enough patching and defending your systems. We don't want you to waste your time with false positives. That's why we don't report any hits against `log4j-api`.
128+
129+
130+
## Why Report About 2.10.0, 2.15.0, and 2.16.0 ? <a name="item2.10.0"></a>
131+
132+
We consider version 2.10.0 important because that's the first version where Log4J's vulnerable "message lookup feature" can be disabled via Log4J configuration.
133+
134+
We consider version 2.15.0 important because that's the first version where Log4J's default out-of-the-box configuration is not vulnerable to CVE-2021-44228.
135+
136+
And version 2.16.0 is important because it's not vulnerable to CVE-2021-45046. Despite CVE-2021-45046 being much less serious,
137+
we anticipate everyone will want to patch to 2.16.0.
138+
139+
## What are those "file1.war!/path/to/file2.zip!/path/to/file3.jar!/path/to/log4j.jar" results about? <a name="itemwar"></a>
140+
141+
The "!" means the log4j-detector entered a zip archive (e.g., *.zip, *.ear, *.war, *.aar, *.jar). Since zip files can
142+
contain zip files, a single result might contain more than one "!" indicator in its result.
143+
144+
Note: the log4j-detector only recursively enters zip archives. It does not enter tar or gz or bz2, etc. The main reason
145+
being that Java systems are often configured to execute jars inside jars, but they are never configured to execute other
146+
file formats (that I know of!). And so a log4j copy inside a *.tar.gz is probably not reachable for a running Java
147+
system, and hence, not a vulnerability worth reporting.
148+
149+
2nd note: for zips-inside-zips our scanner does load the inner-zip completely into memory (using ByteArrayInputStream)
150+
before attempting to scan it. You might need to give Java some extra memory if you have extremely large inner-zips on
151+
your system (e.g., 1 GB or larger).
152+
153+
## What About Log4J 1.2.x ? <a name="item1.2.x"></a>
126154

127155
Only versions of Log4J 2.x (from 2.0-beta9 to 2.14.1) are vulnerable to CVE-2021-44228.
128156

129-
# How Can I Be Sure This Isn't A Trojan Pretending To Be A Log4J Detector?
157+
## How Can I Be Sure This Isn't A Trojan Pretending To Be A Log4J Detector? <a name="itemtrojan"></a>
130158

131159
Great question! Since we include the complete source code here in Github (all 750 lines of Java), as well as the steps
132160
to build it, and since this tool has zero dependencies, it shouldn't take too long to carefully study the code to your
133161
satisfaction. If you don't trust Maven you can go directly into the "src/main/java/com/mergebase/log4j" directory and
134162
type "javac \*.java". That works, too!
135163

136-
# What Is MergeBase All About?
164+
# What Is MergeBase All About? <a name="itemmergebase"></a>
165+
166+
![MergeBase](mergebase-small.png)
137167

138168
[MergeBase](https://mergebase.com/) is an SCA company (Software Composition Analysis) based in Vancouver, Canada. We're
139169
similar to companies like Snyk, Sonatype, Blackduck, etc., in that we help companies detect and manage vulnerable

mergebase-small.png

8.93 KB
Loading

mergebase.png

18.1 KB
Loading

0 commit comments

Comments
 (0)