11 KiB
CLAUDE.md
Guidance for Claude or Claude Code agents working on Enodia Sentinel.
Project Shape
Enodia Sentinel is a zero-runtime-dependency Linux IDS/IPS/EDR platform. The
core agent is pure Python standard library and should stay that way unless a
dependency has clear security/operator value that cannot reasonably be achieved
with stdlib. Its IPS scope is explicit prevention workflow: posture hardening,
containment planning, and future reviewed --apply actions, not silent inline
network blocking or automatic host mutation.
Primary functions:
- Detect: poll detectors, optional eBPF exec/syscall rules, and typed host-event rule fixtures.
- Prevent: posture findings plus reviewed containment/recovery plans.
- Verify: FIM, package DB anchor, signed-package verification, rootcheck.
- Investigate: text/JSON snapshots, incidents, HTTPS management console.
- Respond: dry-run plans first; any state-changing action must be explicit, logged, and tested.
- Assure: heartbeat, watchdog, self-integrity, future external anchors.
Current State Snapshot
As of 2026-07-04, the project is a local-first Linux IDS/IPS/EDR agent at
package version 0.7.0. The branch has a working stdlib-only daemon, CLI,
HTTPS management console, incident model, response planner, rootcheck, posture
checks, file/package integrity checks, push notification backends, and optional
bcc/eBPF telemetry.
An experimental, non-installing Phase 1 Go sidecar now lives under go-agent/.
It is stdlib-only, emits enodia.event.v1 JSONL, captures an injectable process
file-descriptor, and socket view, and currently ports reverse_shell,
ld_preload, deleted_exe, input_snooper, credential_access,
stealth_network, and egress. Python remains the production agent and parity
oracle; do not describe the Go path as a replacement yet.
Implemented detection coverage:
- Poll detectors:
reverse_shell,ld_preload,deleted_exe,input_snooper,credential_access,stealth_network,memory_obfuscation,new_listener,new_suid,persistence, andegress. - eBPF exec rules: fileless execution from writable paths, reverse-shell argv,
web/database service spawning shells, and
curl|wget|shstyle staging. - eBPF syscall rules: RWX
mprotect/mmap,memfd_create, sensitiveptrace, seccomp changes, cross-process memory access, and memory locking. - Typed host-event rules:
tcp_connectJSON fixtures can already exercise interpreter egress to unusual public ports; live event sources are still future work. - Anti-rootkit checks: hidden PIDs,
/procvspsmismatches, hidden modules, hidden TCP/UDP/raw/special-protocol sockets, raw ICMP/SCTP-style channels, promiscuous interfaces, known LKM rootkit names, module taint, and kernel taint.
Implemented investigation/response state:
- Alert snapshots are written as text and JSON under
log_dir. - Incident tracking groups snapshots by process lineage and time window and
exposes
incident list/show/export. - The dashboard is HTTPS-only, token-protected off loopback, and read-only. It shows status, incidents, timelines, alerts, posture findings, integrity/watchdog state, event-rule metadata, event tail, dry-run response plans, and a local Settings menu with persistent themes. Web tests cover the theme registry, integrity console wiring, and core text/status contrast checks.
respond plan <incident-id>builds read-only containment/recovery plans, persists CLI-generated plans underresponse-plans/, and appendsresponse-audit.log. Dashboard/API plan previews do not write artifacts.rules list/show/testexposes built-in and configured event rules and lets operators test exec, syscall, and typed host-event JSON fixtures against the rule engines.rules docsemits generated Markdown rule docs;docs/RULES.mdis the checked-in built-in rule reference with match fields, false positives, and drill guidance.baseline accept/revoke/listreconciles legitimate FIM/package/listener/SUID drift: an operator accepts an identified item with a mandatory reason, stored fingerprint-bound and audited inreconciliation.json. Acks suppress the alert only while live state matches; content kinds (fim/pkgfile) re-alert on further change, identity kinds (listener/suid) retire on TTL or revoke. The filter runs at the daemon chokepoint,fim-check, and the dashboard integrity API.- An optional desktop tray applet (
enodia-sentinel-tray,[tray]extra with pystray/Pillow) opens the dashboard, controls the daemon via systemctl, and runscheck --jsonquick checks. Its logic modules (tray/state.py,actions.py,notify.py) are GUI-free and tested; onlytray/app.pyimports GUI libs, and the core agent stays stdlib-only. - IPS behavior is currently explicit workflow: posture hardening plus reviewed dry-run containment actions. There is no automatic inline blocking or silent host mutation yet.
Near-term open work:
- Audited
--applyresponse execution with tests and rollback notes. - Fixture or red-team drill coverage for every built-in SID, including event-only and future correlation SIDs.
- More event sources and correlation across exec, network, persistence, FIM, and rootcheck signals.
- Stable v1 schema IDs and compatibility tests for alerts, incidents, status, response plans, and response audit records.
Start with:
README.mdfor product overview and architecture.docs/INDEX.mdfor the versioned documentation entry point.docs/SPECIFICATION.mdfor the product model and acceptance criteria.docs/ROADMAP.mdfor sequenced work.docs/COMMAND_REFERENCE.mdfor CLI contracts.docs/OPERATIONS.mdanddocs/RUNBOOKS.mdfor operator workflows.docs/PACKAGING.mdfor package layout and distro install paths.docs/THREAT_MODEL.mdfor security boundaries and non-goals.
Engineering Rules
- Keep the daemon stdlib-only and useful without a dashboard, collector, or network.
- Prefer read-only detection and dry-run response until schemas and audit logs are tested and documented.
- Every new detector, rootcheck, response action, or event rule needs a stable
sid,signature,classtype, tests, and operator documentation. - Do not add stealth, self-hiding, persistence tricks, or automatic destructive remediation.
- Preserve the bash prototype/red-team harness as the behavioral oracle for core signatures.
- If you add config keys, update
config/enodia-sentinel.toml, README, and the relevant docs. - Multiple agent sessions may share this checkout. Before committing, check
git statusfor uncommitted edits you did not make; never sweep foreign hunks into your commit (stage only your own changes) and never stash or revert them.
Current Architecture
enodia_sentinel/cli.pyis the command entry point.daemon.pyruns sweep/cooldown/background tasks.system.pybuilds one cached injectable view of processes and sockets.detectors/contains pure poll detectors.events/contains optional eBPF exec/syscall monitoring plus declarative exec, syscall, and typed host-event rules.snapshot.pywrites forensic.logand.jsonevidence.incident.pygroups snapshots by process lineage and time window.respond.pybuilds read-only response plans from incident evidence; the CLI persists reviewed dry-run plans underresponse-plans/and appendsresponse-audit.log, while dashboard/API previews stay write-free.web.pyserves the HTTPS-only management console and JSON APIs.rootcheck.pyperforms anti-rootkit cross-view checks: hidden processes, processes hidden fromps, hidden modules, hidden TCP/UDP/raw/special-protocol sockets, raw ICMP/SCTP-style channels, promiscuous interfaces, known LKM rootkit module names, and kernel/module taint.posture.pyperforms advisory host hygiene checks.reconcile.pyowns the acknowledged-drift store and thefilter_alertschokepoint that suppresses operator-accepted FIM/package/listener/SUID drift.tray/is the optional desktop tray frontend over the CLI and systemctl; onlytray/app.pymay importpystray/PIL(enforced by an import-guard test).go-agent/is the isolated Phase 1 sidecar with Go config, process-state, detector, schema, and sweep-loop packages. It writes JSONL to stdout and must not share or mutate Python daemon state during parity development.
Current Threat Mapping
Recent local sample families used for defensive coverage:
- Gonzalo-style implant/rootkit behavior: direct input-event keylogging, credential harvesting, LD_PRELOAD/tool tampering, persistence writes, raw ICMP and SCTP-style knock/listener paths, deleted/fileless execution, and hidden sockets/modules, plus heap/string obfuscation and mapped process-hiding libraries.
- Peopleswar-style C2 behavior: TLS C2 listener/check-in traffic, command queue
responses, and API/listener ports. Sentinel should prefer behavior coverage
(
new_listener,egress,stealth_network,memory_obfuscation, rootcheck, credential/input detectors) over brittle sample-name matching unless adding explicit IOCs.
Development Commands
python3 -m unittest discover -s tests -v
python3 -m enodia_sentinel.cli check
python3 -m enodia_sentinel.cli rootcheck
python3 -m enodia_sentinel.cli posture check --json
python3 -m enodia_sentinel.cli incident list
python3 -m enodia_sentinel.cli respond plan <incident-id> --json
python3 -m enodia_sentinel.cli rules list
python3 -m enodia_sentinel.cli web
make test-go
make parity-go
The web dashboard is HTTPS-only. In development it auto-generates a self-signed
certificate under log_dir; tests use an unverified TLS context for that local
certificate.
Testing Notes
- Unit tests are stdlib
unittest;pytestis optional, not required. - Most detectors are pure functions over injectable
SystemState. - Rootcheck tests monkeypatch system views instead of depending on live
/proc,/sys, orss. - Web tests bind a local HTTPS socket and may require permission in sandboxed environments.
- Go tests need a writable build cache; repo targets use
GOCACHE=/tmp/enodia-go-cachefor sandbox-safe verification. - Run the full suite before committing:
python3 -m unittest discover -s tests -v
Documentation Checklist
When changing behavior, update the relevant set:
README.mdfor visible product/architecture behavior.docs/COMMAND_REFERENCE.mdfor CLI/API-visible commands.docs/OPERATIONS.mdfor routine operator workflow.docs/RUNBOOKS.mdfor alert response guidance.docs/SPECIFICATION.mdfor product/data-model changes.docs/THREAT_MODEL.mdfor trust-boundary/security-model changes.docs/ROADMAP.mdfor planned or completed roadmap movement.docs/SCHEMAS.mdfor stable JSON contracts.docs/PACKAGING.mdfor package/install behavior.packaging/release-artifacts.shfor release tarballs, checksums, and optional GPG signatures.docs/VERSION.jsonanddocs/INDEX.mdfor documentation versioning.config/enodia-sentinel.tomlfor config knobs.