Skip to content

Commit 207de51

Browse files
committed
Add XPAV-derived detection rules for cryptominer, webshell, and container escape
This PR adds 6 new detection rules derived from the XPAV project (https://github.com/JNC4/xpav), focusing on threat vectors not covered by existing Falco rules: **Cryptominer Detection:** - Known Cryptominer Process Executed: Detects common miner binaries (xmrig, ethminer, etc.) - complements existing stratum protocol rule **Web Server Abuse (Webshell Detection):** - Web Server Spawned Shell: Detects shells spawned from nginx/apache/php-fpm - Web Server Spawned Suspicious Child: Detects curl/wget/nc from web servers - Reverse Shell from Web Server: Detects common reverse shell patterns **Container Escape:** - Privileged Container Device Access: Detects raw block device access - Container Access to Host Sensitive Paths: Detects /host /rootfs access All rules include: - MITRE ATT&CK technique mapping - Tuning macros (user_known_*) for customization - Detailed descriptions with anti-pattern guidance - Appropriate priority levels These rules address the gap in web server/webshell detection which is a common attack vector not currently covered by Falco's ruleset. Signed-off-by: Julius C <jnc4mail@gmail.com>
1 parent 3591f69 commit 207de51

File tree

1 file changed

+173
-0
lines changed

1 file changed

+173
-0
lines changed

rules/falco-sandbox_rules.yaml

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,3 +1764,176 @@
17641764
output: Netcat/Socat runs on host that allows remote code execution | evt_type=%evt.type user=%user.name user_uid=%user.uid user_loginuid=%user.loginuid process=%proc.name proc_exepath=%proc.exepath parent=%proc.pname command=%proc.cmdline terminal=%proc.tty exe_flags=%evt.arg.flags
17651765
priority: WARNING
17661766
tags: [maturity_sandbox, host, network, process, mitre_execution, T1059]
1767+
1768+
#############################################################################
1769+
# XPAV-derived Detection Rules
1770+
# https://github.com/JNC4/xpav
1771+
#
1772+
# These rules detect cryptominer activity, web server abuse (webshells),
1773+
# and container escape patterns not covered by existing Falco rules.
1774+
#############################################################################
1775+
1776+
# Known cryptominer binary names - complements existing stratum protocol detection
1777+
- list: miner_binaries
1778+
items: [
1779+
xmrig, xmr-stak, minerd, minergate, cpuminer, ccminer,
1780+
ethminer, cgminer, bfgminer, sgminer, claymore, nbminer,
1781+
t-rex, gminer, lolminer, phoenixminer, teamredminer,
1782+
nanominer, bminer, wildrig, srbminer
1783+
]
1784+
1785+
- macro: is_miner_process
1786+
condition: (proc.name in (miner_binaries))
1787+
1788+
- rule: Known Cryptominer Process Executed
1789+
desc: >
1790+
Detects execution of known cryptocurrency mining software by matching process names against
1791+
a list of common miners. Cryptominers are commonly deployed by attackers after gaining initial
1792+
access to monetize compromised systems. This rule complements the existing "Detect crypto miners
1793+
using the Stratum protocol" rule by catching miners that may use renamed binaries but still
1794+
match known miner process names. Consider tuning this rule if you have legitimate mining
1795+
operations in your environment.
1796+
condition: >
1797+
spawned_process
1798+
and is_miner_process
1799+
output: Cryptominer process executed | process=%proc.name exe=%proc.exepath evt_type=%evt.type user=%user.name user_uid=%user.uid user_loginuid=%user.loginuid parent=%proc.pname command=%proc.cmdline terminal=%proc.tty container_id=%container.id container_name=%container.name
1800+
priority: CRITICAL
1801+
tags: [maturity_sandbox, host, container, process, mitre_impact, T1496]
1802+
1803+
# Web server processes - used for webshell detection
1804+
- list: web_server_binaries
1805+
items: [nginx, httpd, httpd-foregroun, apache, apache2, lighttpd, php-fpm, php, php-cgi, php7, php8, gunicorn, uwsgi]
1806+
1807+
# Suspicious child processes that shouldn't be spawned by web servers
1808+
- list: suspicious_web_children
1809+
items: [curl, wget, nc, ncat, netcat, socat, python, python3, perl, ruby, nmap, id, whoami, uname, base64]
1810+
1811+
- macro: spawned_by_web_server
1812+
condition: >
1813+
(proc.pname in (web_server_binaries) or
1814+
proc.aname[2] in (web_server_binaries) or
1815+
proc.aname[3] in (web_server_binaries))
1816+
1817+
- macro: user_known_web_server_shell_activities
1818+
condition: (never_true)
1819+
1820+
- rule: Web Server Spawned Shell
1821+
desc: >
1822+
Detects a web server process (nginx, apache, php-fpm, etc.) spawning an interactive shell.
1823+
This is a strong indicator of webshell exploitation or remote code execution vulnerability
1824+
being actively exploited. Webshells are a common persistence mechanism used by attackers
1825+
after compromising web applications. The macro user_known_web_server_shell_activities can
1826+
be overridden to tune for legitimate use cases like CGI scripts. Note that simple shell
1827+
wrappers used in health checks are excluded.
1828+
condition: >
1829+
spawned_process
1830+
and spawned_by_web_server
1831+
and proc.name in (shell_binaries)
1832+
and not proc.cmdline startswith "sh -c /usr/bin"
1833+
and not proc.cmdline contains "healthcheck"
1834+
and not user_known_web_server_shell_activities
1835+
output: Web server spawned shell | shell=%proc.name web_server=%proc.pname gparent=%proc.aname[2] ggparent=%proc.aname[3] evt_type=%evt.type user=%user.name user_uid=%user.uid user_loginuid=%user.loginuid command=%proc.cmdline terminal=%proc.tty container_id=%container.id container_name=%container.name exe=%proc.exepath
1836+
priority: CRITICAL
1837+
tags: [maturity_sandbox, host, container, process, mitre_persistence, mitre_execution, T1505.003]
1838+
1839+
- macro: user_known_web_server_child_activities
1840+
condition: (never_true)
1841+
1842+
- rule: Web Server Spawned Suspicious Child Process
1843+
desc: >
1844+
Detects web server processes spawning suspicious child processes like curl, wget, netcat,
1845+
or scripting interpreters. These often indicate exploitation of web application vulnerabilities,
1846+
where attackers download additional payloads or establish network connections. This rule is
1847+
more sensitive than the shell spawning rule and may require tuning in environments where
1848+
web applications legitimately execute system commands. Override the macro
1849+
user_known_web_server_child_activities for custom tuning.
1850+
condition: >
1851+
spawned_process
1852+
and spawned_by_web_server
1853+
and proc.name in (suspicious_web_children)
1854+
and not proc.name in (shell_binaries)
1855+
and not proc.cmdline contains "healthcheck"
1856+
and not proc.cmdline contains "status"
1857+
and not user_known_web_server_child_activities
1858+
output: Web server spawned suspicious child process | child=%proc.name web_server=%proc.pname gparent=%proc.aname[2] evt_type=%evt.type user=%user.name user_uid=%user.uid user_loginuid=%user.loginuid command=%proc.cmdline terminal=%proc.tty container_id=%container.id container_name=%container.name
1859+
priority: WARNING
1860+
tags: [maturity_sandbox, host, container, process, mitre_execution, T1059]
1861+
1862+
- rule: Reverse Shell from Web Server
1863+
desc: >
1864+
Detects common reverse shell patterns spawned from web server processes. Attackers frequently
1865+
establish reverse shells after exploiting web vulnerabilities to maintain interactive access
1866+
to the compromised system. This rule looks for specific command patterns known to create
1867+
reverse shells, including bash /dev/tcp redirects, netcat with -e flag, and common scripting
1868+
language reverse shell idioms.
1869+
condition: >
1870+
spawned_process
1871+
and spawned_by_web_server
1872+
and (proc.cmdline contains "/dev/tcp/" or
1873+
proc.cmdline contains "nc -e" or
1874+
proc.cmdline contains "ncat -e" or
1875+
proc.cmdline contains "bash -i" or
1876+
proc.cmdline contains "python -c 'import socket" or
1877+
proc.cmdline contains "python3 -c 'import socket" or
1878+
proc.cmdline contains "perl -e 'use Socket" or
1879+
proc.cmdline contains "ruby -rsocket" or
1880+
(proc.cmdline contains "mkfifo" and proc.cmdline contains "/tmp"))
1881+
output: Reverse shell spawned from web server | process=%proc.name web_server=%proc.pname evt_type=%evt.type user=%user.name user_uid=%user.uid user_loginuid=%user.loginuid command=%proc.cmdline terminal=%proc.tty container_id=%container.id container_name=%container.name
1882+
priority: CRITICAL
1883+
tags: [maturity_sandbox, host, container, process, network, mitre_execution, T1059]
1884+
1885+
# Container escape via privileged device access
1886+
- list: sensitive_block_devices
1887+
items: [/dev/sda, /dev/sdb, /dev/sdc, /dev/nvme0, /dev/nvme1, /dev/vda, /dev/vdb, /dev/xvda, /dev/xvdb]
1888+
1889+
- macro: user_known_privileged_device_access
1890+
condition: (never_true)
1891+
1892+
- rule: Privileged Container Device Access
1893+
desc: >
1894+
Detects container processes accessing raw block devices, which could be used to escape
1895+
container isolation by directly reading or writing to host storage. This technique allows
1896+
attackers to access the host filesystem, modify system files, or extract sensitive data
1897+
even without traditional container escape. Requires the container to have privileged access
1898+
or specific device permissions. Override user_known_privileged_device_access for legitimate
1899+
storage operations.
1900+
condition: >
1901+
(open_read or open_write)
1902+
and container
1903+
and (fd.name startswith /dev/sd or
1904+
fd.name startswith /dev/nvme or
1905+
fd.name startswith /dev/vd or
1906+
fd.name startswith /dev/xvd or
1907+
fd.name = /dev/mem or
1908+
fd.name = /dev/kmem)
1909+
and not user_known_privileged_device_access
1910+
output: Container accessing block device | device=%fd.name evt_type=%evt.type user=%user.name user_uid=%user.uid user_loginuid=%user.loginuid process=%proc.name proc_exepath=%proc.exepath parent=%proc.pname command=%proc.cmdline terminal=%proc.tty container_id=%container.id container_name=%container.name
1911+
priority: CRITICAL
1912+
tags: [maturity_sandbox, container, filesystem, mitre_privilege_escalation, T1611]
1913+
1914+
# Container access to host filesystem paths
1915+
- macro: user_known_host_path_access
1916+
condition: (never_true)
1917+
1918+
# Known container runtimes that legitimately access host paths
1919+
- macro: known_container_runtime_host_access
1920+
condition: (proc.name in (containerd, containerd-shim, dockerd, docker, runc, crio, cri-o, conmon, podman))
1921+
1922+
- rule: Container Access to Host Sensitive Paths
1923+
desc: >
1924+
Detects container processes accessing paths that typically only exist when the host filesystem
1925+
is mounted into the container (like /host, /rootfs, /hostfs). This may indicate a container
1926+
escape attempt or a misconfigured volume mount that exposes the host filesystem. Legitimate
1927+
monitoring or backup containers may access these paths, so tune accordingly using the
1928+
user_known_host_path_access macro.
1929+
condition: >
1930+
(open_read or open_write)
1931+
and container
1932+
and (fd.name startswith /host/ or
1933+
fd.name startswith /rootfs/ or
1934+
fd.name startswith /hostfs/)
1935+
and not known_container_runtime_host_access
1936+
and not user_known_host_path_access
1937+
output: Container accessing host filesystem paths | file=%fd.name evt_type=%evt.type user=%user.name user_uid=%user.uid user_loginuid=%user.loginuid process=%proc.name proc_exepath=%proc.exepath parent=%proc.pname command=%proc.cmdline terminal=%proc.tty container_id=%container.id container_name=%container.name
1938+
priority: WARNING
1939+
tags: [maturity_sandbox, container, filesystem, mitre_privilege_escalation, T1611]

0 commit comments

Comments
 (0)