Devices with Log4j vulnerability alerts may indicate potential exploitation by adversaries leveraging known vulnerabilities to execute arbitrary code. SOC teams should proactively hunt for this behavior in Azure Sentinel to identify and mitigate compromised systems before lateral movement or data exfiltration occurs.
KQL Query
// Get any devices with Log4J related Alert Activity
let DevicesLog4JAlerts = AlertInfo
| where Title in~('Suspicious script launched',
'Exploitation attempt against Log4j (CVE-2021-44228)',
'Suspicious process executed by a network service',
'Possible target of Log4j exploitation (CVE-2021-44228)',
'Possible target of Log4j exploitation',
'Possible Log4j exploitation',
'Network connection seen in CVE-2021-44228 exploitation',
'Log4j exploitation detected',
'Possible exploitation of CVE-2021-44228',
'Possible target of Log4j vulnerability (CVE-2021-44228) scanning',
'Possible source of Log4j exploitation'
'Log4j exploitation attempt via cloud application', // Previously titled Exploitation attempt against Log4j
'Log4j exploitation attempt via email' // Previously titled Log4j Exploitation Attempt
)
// Join in evidence information
| join AlertEvidence on AlertId
| where DeviceId != ""
| summarize by DeviceId, Title;
// Get additional alert activity for each device
AlertEvidence
| where DeviceId in(DevicesLog4JAlerts)
// Add additional info
| join kind=leftouter AlertInfo on AlertId
| summarize DeviceAlerts = make_set(Title), AlertIDs = make_set(AlertId) by DeviceId, bin(Timestamp, 1d)
id: f0f222ae-a6c9-4992-9fdb-4b1601da244c
name: Devices with Log4j vulnerability alerts and additional other alert related context
description: |
Microsoft has observed threat actors exploiting vulnerabilities associated with Log4J.
requiredDataConnectors:
- connectorId: MicrosoftThreatProtection
dataTypes:
- AlertInfo
- AlertEvidence
tactics:
- Vulnerability
query: |
// Get any devices with Log4J related Alert Activity
let DevicesLog4JAlerts = AlertInfo
| where Title in~('Suspicious script launched',
'Exploitation attempt against Log4j (CVE-2021-44228)',
'Suspicious process executed by a network service',
'Possible target of Log4j exploitation (CVE-2021-44228)',
'Possible target of Log4j exploitation',
'Possible Log4j exploitation',
'Network connection seen in CVE-2021-44228 exploitation',
'Log4j exploitation detected',
'Possible exploitation of CVE-2021-44228',
'Possible target of Log4j vulnerability (CVE-2021-44228) scanning',
'Possible source of Log4j exploitation'
'Log4j exploitation attempt via cloud application', // Previously titled Exploitation attempt against Log4j
'Log4j exploitation attempt via email' // Previously titled Log4j Exploitation Attempt
)
// Join in evidence information
| join AlertEvidence on AlertId
| where DeviceId != ""
| summarize by DeviceId, Title;
// Get additional alert activity for each device
AlertEvidence
| where DeviceId in(DevicesLog4JAlerts)
// Add additional info
| join kind=leftouter AlertInfo on AlertId
| summarize DeviceAlerts = make_set(Title), AlertIDs = make_set(AlertId) by DeviceId, bin(Timestamp, 1d)
| Sentinel Table | Notes |
|---|---|
AlertEvidence | Ensure this data connector is enabled |
Scenario: Scheduled Log Processing Job Using Apache Log4j
Description: A legitimate scheduled job runs to process log files using Apache Log4j, which is common in enterprise environments.
Filter/Exclusion: Exclude events where the log source is a known internal log processing tool (e.g., log4j2 used by Apache Kafka or Splunk), or filter by process name like log4j2-server or log4j2-core.
Scenario: Admin Task to Update Log4j Libraries
Description: A system administrator is manually updating Log4j libraries on a server as part of routine maintenance.
Filter/Exclusion: Exclude events where the process is initiated by an admin user (e.g., root, admin, or sysadmin) and the command includes update, patch, or upgrade keywords.
Scenario: Internal Monitoring Tool Using Log4j for Logging
Description: An internal monitoring tool (e.g., Prometheus, Grafana, or ELK Stack) uses Log4j for internal logging.
Filter/Exclusion: Exclude events where the source IP is internal (e.g., 10.0.0.0/8), or filter by application name like elasticsearch, kibana, or prometheus.
Scenario: Log4j Used for Debugging Purposes in Development Environment
Description: Developers in a development environment use Log4j for debugging purposes, which can generate alerts due to its presence.
Filter/Exclusion: Exclude events where the source is a development server (e.g., dev-server-01), or filter by user (e.g., dev-team, developer, or qa).
**Scenario: Log4j Used in a Legacy System