Query Details

Defender for Endpoint - Firewall filtering events

MDE Firewall Events

Query

DeviceEvents
| where ActionType in ("FirewallOutboundConnectionBlocked", "FirewallInboundConnectionBlocked", "FirewallInboundConnectionToAppBlocked")
| project DeviceName, DeviceId , Timestamp , InitiatingProcessFileName , InitiatingProcessParentFileName, RemoteIP, RemotePort, LocalIP, LocalPort
| summarize MachineCount=dcount(DeviceId) by RemoteIP

About this query

Defender for Endpoint - Firewall filtering events

Query Information

Description

Get all filtering events done by the Windows filtering platform. This includes any blocks done by Windows Firewall rules, but also blocks triggered by some 3rd party firewalls.

For firewall events to be displayed in Defender for Endpoint, you'll need to enable the audit policy, see Audit Filtering Platform connection. Firewall covers the following events

Within the Windows Event log the following events are created:

  • 5025 - firewall service stopped
  • 5031 - application blocked from accepting incoming connections on the network
  • 5157 - blocked connection

References

Microsoft 365 Defender

Find Inbound and Outbound blocked events

Explanation

The query is designed to retrieve and summarize firewall filtering events from Microsoft Defender for Endpoint. It focuses on identifying instances where network connections were blocked by either Windows Firewall or third-party firewalls. Here's a simple breakdown of what the query does:

  1. Data Source: It pulls data from DeviceEvents, which logs various device-related activities.

  2. Filter Criteria: The query filters events to only include those where network connections were blocked. Specifically, it looks for three types of blocked events:

    • Outbound connections blocked by the firewall.
    • Inbound connections blocked by the firewall.
    • Inbound connections to an application that were blocked.
  3. Selected Information: For each blocked event, the query extracts specific details:

    • DeviceName: The name of the device where the event occurred.
    • DeviceId: The unique identifier of the device.
    • Timestamp: When the event happened.
    • InitiatingProcessFileName: The name of the process that initiated the connection.
    • InitiatingProcessParentFileName: The name of the parent process of the initiating process.
    • RemoteIP and RemotePort: The IP address and port number of the remote connection.
    • LocalIP and LocalPort: The IP address and port number on the local device.
  4. Summarization: The query summarizes the data by counting the number of unique devices (MachineCount) that experienced blocked connections, grouped by the RemoteIP.

In essence, this query helps identify and analyze blocked network connections across devices, providing insights into potential security incidents or misconfigurations in firewall settings.

Details

Alex Verboon profile picture

Alex Verboon

Released: April 16, 2026

Tables

DeviceEvents

Keywords

DeviceEvents

Operators

whereinprojectsummarizedcountby

Actions

GitHub