Apache Log4j 2.x < 2.16.0 RCE - Nessus

Critical   Plugin ID: 156057

This page contains detailed information about the Apache Log4j 2.x < 2.16.0 RCE Nessus plugin including available exploits and PoCs found on GitHub, in Metasploit or Exploit-DB for verifying of this vulnerability.

Plugin Overview


ID: 156057
Name: Apache Log4j 2.x < 2.16.0 RCE
Filename: apache_log4j_2_16_0.nasl
Vulnerability Published: 2021-12-14
This Plugin Published: 2021-12-14
Last Modification Time: 2022-04-11
Plugin Version: 1.15
Plugin Type: local
Plugin Family: Misc.
Dependencies: apache_log4j_nix_installed.nbin, apache_log4j_win_installed.nbin
Required KB Items [?]: installed_sw/Apache Log4j

Vulnerability Information


Severity: Critical
Vulnerability Published: 2021-12-14
Patch Published: 2021-12-14
CVE [?]: CVE-2021-45046
CPE [?]: cpe:/a:apache:log4j

Synopsis

A package installed on the remote host is affected by a remote code execution vulnerability.

Description

The version of Apache Log4j on the remote host is 2.x < 2.12.2 / 2.16.0. It is, therefore, affected by a remote code execution vulnerability. The fix to address CVE-2021-44228 in Apache Log4j 2.15.0 was incomplete in certain non-default configurations. This could allow attackers with control over Thread Context Map (MDC) input data when the logging configuration uses a non-default Pattern Layout with either a Context Lookup (for example, $${ctx:loginId}) or a Thread Context Map pattern (%X, %mdc, or %MDC) to craft malicious input data using a JNDI Lookup pattern resulting in a remote code execution (RCE) attack.

Note that Nessus has not tested for these issues but has instead relied only on the application's self-reported version number.

Solution

Upgrade to Apache Log4j version 2.3.1, 2.12.2, 2.16.0 or later, or apply the vendor mitigation.

Upgrading to the latest versions for Apache Log4j is highly recommended as intermediate versions / patches have known high severity vulnerabilities and the vendor is updating their advisories often as new research and knowledge about the impact of Log4j is discovered. Refer to https://logging.apache.org/log4j/2.x/security.html for the latest versions.

Public Exploits


Target Network Port(s): N/A
Target Asset(s): N/A
Exploit Available: True (GitHub)
Exploit Ease: Exploits (PoCs) are available

