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.
| Field | What it tells you |
|---|---|
| RuleName | Display name of the new rule |
| RuleId | Identifier of the rule |
| Direction | Inbound or outbound |
| LocalPorts | Local port(s) the rule opens (e.g. 3389 for RDP, 5985 for WinRM, 445 for SMB) |
| Protocol | Protocol number (6 = TCP, 17 = UDP) |
| ApplicationPath | Program the rule applies to, if any |
| ModifyingUser | Account that added the rule |
| ModifyingApplication | Program used to add the rule (e.g. netsh.exe, powershell.exe, svchost.exe) |
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.
Related events
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.
Decode a real event
Paste the XML and every value gets explained. Nothing leaves your browser.
Open decoderWritten 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.