Scan and patch tool for CVE-2021-44228 and related log4j concerns.

Overview

A Log4J2 CVE-2021-44228 Vulnerability Scanner and Patcher

Links to download the latest version:

Linux x64 with glibc2.17+ (RHEL7+) Windows & all other platforms
Download Linux binary Download Java .jar

What is this

This project is an early fork of logpresso/CVE-2021-44228-Scanner, initially modified to recursively inspect archives and to add support for tar/gz compression. Since the fork, the project has evolved in parallel to the original and implements many similar features, even though the majority of the code has been rewritten. While the original 'fix' functionality has been replaced with a patch method that supports some deep nested edge cases and is more tolerant to failure & rollback, the detection mechanism (the scan command) continues to work in a very similar way to the original.

How do I get it

You can download a version of the tool from the Releases page or by following the links at the top of this page. The native image is a standalone executable that will run on EL7 and later. The jar file can be run with java -jar on JRE 1.8+. This is currently the best way to run this on other platforms and older releases of glibc (including Windows, AIX, Solaris, etc).

After downloading the native image it's necessary to chmod +x the file before it can be run.

How do I use it

The command syntax is the same regardless of whether you call the .jar or the native executable. For example, this:

./loguccino help

is functionally identical to this

java -jar ./loguccino-all.jar help

The loguccino help command provides documentation on commands that are available.

Scanning for vulnerable .jars

./loguccino scan /path/to/approot 

This will traverse all subdirectories in /path/to/approot, including recursively traversing all nested .tar.gz, .tgz, .tar, .zip, .ear, .war and .jar archives.

A .csv file by the name of loguccino-scan-[datetime].csv will be created in the working directory, containing the following data:

  • AffectedFile is the full path on the filesystem to the file that was found to contain the vulnerability. Example value: /opt/sas/config/Lev1/Web/Staging/sas.webreportstudio4.4.21w47AIX.ear/install/deploy/21w47SASConfig/Lev5/Web/Staging/sas.webreportstudio4.4.21w47AIX.ear
  • NestedPath is the path within the archived file where the vulnerability was found. For example, here the log4j-core-2.1.jar file was found in the WRS .war archive, packaged inside the .ear archive (AffectedFile above) opt/sas/config/Lev1/Web/Staging/sas.webreportstudio4.4.21w47AIX.ear::sas.webreportstudio.war::WEB-INF/lib/log4j-core-2.1.jar
  • AffectedVersion is the version of Log4J that was found within the affected file on the nested path.
  • Patched signifies whether this instance of this vulnerable Log4J jar within this archive has already been patched.

More information about the scan command is available via ./loguccino help scan.

Patching vulnerable .jars

If vulnerabilities are found, the loguccino-scan-[datetime].csv is used as an input to the patch command:

./loguccino patch ./loguccino-scan-23122021003311.csv

This removes each vulnerability that was found, and creates a loguccino-patch-[timestamp] directory containing a backup of each file that was patched. Where a file was patched for multiple vulnerabilities (such as a larger backup archive containing multiple tools or software releases), multiple versions of the patched file are backed up at each stage of the process to enable staged rollback in case of failure.

Note:
Patching a file on disk does not patch the version of the program already running on the host. Remember that you must stop the relevant services / applications before patching and restart them after the patch for the changes to take effect.

More information about the patch command is available via ./loguccino help patch.

Demo

Known issues

Traversal of corrupted archives

