mirror of
https://github.com/CyberMind-FR/secubox-deb.git
synced 2026-07-29 09:14:33 +00:00
At ~150 execs/s a dpkg -S subprocess per event can't keep up; the scanner fell permanently behind and never reached recent execs. DpkgIndex loads all /var/lib/dpkg/info/*.list paths into a set once at startup. +2 tests. Co-Authored-By: Gerald KERMA <devel@cybermind.fr> |
||
|---|---|---|
| .. | ||
| api | ||
| conf | ||
| debian | ||
| menu.d | ||
| nft | ||
| nginx | ||
| sbin | ||
| sudoers | ||
| systemd | ||
| tests | ||
| www/antirootkit | ||
| pytest.ini | ||
| README.md | ||
secubox-antirootkit
Host-based intrusion detection module for SecuBox-Deb — anti-escape containment + exec-surveillance scanner + integrity wrap + alert-only manual quarantine.
What it does — v1 scope
LIVE
- Anti-escape (A2): any process not resolvable to a dpkg-backed
executable is moved into
sbx-untrusted.slice, a top-level cgroup whose egress is dropped by thesecubox_antiescapenft table except forlan_safedestinations (RFC1918 + loopback). Jailing is performed by the root-onlysecubox-antirootkitctl jail <pid>helper via a scoped, exact-path sudoers rule (sudoers/secubox-antirootkit) — the daemon itself never runs as root. - Exec scanner (A): targeted auditd watches
(
conf/99-sbx-procwatch.rules, keysbx_exec) on the common unbacked-exec surface —/usr/local/bin,/usr/local/sbin,/tmp,/dev/shm,/opt,/usr/lib/jvm,/home— feedapi/execwatch.py, which decides allow-vs-jail using the dpkg-backing resolver (api/dpkg_backing.py) plus a TOML allowlist (api/allowlist.py,/etc/secubox/antirootkit.toml) and appends every decision to an append-only SQLite forensic log (api/execlog.py). The daemon (api/daemon.py) tracks a real polling cursor so each audit record is processed exactly once, even when two successiveausearchwindows overlap. The watch list is deliberately targeted, not global, to keep audit volume low on a box running ~200 services. - Alert-only quarantine-prep (C): whenever the daemon jails a process it
also appends an alert (
api/alerts.build_alert) to the shared SQLite-backed store (api/alertstore.py,/var/lib/secubox/antirootkit/alerts.db) — the daemon (sbx-antirootkitd.service) and the API (secubox-antirootkit.service) are separate processes, so this store cannot be a plain in-memory list;GET /alertsreturns it, most-recent-first.POST /quarantine-prepNEVER executes chmod/cp/nft/systemctl itself — it only returns an operator-reviewable plan (api/quarantine.py) that a human runs by hand. The web panel is served at/antirootkit/.
SCAFFOLDED — v1.1 follow-up (not yet running automatically)
- Integrity wrap (B):
api/integrity.pywrapsdebsums/rkhunterand the module Recommendsaide,rkhunterandchkrootkitalongside a harddebsumsdependency, but no.timerschedules a scan yet in this release. Do not assume integrity scanning runs automatically until that timer ships.
Runtime topology
secubox-antirootkit.service— FastAPI dashboard (status/execlog/alerts/ quarantine-prep) on its own/run/secubox/antirootkit.sock, no aggregator dependency, runs as the confinedsecubox-antirootkitsystem user.sbx-antirootkitd.service— the exec-watcher daemon (api/daemon.py), tailsausearch -k sbx_execand jails unknown execs via sudo into the ctl.NoNewPrivileges=no(needed for the scoped sudo call).sbx-untrusted.slice— top-level (cgroup-root) slice; must stay unnested sosocket cgroupv2 level 1 "sbx-untrusted.slice"in the nft rule keeps matching.
Prerequisite (out-of-package, apt/boot)
auditd must actually be running (systemctl enable --now auditd) and the
kernel must support cgroup v2 unified hierarchy for the anti-escape jail to
take effect; this package installs the config/rules but does not itself
change the box's cgroup boot mode.