Here's the list of publicly known exploits and PoCs for verifying the Apache Log4j 2.x < 2.16.0 RCE vulnerability:

  1. GitHub: https://github.com/Aschen/log4j-patched
    [CVE-2021-45046: Provide patched version of Log4J against CVE-2021-44228 and CVE-2021-45046 as well ...]
  2. GitHub: https://github.com/Awisefew/Lof4j
    [CVE-2021-45046]
  3. GitHub: https://github.com/BobTheShoplifter/CVE-2021-45046-Info
    [CVE-2021-45046: Oh no another one]
  4. GitHub: https://github.com/CaptanMoss/Log4Shell-Sandbox-Signature
    [CVE-2021-45046: Log4Shell(CVE-2021-45046) Sandbox Signature]
  5. GitHub: https://github.com/CptOfEvilMinions/ChooseYourSIEMAdventure
    [CVE-2021-45046]
  6. GitHub: https://github.com/DANSI/PowerShell-Log4J-Scanner
    [CVE-2021-45046: can find, analyse and patch Log4J files because of CVE-2021-44228, CVE-2021-45046 ...]
  7. GitHub: https://github.com/DXC-StrikeForce/Burp-Log4j-HammerTime
    [CVE-2021-45046: Burp Active Scan extension to identify Log4j vulnerabilities CVE-2021-44228 an ...]
  8. GitHub: https://github.com/Diablo5G/Certification-Prep
    [CVE-2021-45046]
  9. GitHub: https://github.com/HackJava/Log4j2
    [CVE-2021-45046]
  10. GitHub: https://github.com/HynekPetrak/log4shell-finder
    [CVE-2021-45046]
  11. GitHub: https://github.com/HynekPetrak/log4shell_finder
    [CVE-2021-45046: Searches filesystem for CVE-2021-44228 and CVE-2021-45046 vulnerable instances, ...]
  12. GitHub: https://github.com/NUMde/compass-num-conformance-checker
    [CVE-2021-45046]
  13. GitHub: https://github.com/NiftyBank/java-app
    [CVE-2021-45046]
  14. GitHub: https://github.com/Qualys/log4jscanwin
    [CVE-2021-45046]
  15. GitHub: https://github.com/Staubgeborener/stars
    [CVE-2021-45046]
  16. GitHub: https://github.com/TheInterception/Log4JPentester
    [CVE-2021-45046: Automated pentesting tools and vulnerability fixes for Log4Shell CVE-2021-44228 / ...]
  17. GitHub: https://github.com/TheInterception/Log4J-Simulation-Tool
    [CVE-2021-45046: Vulerability analysis, patch management and exploitation tool CVE-2021-44228 / ...]
  18. GitHub: https://github.com/X1pe0/Log4J-Scan-Win
    [CVE-2021-45046: Windows Server Log4j Scanner - Powershell - CVE-2021-45046 and CVE-2021-44228]
  19. GitHub: https://github.com/Yuji-Kakeya/log4j-CVE-2021-45046-poc
    [CVE-2021-45046]
  20. GitHub: https://github.com/adelarsq/awesome-bugs
    [CVE-2021-45046]
  21. GitHub: https://github.com/allegroai/clearml-server
    [CVE-2021-45046]
  22. GitHub: https://github.com/andalik/log4j-scanner
    [CVE-2021-45046: Scanner local em Python para varredura e localização de versões vulneráveis do ...]
  23. GitHub: https://github.com/anuvindhs/how-to-check-patch-secure-logj4-CVE-2021-45046
    [CVE-2021-45046]
  24. GitHub: https://github.com/binkley/modern-java-practices
    [CVE-2021-45046]
  25. GitHub: https://github.com/cckuailong/Log4j_CVE-2021-45046
    [CVE-2021-45046: Log4j 2.15.0 Privilege Escalation -- CVE-2021-45046]
  26. GitHub: https://github.com/census-instrumentation/opencensus-java
    [CVE-2021-45046]
  27. GitHub: https://github.com/cowbe0x004/cowbe0x004
    [CVE-2021-45046]
  28. GitHub: https://github.com/davejwilson/azure-spark-pools-log4j
    [CVE-2021-45046]
  29. GitHub: https://github.com/dileepdkumar/https-github.com-cisagov-log4j-affected-dbv2
    [CVE-2021-45046]
  30. GitHub: https://github.com/docker-solr/docker-solr
    [CVE-2021-45046]
  31. GitHub: https://github.com/dtact/divd-2021-00038--log4j-scanner
    [CVE-2021-45046: Scan systems and docker images for potential log4j vulnerabilities. Able to patch ...]
  32. GitHub: https://github.com/eventsentry/scripts
    [CVE-2021-45046]
  33. GitHub: https://github.com/gitlab-de/log4j-resources
    [CVE-2021-45046: This repository is designed to be a collection of resources to learn about, detect ...]
  34. GitHub: https://github.com/hypertrace/hypertrace
    [CVE-2021-45046]
  35. GitHub: https://github.com/imTigger/webapp-hardware-bridge
    [CVE-2021-45046]
  36. GitHub: https://github.com/insignit/cve-informatie
    [CVE-2021-45046]
  37. GitHub: https://github.com/integralads/dependency-deep-scan-utilities
    [CVE-2021-45046]
  38. GitHub: https://github.com/jacobalberty/unifi-docker
    [CVE-2021-45046]
  39. GitHub: https://github.com/justb4/docker-jmeter
    [CVE-2021-45046]
  40. GitHub: https://github.com/kdpuvvadi/Omada-Ansible
    [CVE-2021-45046]
  41. GitHub: https://github.com/logpresso/CVE-2021-44228-Scanner
    [CVE-2021-45046]
  42. GitHub: https://github.com/ludy-dev/cve-2021-45046
    [CVE-2021-45046]
  43. GitHub: https://github.com/lukepasek/log4jjndilookupremove
    [CVE-2021-45046: A simple script to remove Log4J JndiLookup.class from jars in a given directory, to ...]
  44. GitHub: https://github.com/manishkanyal/log4j-scanner
    [CVE-2021-45046: A Log4j vulnerability scanner is used to identify the CVE-2021-44228 and ...]
  45. GitHub: https://github.com/mergebase/csv-compare
    [CVE-2021-45046]
  46. GitHub: https://github.com/mergebase/log4j-detector
    [CVE-2021-45046: Detects vulnerable Log4J versions (CVE-2021-44228, CVE-2021-45046, etc) on your ...]
  47. GitHub: https://github.com/mergebase/log4j-samples
    [CVE-2021-45046: Samples of log4j library versions to help log4j scanners / detectors improve their ...]
  48. GitHub: https://github.com/nlmaca/Wowza_Installers
    [CVE-2021-45046]
  49. GitHub: https://github.com/open-source-agenda/new-open-source-projects
    [CVE-2021-45046]
  50. GitHub: https://github.com/pravin-pp/log4j2-CVE-2021-45046
    [CVE-2021-45046]
  51. GitHub: https://github.com/srhercules/log4j_mass_scanner
    [CVE-2021-45046]
  52. GitHub: https://github.com/sudo6/l4shunter
    [CVE-2021-45046: L4Shunter - Log4Shell Hunter - Remote scanner for CVE-2021-44228 or CVE-2021-45046 ...]
  53. GitHub: https://github.com/taise-hub/log4j-poc
    [CVE-2021-45046: Explanation of CVE-2021-45046 for classroom use]
  54. GitHub: https://github.com/tcoliver/IBM-SPSS-log4j-fixes
    [CVE-2021-45046]
  55. GitHub: https://github.com/tejas-nagchandi/CVE-2021-45046
    [CVE-2021-45046: Replicating CVE-2021-45046]
  56. GitHub: https://github.com/thl-cmk/CVE-log4j-check_mk-plugin
    [CVE-2021-45046]
  57. GitHub: https://github.com/tmax-cloud/install-EFK
    [CVE-2021-45046]
  58. GitHub: https://github.com/trickyearlobe/inspec-log4j
    [CVE-2021-45046: An Inspec profile to check for Log4j CVE-2021-44228 and CVE-2021-45046]
  59. GitHub: https://github.com/whitesource-ps/ws-bulk-report-generator
    [CVE-2021-45046]
  60. GitHub: https://github.com/whitesource/log4j-detect-distribution
    [CVE-2021-45046]
  61. GitHub: https://github.com/lijiejie/log4j2_vul_local_scanner
    [CVE-2021-45046: Log4j 漏洞本地检测脚本。 Scan all java processes on your host to check ...]

