diff --git a/.env.sample b/.env.sample index c349b05..10c54c7 100644 --- a/.env.sample +++ b/.env.sample @@ -50,7 +50,7 @@ RUST_BACKTRACE=full # longer alerts are truncated to fit. #STACKDOG_DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/.../... # Telegram: create a bot with @BotFather, invite it to a channel or group, and -# set both values. Alerts only — action notifications (bans, quarantines) are +# set both values. Alerts only - action notifications (bans, quarantines) are # not sent to Telegram. Telegram allows 4096 characters per message; longer # alerts are truncated to fit. #STACKDOG_TELEGRAM_BOT_TOKEN=123456789:AAF... @@ -62,7 +62,7 @@ RUST_BACKTRACE=full #STACKDOG_SMTP_USER=alerts@example.com #STACKDOG_SMTP_PASSWORD=secret #STACKDOG_EMAIL_RECIPIENTS=soc@example.com,oncall@example.com -# Identity shown as "Instance" in notifications — say which host sent the +# Identity shown as "Instance" in notifications - say which host sent the # alert. Falls back to the machine hostname when unset; set this explicitly # for stable names in a fleet. #STACKDOG_NOTIFICATION_LABEL=prod-eu-1 @@ -140,7 +140,7 @@ RUST_BACKTRACE=full # Dashboard container (docker-compose.yml / docker-compose.app.yml) # --------------------------------------------------------------------------- # Host:port a browser uses to reach the API. Read by the dashboard container at -# start-up, so a restart is enough — no rebuild. +# start-up, so a restart is enough - no rebuild. #STACKDOG_API_HOST=192.0.2.10:5000 # Port the dashboard is published on. #STACKDOG_UI_PORT=3000 diff --git a/CHANGELOG.md b/CHANGELOG.md index 46063b6..17b0870 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,16 +12,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - NGINX2Root exposure (CVE-2026-123007, CVE-2026-123633, CVE-2026-123634, CVE-2026-121810, CVE-2026-113425): `vuln.nginx2root` flags nginx builds older than 1.30.7 (stable) / 1.31.9 (mainline) whose config reaches one of the five - CVEs — HTTP/2, HTTP/3, the mail proxy, or `proxy_pass` with a variable plus an + CVEs - HTTP/2, HTTP/3, the mail proxy, or `proxy_pass` with a variable plus an SSI/mirror subrequest. It reads `NGINX_VERSION` from official images and the package databases, follows nginx's two version tracks, and names the CVE, the feature and the mitigation. `nginx.worker-crash` alerts on a run of nginx workers dying on memory faults. `kernel.sctp-exposed` alerts when the Linux - `sctp` module is loaded — the unpatched kernel step of the root-escalation + `sctp` module is loaded - the unpatched kernel step of the root-escalation chain. `web.worker-exec` alerts when a web-server worker executes a program, the RCE end state (reads eBPF syscall events, which `serve` does not yet collect). `kernel.sctp-socket` alerts when a web worker or container process - creates an SCTP socket — the first step of the kernel root-escalation. + creates an SCTP socket - the first step of the kernel root-escalation. `nginx.http2-spray` is a workload-level heuristic that flags a container whose inbound bytes grew while its logged request count stayed small, the footprint of the HTTP/2 heap spray. The eBPF collector now traces `socket()` as well, so @@ -37,7 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 running containers against the public feeds. OSV answers "does this exact version have known vulnerabilities" (Debian and Ubuntu versions server-side, Alpine versions without the `-rN` package revision), CISA's KEV catalog says - which are exploited in the wild — those are Critical, the rest carry the + which are exploited in the wild - those are Critical, the rest carry the advisory's severity label. Alerts once per package and CVE, 50 per pass worst first, caches answers for 24h. A match means a fix is missing, not that a box is exploitable: alerts say to check the vendor's advisory. @@ -45,7 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Configuration is also read from `~/.config/stackdog/.env` (`$XDG_CONFIG_HOME/stackdog/.env` when set), behind the working-directory `.env`: the nearest file wins and real environment variables win over both. - A missing file is no longer a warning — every setting has a default. + A missing file is no longer a warning - every setting has a default. - `stackdog init` writes the starter config to that directory and never overwrites an existing file (it holds credentials). - Discord webhook notifications (`STACKDOG_DISCORD_WEBHOOK_URL`), routed exactly @@ -117,10 +117,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - PHP shell detection. Each sniff pass scores the PHP files in host web roots (`STACKDOG_PHPSHELL_PATHS`) and in the docroots of PHP containers for webshell code, and alerts on new or changed files that score as one (`php.shell-file`). - Requests that drive a shell — any request to a flagged upload through an + Requests that drive a shell - any request to a flagged upload through an `uploads/` URL, parameters sent to a flagged file that is not a common entry point, a POST to PHP under an `uploads/` URL (PATH_INFO and `//`, `.`, `..` - resolved) — are banned like other detector findings (`web.php-shell-access`). + resolved) - are banned like other detector findings (`web.php-shell-access`). A plain visit to an infected page is an alert only (`php.shell-request`). Running in Docker, mount the host read-only and set `STACKDOG_HOST_ROOT`. Extra signatures load from JSON (`STACKDOG_PHPSHELL_SIGNATURES`). @@ -138,14 +138,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - **The AI `ban_ip` tool must name a confirmed attack.** It banned addresses - for "repeated connection attempts" — background internet noise the auto path + for "repeated connection attempts" - background internet noise the auto path deliberately ignores. Weak reasons are now refused with a message telling the model to report an alert instead, tool-driven bans respect the per-minute ceiling (the CLI stays exempt), and the tool description says what counts as a confirmed attack. - **Alerts say which host sent them.** The Slack "Instance" field comes from `STACKDOG_NOTIFICATION_LABEL`, and now falls back to the machine hostname - when the label is unset — an unattributable alert is half an alert in a fleet. + when the label is unset - an unattributable alert is half an alert in a fleet. ## [0.2.5] - 2026-10-26 @@ -159,7 +159,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 used to skip all of these checks. - **Ban rules are tagged and reconciled.** Rules now carry a `stackdog` marker; on start, rules with no database record are removed and recorded bans with no - rule are re-applied — a crash between the firewall write and the database + rule are re-applied - a crash between the firewall write and the database write used to strand a DROP rule nothing would ever remove. - **Expired bans are released in `stackdog sniff` too.** The expiry loop ran only under `serve`; a sniff-only deployment banned permanently. @@ -175,26 +175,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- `stackdog unban ` — release a ban and remove its firewall rules, even +- `stackdog unban ` - release a ban and remove its firewall rules, even when the database has no record of it (crash leftovers). -- `stackdog unban --all` — release every ban and remove every Stackdog firewall +- `stackdog unban --all` - release every ban and remove every Stackdog firewall rule: the one command to restore connectivity after a wrong ban. -- `stackdog firewall list` — show blocked addresses in the firewall and the +- `stackdog firewall list` - show blocked addresses in the firewall and the database side by side. -- `stackdog firewall reconcile` — run the startup reconciliation on demand. +- `stackdog firewall reconcile` - run the startup reconciliation on demand. - AI tool `unban_ip`, symmetric to `ban_ip`. -- `STACKDOG_IP_BAN_PROTECT_LOCAL_IPS` (default `true`) — never ban addresses of +- `STACKDOG_IP_BAN_PROTECT_LOCAL_IPS` (default `true`) - never ban addresses of this host or its containers. ## [0.2.2] - 2026-04-07 ### Fixed -- **CLI startup robustness** — `.env` loading is now non-fatal. +- **CLI startup robustness** - `.env` loading is now non-fatal. - `stackdog --help` and other commands no longer panic when `.env` is missing or contains malformed lines. - Stackdog now logs a warning and continues with existing environment variables. -- **Installer release resolution** — `install.sh` now handles missing `/releases/latest` responses gracefully. +- **Installer release resolution** - `install.sh` now handles missing `/releases/latest` responses gracefully. - Falls back to the most recent release entry when no stable "latest" release is available. - Improves error messaging and updates install examples to use the `main` branch script URL. @@ -211,7 +211,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - RFC3164 and RFC5424 parsing in file-based log ingestion for cleaner timestamps and normalized message bodies. #### Log Sniffing & Analysis (`stackdog sniff`) -- **CLI Subcommands** — Multi-mode binary with `stackdog serve` and `stackdog sniff` +- **CLI Subcommands** - Multi-mode binary with `stackdog serve` and `stackdog sniff` - `--once` flag for single-pass mode - `--consume` flag to archive logs (zstd) and purge originals - `--sources` to add custom log paths @@ -219,48 +219,48 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `--interval` for polling frequency - `--output` for archive destination -- **Log Source Discovery** — Automatic and manual log source management +- **Log Source Discovery** - Automatic and manual log source management - System logs (`/var/log/syslog`, `messages`, `auth.log`, etc.) - Docker container logs via bollard API - Custom file paths (CLI, env var, or REST API) - Incremental read position tracking (byte offset persisted in DB) -- **Log Readers** — Trait-based reader abstraction +- **Log Readers** - Trait-based reader abstraction - `FileLogReader` with byte-offset tracking and log rotation detection - `DockerLogReader` using bollard streaming API - `JournaldReader` (Linux-gated) for systemd journal -- **AI-Powered Analysis** — Dual-backend log summarization - - `OpenAiAnalyzer` — works with any OpenAI-compatible API (OpenAI, Ollama, vLLM) - - `PatternAnalyzer` — local fallback with error/warning counting and spike detection +- **AI-Powered Analysis** - Dual-backend log summarization + - `OpenAiAnalyzer` - works with any OpenAI-compatible API (OpenAI, Ollama, vLLM) + - `PatternAnalyzer` - local fallback with error/warning counting and spike detection - Structured `LogSummary` with anomaly detection (`LogAnomaly`, severity levels) -- **Log Consumer** — Archive and purge pipeline +- **Log Consumer** - Archive and purge pipeline - FNV hash-based deduplication - zstd compression (level 3) for archived logs - File truncation and Docker log purge - `ConsumeResult` tracking (entries archived, duplicates skipped, bytes freed) -- **Reporter** — Bridges log analysis to existing alert system +- **Reporter** - Bridges log analysis to existing alert system - Converts `LogAnomaly` → `Alert` using `AlertManager` infrastructure - Routes notifications via `route_by_severity()` to configured channels - Persists `LogSummary` records to database - **REST API Endpoints** - - `GET /api/logs/sources` — list discovered log sources - - `POST /api/logs/sources` — manually add a custom source - - `GET /api/logs/sources/{path}` — get source details - - `DELETE /api/logs/sources/{path}` — remove a source - - `GET /api/logs/summaries` — list AI-generated summaries (filterable by source) + - `GET /api/logs/sources` - list discovered log sources + - `POST /api/logs/sources` - manually add a custom source + - `GET /api/logs/sources/{path}` - get source details + - `DELETE /api/logs/sources/{path}` - remove a source + - `GET /api/logs/summaries` - list AI-generated summaries (filterable by source) -- **Database Tables** — `log_sources` and `log_summaries` with indexes +- **Database Tables** - `log_sources` and `log_summaries` with indexes #### Dependencies -- `clap = "4"` (derive) — CLI argument parsing -- `async-trait = "0.1"` — async trait support -- `reqwest = "0.12"` (json) — HTTP client for AI APIs -- `zstd = "0.13"` — log compression -- `futures-util = "0.3"` — Docker log streaming +- `clap = "4"` (derive) - CLI argument parsing +- `async-trait = "0.1"` - async trait support +- `reqwest = "0.12"` (json) - HTTP client for AI APIs +- `zstd = "0.13"` - log compression +- `futures-util = "0.3"` - Docker log streaming ### Changed diff --git a/README.md b/README.md index 31a2369..dfcc70a 100644 --- a/README.md +++ b/README.md @@ -17,16 +17,16 @@ ### 🔥 Key Features -- **📊 Real-time Monitoring** — eBPF-based syscall monitoring with minimal overhead (<5% CPU) -- **🔍 Log Sniffing** — Discover, read, and AI-summarize logs from containers and system files -- **🐘 PHP Shell Detection** — Finds webshells in host and container web roots and bans the clients driving them -- **🧭 Detector Framework** — Rust-native detector registry for web attack heuristics and outbound exfiltration indicators -- **🤖 AI/ML Detection** — Candle-powered anomaly detection + OpenAI/Ollama log analysis -- **🚨 Alert System** — Multi-channel notifications (Slack, Discord, Telegram, email, webhook) -- **🔒 Automated Response** — nftables/iptables firewall, container quarantine -- **📈 Threat Scoring** — Configurable scoring with time-decay -- **🎯 Signature Detection** — 10+ built-in threat signatures -- **📦 Log Archival** — Deduplicate and compress logs with zstd, optionally purge originals +- **📊 Real-time Monitoring** - eBPF-based syscall monitoring with minimal overhead (<5% CPU) +- **🔍 Log Sniffing** - Discover, read, and AI-summarize logs from containers and system files +- **🐘 PHP Shell Detection** - Finds webshells in host and container web roots and bans the clients driving them +- **🧭 Detector Framework** - Rust-native detector registry for web attack heuristics and outbound exfiltration indicators +- **🤖 AI/ML Detection** - Candle-powered anomaly detection + OpenAI/Ollama log analysis +- **🚨 Alert System** - Multi-channel notifications (Slack, Discord, Telegram, email, webhook) +- **🔒 Automated Response** - nftables/iptables firewall, container quarantine +- **📈 Threat Scoring** - Configurable scoring with time-decay +- **🎯 Signature Detection** - 10+ built-in threat signatures +- **📦 Log Archival** - Deduplicate and compress logs with zstd, optionally purge originals --- @@ -70,7 +70,7 @@ Three settings are worth reviewing after upgrading: | Variable | Default | Why | |---|---|---| -| `STACKDOG_IP_BAN_ALLOWLIST` | empty | Addresses never banned. Put load balancers, health checkers and this host's own public address here — banning them takes the service down. | +| `STACKDOG_IP_BAN_ALLOWLIST` | empty | Addresses never banned. Put load balancers, health checkers and this host's own public address here - banning them takes the service down. | | `STACKDOG_TRUSTED_PROXY_RANGES` | RFC1918 only | A public-facing proxy is **not** covered by the defaults, so its own address is banned instead of the client behind it. Add it as `/32`. | | `STACKDOG_IP_BAN_MAX_PER_MINUTE` | `10` | Ceiling on blocks per minute. A burst is more often a misread log than a crowd of attackers. `0` disables it. | @@ -82,10 +82,10 @@ To ban only on deterministic detectors and never on analyzer prose, set In a microservice stack the ban plane used to turn on the application itself: - a service calling its peers over published ports or a load balancer logged - the peer's address, and a wrong ban dropped it in `INPUT` **and** `FORWARD` — + the peer's address, and a wrong ban dropped it in `INPUT` **and** `FORWARD` - the service lost its own components; - `stackdog ban-ip` and the AI `ban_ip` tool accepted any string, CIDR ranges - included, and skipped the allowlist — `iptables -s 172.16.0.0/12 -j DROP` + included, and skipped the allowlist - `iptables -s 172.16.0.0/12 -j DROP` would take down a Docker network; - a crash between the firewall write and the database write left a DROP rule nothing would ever remove, and there was no way to clear it. @@ -106,14 +106,14 @@ stackdog firewall reconcile # drop orphans, restore missing rules Two related changes: bare `401` lines no longer count as a brute-force attempt, and the mail abuse guard quarantines a container only when it is actually -observing outbound SMTP (`STACKDOG_MAIL_GUARD_REQUIRE_SMTP`, on by default) — +observing outbound SMTP (`STACKDOG_MAIL_GUARD_REQUIRE_SMTP`, on by default) - the traffic heuristic alone matches ordinary service chatter, and quarantine is a network disconnect that needs manual release. ### The offense table is rewritten on first start `ip_offenses` held one row per detection with `offense_count` stuck at `1`, so -the table grew with every hit and one ban left several rows behind — which is +the table grew with every hit and one ban left several rows behind - which is why a single expiry emitted several "Released IP ban" notifications. The first start after upgrading collapses each `(ip_address, source_type)` group @@ -281,9 +281,9 @@ This starts: The compose stack uses: -- `stackdog` service — builds `docker/backend/Dockerfile`, runs `stackdog serve`, mounts `/var/run/docker.sock`, uses `network_mode: host`, and adds `NET_ADMIN` capability for IP banning -- `stackdog-ui` service — builds the React app and serves it with Nginx -- `stackdog-data` volume — persists the SQLite database between restarts +- `stackdog` service - builds `docker/backend/Dockerfile`, runs `stackdog serve`, mounts `/var/run/docker.sock`, uses `network_mode: host`, and adds `NET_ADMIN` capability for IP banning +- `stackdog-ui` service - builds the React app and serves it with Nginx +- `stackdog-data` volume - persists the SQLite database between restarts > **Prerequisite for IP banning:** The `network_mode: host` and `cap_add: NET_ADMIN` settings are required so that `iptables`/`nftables` rules applied inside the container affect the host's network stack. Without them, IP ban firewall rules cannot reach host traffic. @@ -552,7 +552,7 @@ stackdog sniff --sources "/app/logs/api.log,/app/logs/worker.log" - 🤖 AI summarization via OpenAI, Ollama, or local pattern analysis - 📦 Deduplicates and compresses logs with zstd - 🗑️ Optional `--consume` mode: archives then purges originals -- 📊 Incremental reading — tracks byte offsets, never re-reads old entries +- 📊 Incremental reading - tracks byte offsets, never re-reads old entries - 🚨 Anomaly alerts routed to configured notification channels **REST API:** @@ -575,7 +575,7 @@ Every sniff pass reads the PHP files in web roots and scores them for webshell code: request input reaching `eval`/`system`/`assert`, `eval` of decoded data, `preg_replace` with `/e`, request input called as a function, and markers of known families (c99, r57, WSO, b374k, p0wny, China Chopper). One keyword never -flags a file — WordPress calls `base64_decode`, Composer calls `proc_open` — the +flags a file - WordPress calls `base64_decode`, Composer calls `proc_open` - the score does. PHP in an upload directory, and PHP hidden in an image there, add to it. @@ -602,7 +602,7 @@ volumes: |---|---|---| | `php.shell-file` | a new or changed file scores as a shell | alert (a file names no attacker) | | `web.php-shell-access` | any request to a flagged upload whose URL goes through `uploads/`; a request with parameters to a flagged file that is not a common entry point; a POST to PHP under an `uploads/` URL (`/images/`, `/files/`, `/tmp/` URLs never ban on their own) | alert + IP ban | -| `php.shell-request` | a plain visit to a flagged page such as `index.php` | alert only, never a ban — banning visitors of an infected page would ban its audience | +| `php.shell-request` | a plain visit to a flagged page such as `index.php` | alert only, never a ban - banning visitors of an infected page would ban its audience | Bans go through the same gate as every other ban: `STACKDOG_IP_BAN_ALLOWLIST`, protected local addresses and the per-minute ceiling all apply. Stackdog never @@ -624,7 +624,7 @@ fix is upgrading PHP; Stackdog tells you where you still have to. | Finding | When | Action | |---|---|---| | `vuln.php2shell` | a PHP build older than 8.2.35, 8.3.36, 8.4.27 or 8.5.12, or any 8.1 and older | Critical alert for upstream builds (official `php` images, read from `PHP_VERSION`); Medium "check your vendor" alert for distribution packages, which backport fixes without changing the version number | -| `php.worker-crash` | 3 or more php-fpm or Apache workers dying on SIGSEGV, SIGBUS, SIGABRT or SIGILL in one log source within one pass; 1–2 per pass never alert, so one flaky extension stays quiet | alert; repeated crashes are what attempts against PHP memory bugs leave behind | +| `php.worker-crash` | 3 or more php-fpm or Apache workers dying on SIGSEGV, SIGBUS, SIGABRT or SIGILL in one log source within one pass; 1-2 per pass never alert, so one flaky extension stays quiet | alert; repeated crashes are what attempts against PHP memory bugs leave behind | | `web.php2shell-attempt` | the exploit's out-of-memory step, with the client address: Apache `[client …] PHP Fatal error: Allowed memory size … in Unknown on line 0`; nginx `upstream sent unexpected FastCGI record … client: …, request: "POST …"` (php-fpm); or the public scanner's `php2shell-…` User-Agent | alert + an offense per line, so a client causing 5 within the ban window is banned in the pass that reads them | The version check reads `php8.x-common` (Debian, Ubuntu) and `php8x-common` or `php8x` (Alpine) @@ -673,7 +673,7 @@ whose password field is `*`, such as root. Fixed in OpenSSH 10.6p2. The version check reads apk databases only: musl is the affected half of the configuration, and the PAM flavor (`openssh-server-pam`) and glibc distributions are not affected by the CVE. The log half reads the auth and -syslog sources the brute-force bans come from — on Alpine, sshd logs to +syslog sources the brute-force bans come from - on Alpine, sshd logs to `/var/log/messages`. Key-only accounts are `root` and `alpine`; add yours with `STACKDOG_SSHOLE_KEYONLY_USERS`. Stackdog cannot patch OpenSSH: upgrading is the fix. @@ -695,7 +695,7 @@ are Critical, the rest carry the advisory's own severity label. Each package is re-queried at least every 24 hours, which is what catches newly published CVEs; answers are cached in the database so a restart does not re-query everything. Alerts are capped at 50 per pass, worst first. Honest -limits: a match says a fix is missing, not that a machine is exploitable — +limits: a match says a fix is missing, not that a machine is exploitable - distributions backport fixes, and configuration-dependent CVEs do not survive being flattened into a version range, so treat findings as "check your vendor's advisory". Very fresh CVEs may not be in the feeds yet; the @@ -712,10 +712,10 @@ version. Fixed in nginx 1.30.7 (stable) and 1.31.9 (mainline). | Finding | When | Action | |---|---|---| -| `vuln.nginx2root` | an nginx build older than the fixes whose config reaches one of the five CVEs: HTTP/2 (CVE-2026-123007, CVE-2026-123633), HTTP/3/QUIC (CVE-2026-121810), the mail proxy (CVE-2026-113425), or `proxy_pass` with a variable plus an SSI/mirror subrequest (CVE-2026-123634) | alert naming the CVE, the feature and the mitigation (e.g. `http2 off`) until you upgrade and **restart** nginx — a reload does not replace the binary. Never bans | +| `vuln.nginx2root` | an nginx build older than the fixes whose config reaches one of the five CVEs: HTTP/2 (CVE-2026-123007, CVE-2026-123633), HTTP/3/QUIC (CVE-2026-121810), the mail proxy (CVE-2026-113425), or `proxy_pass` with a variable plus an SSI/mirror subrequest (CVE-2026-123634) | alert naming the CVE, the feature and the mitigation (e.g. `http2 off`) until you upgrade and **restart** nginx - a reload does not replace the binary. Never bans | | `nginx.worker-crash` | a run of nginx workers dying on memory faults (SIGSEGV and friends) | alert: that crash spray is what heap-grooming exploits leave behind | -| `web.worker-exec` | a web-server worker (nginx, Apache, php-fpm) executed a program | Critical alert: workers do not exec, so the process was hijacked — the RCE end state | -| `nginx.http2-spray` | a workload moved a lot of inbound bytes while logging few or no requests | review alert: the HTTP/2 heap spray's control frames are never logged, so its traffic looks like this (heuristic — a large upload can too; correlate with the two above) | +| `web.worker-exec` | a web-server worker (nginx, Apache, php-fpm) executed a program | Critical alert: workers do not exec, so the process was hijacked - the RCE end state | +| `nginx.http2-spray` | a workload moved a lot of inbound bytes while logging few or no requests | review alert: the HTTP/2 heap spray's control frames are never logged, so its traffic looks like this (heuristic - a large upload can too; correlate with the two above) | | `kernel.sctp-socket` | a web worker or container process created an SCTP socket | Critical/High alert: the first step of the kernel root-escalation | | `kernel.sctp-exposed` | the Linux `sctp` module is loaded | alert: the unpatched kernel step of the chain is reachable; block it (`install sctp /bin/false`) on hosts that do not need SCTP | @@ -728,7 +728,7 @@ nginx images set `NGINX_VERSION`, which is read directly. turn the two checks off. Honest limits: the exploit's HTTP/2 control frames are not logged as requests, -so Stackdog cannot see the attack traffic itself — it sees the exposure (version +so Stackdog cannot see the attack traffic itself - it sees the exposure (version and config), the crash spray, the network footprint, and the RCE aftermath. `web.worker-exec` and `kernel.sctp-socket` read eBPF syscall events, which the `serve` runtime does not collect yet. `nginx.http2-spray` is a workload-level diff --git a/docs/nginx2root-user-announcement.md b/docs/nginx2root-user-announcement.md index c0a2731..056ef4b 100644 --- a/docs/nginx2root-user-announcement.md +++ b/docs/nginx2root-user-announcement.md @@ -1,8 +1,8 @@ -# Security update — NGINX2Root (CVE-2026-123007): update your trydirect/nginx image and install Stackdog +# Security update - NGINX2Root (CVE-2026-123007): update your trydirect/nginx image and install Stackdog **Severity:** Critical (CVSS 9.2) · **Disclosed:** 18 Nov 2026 · **Action required** -> **TL;DR** — A critical, remotely exploitable nginx bug (CVE-2026-123007) is public. +> **TL;DR** - A critical, remotely exploitable nginx bug (CVE-2026-123007) is public. > Update your `trydirect/nginx` image and **restart** your containers (a reload is > not enough), then install Stackdog to keep watching for it and for other recent > vulnerabilities such as PHP2Shell. @@ -11,15 +11,15 @@ ## What happened -On **18 November 2026**, five memory-corruption vulnerabilities in nginx — together -called **NGINX2Root** — were disclosed. The worst, **CVE-2026-123007**, is +On **18 November 2026**, five memory-corruption vulnerabilities in nginx - together +called **NGINX2Root** - were disclosed. The worst, **CVE-2026-123007**, is **unauthenticated remote code execution over HTTP/2**: anyone who can reach a server with HTTP/2 enabled can run commands as the nginx worker, with no application bug required. A public proof-of-concept exists. A separate, still **unpatched** Linux kernel bug can then escalate that access to **root**, including escaping a Docker container onto the host. -This affects any nginx reachable directly from the internet — including static +This affects any nginx reachable directly from the internet - including static sites. The fixed releases are **nginx 1.30.7 (stable)** and **1.31.9 (mainline)** (NGINX Plus 37.0.8.1 / 37.3.0.1). @@ -31,7 +31,7 @@ We've released an updated **`trydirect/nginx`** image that carries the fix. --- -## 1 — Update your `trydirect/nginx` image +## 1 - Update your `trydirect/nginx` image Pull the fixed image and **re-create** your containers (do not keep running the old one): @@ -54,14 +54,14 @@ Confirm the running build is fixed: ```bash docker exec nginx -v # expect 1.30.7 / 1.31.9 or later (distro builds may show an older upstream -# number while still carrying the backported fix — check your package version) +# number while still carrying the backported fix - check your package version) ``` **If you can't update right now**, turn the affected features off as a stopgap and restart: ```nginx -http2 off; # CVE-2026-123007 / CVE-2026-123633 — or drop "http2" from listen +http2 off; # CVE-2026-123007 / CVE-2026-123633 - or drop "http2" from listen # remove quic/http3 listeners # CVE-2026-121810 # point proxy_pass at a fixed upstream # CVE-2026-123634 (no variables + SSI/mirror) # restrict mail listeners to trusted IPs # CVE-2026-113425 @@ -76,9 +76,9 @@ sudo rmmod sctp 2>/dev/null || true --- -## 2 — Install Stackdog for ongoing protection +## 2 - Install Stackdog for ongoing protection -Stackdog is a lightweight security agent for Linux hosts and Docker containers — +Stackdog is a lightweight security agent for Linux hosts and Docker containers - real-time threat detection and response (a modern fail2ban, plus container and host monitoring). One command to install: @@ -91,12 +91,12 @@ Stackdog watches for **NGINX2Root** and other recent vulnerabilities: | Threat | What Stackdog does | |---|---| | **NGINX2Root** (CVE-2026-123007 + 4 more) | Flags exposed nginx builds and the exact config that reaches each CVE (HTTP/2, HTTP/3, mail proxy, resolver) on the host and in containers; alerts on the worker-crash spray and on **any command run by an nginx worker** (the RCE tell); warns when the kernel SCTP escalation step is reachable. | -| **PHP2Shell** (CVE-2026-109618 / 109619) | Detects exposed PHP builds, PHP worker crashes, and the exploit footprint — and bans the clients driving it. | +| **PHP2Shell** (CVE-2026-109618 / 109619) | Detects exposed PHP builds, PHP worker crashes, and the exploit footprint - and bans the clients driving it. | | **SSHole** (CVE-2026-123158) | Flags vulnerable OpenSSH builds and bans password logins to key-only accounts. | | **Everything else** (`vuln.cve-watch`) | Continuously matches every installed package on the host **and in containers** against OSV and CISA's known-exploited catalog. | It also does fail2ban-style IP bans, container quarantine, file-integrity -monitoring, and webshell detection. It **detects and responds** — it does not +monitoring, and webshell detection. It **detects and responds** - it does not patch, so keep your images updated. --- @@ -106,7 +106,7 @@ patch, so keep your images updated. The attack is deliberately quiet (its HTTP/2 control frames are never logged), so look for the aftermath: -- **Programs started by the nginx worker** — workers serve requests, they don't +- **Programs started by the nginx worker** - workers serve requests, they don't run programs. Anything spawned by one is a strong sign of compromise: ```bash ps -u www-data -o pid,ppid,lstart,cmd # or your nginx user @@ -127,7 +127,7 @@ rotate secrets, and investigate before bringing it back. ## Summary -1. **Update `trydirect/nginx`** and **restart / re-create** your containers — a +1. **Update `trydirect/nginx`** and **restart / re-create** your containers - a reload does not fix this. 2. **Install Stackdog** to continuously detect NGINX2Root, PHP2Shell, SSHole and other vulnerabilities across your hosts and containers. diff --git a/src/detectors/nginx.rs b/src/detectors/nginx.rs index b37ddd2..8abb966 100644 --- a/src/detectors/nginx.rs +++ b/src/detectors/nginx.rs @@ -588,7 +588,7 @@ fn is_nginx_worker_crash(line: &str) -> bool { /// /// A web worker (nginx, Apache, php-fpm) serves requests; it does not exec a /// program as part of normal operation. When one does, the process has almost -/// certainly been hijacked — the classic end state of a remote-code-execution +/// certainly been hijacked - the classic end state of a remote-code-execution /// exploit such as NGINX2Root (CVE-2026-123007). This is the "programs started /// by an nginx worker" indicator, matched on the process that calls exec, which /// the eBPF collector captures at syscall entry before exec replaces it. diff --git a/website/app/nginx2root/page.tsx b/website/app/nginx2root/page.tsx index b1785e8..6deb7fd 100644 --- a/website/app/nginx2root/page.tsx +++ b/website/app/nginx2root/page.tsx @@ -106,7 +106,7 @@ const iocs = [ const stackdogDetections = [ [ 'vuln.nginx2root', - 'Exposure detection. Flags nginx builds older than the fixes whose configuration actually reaches one of the five CVEs: it reads HTTP/2, HTTP/3, mail proxy and proxy_pass + SSI/mirror reachability from the config on the host and inside running containers, and reads NGINX_VERSION from official images and package databases. It follows nginx\u2019s two version tracks, names the CVE, and prints the exact mitigation \u2014 set http2 off, drop the quic listeners, and so on \u2014 next to the upgrade it does not replace.' + 'Exposure detection. Flags nginx builds older than the fixes whose configuration actually reaches one of the five CVEs: it reads HTTP/2, HTTP/3, mail proxy and proxy_pass + SSI/mirror reachability from the config on the host and inside running containers, and reads NGINX_VERSION from official images and package databases. It follows nginx\u2019s two version tracks, names the CVE, and prints the exact mitigation - set http2 off, drop the quic listeners, and so on - next to the upgrade it does not replace.' ], [ 'nginx.worker-crash', @@ -114,11 +114,11 @@ const stackdogDetections = [ ], [ 'nginx.http2-spray', - 'Network footprint. A workload-level heuristic that flags a container whose inbound bytes grew while its logged request count stayed small \u2014 what an HTTP/2 heap spray looks like, because its control frames are never logged. A review signal, not a certainty: a large upload can look similar, so it is read alongside the crash and RCE detections.' + 'Network footprint. A workload-level heuristic that flags a container whose inbound bytes grew while its logged request count stayed small - what an HTTP/2 heap spray looks like, because its control frames are never logged. A review signal, not a certainty: a large upload can look similar, so it is read alongside the crash and RCE detections.' ], [ 'web.worker-exec', - 'RCE detection. Alerts when a web-server worker \u2014 nginx, Apache or php-fpm \u2014 executes a program, watched through eBPF syscall monitoring. Web workers do not run programs, so this is the RCE end state.' + 'RCE detection. Alerts when a web-server worker - nginx, Apache or php-fpm - executes a program, watched through eBPF syscall monitoring. Web workers do not run programs, so this is the RCE end state.' ], [ 'kernel.sctp-socket', @@ -126,11 +126,11 @@ const stackdogDetections = [ ], [ 'kernel.sctp-exposed', - 'Kernel escalation exposure. Alerts when the Linux SCTP kernel module is loaded and reachable \u2014 the unpatched root-escalation step of the chain \u2014 and recommends blocking it with install sctp /bin/false when you do not need it.' + 'Kernel escalation exposure. Alerts when the Linux SCTP kernel module is loaded and reachable - the unpatched root-escalation step of the chain - and recommends blocking it with install sctp /bin/false when you do not need it.' ], [ 'container.posture-risk', - 'Container posture. Flags privileged, host-network and host-PID containers \u2014 nginx inside one of those turns this chain straight into host root \u2014 and Stackdog can quarantine a compromised container while you investigate.' + 'Container posture. Flags privileged, host-network and host-PID containers - nginx inside one of those turns this chain straight into host root - and Stackdog can quarantine a compromised container while you investigate.' ] ] as const; @@ -258,7 +258,7 @@ export default function Nginx2RootPage() { On 18 November 2026, Xint (Theori) disclosed five memory-corruption vulnerabilities in nginx. The worst of them, CVE-2026-123007, is unauthenticated remote code execution over plain HTTPS. A separate bug in the Linux kernel's SCTP stack, still - unpatched, turns that code execution into root — including from inside a Docker + unpatched, turns that code execution into root - including from inside a Docker container onto the host kernel. Together they are being called NGINX2Root: nginx to root.

