Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand All @@ -62,7 +62,7 @@ RUST_BACKTRACE=full
#[email protected]
#STACKDOG_SMTP_PASSWORD=secret
#[email protected],[email protected]
# 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
Expand Down Expand Up @@ -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
72 changes: 36 additions & 36 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,15 +37,15 @@ 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.
`STACKDOG_CVE_WATCH_ENABLED=false` turns it off.
- 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
Expand Down Expand Up @@ -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`).
Expand All @@ -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

Expand All @@ -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.
Expand All @@ -175,26 +175,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- `stackdog unban <ip>` — release a ban and remove its firewall rules, even
- `stackdog unban <ip>` - 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.

Expand All @@ -211,56 +211,56 @@ 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
- `--ai-provider` to select AI backend (openai/candle)
- `--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

Expand Down
Loading
Loading