When scanning for vulnerabilities, some archives may be reported as corrupted (this also happens with nested archives where compression methods don't match the extension of the archive). The scan command will print the path to these in the logpresso-scan-[datetime].log. If they're deemed significant, these archives should be decompressed and inspected (or scanned) manually to confirm that they are in fact corrupted.

Unknown issues

If you encounter any bugs or unexpected behavior, please open an issue and attach any steps to reproduce the bug alongside other background information.

Pull requests and updates to the code are welcome and encouraged.

Comments
  • Error while patching : java.io.IOException: This archive contains unclosed entries.

    Error while patching : java.io.IOException: This archive contains unclosed entries.

    ?? Patching /opt/sas/sashome/SASEnvironmentManager/2.5/installs/hypericsvr_lax_2.5_M3_HFE8M004/SASHome/xx/SASEnvironmentManager/2.5/server-5.8.0.tar.gz::server-5.8.0-EE/hqapi1-client-6.0.2/lib/log4j-core-2.11.1.jar ? null ? null ? null ? null ? null ? null ? null ? null ? null ? null ERROR: Error while patching : java.io.IOException: This archive contains unclosed entries. at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.finish(TarArchiveOutputStream.java:291) at com.sas.vulnerabilities.utils.ArchiveCompressUtils.compressArchive(ArchiveCompressUtils.java:108) at com.sas.vulnerabilities.patcher.SequentialPatcher.packageNextArchive(SequentialPatcher.java:38) at com.sas.vulnerabilities.patcher.SequentialPatcher.packageNextArchive(SequentialPatcher.java:41) at com.sas.vulnerabilities.patcher.SequentialPatcher.patchSingleCVE(SequentialPatcher.java:58) at com.sas.vulnerabilities.patcher.SequentialPatcherInventoryTask.runSingleCveInventoryPath(SequentialPatcherInventoryTask.java:68) at com.sas.vulnerabilities.patcher.SequentialPatcherInventoryTask.run(SequentialPatcherInventoryTask.java:93) at lukfor.progress.tasks.Task.call(Task.java:39) at lukfor.progress.tasks.Task.call(Task.java:1) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519) at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)

    testplease 
    opened by sridharamirneni 4
  • Scan doesn't follow symlinks

    Scan doesn't follow symlinks

    It seems like the scan option doesn't work if you specify a symlink. For example if I have the home path specified as /sso/sfw/sas/940M6 where 940M6 is a symlink to 940A, it appears to run but doesn't actually scan anything. If I run it directly on 940A it works as expected.

    opened by damcwa 3
  • Operation Not permitted

    Operation Not permitted

    I’m traying to fix the log4j vulnerability in Viya 3.5 environment on Linux. It only found one jar, however when I run it to fix it, I get the error: Error while patching : java.nio.file.FileSystemException: ./loguccino-patch-27122021120042/inventoryOriginals/0/opt/sas/viya/home/libexec/cachelocator-service-1.25.14.jar: Operation not permitted

    I have been running both with the user who owns the jar and with the installer user but in both cases the error is the same.

    Should the patch be run with a specific user?

    opened by NuriaU 3
  • Sasviya 3.5  After patched     service  can't not  start

    Sasviya 3.5 After patched service can't not start

    Sasviya 3.5 After patched sas-viya-cachelocator-default service can't not start

    see the error message https://imgur.com/a/mfVRVUz

    https://imgur.com/a/YOUcN2J

    triaging 
    opened by 2015eva 2
  • Vulnerability persists on these two files

    Vulnerability persists on these two files

    C:\Program Files\SASHome\SASDeploymentManager\9.4\products\cfgwizard__94550__prt__xx__sp0__1\Utilities\AppServer\Source\Config\vfabrictcsvr\gemfire.zip::gemfire/lib/log4j-core-2.1.jar C:\Program Files\SASHome\SASDeploymentManager\9.4\products\cfgwizard__94550__prt__xx__sp0__1\Utilities\AppServer\Source\Config\vfabrictcsvr\jars\gemfire\log4j-core-2.1.jar

    Java error: ERROR: Error while patching : java.nio.file.AccessDeniedException: C:\Program Files\SASHome\SASDeploymentManager\9.4\products\cfgwizard__94550__prt__xx__sp0__1\Utilities\AppServer\Source\Config\vfabrictcsvr\jars\gemfire\log4j-core-2.1.jar -> .\loguccino-patch-08012022144324\inventoryOriginals\0\C\Program Files\SASHome\SASDeploymentManager\9.4\products\cfgwizard__94550__prt__xx__sp0__1\Utilities\AppServer\Source\Config\vfabrictcsvr\jars\gemfire\log4j-core-2.1.jar at sun.nio.fs.WindowsException.translateToIOException(Unknown Source) at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source) at sun.nio.fs.WindowsFileCopy.move(Unknown Source) at sun.nio.fs.WindowsFileSystemProvider.move(Unknown Source) at java.nio.file.Files.move(Unknown Source) at com.sas.vulnerabilities.patcher.SequentialPatcherInventoryTask.runSingleCveInventoryPath(SequentialPatcherInventoryTask.java:81) at com.sas.vulnerabilities.patcher.SequentialPatcherInventoryTask.run(SequentialPatcherInventoryTask.java:93) at lukfor.progress.tasks.Task.call(Task.java:39) at lukfor.progress.tasks.Task.call(Task.java:1) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) INFO: Patch results written to CSV file: C:\Users\Simon\scan\loguccino-patch-08012022144324\patch.csv

    opened by sgeletta 2
  • Loguccino bombs out immediately in the scan when it cannot find /bin/ldapsearch

    Loguccino bombs out immediately in the scan when it cannot find /bin/ldapsearch

    sudo /sso/sfw/loguccino/loguccino_scan.sh env: /bin/ldapsearch: No such file or directory

    Is ldapsearch a requirement?

    When I pointed to a version of ldapsearch, it didn't seem to like the version. /bin#> sudo ln -s /opt/quest/bin/ldapsearch ldapsearch /loguccino#> sudo /sso/sfw/loguccino/loguccino_scan.sh ldapsearch: -D not supported in VAS version, please use -u instead

    opened by EJJSAS 1
  • Incorrect command for Viya 3.x

    Incorrect command for Viya 3.x

    You need to use --no-compress option in command line for Viya 3.x as documented in SAS documentation, so please can you align GitHub documentation path-to-bin-java -jar loguccino-version.jar patch --no-compress path-to-myOutput.csv

    opened by JMPoilane 1
  • Download Linux Binary link is broken

    Download Linux Binary link is broken

    I am unable to download the Linux Binary for loguccino. The link seems to be broken as given on the software download Page

    Link : https://github.com/sassoftware/loguccino/releases/download/v3.0.0/loguccino

    opened by pchegoor 1
  • empty

    empty

    The SAS documentation* refers to this repo, but the repo is empty. *https://go.documentation.sas.com/doc/en/log4j/1.0/n0emauiusfguyrn1wt2djefsqgtu.htm

    opened by stomioka 1
  • automatically detecting nested jar files

    automatically detecting nested jar files

    This is a suggestion that the tool automatically detect nested jar files and reapply the same so that --no-compress is not necessary. This will reduce the chances of mistakes being made that would result in impactful production outages and then urgent escalated calls for support.

    enhancement 
    opened by bullcity42 0
  • How to Automate?

    How to Automate?

    I have about 20 machines that are running SAS 9.4 that need to be patched. Is there a way to possibly automate the scan/patch operations? I would like to deploy this patch via GPO script.

    opened by harbinc 0
  • The patching mechanism should be explained better

    The patching mechanism should be explained better

    Please explain better how the patching mechanism works.

    For example...does it:

    1. copy the vulnerable archive/file
    2. Expand it in the patching directory
    3. Patch it
    4. re-archive the patched version
    5. copy the patched version into place of the vulnerable archive/file in the deployment
    6. In the patched directory, the copy of the original (vulnerable) file/archive remains

    We want to be clear about what is being left behind here and in what state so folks can determine whether/when it's safe to delete any content that contains the vulnerability.

    Thanks!

    opened by glswager 0
  • Error reading tar.gz files

    Error reading tar.gz files

    While using the latest version of the loguccino utility (v3.1.0) i am noticing that the tar.gz files are not being read. The log shows following Error

    14:23:09.880 ERROR: Could not scan file: /app/SAS/9.4_config/meta/Lev1/Web/SASEnvironmentManager/agent-5.8.0-EE/bundles/agent-5.8.0/product_connectors/rt-1.0.2.tar.gz. The exception was java.nio.charset.MalformedInputException: Input length = 1

    14:23:09.880 ERROR: Could not scan file: /app/SAS/9.4_config/meta/Lev1/Web/SASEnvironmentManager/agent-5.8.0-EE/bundles/agent-5.8.0/product_connectors/snmp-1.0.2.tar.gz. The exception was java.nio.charset.MalformedInputException: Input length = 1

    opened by pchegoor 1
  • Tar.gz files were not unzipping

    Tar.gz files were not unzipping

    After testing I saw issues with tar.gz files not being readable. I updated archive utils to follow the example from https://commons.apache.org/proper/commons-compress/examples.htm

    As far as I can tell this has fixed the issue.

    opened by briml3y 4