@@ -311,7 +311,7 @@ export default function Nginx2RootPage() {

The end state of the first stage is deliberately unglamorous: the payload runs as - the nginx worker process. No dropped webshell, no new service — just the process + the nginx worker process. No dropped webshell, no new service - just the process that was already serving your traffic, now executing someone else's code.

@@ -340,7 +340,7 @@ export default function Nginx2RootPage() { misconfiguration. Every nginx back to 1.9.5 is affected. A working proof of concept is public, and Rapid7's reproduction pushes roughly 128 GB of HTTP/2 traffic at the target to groom the heap and brute-force ASLR before the payload - lands — as the nginx worker process. + lands - as the nginx worker process.

@@ -363,7 +363,7 @@ export default function Nginx2RootPage() { ))}

- All five are fixed in the same releases — which is convenient, because the hard part + All five are fixed in the same releases - which is convenient, because the hard part was never the patch. It was noticing whether the patch is actually running.

@@ -381,7 +381,7 @@ export default function Nginx2RootPage() { The name of the chain comes from its second half. Once code runs as the nginx worker, the unpatched SCTP use-after-free in the Linux kernel takes it the rest of the way: to root. And because the kernel is shared, the boundary a Docker container - is supposed to provide does not help — the escalation works from inside a container + is supposed to provide does not help - the escalation works from inside a container out to the host kernel. A "just a web container" nginx is one kernel bug away from being your whole machine.

@@ -395,7 +395,7 @@ export default function Nginx2RootPage() {

On hosts that do not need SCTP, block it until the kernel fix lands:{' '} echo 'install sctp /bin/false' > /etc/modprobe.d/zz-block-sctp.conf - . If the module is loaded already, a rule only stops it loading — run{' '} + . If the module is loaded already, a rule only stops it loading - run{' '} rmmod sctp (or reboot) to drop it.

@@ -405,12 +405,12 @@ export default function Nginx2RootPage() {
Fixed releases -

Upgrade, then restart — a reload fixes nothing

+

Upgrade, then restart - a reload fixes nothing

The nginx bugs are fixed in nginx 1.30.7 (stable) and{' '} nginx 1.31.9 (mainline), and in NGINX Plus 37.0.8.1 and 37.3.0.1. nginx - keeps two live tracks — odd minors are mainline, even minors are stable — and a + keeps two live tracks - odd minors are mainline, even minors are stable - and a version is fixed when it reaches the fix on its own track. 1.31.0 sorts above 1.30.7 and is still vulnerable.

@@ -430,7 +430,7 @@ export default function Nginx2RootPage() {

A reload does not fix this. nginx -s reload and{' '} systemctl reload nginx swap the configuration but keep the old code in - every running worker — the vulnerable binary is still what answers connections. + every running worker - the vulnerable binary is still what answers connections. Restart the service, or re-create your containers from a fixed image. An "updated" nginx that was only reloaded is still a vulnerable nginx.

@@ -479,7 +479,7 @@ export default function Nginx2RootPage() {

1.30.7 on the stable track, 1.31.9 on mainline, or your vendor's fixed build (NGINX Plus 37.0.8.1 / 37.3.0.1). Then restart the binary or re-create your - containers — a configuration reload leaves the vulnerable code in place. + containers - a configuration reload leaves the vulnerable code in place.

@@ -490,7 +490,7 @@ export default function Nginx2RootPage() { kernel step.

- These are lossy — no HTTP/2 means no HTTP/2 — so treat them as the bridge to the + These are lossy - no HTTP/2 means no HTTP/2 - so treat them as the bridge to the upgrade, not the destination.

@@ -522,7 +522,7 @@ export default function Nginx2RootPage() {

Detection for every step of the chain

Stackdog is a Rust-based, real-time threat detection and automated response platform - for Docker containers and Linux servers — a modern fail2ban with eyes on the kernel + for Docker containers and Linux servers - a modern fail2ban with eyes on the kernel and the container runtime. It does not patch anything; upgrading nginx is the fix. What it does is answer, continuously and without network scanning, the two questions this chain raises: is a vulnerable nginx reachable, and has anyone used it? @@ -541,7 +541,7 @@ export default function Nginx2RootPage() { The exposure check alone is worth the install: it reads HTTP/2, HTTP/3, mail proxy and{' '} proxy_pass + SSI/mirror reachability from the nginx configuration on the host and inside every running container, so it names the CVEs that apply to{' '} - your config — and the exact mitigation for each — instead of a generic + your config - and the exact mitigation for each - instead of a generic "upgrade nginx".

@@ -570,8 +570,8 @@ export default function Nginx2RootPage() { SSHole {' '} - (CVE-2026-123158) likewise. Where a client address is available — webshells, brute - force, the PHP2Shell attempt footprint — the ban engine acts on it fail2ban-style, + (CVE-2026-123158) likewise. Where a client address is available - webshells, brute + force, the PHP2Shell attempt footprint - the ban engine acts on it fail2ban-style, firewall rule reconciled against its own database every pass.{' '} The comparison has its own page @@ -603,7 +603,7 @@ export default function Nginx2RootPage() { ))}

Happy to answer questions about the detection side. And if you have seen this chain - in your own logs — or seen it miss your logs entirely — we genuinely want to hear + in your own logs - or seen it miss your logs entirely - we genuinely want to hear about it.{' '} Contact us @@ -625,8 +625,8 @@ export default function Nginx2RootPage() { stackdog init writes a starter config and every setting has a safe default, so it runs with nothing configured at all. Also on Homebrew ( brew install trydirect/tap/stackdog) and cargo ( - cargo install stackdog). The full walkthrough — settings, systemd unit, - a safe test — is on the{' '} + cargo install stackdog). The full walkthrough - settings, systemd unit, + a safe test - is on the{' '} quick start page