@profullstack/threatcrush 0.13.81 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +242 -1
- package/dist/daemon.js +10421 -1613
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +20546 -8523
- package/dist/index.js.map +1 -1
- package/dist/systemd/threatcrushd.service +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -102,6 +102,8 @@ threatcrush tui # Interactive dashboard (htop for security)
|
|
|
102
102
|
threatcrush action-center # Fleet-wide detections, host health and queued actions (login required)
|
|
103
103
|
threatcrush scan ./src # Scan code for vulnerabilities & secrets
|
|
104
104
|
threatcrush scan . --format sarif --output out.sarif --fail-on critical,high
|
|
105
|
+
sudo threatcrush scan --host # Rootkit / host integrity scan of this machine (alias: host-scan)
|
|
106
|
+
sudo threatcrush respond ... # Incident response: kill sessions, ban, pull stolen keys, lock sshd (dry run unless --apply)
|
|
105
107
|
threatcrush pentest URL # Quick web security checks against a URL
|
|
106
108
|
threatcrush init # Auto-detect services, generate config
|
|
107
109
|
threatcrush status # Show daemon status & loaded modules
|
|
@@ -110,6 +112,206 @@ threatcrush store # Browse the module marketplace
|
|
|
110
112
|
threatcrush update # Upgrade the CLI using the supported path
|
|
111
113
|
```
|
|
112
114
|
|
|
115
|
+
### Host integrity / rootkit scan
|
|
116
|
+
|
|
117
|
+
`threatcrush scan --host` (alias `--localhost`, or `threatcrush host-scan`) checks
|
|
118
|
+
the machine it runs on instead of a code tree. It only reads: it never installs,
|
|
119
|
+
deletes or fixes anything.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
sudo threatcrush scan --host # every check, text report
|
|
123
|
+
sudo threatcrush host-scan --json > host-scan.json # machine-readable
|
|
124
|
+
sudo threatcrush host-scan --since 3d --deny-keys ./stolen-keys.txt
|
|
125
|
+
sudo threatcrush host-scan --checks ssh-keys,persistence,uid0-accounts
|
|
126
|
+
sudo threatcrush host-scan --skip-checks rkhunter,chkrootkit,suid-sgid # the slow ones
|
|
127
|
+
sudo threatcrush host-scan --checks network-exposure,secrets-on-disk # what an intruder reaches and harvests
|
|
128
|
+
sudo threatcrush host-scan --checks secrets-on-disk --deep --secrets-timeout 600
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
| Check | Fails when | Warns when |
|
|
132
|
+
|---|---|---|
|
|
133
|
+
| `package-integrity` | `dpkg --verify` / `rpm -Va` says a binary in `/bin` `/sbin` `/usr/bin` `/usr/sbin`, a PAM module (`lib*/security`) or a shared object differs from its package | other `/usr/lib` files differ, packaged binaries are missing (config files are ignored) |
|
|
134
|
+
| `rkhunter` | a warning names a rootkit, trojan or backdoor | any other rkhunter warning; rkhunter is not installed (install command printed) |
|
|
135
|
+
| `chkrootkit` | a command is `INFECTED` and its binary does **not** match its package | `INFECTED` but the binary verifies against its package (e.g. rust-coreutils false positives); unpackaged suspicious files; not installed |
|
|
136
|
+
| `hidden-processes` | `unhide quick` finds a hidden PID, or (without unhide) a PID answers `stat()` but is missing from `/proc` or from `ps` | |
|
|
137
|
+
| `kernel-modules` | a module has an initstate in `/sys/module` but is missing from `/proc/modules`, or a loaded module is not from `/lib/modules/$(uname -r)` | |
|
|
138
|
+
| `ld-preload` | `/etc/ld.so.preload` exists | |
|
|
139
|
+
| `suspicious-exe` | | a process runs a `(deleted)` executable or one under `/tmp`, `/dev/shm`, `/var/tmp` (deleted after a package upgrade is common, so this is a warning) |
|
|
140
|
+
| `ssh-keys` | a key in any `authorized_keys` (root, every account home, `/home/*`, honouring `AuthorizedKeysFile`) matches `--deny-keys` | a key has no `command=` and no `from=`; the same key appears more than once |
|
|
141
|
+
| `sshd-config` | | `sshd -T` shows `PermitRootLogin` other than `no`, or `PasswordAuthentication yes` |
|
|
142
|
+
| `docker-containers` | | a running container is `--privileged`, `--pid=host`, or bind-mounts `/` or the Docker socket |
|
|
143
|
+
| `docker-group` | | anyone is in the `docker` group (docker group == root) |
|
|
144
|
+
| `persistence` | | a file under `/etc/cron*`, `/var/spool/cron`, `/etc/systemd/system`, `~/.config/systemd`, `/etc/pam.d`, `/etc/ssh/sshd_config.d`, `/etc/sudoers.d`, `/etc/profile.d`, `authorized_keys` and similar changed inside `--since` (default `7d`) |
|
|
145
|
+
| `uid0-accounts` | an account other than `root` has uid 0 | |
|
|
146
|
+
| `suid-sgid` | | a setuid/setgid file on the root filesystem is not owned by any package (container storage and snaps are skipped) |
|
|
147
|
+
| `network-exposure` | a datastore / admin port (see below) listens on a public address (`0.0.0.0`, `[::]`, a public IP) and no firewall rule blocks it | the `DOCKER-USER` chain is empty while Docker publishes ports on `0.0.0.0`; `DOCKER-USER` has live rules but nothing restores them at boot; a `DOCKER-USER` rule matches `--dport <host port>` for a mapping whose container port differs (it never fires); a sensitive port is explicitly allowed from anywhere in ufw; not root (firewall unreadable) |
|
|
148
|
+
| `secrets-on-disk` | a key, token or credential file is readable by other users (world-readable with every parent directory traversable, or group-readable by a shared group); `--deep`: a private key is in a git repository's history | each plaintext secret found (inventory: path, type, owner, mode, size, age; never the value) |
|
|
149
|
+
|
|
150
|
+
#### `network-exposure`
|
|
151
|
+
|
|
152
|
+
Sensitive ports: postgres 5432 / pgbouncer 6432 / 6543, mysql 3306, mongodb
|
|
153
|
+
27017, redis 6379, elasticsearch 9200 / 9300, clickhouse 8123 / 9000, couchdb
|
|
154
|
+
5984, memcached 11211, neo4j 7687 / 7474, influxdb 8086, rabbitmq 5672 / 15672,
|
|
155
|
+
kafka 9092, etcd 2379, Docker API 2375 / 2376, kubelet 10250, cups 631.
|
|
156
|
+
|
|
157
|
+
Listeners come from `ss -tlnpH` (or `/proc/net/tcp{,6}` without `ss`); Docker
|
|
158
|
+
port bindings from `docker ps`. A Docker mapping counts as sensitive when its
|
|
159
|
+
host port **or its container port** is on the list, so `-p 5601:5432` is postgres.
|
|
160
|
+
|
|
161
|
+
Docker-published ports never pass through ufw or the `INPUT` chain: only the
|
|
162
|
+
`DOCKER-USER` chain can block them, and it sees packets **after** DNAT. So for
|
|
163
|
+
`-p 6543:6432` the check looks for a `DROP`/`REJECT` matching `--dport 6432`
|
|
164
|
+
(the container port) or `-m conntrack --ctorigdstport 6543` (the host port),
|
|
165
|
+
walking the chain first-match (source-limited `ACCEPT`s are reported as an
|
|
166
|
+
allowlist, source-limited `DROP`s do not count as a block). Host processes are
|
|
167
|
+
judged by ufw when active, else the `INPUT` chain policy and rules, plus any
|
|
168
|
+
native nftables `hook input` chains. IPv6 bindings are only considered when the
|
|
169
|
+
host has a global IPv6 address.
|
|
170
|
+
|
|
171
|
+
Rules added with `iptables -I DOCKER-USER ...` live only in the kernel. The
|
|
172
|
+
check warns unless something restores them at boot: a file under
|
|
173
|
+
`/etc/systemd/system`, `/usr/local/{s,}bin`, `/etc/network/if-*.d`, `/etc/docker`,
|
|
174
|
+
a script a unit's `ExecStart` runs, `/etc/ufw/*.rules`, or `-A DOCKER-USER`
|
|
175
|
+
lines in `/etc/iptables/rules.v4`.
|
|
176
|
+
|
|
177
|
+
The check makes no outbound connections. To confirm from outside, from another
|
|
178
|
+
machine run `nc -vz -w3 <public-ip> 5432` (or `nmap -Pn -p 5432,6432,6543,3306,6379,27017 <public-ip>`)
|
|
179
|
+
for each port it lists; "Connection refused" or a timeout is what you want.
|
|
180
|
+
|
|
181
|
+
#### `secrets-on-disk`
|
|
182
|
+
|
|
183
|
+
Walks `/root` and `/home/*` (7 levels deep, never following symlinks; skips
|
|
184
|
+
`node_modules`, `.git`, `.cache`, package-manager caches, build output and
|
|
185
|
+
files over 1 MB) and `/etc` (4 levels; only world-readable findings are
|
|
186
|
+
reported there). It opens only files whose name suggests a secret and looks for:
|
|
187
|
+
|
|
188
|
+
- unencrypted private keys: `id_*`, `*.pem`, `*.key`, anything in `~/.ssh`
|
|
189
|
+
(OpenSSH keys with cipher `none`, PKCS#1/SEC1 without `Proc-Type: 4,ENCRYPTED`,
|
|
190
|
+
unencrypted PKCS#8; passphrase-protected keys are not reported)
|
|
191
|
+
- `~/.config/gh/hosts.yml` `oauth_token`, `.npmrc` `_authToken`, `.pypirc`
|
|
192
|
+
passwords, `.git-credentials`, `.netrc`, `.vault-token`, Terraform Cloud tokens
|
|
193
|
+
- `~/.docker/config.json` registries with stored `auth`, `~/.aws/credentials`,
|
|
194
|
+
`~/.config/gcloud` credentials, `~/.kube/config` with embedded tokens or keys
|
|
195
|
+
- `.env`, `.env.*` and `*.env` (not `.example` / `.sample` / `.template`): the
|
|
196
|
+
count and **names** of variables that look like keys, tokens, secrets or
|
|
197
|
+
passwords, or URLs with an embedded password
|
|
198
|
+
- JSON identity / service-account files holding a private key, secret or token
|
|
199
|
+
- plaintext password-manager exports (Bitwarden / LastPass / 1Password /
|
|
200
|
+
browser CSV headers, unencrypted Bitwarden JSON, `.1pux` / `.1pif`)
|
|
201
|
+
|
|
202
|
+
Paths under `test/`, `fixtures/`, `examples/` and similar are labelled
|
|
203
|
+
`[test fixture path]` and never fail. `--deep` also runs
|
|
204
|
+
`git log --all --pickaxe-regex -S '-----BEGIN [A-Z ]*PRIVATE KEY-----'` in each
|
|
205
|
+
repository found (as the repository's owner when run as root, so a hostile repo
|
|
206
|
+
config cannot run anything as root); worktrees sharing a leaked commit are
|
|
207
|
+
reported once. The whole check is time-boxed by `--secrets-timeout <seconds>`
|
|
208
|
+
(default 120); what it found before the budget ran out is reported and the check
|
|
209
|
+
is marked `[partial]`.
|
|
210
|
+
|
|
211
|
+
The exit code is 1 when any check fails, 2 on bad arguments, 0 otherwise.
|
|
212
|
+
`--json` prints `{ host, kernel, root, summary: {pass, warn, fail, skip}, skipped, checks: [{ id, status, reason, items, partial, install }] }`.
|
|
213
|
+
`--deep` and `--secrets-timeout` only affect `secrets-on-disk`.
|
|
214
|
+
`--deny-keys` takes one entry per line: a full public key line, a bare base64
|
|
215
|
+
key blob, or a `SHA256:` fingerprint.
|
|
216
|
+
|
|
217
|
+
Run it as root. Without root, `rkhunter`, `chkrootkit` and `sshd-config` are
|
|
218
|
+
skipped and listed as such, and checks that could only read part of the system
|
|
219
|
+
(other users' keys, other users' processes) are marked `[partial]`.
|
|
220
|
+
|
|
221
|
+
### GitHub Actions workflow rules
|
|
222
|
+
|
|
223
|
+
`threatcrush scan <path>` parses every `.github/workflows/*.yml` (and Forgejo/Gitea
|
|
224
|
+
`.forgejo/workflows`, `.gitea/workflows`, or any YAML with top-level `on:` and
|
|
225
|
+
`jobs:`) as YAML and reads each `run:` script together with the workflow around
|
|
226
|
+
it: which inputs are free text, which `env:` variables hold input or secrets, and
|
|
227
|
+
what `ssh`, `sh -c` and `eval` do with their arguments. Findings carry the exact
|
|
228
|
+
`file:line` inside multi-line `run: |` blocks, and a fix hint (`Fix:` in the text
|
|
229
|
+
report, in the rule help in SARIF and in `fix` in JSON).
|
|
230
|
+
|
|
231
|
+
| Rule | Severity | Flags |
|
|
232
|
+
|---|---|---|
|
|
233
|
+
| `gha-expression-injection` | high | `${{ inputs.* }}`, `${{ github.event.inputs.* }}`, issue/PR/discussion `title`/`body`, `pull_request.head.ref`, `comment.body`, `github.head_ref`, commit messages, `client_payload` and other attacker-controllable contexts pasted directly into a `run:` script or an `actions/github-script` body. Fix: pass through `env:` and use `"$VAR"`. |
|
|
234
|
+
| `gha-input-in-remote-shell` | critical | Such a value, or an env var assigned from one (step, job or workflow `env:`, an in-script assignment, or a `$GITHUB_ENV` export from an earlier step), expanded into a string another shell parses: the `ssh` remote command line (including the `"VAR='$VAR' bash -s"` pattern), a here-string, pipe or unquoted heredoc into a remote shell, `bash -c`/`sh -c`, `eval`, or an `appleboy/ssh-action` `script:`. Env keeps it data locally only. Reported at medium when the variable is checked with `[[ … =~ … ]]` or `case` in the same step. |
|
|
235
|
+
| `gha-dispatch-remote-exec` | critical | A `workflow_dispatch`/`repository_dispatch` workflow that runs a free-text input as the whole remote command: `ssh host "$CMD"`, `ssh host bash -s <<<"$CMD"`, `echo "$CMD" \| ssh host bash`. |
|
|
236
|
+
| `gha-ssh-key-secret` | medium | A step writes a secret to `~/.ssh/id_*` (or uses an ssh-key action) and the job runs `ssh`/`scp`/`rsync`. Whether the server-side key is limited with `restrict,command=…` cannot be verified from the repository; the finding asks you to check. |
|
|
237
|
+
| `gha-pull-request-target-checkout` | high | A `pull_request_target` workflow whose `actions/checkout` `ref`/`repository` is the PR head (`github.event.pull_request.head.sha`/`ref`, `github.head_ref`). |
|
|
238
|
+
| `gha-secrets-to-log` | medium | `echo`/`printf` of `${{ secrets.* }}` or of a variable holding one to the log (not to a file or a `--password-stdin` consumer), a secret piped through `base64`/`openssl enc`/`gpg --armor` and printed (masking bypass), `toJSON(secrets)`, and `set -x` in a step that uses secrets. |
|
|
239
|
+
|
|
240
|
+
Not flagged: inputs used only in `with:` of other actions or in `if:` conditions,
|
|
241
|
+
`boolean`/`choice`/`number` inputs, env vars used by the local shell as `"$VAR"`,
|
|
242
|
+
single-quoted ssh commands (`ssh host 'echo $X'` does not expand locally), and
|
|
243
|
+
input piped as data to a non-shell remote command
|
|
244
|
+
(`printf '%s\n' "$IPS" | ssh host 'xargs -n1 threatcrush unblock --'`). Step
|
|
245
|
+
outputs and reusable-workflow inputs are not followed. Suppress a reviewed line
|
|
246
|
+
with `# threatcrush-disable-next-line <rule-id>`.
|
|
247
|
+
|
|
248
|
+
### Incident response: `threatcrush respond`
|
|
249
|
+
|
|
250
|
+
Containment for a box, or a fleet, after stolen SSH keys or a stolen password.
|
|
251
|
+
It is a **dry run by default**: it shows what it found and what it would do.
|
|
252
|
+
`--apply` acts. Every action is reported, in text or `--json`, with its status
|
|
253
|
+
(`planned`, `done`, `failed`, `refused`, `needs-root`); the exit code is 1 when
|
|
254
|
+
anything failed or was refused.
|
|
255
|
+
|
|
256
|
+
| Subcommand | What it does |
|
|
257
|
+
|---|---|
|
|
258
|
+
| `respond ip <ip...>` | Lists established connections and recent sshd logins/failures from the address; with `--apply` bans it (through `threatcrushd`, else a direct `nft`/`iptables` drop), then kills its per-connection `sshd-session` processes and closes its sockets with `ss -K`. Refuses private/loopback/tailnet ranges, Cloudflare and public resolvers, the gateway, the daemon's protected list and the address of your own session. `--ttl` sets the ban (default `30d`). |
|
|
259
|
+
| `respond key <SHA256:fp \| key-file...>` | Finds the key in **every** `authorized_keys*` file under `/root` and `/home/*` and every `AuthorizedKeysFile` (a non-root glob silently misses other users' homes, so run it as root), shows user, file, line and restrictions, and with `--apply` removes those lines, deletes stale copies (`authorized_keys.bak`, `.old`, ...) holding it, and shreds private-key files whose public half matches. `command=` (deploy) keys are removed like any other: a restricted key is still a stolen key. Nothing is backed up; the removed fingerprints are printed. |
|
|
260
|
+
| `respond sshd [--lockdown]` | Shows the effective `PermitRootLogin`, `PasswordAuthentication` and `KbdInteractiveAuthentication` (`sshd -T -C user=root,host=x,addr=1.2.3.4`). `--lockdown` writes `00-0-threatcrush-lockdown.conf` (all three `no`) and, only with `--allow-root-localhost`, `99-threatcrush-root-localhost.conf` (`Match Address 127.0.0.1,::1` then `PermitRootLogin prohibit-password`), validates with `sshd -t`, restores the old files and does **not** reload if that fails, then shows the values before and after. |
|
|
261
|
+
| `respond keys-audit` | Every authorized key on the box with user, file, fingerprint, comment, restrictions and last use (from the sshd journal), flagging unrestricted keys, the same key on several accounts, keys unused for 30 days, stale copies, and deploy keys (`command=`): treat those as secrets and rotate them if CI secrets may have leaked. |
|
|
262
|
+
|
|
263
|
+
Two guards come from the 2026-11-20 incident:
|
|
264
|
+
|
|
265
|
+
- **Lockout guard.** `respond key` refuses to remove a key when it would leave
|
|
266
|
+
the invoking user (`SUDO_USER`, or the ssh login user on a remote host) with
|
|
267
|
+
no key that gives a shell, and says so when the key is the one this very
|
|
268
|
+
session logged in with. `command=` and `restrict` keys do not count as a way
|
|
269
|
+
back in. It prints how to install and test a replacement first;
|
|
270
|
+
`--allow-lockout` overrides it when you have console access.
|
|
271
|
+
- **Drop-in ordering.** sshd keeps the **first** value it reads, and a `Match`
|
|
272
|
+
block swallows every directive after it. So the global settings go in a file
|
|
273
|
+
that sorts first and the `Match` in one that sorts last. `--lockdown` refuses
|
|
274
|
+
to write when `sshd_config` does not include `sshd_config.d`, when a file read
|
|
275
|
+
earlier sets a different value, or when another drop-in sorts after the
|
|
276
|
+
`Match` file.
|
|
277
|
+
|
|
278
|
+
`--hosts <file|list>` runs any subcommand on remote hosts over ssh (a file with
|
|
279
|
+
one host per line, or `dev1,dev2`), 3 at a time, and prints one report per host
|
|
280
|
+
plus a summary. A host with `threatcrush respond` installed runs
|
|
281
|
+
`sudo -n threatcrush respond ... --json` itself; any other host gets the same
|
|
282
|
+
read-only gather script streamed over ssh's stdin, the same analysis runs here,
|
|
283
|
+
and with `--apply` a second script performs exactly the planned actions. Key
|
|
284
|
+
targets travel as fingerprints only; private keys never leave their host and
|
|
285
|
+
nothing secret is put on a command line. `sudo` must work without a password
|
|
286
|
+
(`sudo -n`); otherwise the host is audited read-only.
|
|
287
|
+
|
|
288
|
+
Without root nothing is changed: the run is read-only and lists the actions that need root.
|
|
289
|
+
|
|
290
|
+
Incident runbook (stolen key `SHA256:AbC...`, attacker at `203.0.113.7`):
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
# 0. What is out there? Run read-only across the fleet first.
|
|
294
|
+
threatcrush respond keys-audit --hosts fleet.txt
|
|
295
|
+
threatcrush respond ip 203.0.113.7 --hosts fleet.txt
|
|
296
|
+
|
|
297
|
+
# 1. Cut the attacker off everywhere: ban, then kill live sessions.
|
|
298
|
+
threatcrush respond ip 203.0.113.7 --hosts fleet.txt --apply
|
|
299
|
+
|
|
300
|
+
# 2. Install and TEST your replacement key on every host before removing anything.
|
|
301
|
+
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_new
|
|
302
|
+
for h in $(cat fleet.txt); do ssh-copy-id -i ~/.ssh/id_ed25519_new.pub "$h"; done
|
|
303
|
+
|
|
304
|
+
# 3. Pull the stolen key (dry run first: read the lockout guard's verdict).
|
|
305
|
+
threatcrush respond key SHA256:AbC... --hosts fleet.txt
|
|
306
|
+
threatcrush respond key SHA256:AbC... --hosts fleet.txt --apply
|
|
307
|
+
|
|
308
|
+
# 4. No root and no passwords over ssh; validated before reload.
|
|
309
|
+
threatcrush respond sshd --lockdown --hosts fleet.txt --apply
|
|
310
|
+
|
|
311
|
+
# 5. Re-audit, and rotate every deploy key it flags.
|
|
312
|
+
threatcrush respond keys-audit --hosts fleet.txt --json > audit.json
|
|
313
|
+
```
|
|
314
|
+
|
|
113
315
|
### CIS evidence report export
|
|
114
316
|
|
|
115
317
|
Export the current `harden` findings as Markdown, JSON, or PDF:
|
|
@@ -160,7 +362,8 @@ threatcrush store publish https://github.com/you/my-module # Publish your own
|
|
|
160
362
|
| `user-journal` | journald — the systemd journal |
|
|
161
363
|
| `network-monitor` | Inbound connections to your listening ports — port scans, SYN floods |
|
|
162
364
|
| `dns-monitor` | Resolver logs (systemd-resolved, dnsmasq, bind, Pi-hole) — DNS tunneling, DGA detection |
|
|
163
|
-
| `threatcrush scan` | Vulnerabilities, secrets, dependency CVEs (OSV.dev, with `--deps`) |
|
|
365
|
+
| `threatcrush scan` | Vulnerabilities, secrets, GitHub Actions injection and remote-exec workflows, dependency CVEs (OSV.dev, with `--deps`) |
|
|
366
|
+
| `threatcrush scan --host` | Rootkit / host integrity scan: package file integrity, rkhunter, chkrootkit, hidden processes and kernel modules, `ld.so.preload`, SSH keys, Docker, recent persistence, SUID outside packages |
|
|
164
367
|
| `threatcrush pentest` | Header, CORS, cookie, SQL-error, path-traversal and HTTP-method checks |
|
|
165
368
|
| auto-defend | Bans via fail2ban, nftables or iptables |
|
|
166
369
|
| alerts | Slack, Discord, email, webhook, PagerDuty |
|
|
@@ -197,6 +400,44 @@ poll_seconds = 15 # how soon new or restarted containers a
|
|
|
197
400
|
|
|
198
401
|
Check a line without touching the firewall: `threatcrush rules test postgres-auth-bruteforce --repeat 5 --line '<log line>'`.
|
|
199
402
|
|
|
403
|
+
### Postgres running a shell (COPY FROM PROGRAM)
|
|
404
|
+
|
|
405
|
+
A database superuser can run OS commands with `COPY ... FROM PROGRAM`, which starts `/bin/sh -c` as a child of the backend. Every few seconds the daemon walks `/proc` (which includes processes inside containers) and raises a critical `postgres-shell-exec` alert for any shell or common LOLBin (`sh`, `bash`, `dash`, `busybox`, `curl`, `wget`, `nc`, `ncat`, `python*`, `perl`, `base64`, anything touching `/dev/tcp`) whose parent chain includes `postgres`, `postmaster` or `.postgres-wrapper`. With `[docker_logs]` on, Postgres container log lines naming `FROM PROGRAM`/`TO PROGRAM` raise `postgres-copy-program` (critical), and plain shell errors or job-control output in that log (`sh: 1: curl: not found`, `Killed`, `Terminated`) raise `postgres-shell-output` (high). A command that finishes between two polls can be missed by the process check; reverse shells, downloaders and miners cannot.
|
|
406
|
+
|
|
407
|
+
```toml
|
|
408
|
+
[postgres_shell]
|
|
409
|
+
enabled = true # default on (Linux)
|
|
410
|
+
poll_seconds = 3
|
|
411
|
+
kill = false # SIGKILL the process tree postgres spawned; never postgres itself; not in dry_run
|
|
412
|
+
allow_cmdline = [] # extra regexes (whole command line) for programs postgres may run, e.g. an archive_command
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
Supabase's `pgsodium_getkey` and plain `sh -c wal-g|pgbackrest|barman-wal-* ...` archive commands (with no shell metacharacters) are allowed by default.
|
|
416
|
+
|
|
417
|
+
### Suspicious successful SSH logins
|
|
418
|
+
|
|
419
|
+
A stolen key logs in without a single failure. Every accepted SSH login is classified:
|
|
420
|
+
|
|
421
|
+
- `ssh-login-tor` (critical): from a Tor exit.
|
|
422
|
+
- `ssh-login-sensitive` (critical for root, high otherwise): root, a `sensitive_users` entry or a member of `sensitive_groups` logged in from an address outside `trusted_login_cidrs` and the `[remediation] protected` list. With no trusted CIDRs, every public login of those users alerts.
|
|
423
|
+
- `ssh-login-new-network` (medium): the user's first login from that /24 (IPv6: /48). Seen networks are kept in the state db; the first start learns the last 30 days from the journal.
|
|
424
|
+
|
|
425
|
+
A key pinned to a forced command in that user's `authorized_keys` (`restrict,command="... ci-deploy owner/repo" ssh-ed25519 ...`, as CI deploy keys are) logs from any address at info as `ssh-login-forced-command`, with the command, instead of raising `ssh-login-sensitive` or `ssh-login-new-network`; from a Tor exit it still raises `ssh-login-tor`. The fingerprint-to-command map is cached per user and re-read when `~/.ssh/authorized_keys` (or `authorized_keys2`) changes. Keys named by a custom `AuthorizedKeysFile` are not read.
|
|
426
|
+
|
|
427
|
+
Alerts name the user, address, auth method and key fingerprint. Private, loopback and tailnet ranges (10/8, 172.16/12, 192.168/16, 100.64/10, 127/8, ::1, fc00::/7) are never flagged or acted on.
|
|
428
|
+
|
|
429
|
+
```toml
|
|
430
|
+
[login_watch]
|
|
431
|
+
enabled = true
|
|
432
|
+
sensitive_users = ["root"] # root is always included
|
|
433
|
+
sensitive_groups = ["sudo", "admin", "wheel", "docker"]
|
|
434
|
+
trusted_login_cidrs = [] # e.g. ["203.0.113.0/24"]; empty = alert on every public login of those users
|
|
435
|
+
first_seen = true # first login per user per /24
|
|
436
|
+
auto_response = false # high/critical: ban the address and kill that user's sshd sessions from it (not in dry_run)
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
`kill` and `auto_response` need `CAP_KILL`, which the unit from `threatcrush install-service` now grants; re-run it after upgrading if you turn either on.
|
|
440
|
+
|
|
200
441
|
### Local shell history protection
|
|
201
442
|
|
|
202
443
|
Command-history collection is opt-in because shell histories may contain credentials or private work details:
|