Event ID 5156
Event ID 5156: WFP Connection Permitted
The Windows Filtering Platform has permitted a connection
- Log source
- Security
- How to enable it
- Object Access > Audit Filtering Platform Connection (Success)
- Category
- Lateral Movement
- Priority
- Low
- Typical volume
- Very high
- MITRE ATT&CK
What Event ID 5156 means
5156 is written when the Windows Filtering Platform allows a connection. It ties a program to an address and a port without any agent, which makes it the built-in alternative to Sysmon event 3.
Volume is severe. A busy server produces thousands per minute, and turning it on everywhere can push other events out of the Security log within hours. Use it selectively: on domain controllers for a limited period, during an incident on suspect hosts, or with collection filters that keep only certain ports and programs.
Paths are in device form, such as \device\harddiskvolume3\windows\system32\svchost.exe, and directions are codes. Both need translation before they can be compared with other sources. The event has no user, only a process identifier.
Key fields to inspect
| Field | Meaning | Suspicious when |
|---|---|---|
Application | Program, as a device path in lowercase. | Programs in user or temporary folders, or rundll32.exe, powershell.exe and msbuild.exe going to the internet. |
Direction | %%14592 is inbound and %%14593 is outbound. | Inbound connections to a workstation from another workstation. |
DestAddress | Destination address. | Addresses in no known range, or internal hosts outside the program's role. |
DestPort | Destination port. | 445, 135, 3389 or 5985 from a workstation, or 88 and 389 from a program other than lsass.exe. |
SourceAddress | Source address. | Useful on hosts with several addresses. |
ProcessID | Process identifier in decimal. | Convert it to hexadecimal to match NewProcessId in 4688. |
Protocol | Protocol number. 6 is TCP and 17 is UDP. | Unusual values such as 1 (ICMP) in quantity. |
Detection queries
Find script hosts and system binaries that connect to public addresses, or that fan out to many internal hosts on administrative ports. Adjust names and thresholds to your environment. About these queries.
Splunk SPL
index=windows source="XmlWinEventLog:Security" EventCode=5156
Direction="%%14593"
| rex field=Application "(?<program>[^\\\\]+)$"
| eval internal=if(cidrmatch("10.0.0.0/8", DestAddress) OR cidrmatch("172.16.0.0/12", DestAddress) OR cidrmatch("192.168.0.0/16", DestAddress), 1, 0)
| stats dc(eval(if(internal=0, DestAddress, null()))) AS public dc(eval(if(internal=1 AND (DestPort=445 OR DestPort=3389 OR DestPort=5985), DestAddress, null()))) AS admin_hosts BY Computer program
| where (public>0 AND match(program, "(?i)^(powershell|pwsh|rundll32|regsvr32|mshta|msbuild|wscript|cscript)\.exe$")) OR admin_hosts>=10 Microsoft Sentinel KQL
SecurityEvent
| where EventID == 5156
| extend Application = extract(@'Name="Application">([^<]*)<', 1, EventData)
| extend DestAddress = extract(@'Name="DestAddress">([^<]*)<', 1, EventData)
| extend DestPort = extract(@'Name="DestPort">([^<]*)<', 1, EventData)
| extend Direction = extract(@'Name="Direction">([^<]*)<', 1, EventData)
| where Direction == "%%14593"
| extend Program = tolower(tostring(split(Application, "\\")[-1])), Internal = ipv4_is_private(DestAddress)
| summarize Public = dcountif(DestAddress, Internal == false), AdminHosts = dcountif(DestAddress, Internal == true and DestPort in ("445", "3389", "5985")) by Computer, Program, bin(TimeGenerated, 1h)
| where (Public > 0 and Program in ("powershell.exe", "pwsh.exe", "rundll32.exe", "regsvr32.exe", "mshta.exe", "msbuild.exe", "wscript.exe", "cscript.exe")) or AdminHosts >= 10 PowerShell
Get-WinEvent -FilterHashtable @{ LogName = 'Security'; Id = 5156; StartTime = (Get-Date).AddDays(-1) } |
ForEach-Object { $d = @{ Time = $_.TimeCreated }; ([xml]$_.ToXml()).Event.EventData.Data | ForEach-Object { $d[$_.Name] = $_.'#text' }; [pscustomobject]$d } |
Where-Object { $_.Direction -eq '%%14593' -and $_.DestAddress -notmatch '^(10\.|127\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.|::1|fe80)' } |
Select-Object Time, Application, DestAddress, DestPort, ProcessID | Format-Table -AutoSize Attack scenarios
Command and control from a trusted binary
Injected code makes rundll32.exe, regsvr32.exe or dllhost.exe connect to the internet at regular intervals. The program is signed and the destination is new, so the combination is the signal.
Internal port scan
One program connects to hundreds of internal addresses on 445, 135 or 3389. Only permitted connections appear here, so blocked attempts (5157) show how much was really tried.
Roasting and enumeration tools
Kerberos (88) and LDAP (389) traffic from a program other than lsass.exe is typical of attack tools that implement the protocols themselves.
Investigation checklist
- Convert ProcessID to hexadecimal and join with 4688 for user and command line.
- Check the destination's reputation, age and ownership.
- Look for regular intervals between connections.
- Find which rule allowed it, and block the destination if needed.
Common benign causes
- Browsers, update services and cloud agents, which dominate the volume.
- PowerShell modules and management scripts that reach the internet.
- Vulnerability scanners and monitoring probes.
Event ID 5156 FAQ
Should I enable event 5156?
Not everywhere. It can overwhelm the Security log. Enable it on selected hosts or during an investigation, or use Sysmon event 3 with a filter for a permanent solution.
What do %%14592 and %%14593 mean?
%%14592 is inbound and %%14593 is outbound. These codes are resolved to words when the event is displayed, but they stay as codes in the XML.
What is the difference between 5156 and 5157?
5156 is a permitted connection and 5157 is a blocked one. Both belong to the same audit subcategory, as success and failure respectively.