Before running any exploit against any system, make sure you are authorized by the owner of the target system(s) to perform such activity. In any other case, this would be considered as an illegal activity.

WARNING: Beware of using unverified exploits from sources such as GitHub or Exploit-DB. These exploits and PoCs could contain malware. For more information, see how to use exploits safely.

Risk Information


CVSS Score Source [?]: CVE-2021-45046
CVSS V2 Vector: AV:N/AC:H/Au:N/C:P/I:P/A:P/E:U/RL:OF/RC:C
CVSS Base Score:5.1 (Medium)
Impact Subscore:6.4
Exploitability Subscore:4.9
CVSS Temporal Score:3.8 (Low)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:3.8 (Low)
CVSS V3 Vector: CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H/E:U/RL:O/RC:C
CVSS Base Score:9.0 (Critical)
Impact Subscore:6.0
Exploitability Subscore:2.2
CVSS Temporal Score:7.8 (High)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:7.8 (High)
STIG Severity [?]: I
STIG Risk Rating: High

Go back to menu.

Plugin Source


This is the apache_log4j_2_16_0.nasl nessus plugin source code. This script is Copyright (C) 2021-2022 and is owned by Tenable, Inc. or an Affiliate thereof.

#%NASL_MIN_LEVEL 70300
##
# (C) Tenable Network Security, Inc.
##

include('deprecated_nasl_level.inc');
include('compat.inc');

