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