Releases(v3.2.0)
Owner
SAS Software
Open Source from SAS Software
SAS Software
Small example repo for looking into log4j CVE-2021-44228

log4j CVE-2021-44228 Lame useless repo to look into log4j CVE-2021-44228. Setup The repository contains a .idea/ folder which is a IntelliJ IDEA proje

null 65 Dec 13, 2022
Log4J CVE-2021-44228 Minecraft PoC

CVE-2021-44228 in Minecraft Java 16 Paper server build #397 Minecraft 1.17.1 Exploitation In Java 16 only deserialization attacks work by default usin

myxl 5 Feb 15, 2022
Log4j CVE-2021-44228 examples: Remote Code Execution (through LDAP, RMI, ...), Forced DNS queries, ...

Log4j CVE-2021-44228 and CVE-2021-45046 Requisites Use a vulnerable JDK, for instance JDK 1.8.0_181 Usage Malicious server The malicious server deploy

Manuel Álvarez Álvarez 5 Feb 7, 2022
CVE-2021-44228 - Apache log4j RCE quick test

Build ./build.sh Start log4j RCE Server ./start-log4j-rce-server.sh Test Run java -cp log4j-rce-1.0-SNAPSHOT-all.jar log4j Check if you get logs in ha

Jeffrey Li 3 Feb 1, 2022
Some tools to help mitigating Apache Log4j 2 CVE-2021-44228

