Detect Disable or Modify System Firewall in Elastic Security
Adversaries may disable or modify system firewalls in order to bypass controls limiting network usage. Changes could be disabling the entire mechanism as well as adding, deleting, or modifying particular rules. This can be done via command-line tools (netsh, iptables, ufw, pfctl), editing Windows Registry keys, or through the Windows Control Panel. On ESXi, firewall rules may be modified via esxcli. Adversaries may add new firewall rules for RDP on non-standard ports or open all traffic to enable C2, lateral movement, and data exfiltration.
MITRE ATT&CK
- Tactic
- Defense Evasion
- Technique
- T1562 Impair Defenses
- Sub-technique
- T1562.004 Disable or Modify System Firewall
- Canonical reference
- https://attack.mitre.org/techniques/T1562/004/
Elastic Detection Query
sequence by host.name, user.name with maxspan=5m
[process where event.type == "start" and (
(process.name in ("netsh.exe", "cmd.exe", "powershell.exe") and (
process.args : "*advfirewall*" and process.args : ("*set allprofiles state off*", "*opmode disable*", "*firewall add*", "*firewall delete*")
)) or
(process.name == "powershell.exe" and (
process.args : "*Set-NetFirewallProfile*" and process.args : "*Enabled*False*" or
process.args : "*New-NetFirewallRule*" or
process.args : "*Remove-NetFirewallRule*"
)) or
(process.name in ("iptables", "ip6tables") and process.args : ("-F", "-X", "-P")) or
(process.name == "ufw" and process.args : "disable") or
(process.name == "pfctl" and process.args : "-d") or
(process.name == "esxcli" and process.args : "*network firewall set*")
)]
| where not (user.name in ("ansible", "chef", "puppet") and process.parent.name in ("ansible-playbook", "ruby")) Detects firewall disablement or rule modification across Windows, Linux, and ESXi via process execution of netsh, iptables, ufw, pfctl, esxcli, or PowerShell firewall cmdlets. Sequences events by host and user within a 5-minute window to correlate related activity.
Data Sources
Required Tables
False Positives & Tuning
- Legitimate system administrators running firewall configuration scripts during maintenance windows or change control procedures.
- Configuration management tools such as Ansible, Chef, Puppet, or SaltStack modifying firewall rules as part of automated infrastructure provisioning.
- Security scanning tools or vulnerability management platforms temporarily modifying firewall rules to perform authorized network assessments.
Other platforms for T1562.004
Testing Methodology
Validate this detection against 3 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Disable Windows Firewall All Profiles
Expected signal: Sysmon Event ID 1: netsh.exe process creation. Windows Firewall Event ID 2003: Firewall profile changed. Each profile state change generates a separate event.
- Test 2Add Firewall Rule for RDP on Non-Standard Port
Expected signal: Sysmon Event ID 1: netsh.exe with 'firewall add rule'. Windows Firewall Event ID 2004: A rule has been added.
- Test 3Flush IPTables Rules on Linux
Expected signal: Auditd execve syscall records for iptables. Syslog entries for iptables commands. MDE DeviceProcessEvents if MDE for Linux is deployed.
References (4)
Unlock Pro Content
Get the full detection package for T1562.004 including response playbook, investigation guide, and atomic red team tests.