From 00ccdfdce839361c40cad4ada0238750c2c59cac Mon Sep 17 00:00:00 2001 From: Tony Gauda <5620541+tgauda@users.noreply.github.com> Date: Tue, 14 Dec 2021 17:54:11 -0500 Subject: [PATCH] Update standard-query-library.yml to detect Log4J (#3367) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added query to detect Log4j in response to CVE-2021–44228 on macOS and Linux Co-authored-by: Zach Wasserman --- .../standard-query-library.yml | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/docs/01-Using-Fleet/standard-query-library/standard-query-library.yml b/docs/01-Using-Fleet/standard-query-library/standard-query-library.yml index 173102ea29..01529ebc97 100644 --- a/docs/01-Using-Fleet/standard-query-library/standard-query-library.yml +++ b/docs/01-Using-Fleet/standard-query-library/standard-query-library.yml @@ -556,3 +556,50 @@ spec: query: SELECT * FROM last WHERE username = "root" AND time > (( SELECT unix_time FROM time ) - 86400 ); purpose: Informational contributors: DominusKelvin +--- +apiVersion: v1 +kind: query +spec: + name: Detect active processes with Log4j running + platforms: macOS, Linux + description: Returns a list of active processes and the Jar paths which are using Log4j. Version numbers are usually within the Jar filename. + query: | + WITH target_jars AS ( + SELECT DISTINCT path + FROM ( + WITH split(word, str) AS( + SELECT '', cmdline || ' ' + FROM processes + UNION ALL + SELECT substr(str, 0, instr(str, ' ')), substr(str, instr(str, ' ') + 1) + FROM split + WHERE str != '') + SELECT word AS path + FROM split + WHERE word LIKE '%.jar' + UNION ALL + SELECT path + FROM process_open_files + WHERE path LIKE '%.jar' + ) + ) + SELECT path, matches + FROM yara + WHERE path IN (SELECT path FROM target_jars) + AND count > 0 + AND sigrule IN ( + 'rule log4jJndiLookup { + strings: + $jndilookup = "JndiLookup" + condition: + $jndilookup + }', + 'rule log4jJavaClass { + strings: + $javaclass = "org/apache/logging/log4j" + condition: + $javaclass + }' + ); + purpose: Detection + contributors: zwass,tgauda