JndiLookup Some tool to help analyzing Apache Log4j 2 CVE-2021-44228 This tool uses the "lookup" feature from log4j-2 to test against the JNDI vulnera

Daniel Fages 3 Dec 18, 2021
This project will help to test the Log4j CVE-2021-44228 vulnerability.

Log4j-JNDIServer This project will help to test the Log4j CVE-2021-44228/CVE-2021-45046 vulnerabilities. Installation and Building Load the project on

Immunity, Inc 9 Jun 30, 2022
Spring Boot Log4j - CVE-2021-44228 Docker Lab

Spring Boot Log4j - CVE-2021-44228 The Log4Shell vulnerability (CVE-2021-44228) ultimately is a quite simple JNDI Injection flaw, but in a really real

Tri Wanda Septian 19 Jun 10, 2022
Deploys an agent to fix CVE-2021-44228 (Log4j RCE vulnerability) in a running JVM process

-- This repository has been archived -- Further development of this tool will continue at corretto/hotpatch-for-apache-log4j2. Thanks for sharing, com

Volker Simonis 108 Dec 23, 2021
Log4j-RCE (CVE-2021-44228) Proof of Concept with additional information

Log4J-RCE-Proof-Of-Concept (CVE-2021-44228) This is a proof of concept of the log4j rce. Here are some links for the CVE-2021-44228: https://www.lunas

Johannes Jäger 181 Dec 2, 2022
An agent to hotpatch the log4j RCE from CVE-2021-44228.

Log4jHotPatch This is a tool which injects a Java agent into a running JVM process. The agent will attempt to patch the lookup() method of all loaded

null 493 Dec 13, 2022
Oxygen-log4j-patcher - A tool that upgrades the log4j from an Oxygen installation to version 2.16

Oxygen XML Patch Tool for Apache Log4j vulnerability CVE-2021-44228, CVE-2021-45046 and CVE-2021-45105 This is a tool that updates the log4j version 2

oXygen XML Editor 3 Jan 10, 2022
Apache Log4j2 CVE-2021-44228 RCE Demo with RMI and LDAP

CVE-2021-44228-Demo 利用 CVE-2021-44228,通过 RMI 和 LDAP 两种方式远程注入代码的示例。 Exploit class from RMI Server loaded Hello, ${jndi:rmi://127.0.0.1:1099/exploit} Ex

Zhuang Ma 2 Dec 14, 2021
log4j2 Log4Shell CVE-2021-44228 proof of concept

Log4Shell CVE-2021-44228 proof of concept Requirement Java (JDK/JRE) 8 or later version curl exploitable Simple spring boot application that serves a

Seshu Pasam 2 Dec 21, 2021
An evil RMI server that can launch an arbitrary command. May be useful for CVE-2021-44228

evil-rmi-server An evil RMI server that can launch an arbitrary command. May be useful for CVE-2021-44228 in a local privesc scenario Build ./gradlew

Adam Bertrand 12 Nov 9, 2022
Test case to check if the Log4Shell/CVE-2021-44228 hotfix will raise any unexpected exceptions

Log4Shell Hotfix Side Effect Test Case I wanted to know if any ClassNotFoundException or similar unexpected exception is raised when one applies the C

Malte S. Stretz 3 Nov 9, 2022
A short demo of CVE-2021-44228

sample-ldap-exploit A short demo of CVE-2021-44228 Build $ mvn clean verify Run Attacker $ java \ -cp 'attacker/target/sample-attacker.jar:attacker

Philip Oswald 6 Oct 19, 2022
Spring Boot web application vulnerable to CVE-2021-44228, nicknamed Log4Shell.

Log4Shell sample vulnerable application (CVE-2021-44228) This repository contains a Spring Boot web application vulnerable to CVE-2021-44228, nickname

Christophe Tafani-Dereeper 1k Jan 5, 2023
Vulnerability CVE-2021-44228 checker

CVE-2021-44228 checker This is the repository for checking for vulnerability CVE-2021-44228. This is a PoC that only displays strings without any exte

Yasuhiro Yamada 36 Nov 9, 2022
log4j-scanner is a project derived from other members of the open-source community by CISA's Rapid Action Force team to help organizations identify potentially vulnerable web services affected by the log4j vulnerabilities.

Log4j Scanner This repository provides a scanning solution for the log4j Remote Code Execution vulnerabilities (CVE-2021-44228 & CVE-2021-45046). The

Cybersecurity and Infrastructure Security Agency 1.3k Dec 22, 2022