Windows Filtering Platform
How Windows intercepts every network packet, how EDRs and AV products plug into the kernel to inspect traffic, and how attackers try to blind or bypass the entire filtering stack.
Scenario
A red team operator deploys a new implant on a target. Their C2 traffic is encrypted TLS — but within two minutes the endpoint EDR fires an alert: "Suspicious outbound connection from lsass.exe to IP 45.33.32.156 port 443." No network firewall flagged it. No proxy saw it. The EDR caught it at the kernel, before the packet ever left the NIC. The mechanism that made this possible is the Windows Filtering Platform. Understanding WFP tells you exactly how defenders see your traffic — and what attackers do to prevent it.
What WFP Is
The Windows Filtering Platform (WFP) is the kernel-level framework introduced in Windows Vista that replaced the old packet filtering model. Every firewall, every EDR network inspection capability, and Windows Defender Firewall itself is built on top of WFP. It provides:
- A layered filtering architecture covering the full network stack
- A kernel-mode callout API for deep packet inspection
- A user-mode management API for adding/removing filter rules
- A persistent policy database managed by the Base Filtering Engine (BFE)
EDR products that register WFP callout drivers can see every network connection with full process context — which PID, which thread, which image path originated the traffic. This is why EDRs can correlate network IOCs with process behavior without a network sensor. If you want to understand why detection works (or doesn't), you need to understand WFP.
WFP Architecture
┌──────────────────────────────────────────────────────────────┐ │ USER MODE │ │ │ │ Windows Firewall EDR Agent Custom App │ │ (mpssvc.dll) (vendor) (fwpuclnt.dll) │ │ │ │ │ │ │ └──────────────────┴─────────────┘ │ │ │ │ │ BFE Service (bfe.dll in svchost) │ │ Base Filtering Engine — manages filter database │ │ │ │ ├────────────────────────────┼─────────────────────────────────┤ │ KERNEL MODE │ │ │ │ │ Filter Engine (netio.sys / fwpkclnt.sys) │ │ │ │ │ ┌───────────────────────┴────────────────────────────┐ │ │ │ WFP Layers (processing order) │ │ │ │ │ │ │ │ L2 (Ethernet) → Network → Transport → Stream │ │ │ │ ALE Connect → ALE Accept → ALE Auth │ │ │ │ │ │ │ │ At each layer: filters are evaluated │ │ │ │ Callout drivers get classify/notify callbacks │ │ │ └────────────────────────────────────────────────────┘ │ │ │ │ │ TCP/IP Stack (tcpip.sys) │ └──────────────────────────────────────────────────────────────┘
The Three Main Components
| Component | Location | Role |
|---|---|---|
| Base Filtering Engine (BFE) | User mode — bfe.dll in svchost | Stores filter policy database, manages callout registration, handles API calls from user mode |
| Filter Engine | Kernel mode — fwpkclnt.sys, netio.sys | Evaluates filters against packets/connections, dispatches classify calls to callout drivers |
| Callout Drivers | Kernel mode — vendor .sys files | Registered by EDR/AV/firewall, receive callbacks for every matching packet or connection event |
WFP Layers
WFP processes traffic at multiple layers corresponding to different points in the network stack. Each layer has a fixed set of data fields (IP address, port, PID, etc.) available for filter conditions.
| Layer Constant | When Triggered | Key Fields Available | Detection Use |
|---|---|---|---|
FWPM_LAYER_INBOUND_IPPACKET_V4 | Inbound IP packet received | Source/dest IP, protocol | Block inbound IPs |
FWPM_LAYER_OUTBOUND_IPPACKET_V4 | Outbound IP packet before sending | Source/dest IP, protocol | Block outbound IPs |
FWPM_LAYER_INBOUND_TRANSPORT_V4 | Inbound TCP/UDP segment | Ports + IPs | Port-based filtering |
FWPM_LAYER_OUTBOUND_TRANSPORT_V4 | Outbound TCP/UDP segment | Ports + IPs + process | Port + process filtering |
FWPM_LAYER_ALE_AUTH_CONNECT_V4 | Application initiates connect() | Process ID, image path, user SID, remote IP/port | Most valuable — full process context |
FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V4 | Application accepts inbound connection | Process ID, image path, local port | Detect unexpected listeners |
FWPM_LAYER_ALE_BIND_REDIRECT_V4 | Application calls bind() | Process ID, local address | Detect socket binding |
FWPM_LAYER_STREAM_V4 | Per-stream data (TCP) | Stream data buffer | Deep packet inspection, pattern matching |
FWPM_LAYER_DATAGRAM_DATA_V4 | UDP datagram data | Datagram buffer | DNS inspection, UDP DPI |
Application Layer Enforcement (ALE) layers fire once per connection (not per packet) and provide process identity — the PID, image path, and user SID of the process making the connection. This is how EDRs attribute network traffic to a specific process without expensive per-packet inspection. FWPM_LAYER_ALE_AUTH_CONNECT_V4 is where most behavioral detection happens.
Callout Drivers — How EDRs Plug In
A WFP callout driver registers with the filter engine and receives callbacks for every packet or connection that matches its filters. The callbacks are:
// The three callout functions every WFP callout implements
// 1. ClassifyFn — called for every matching event, must act on it
VOID ClassifyFn(
const FWPS_INCOMING_VALUES0* inFixedValues, // IP, port, PID, etc.
const FWPS_INCOMING_METADATA_VALUES0* inMetaValues, // Process path, flow ID
void* layerData, // Packet data (at stream layers)
const void* classifyContext,
const FWPS_FILTER0* filter,
UINT64 flowContext,
FWPS_CLASSIFY_OUT0* classifyOut // Set PERMIT / BLOCK / ABSORB
);
// 2. NotifyFn — called when filter is added/removed
NTSTATUS NotifyFn(
FWPS_CALLOUT_NOTIFY_TYPE notifyType,
const GUID* filterKey,
FWPS_FILTER0* filter
);
// 3. FlowDeleteFn — called when a flow (connection) is torn down
VOID FlowDeleteFn(
UINT16 layerId,
UINT32 calloutId,
UINT64 flowContext
);
In ClassifyFn, the callout reads inMetaValues->processPath and inFixedValues to get process + network context, logs the connection to user-mode (via shared memory or IOCTL), and sets classifyOut->actionType to either FWP_ACTION_PERMIT or FWP_ACTION_BLOCK.
How an EDR Registers Its Callout
EDR kernel driver loading:
1. FwpsCalloutRegister() — register ClassifyFn/NotifyFn/FlowDeleteFn
returns calloutId (UINT32)
2. FwpmCalloutAdd() — add callout to BFE database (survives reboot)
3. FwpmFilterAdd() — add filter rule:
layer = ALE_AUTH_CONNECT_V4
condition = match all (or specific ports)
action = FWP_ACTION_CALLOUT_INSPECTION
weight = high priority
Result: every outbound connect() triggers ClassifyFn in the EDR driver,
with full process context available.Enumerating Registered Callouts
You can enumerate all registered WFP callouts and filters with netsh advfirewall or the WFP API:
# List all registered WFP providers (shows vendor names)
(New-Object -ComObject HNetCfg.FwMgr).LocalPolicy.CurrentProfile | Out-Null
Get-NetFirewallRule | Where-Object { $_.Enabled -eq 'True' } | Select DisplayName, Direction
# For deep WFP enumeration — use fwpuclnt.dll via P/Invoke
# Or: WFPExplorer (GUI tool) — shows every filter, callout, and provider
# Or: netsh wfp show filters (dumps XML of all filters)
Run netsh wfp show state on a machine with an EDR installed. Save the XML output and search for the vendor's provider GUID or name. You'll see every filter layer they've registered at and what conditions trigger their callout — this reveals exactly what network behavior they're watching.
WFP Bypass Techniques
Attackers targeting WFP-based detection use several approaches, each with different detection opportunities:
| Technique | Mechanism | Detection |
|---|---|---|
| Raw sockets (SOCK_RAW) | Bypass TCP/IP stack entirely — craft packets at IP level. WFP does still fire at IP layers, but process context may be missing at stream layers. | Sysmon Event 3 still fires; unusual use of raw sockets by non-system processes |
| NDIS filter driver | Install a driver below WFP in the network stack, intercept frames before they reach netio.sys | Driver installation events (7045), kernel driver load events, unusual driver signing |
| Disable BFE service | Stop the Base Filtering Engine — disables Windows Firewall and partially disrupts WFP-based products | Service stop Event 7036 for BFE, Security Event 4950 (firewall setting changed) |
| Kernel callout removal | Directly remove the EDR's registered callout from the filter engine via FwpsCalloutUnregisterById() | Requires kernel privileges; driver load of attacker tooling, unusual WFP API calls from non-vendor processes |
| FwpmFilterDeleteByKey() | Remove specific filter entries from BFE database | Requires BFE write access (high IL or kernel); auditable via WFP event log |
| Process injection into network process | Inject into a trusted process (svchost, browser) so connections appear to come from a legitimate image path | Process injection detections (Sysmon 8/10); network connection from injected process |
| DNS-over-HTTPS / encrypted DNS | Bypass DNS inspection callouts by routing DNS to port 443 via HTTPS | Behavioral: system process using unusual DNS resolver IP; volume of HTTPS to non-standard DNS providers |
Raw sockets do not fully bypass WFP. The IP packet layers (FWPM_LAYER_OUTBOUND_IPPACKET_V4) still fire. What raw sockets bypass is the stream/transport layer context — but modern EDRs register at the ALE and IP layers both, so raw socket traffic is still visible, just with less per-flow context.
Detection Opportunities
WFP Audit Events
| Event ID | Log | Description | Detection Value |
|---|---|---|---|
| 4946 | Security | A rule was added to the Windows Firewall exception list | Medium — attackers add firewall exceptions to allow inbound C2 |
| 4947 | Security | A rule was modified in the Windows Firewall exception list | Medium — existing rule tampered |
| 4948 | Security | A rule was deleted from the Windows Firewall exception list | High — deleting block rules to enable attacker traffic |
| 4950 | Security | A Windows Firewall setting has changed | High — disabling firewall entirely |
| 4951 | Security | A rule has been ignored because its major version number was not recognized | Low |
| 5152 | Security | WFP blocked a packet | Very noisy — enable only for targeted IPs |
| 5154 | Security | WFP permitted an application to listen on a port | High — new listener on unusual port |
| 5156 | Security | WFP allowed a connection | High value if filtered to suspicious processes/ports — very noisy otherwise |
| 5157 | Security | WFP blocked a connection | Medium — blocked C2 attempts visible here |
| 5158 | Security | WFP permitted local port bind | Medium — bind by unusual process |
Events 5152–5158 are off by default. Enable them with: auditpol /set /subcategory:"Filtering Platform Packet Drop" /success:enable /failure:enable and auditpol /set /subcategory:"Filtering Platform Connection" /success:enable /failure:enable. Be selective — 5156 fires for every allowed connection and will generate millions of events on a busy host.
Sigma: Firewall Disabled
title: Windows Firewall Disabled
id: 57b8a1e2-4d56-4c3a-a8d6-3e4f9a12bc01
status: stable
description: Detects disabling of Windows Firewall via Event 4950
logsource:
product: windows
service: security
detection:
selection:
EventID: 4950
NewSettingValue: 'Off'
condition: selection
falsepositives:
- Legitimate administrative firewall management
level: high
tags:
- attack.defense_evasion
- attack.t1562.004
Sigma: New Inbound Firewall Exception
title: New Windows Firewall Rule Added
id: 9e3f1b7c-2a8d-4f6e-b1c3-5d7e8f901234
status: stable
description: Detects addition of new firewall exception rules (4946)
logsource:
product: windows
service: security
detection:
selection:
EventID: 4946
filter_legitimate:
RuleName|contains:
- 'Windows Update'
- 'Microsoft Edge'
- 'Windows Defender'
condition: selection and not filter_legitimate
falsepositives:
- Software installation adding firewall exceptions
level: medium
tags:
- attack.defense_evasion
- attack.t1562.004
Sysmon for WFP-Adjacent Detection
Sysmon Event 3 (Network Connection) is powered by WFP at the ALE layer. It gives you process + network context without needing to enable noisy WFP auditing:
title: Network Connection from LSASS
id: 4c3f1e9a-5b7d-4c2a-8e6f-1b3d5a7c9e01
status: stable
description: LSASS making outbound network connection — possible DCSync or C2
logsource:
product: windows
service: sysmon
detection:
selection:
EventID: 3
Image|endswith: '\lsass.exe'
Initiated: 'true'
condition: selection
falsepositives:
- Domain controller replication (adjust to exclude DC-to-DC)
level: critical
tags:
- attack.lateral_movement
- attack.credential_access
WFP from the Offensive Perspective
Understanding WFP helps explain why certain tradecraft choices matter:
- Process injection for C2 — injecting into a trusted browser or system process makes your network traffic appear under that process's image path at the WFP ALE layer, defeating process-based filtering
- Port 443/80 for C2 — WFP stream-layer callouts doing DPI are expensive; many deployments only register at ALE layer (connection metadata), not stream layer (payload data), making HTTPS C2 blind at the content level
- DNS-based C2 — DNS (UDP/53) has lower inspection coverage than TCP in many WFP deployments; DoH moves C2 to encrypted port 443 and defeats plain UDP inspection
- Sleep jitter and low beacon rates — WFP callouts don't do statistical analysis; that lives in user-mode EDR logic, making low-rate beaconing harder to fingerprint
Q & A
What is the difference between WFP and Windows Firewall?
Windows Defender Firewall is a user of WFP — it's a product built on top of the WFP infrastructure. WFP is the kernel framework; Firewall is one policy engine that registers filters into WFP. Multiple products can coexist in WFP simultaneously. Disabling Firewall removes its filters from WFP but does not disable WFP itself or the EDR callouts registered separately.
Why can EDRs see the process name for every network connection?
The ALE layers (FWPM_LAYER_ALE_AUTH_CONNECT_V4) provide FWPS_INCOMING_METADATA_VALUES0.processPath and .processId directly to the callout's ClassifyFn. These are kernel-resolved — the process identity comes from the kernel's process table, not from user mode, so it can't be spoofed by the connecting process itself. Injection into another process is the way around this because the process identity is legitimately that of the host process.
How does a threat actor disable WFP-based EDR callouts?
From user mode: call FwpmFilterDeleteByKey() against specific filter GUIDs — requires BFE write access, which typically needs SeManageVolume or an admin token. From kernel mode: call FwpsCalloutUnregisterById() directly on the callout ID. Both actions are auditable: the BFE logs filter changes to the Security event log (4946/4948) and the WFP diagnostic event log. The most practical offensive approach is process injection into a trusted process so traffic appears legitimate rather than removing filters.
What Event IDs should I enable to monitor WFP on a high-value host?
At minimum: 4946 (firewall rule added), 4948 (firewall rule deleted), 4950 (firewall setting changed) — these are low-volume and high-signal. For connection telemetry: 5154 (new listener) and 5156 (connections allowed, filtered to suspicious processes). Avoid enabling 5152/5156 globally — they generate enormous volume. Better alternative: use Sysmon Event 3 for network connection telemetry with process context; it's tunable via Sysmon config and much more practical than raw WFP events.
What tool can I use to see all WFP filters and callouts on a system?
Three options: (1) netsh wfp show state — dumps an XML file of all filters, providers, and callouts; (2) WFPExplorer by Pavel Yosifovich — a GUI tool that shows everything with friendly names; (3) netsh wfp show filters — shows active filter rules in human-readable format. On a system with an EDR, you'll see the vendor's callout GUIDs and the layers they've registered at — revealing their detection surface.