if (description)
{
  script_id(156057);
  script_version("1.15");
  script_set_attribute(attribute:"plugin_modification_date", value:"2022/04/11");

  script_cve_id("CVE-2021-45046");
  script_xref(name:"IAVA", value:"2021-A-0573");
  script_xref(name:"IAVA", value:"2021-A-0598");
  script_xref(name:"IAVA", value:"2021-A-0597");
  script_xref(name:"IAVA", value:"2021-A-0596");
  script_xref(name:"IAVA", value:"0001-A-0650");

  script_name(english:"Apache Log4j 2.x < 2.16.0 RCE");

  script_set_attribute(attribute:"synopsis", value:
"A package installed on the remote host is affected by a remote code execution vulnerability.");
  script_set_attribute(attribute:"description", value:
"The version of Apache Log4j on the remote host is 2.x < 2.12.2 / 2.16.0. It is, therefore, affected by a remote 
code execution vulnerability. The fix to address CVE-2021-44228 in Apache Log4j 2.15.0 was incomplete in certain 
non-default configurations. This could allow attackers with control over Thread Context Map (MDC) input data 
when the logging configuration uses a non-default Pattern Layout with either a Context Lookup (for example, 
$${ctx:loginId}) or a Thread Context Map pattern (%X, %mdc, or %MDC) to craft malicious input data using 
a JNDI Lookup pattern resulting in a remote code execution (RCE) attack.

Note that Nessus has not tested for these issues but has instead relied only on the application's self-reported version
number.");
  script_set_attribute(attribute:"see_also", value:"https://github.com/advisories/GHSA-7rjr-3q55-vv33");
  script_set_attribute(attribute:"see_also", value:"https://access.redhat.com/security/cve/cve-2021-45046");
  script_set_attribute(attribute:"solution", value:
"Upgrade to Apache Log4j version 2.3.1, 2.12.2, 2.16.0 or later, or apply the vendor mitigation.

Upgrading to the latest versions for Apache Log4j is highly recommended as intermediate 
versions / patches have known high severity vulnerabilities and the vendor is updating 
their advisories often as new research and knowledge about the impact of Log4j is 
discovered. Refer to https://logging.apache.org/log4j/2.x/security.html for the latest 
versions.");
  script_set_attribute(attribute:"agent", value:"all");
  script_set_cvss_base_vector("CVSS2#AV:N/AC:H/Au:N/C:P/I:P/A:P");
  script_set_cvss_temporal_vector("CVSS2#E:U/RL:OF/RC:C");
  script_set_cvss3_base_vector("CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H");
  script_set_cvss3_temporal_vector("CVSS:3.0/E:U/RL:O/RC:C");
  script_set_attribute(attribute:"cvss_score_source", value:"CVE-2021-45046");

  script_set_attribute(attribute:"exploitability_ease", value:"No known exploits are available");

  script_set_attribute(attribute:"vuln_publication_date", value:"2021/12/14");
  script_set_attribute(attribute:"patch_publication_date", value:"2021/12/14");
  script_set_attribute(attribute:"plugin_publication_date", value:"2021/12/14");

  script_set_attribute(attribute:"plugin_type", value:"local");
  script_set_attribute(attribute:"cpe", value:"cpe:/a:apache:log4j");
  script_set_attribute(attribute:"stig_severity", value:"I");
  script_set_attribute(attribute:"thorough_tests", value:"true");
  script_end_attributes();

  script_category(ACT_GATHER_INFO);
  script_family(english:"Misc.");

  script_copyright(english:"This script is Copyright (C) 2021-2022 and is owned by Tenable, Inc. or an Affiliate thereof.");

  script_dependencies("apache_log4j_nix_installed.nbin", "apache_log4j_win_installed.nbin");
  script_require_keys("installed_sw/Apache Log4j");

  exit(0);
}

include('vcf.inc');

var app = 'Apache Log4j';

var app_info = vcf::get_app_info(app:app);

if (report_paranoia != 2 && app_info['JndiLookup.class association'] == "Unknown")
  audit(AUDIT_OS_CONF_UNKNOWN, app, app_info.version);

if (app_info['JndiLookup.class association'] == "Not Found")
  audit(AUDIT_OS_CONF_NOT_VULN, app, app_info.version);

var constraints = [
  {'min_version':'2.0', 'fixed_version':'2.3.1'},
  {'min_version':'2.4', 'fixed_version':'2.12.2'},
  {'min_version':'2.13', 'fixed_version':'2.16.0'}
];

vcf::check_version_and_report(
  app_info:app_info,
  constraints:constraints,
  severity:SECURITY_WARNING
);  

The latest version of this script can be found in these locations depending on your platform:

  • Linux / Unix:
    /opt/nessus/lib/nessus/plugins/apache_log4j_2_16_0.nasl
  • Windows:
    C:\ProgramData\Tenable\Nessus\nessus\plugins\apache_log4j_2_16_0.nasl
  • Mac OS X:
    /Library/Nessus/run/lib/nessus/plugins/apache_log4j_2_16_0.nasl

Go back to menu.

How to Run


Here is how to run the Apache Log4j 2.x < 2.16.0 RCE as a standalone plugin via the Nessus web user interface (https://localhost:8834/):

  1. Click to start a New Scan.
  2. Select Advanced Scan.
  3. Navigate to the Plugins tab.
  4. On the top right corner click to Disable All plugins.
  5. On the left side table select Misc. plugin family.
  6. On the right side table select Apache Log4j 2.x < 2.16.0 RCE plugin ID 156057.
  7. Specify the target on the Settings tab and click to Save the scan.
  8. Run the scan.

Here are a few examples of how to run the plugin in the command line. Note that the examples below demonstrate the usage on the Linux / Unix platform.

Basic usage:

/opt/nessus/bin/nasl apache_log4j_2_16_0.nasl -t <IP/HOST>

Run the plugin with audit trail message on the console:

/opt/nessus/bin/nasl -a apache_log4j_2_16_0.nasl -t <IP/HOST>

Run the plugin with trace script execution written to the console (useful for debugging):

/opt/nessus/bin/nasl -T - apache_log4j_2_16_0.nasl -t <IP/HOST>

Run the plugin with using a state file for the target and updating it (useful for running multiple plugins on the target):

/opt/nessus/bin/nasl -K /tmp/state apache_log4j_2_16_0.nasl -t <IP/HOST>

Go back to menu.

References


IAVA | Information Assurance Vulnerability Alert:
  • 0001-A-0650, 2021-A-0573, 2021-A-0596, 2021-A-0597, 2021-A-0598
See also: Similar and related Nessus plugins:
  • 156175 - Amazon Linux 2 : java-1.8.0-amazon-corretto (ALAS-2021-001) (deprecated)
  • 156112 - Amazon Linux 2 : aws-kinesis-agent (ALAS-2021-1730)
  • 156182 - Amazon Linux 2 : java-17-amazon-corretto, java-11-amazon-corretto, java-1.8.0-openjdk, java-1.7.0-openjdk (ALAS-2021-1731)
  • 160410 - Amazon Linux 2 : java-1.8.0-amazon-corretto (ALASCORRETTO8-2021-001)
  • 156174 - Amazon Linux AMI : java-1.8.0-openjdk, java-1.7.0-openjdk, java-1.6.0-openjdk (ALAS-2021-1553)
  • 156165 - Apache Log4j 2.x < 2.16.0 RCE (MacOS) (deprecated)
  • 156164 - Apache Log4Shell CVE-2021-45046 Bypass Remote Code Execution
  • 156124 - Debian DSA-5022-1 : apache-log4j2 - security update
  • 156210 - FreeBSD : graylog -- remote code execution in log4j from user-controlled log input (650734b2-7665-4170-9a0a-eeced5e10a5e)
  • 156324 - FreeBSD : OpenSearch -- Log4Shell (b0f49cb9-6736-11ec-9eea-589cfc007716)
  • 160471 - Splunk Enterprise 8.1.x < 8.1.7.2 / 8.2.x < 8.2.3.3 Log4j (macOS)
  • 156218 - openSUSE 15 Security Update : log4j (openSUSE-SU-2021:1601-1)
  • 156153 - openSUSE 15 Security Update : log4j (openSUSE-SU-2021:4094-1)
  • 156139 - openSUSE 15 Security Update : log4j (openSUSE-SU-2021:4107-1)
  • 157876 - Palo Alto Networks PAN-OS for Panorama < 9.0.15 / 9.1.12-h3 / 10.0.8-h8 Multiple RCE (Log4Shell)
  • 159653 - RHEL 7 : Red Hat JBoss Enterprise Application Platform 7.4.4 (RHSA-2022:1296)
  • 159664 - RHEL 8 : Red Hat JBoss Enterprise Application Platform 7.4.4 (RHSA-2022:1297)
  • 158383 - Splunk Enterprise 8.1.x < 8.1.7.2 / 8.2.x < 8.2.3.3 Log4j
  • 156104 - Ubuntu 20.04 LTS : Apache Log4j 2 vulnerability (USN-5197-1)

Version


This page has been produced using Nessus Professional 10.1.2 (#68) LINUX, Plugin set 202205072148.
Plugin file apache_log4j_2_16_0.nasl version 1.15. For more plugins, visit the Nessus Plugin Library.

Go back to menu.