Much data has been shared since the Log4j vulnerability was made public and there’s no doubt organizations are overwhelmed trying to search for systems, patch vulnerable servers, block malicious activity, and ensure they conduct a full assessment, all while also supporting day-to-day activities. A graphic by the Swiss Government CERT “The Log4j JDNI Attack and How to Prevent It” can help organizations better understand the attack.
Here are steps that organizations should have already completed or should plan to complete very soon:
1) Implement Sensor Blocks – Web Application Firewall (WAF), Intrusion Detection System (IDS), and firewall blocks should have been implemented on all perimeter and internal devices. While your options may vary by vendor, a running GitHub Gist has been created to provide vendor-specific guidance and links to the most updated KBs.
2) Disable Log4j – In cases where Log4J logging can be disabled, placing a property string within the src folder will disable the Java Naming and Directory Interface (JNDI). Under src/main/resources, create or edit spring.properties and add spring.jndi.ignore=true to the file. This will disable Log4j from running.
3) Identify and Patch Vulnerable Versions – An update for the log4j vulnerability has been posted. When possible, an update should be applied from Apache’s website or GitHub (Before applying, don’t forget to verify PGP and SHA512 signatures). It’s incredibly important that security teams ensure version 2.17 is the patch applied. Version 2.16 completely removed the JNDI library. Version 2.15 is vulnerable to the same exploit as 2.14 and CVE-2021-44228.
4) Disable JNDI Lookups – In the case where applications need JNDI to run, organizations should consider disabling JNDI lookups from hitting the LDAP servers. LDAP serves an important aspect within enterprises of providing direction to data—however, in this case, attackers can exploit JDNI lookups to further enumerate networks, collect data, and discover traversal paths.
To disable JNDI lookups, first disable all Java Services on your respective system, then, Disable Logging in System Properties for both the client and server components for versions >=2.10 by either
a. Add -Dlog4j2.formatMsgNoLookups=true to the startup scripts of Java programs.
b. Set the following environment variable: LOG4J_FORMAT_MSG_NO_LOOKUPS=”true”.
c. Alternatively, disabling the JndiLookup class from the classpath will also work. To do so, a command such as zip -q -d log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class will remove the class from the log4j-core.
5) Disable Remote Codebases – Log4Shell is possible due to how the JNDI library uses LDAP to load remote Java classes. Disabling the remote calls to Java libraries is ideal—however, as always, this should be tested and observed closely, as this may break some legacy Java applications.
6) Perform Scan with Updated Vulnerability Management Templates – Ensure that vulnerability scanners have credentialed access to scan as some may not pick up the vulnerability without it. Some organizations may be able to use a few open-source tools such as Grype and Syft. Both are trusted tools from Anchore but may require the installation of Go. Scan for evidence.
7) Perform Searches and Analysis of All Security Logs for Evidence of Enumeration or Compromise – Leverage other security tools and look beyond the SIEM if logs are not being aggregated or consolidated into an enterprise log management solution. A conscious effort should be made to consolidate logs not going to SIEM into a central location if possible.
Special attention should be paid to
${jndi:ldap:/}
${jndi:ldaps:/}
${jndi:rmi:/}
${jndi:dns:/}
${jndi:iiop:/}
Emerging Threats maintains a list of Suricata rules, including 12 rules that alert on LOG4Shell.
Many attempts may involve obfuscated code and are not easily searchable by simply searching files. Tools such as Florian Roth’s log4j scanner consider the obfuscation attempts. Organizations should consider writing/moving logs to a central location and cron-ing the Python script. An example may be ‘5 * * * * -a source/file/path new/file/path’ should help keep files in sync then ‘ 5 * * * * /path/to/python3 log4shell-detector.py —defaultpaths >> .log4shelloutput.log’.
8) Consolidate, Communicate, and Disseminate Updated Threat Intel Associated with Log4j – With the amount of info and intel that is being released by numerous sources it is essential that stakeholders and system owners are receiving the latest intel and applying the updated patches applicable to their applications and systems. An organization should designate a person or team to sift through all the potential disparate and extract the intel that is most relevant to their respective environment, including applications and systems.
9) Track All Remediation and Mitigation Efforts and Tasks – Related to the amount of intel being released are the associated tasks that need to be performed to remediate the vulnerability and enable additional protection mechanisms to increase the security resiliency. Organizations should be tracking in a master Log4j designated ticket or case management solution what applications and systems are being worked on, and by what teams, and any, and all issues that are preventing tasks from being completed. This helps ensure that there are no gaps in remediation and mitigation coverage that an attacker could leverage to compromise.
10) Continue to Apply Up-To-Date Blocking Measures – Ensure systems are receiving the most up-to-date IOCs. While IP blocking is a game of whack-a-mole a few sites like Zeek and GreyNoise are providing up-to-date info and helping rule out malicious attempts from benign internet scanning.
11) Monitor LDAP Traffic – Once all immediate and short-term mitigations have been applied, organizations should monitor for malicious LDAP traffic against known/allow list traffic.
12) Move Vulnerable Systems Behind Additional Firewalls – Finally, if systems cannot be updated at this time, all vulnerable systems should be moved behind additional protection.