Skip to content
WETNav
FirewallDefense Evasion

Event ID 2004: Firewall rule added

Written when a rule is added to the Windows Defender Firewall. Records the rule, its direction, ports, program and the account that added it.

Channel
Microsoft-Windows-Windows Firewall With Advanced Security/Firewall
Logged by default
Yes
Written on
Any host
Volume
Low
Provider
Microsoft-Windows-Windows Firewall With Advanced Security
Needs a SACL
No

Key fields

Exact XML field names, as they appear in <Data Name="…"> and in SIEM field extractions.

RuleNameDisplay name of the new rule
RuleIdIdentifier of the rule
DirectionInbound or outbound
LocalPortsLocal port(s) the rule opens (e.g. 3389 for RDP, 5985 for WinRM, 445 for SMB)
ProtocolProtocol number (6 = TCP, 17 = UDP)
ApplicationPathProgram the rule applies to, if any
ModifyingUserAccount that added the rule
ModifyingApplicationProgram used to add the rule (e.g. netsh.exe, powershell.exe, svchost.exe)
Have one of these events? Paste it into the decoder

Analyst notes

  • 01A new inbound rule opening RDP (3389), WinRM (5985/5986), SMB (445) or a high ephemeral port is a common step to enable remote access or a backdoor; check Direction and LocalPorts.
  • 02ModifyingApplication of netsh.exe or powershell.exe outside a change window is worth attention; legitimate installers add rules too, so weigh the port and program.
  • 03Correlate with 7045 (a new service listening), with the Security firewall events (4946/4947), and with the matching listener coming online.

Pull this event

Retrieval queries for a live host, a collected .evtx file and common SIEMs. Filter further on the key fields above.

Get-WinEvent -LogName 'Microsoft-Windows-Windows Firewall With Advanced Security/Firewall' -FilterXPath "*[System[(EventID=2004)]]" -MaxEvents 50 |
  Select-Object TimeCreated, Id, MachineName, Message

-FilterXPath supports exact matches only. For substring matching, filter in Where-Object.

ATT&CK mapping

Techniques this event can help detect. Most of these depend on specific field values; the event alone does not mean the technique happened.

Common questions

What does Windows event ID 2004 mean?
Written when a rule is added to the Windows Defender Firewall. Records the rule, its direction, ports, program and the account that added it. It is written to the Windows Defender Firewall log (Microsoft-Windows-Windows Firewall With Advanced Security/Firewall).
Is event 2004 logged by default?
Yes, a default Windows installation records it.
Where is event 2004 recorded?
In the Microsoft-Windows-Windows Firewall With Advanced Security/Firewall channel on the any host.

Written when a rule is added to the Windows Defender Firewall. Records the rule, its direction, ports, program and the account that added it. Key fields, logging requirements, ATT&CK mapping and ready-to-run queries.