Preserve independent support, typed rule namespaces and stable process lifetimes. Share authoritative managed-set reconciliation across daemon and offline correlation, load offline policy without seeding/migration, and release resources after shutdown-flush exceptions. Keep retirement history, transaction ownership and fault/allocation regressions; no whole-set crash-atomicity or live acceptance claim.
Allowlisting a binary suppressed only *new* detections: the findings
already stored for it stayed in the evidence store, and every reload
re-materialised them. That is why the ~9k iproute2 `ss` false positives
kept "coming back" after the hash was allowlisted a day earlier -- nothing
retracted them, and the only cleanup was `doctor fix
retire-allowlisted-findings`, which operators do not know to run.
allowlist-add now retires the now-allowlisted findings at the moment of
the action (alongside the existing containment release) and reports the
count as `retired_findings` in its reply. retire_allowlisted_findings is
hash-based and self-filtering, so a path/rule entry that matches no
fully-allowlisted finding retires nothing.
Regression test (test_daemon_runtime): a detected binary's finding is
materialised (forced correlation), allowlist-add reports
retired_findings >= 1, and after correlation re-runs the finding does not
come back (A already makes correlation skip allowlisted entities).
Also refresh the doctor findings.allowlisted message, which claimed
allowlisting does not delete stored findings -- it now does.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
First half of the sandbox-safe tracker transport (architecture deep dive). The
daemon's old loopback TCP listener could not bind under its own sandbox
(PrivateNetwork=true + RestrictAddressFamilies=AF_UNIX). Replace it with an
AF_UNIX ingest socket the daemon *can* bind under the sandbox; a host-namespace
relay (next change) will bind the OpenSnitch port, strip argv/env, and forward
redacted tuples here.
- opensnitch_events.hpp/cpp: encode_connection / decode_connection serialize only
the redacted fields (never argv/env, which the parser already drops) as one
JSON object — the relay->daemon wire form. New TrackerIngestServer: an AF_UNIX
stream listener (Linux-only, like the TCP listener) that accepts only a root
peer (SO_PEERCRED), frames with take_json_objects, decodes and calls back;
bounded clients/object/buffer as before.
- daemon: start_tracker_attribution now opens the ingest socket
(opensnitch_ingest_socket, default /run/strawberry/trackers.sock) instead of
the in-sandbox TCP listener, so it works with the sandbox unchanged and is
simply idle until a relay connects. status privacy.listener reports the ingest
socket + relay_events; shutdown stops it. New config key opensnitch_ingest_socket.
- Tests: E8 encode/decode round-trip + redaction (no args/env on the wire);
E9 TrackerIngestServer end to end (connect, two tuples, callback, stats);
daemon-runtime configs set privacy_trackers=false (not under test).
Suite 51/51; clang static analyzer and clang-tidy clean on the changed TUs. The
relay run-mode + systemd unit + install wiring + docs follow in WS2b/WS2c.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Second piece of tracker attribution (docs/tracker-attribution.md): which
programs reach domains on a trackers list. Advisory only: never a block,
never a finding (source invariant R11).
- OpenSnitch event listener: OpenSnitch's JSON "remote" logger is the
hostname source (Strawberry's eBPF connects have none). It streams over
TCP and cannot leave fields out, so events carry command lines and
environments. The listener binds 127.0.0.1 at a port below 1024 (only
root can), accepts only root-owned peers (/proc/net/tcp), bounds
clients/object size/buffering, and reads only pid, uid, path,
destination and action; arguments and environment are never copied.
- TrackerContacts: per program x domain, bounded at 20000 keys. A root-only
tracker_contact telemetry record (type 25) on the first contact, then at
most hourly with the count since.
- Status `privacy` block; control verb privacy-trackers; CLI
`strawberry privacy trackers [--json]`.
- `strawberry opensnitch enable-events` adds the logger to OpenSnitch's
config (with a .bak); the installer runs it when OpenSnitch is present,
unless privacy_trackers=false. Config: privacy_trackers (default true),
opensnitch_events (default 127.0.0.1:979).
- EasyPrivacy is a default trackers feed (GPL-3.0+ or CC-BY-SA-3.0,
downloaded at run time).
Tests: E1-E7 (test_opensnitch_events: event fields, stream splitting,
peer uid, address rules, listener end to end, contacts and record, config
editor), the control verb, CLI translation and help, daemon status. New
fuzz_opensnitch_events (90 s clean).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shadow scorer's rarity model started empty at every daemon start, so
each restart cost an hour of warm-up with no decisions. The daemon now
saves it to model_dir/rarity.state (checksummed, atomic write, hourly and
at stop) and restores it at start. A restored state younger than the
7-day half-life skips the warm-up; decay catches up on the first event.
A file made with other rarity settings, a bad checksum, or a negative or
non-finite count is refused with a reason (status model.rarity_state,
doctor model.rarity_state) and the model starts empty. The file must be
owned by the daemon user and not group/world writable, like model files.
Also fixes status model.warmup_windows, which was never filled in.
Tests: R1/R2 in test_learn (round trip, decay clock, refusals), S8 in
test_shadow (warm-up skipped only when recent), daemon restart restores
the saved state, doctor warning; new fuzz_rarity_state target.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A promoted model (promoted.sbm, written only by `model promote` after the
gate) can now request real inspections. Only two, both additive:
- memory_scan: through the daemon's memory-scan queue;
- deep_rescan: the root's image re-scanned on demand; new matches are
recorded as indicators of kind model_inspection (findings titled "YARA
match found by a deeper rescan the inspection model requested") and
positive labels.
watch_subtree has no mechanism and rescan_on_next_rules is the retro-hunt's
job, so both are masked out of acting decisions (kExecutableActions), and
replay's policy evaluation uses the same action set.
Guardrails:
- InspectionExecutor (bounded queue, one low-priority worker, submit()
never blocks); WorkClass::model_inspect lets the governor defer it, and
a deferred decision is dropped.
- Each action rechecks that the promoted model is still active at the
decision's generation (demoting or replacing it revokes queued work),
that the root's node id and raw image path still match (decisions carry
root_image, not the feature template), and skips protected processes.
A deep rescan discards its result if the process, image or rules changed
during the scan.
- An acting decision is durably written before it is dispatched; every
attempt becomes an inspection_outcome record (queued, scanned, skipped,
deferred, revoked, queue_full, failed).
- Source invariant R10: no file may couple learning types to the
exec-guard, OpenSnitch or policy APIs (daemon_app.cpp and main.cpp, the
wiring points, are reviewed by hand). Models never block, contain, kill
or create findings directly.
- Config model_act and model_lambda; status model block reports acting
stats; timings.model_inspection.
docs/evaluation/stage4-execution-gate.md amends the gate's method (not its
thresholds): executable action set, greedy promoted decisions, budgets as
estimated inspection seconds by scan profile.
Also: TerminalSafeBuf's destructor no longer lets an exception escape;
the health message clamps huge durations; replay timestamp overflow; the
Docker test build runs with -j2.
Tests: test_inspection_executor (every skip and execute path, revocation,
queue limits); shadow and replay acting cases; R10 fixture; fault injection
and invariant updates. Validation reported by the session that wrote it:
48/48 local, 46/46 Docker plus privileged live checks, 20 fuzz targets
(9.5M runs), three paired KPI runs without regressions (no acting model
was loaded, so active-inspection cost is not measured yet).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The daemon now scores live windows with the shadow model and logs the
inspection it would request. Nothing is executed.
- learn/shadow: a live replay engine (same windows and rarity as
`strawberry replay`) fed every telemetry record on the writer thread.
When a window closes, the model's value v gives each action a benefit
v x reach - lambda x CPU cost; the best positive one is chosen if the
hour's budget (10/30/120 CPU-s by scan profile) allows, else none.
With probability 0.02 a uniformly random other action is taken instead,
and every decision records its propensity for off-policy evaluation.
Decisions are inspection_action telemetry records.
- Replay gains a live mode (no ranking bookkeeping, so memory stays
bounded) and a window-closed callback.
- Daemon: model_shadow (default on) loads <model_dir>/shadow.sbm when it
appears or changes, checked every minute; an invalid file is reported
and not used. Status gains a `model` block (kernel, generation,
decisions by action, exploration, would-be spend, budget refusals).
- learn_sources in src/meson.build: tests that compile the daemon from
sources take the learning library whole.
Limits, documented: decisions come when a window closes (a few minutes
after its first exec), and the live rarity model starts empty at each
daemon start (the first hour is learned, not decided).
Tests: test_shadow (no model, greedy choices, budget never exceeded,
determinism, exploration rate and propensities, record codec); daemon
status; fuzz_telemetry_records covers inspection_action.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
include/strawberry/platform_process.hpp answers what /proc answers on
Linux: running PIDs (proc_listallpids), executable path
(proc_pidpath), parent and start time (sysctl KERN_PROC_PID, readable
for every process), argv (KERN_PROCARGS2) and a boot id
(kern.bootsessionuuid). A process is identified by its start time in
microseconds since the epoch plus the boot id, so node ids survive PID
reuse as on Linux. It is header-only, so the per-test source lists stay
as they are.
Users on macOS: resolve_process_ref (default root), the pipeline's
image hashing and exec-decision actor, and YaraScanner::scan_process
(scans the image by path). A synthetic procfs root still takes the
procfs code, so the existing procfs tests run on macOS too.
The resource governor samples Mach/sysctl on macOS: own CPU from
getrusage, RSS from task_info, load from getloadavg, available memory
from host_statistics64 (free + inactive + purgeable + speculative).
The behavior engine knows macOS debuggers (debugserver, dtrace) and
kext loaders (kernelmanagerd, kmutil), and macOS temp and Downloads
paths count as drop locations. The Linux lists are unchanged.
The KERN_PROCARGS2 parser is portable: a property test (exact argv
recovery, truncation never invents data, total on junk) and the
fuzz_procargs target run on every platform. test_platform_process
checks the live helpers against this process; the daemon test reads
the stopped state through sysctl on macOS.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- doctor (control verb, read-only): store health and disk floor,
telemetry growth per day and days until the floor when retention is
unlimited, leftover store files, superseded findings, retro-hunt state,
thread/write errors, logs (journald rotates them), model (none yet).
Each check carries a maintenance action or advice. Pure checks over
gathered inputs (src/doctor.cpp), so they test without a daemon.
- maintain (control payload verb, privileged, rate limited, audited):
retire-superseded-findings and clean-store, each with dry_run.
- finding_retired evidence record: removes a finding from view; it stays
in the stream's history. CorrelationEngine::superseded_findings finds
old hash/rule findings by recomputing the stable id, and old lineage
findings only when the current one's parent process is among their
nodes (a reused pid on another boot is not a match). Lineage findings
now record parent_process_node_id.
- store::inspect_store_files / clean_store_leftovers: orphan/ files older
than N days and *.compact / MANIFEST.tmp temp files; never a listed
segment.
Tests: test_doctor (check statuses, superseded detection including pid
reuse and no-replacement cases, retirement surviving a reopen, cleanup
keeping recent orphans and listed segments); daemon test exercises both
verbs over the socket. fuzz_evidence_records covers finding_retired.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
File node ids: include/strawberry/node_ids.hpp is now the only place
they are built (file_<sha256> or file_path_<sha256 of path>). The three
modules disagreed: correlation used a 16-digit path hash and behavior
detections the raw path, so path-keyed evidence never met the rest. An
exec detection with a known hash also writes a same_path edge from the
path id to the content id. Source invariant R8 rejects hand-built file
ids in src/ and include/.
Processes carry the real uid and kernel comm: from the eBPF exec event
(which now includes the uid) or /proc. Stored on process nodes and in
process_exec telemetry (fields 14, 15).
Command lines are redacted before any storage (capture_redact_cmdline,
default on): sensitive flags and KEY=value pairs, Authorization/Bearer
credentials, URL passwords, tokens used as URL user names, well-known
token shapes (GitHub, GitLab, Slack, AWS key ids, sk-, JWTs) and mysql
-p<password>. The rules repeat to a fixed point, so redaction is
idempotent by construction. tests/test_redact.cpp covers the rules plus
idempotence, size and planted-secret properties; fuzz_cmdline_redactor
found two idempotence bugs and a leak (--password --token X) that are
fixed here.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Teacher signals and context for the learning stages, written to the
evidence stream (retention never removes it):
- label: operator actions from the control socket (quarantine, contain,
kill, suspend: positive; allowlist-add: negative; allowlist-remove and
quarantine-remove: retracted) and allowlist suppressions (negative,
once per entry, subject and rule). Never from the MCP.
- rules_generation: every rules load attempt, with sources, counts and
the error of a failed reload.
- policy_generation: each policy change, with a sha256 of the policy.
- lifecycle: daemon start and stop.
governor_sample (pressure level, CPU/IO/memory, per-class admissions) goes
to the telemetry stream once a minute.
Database::append_evidence writes records the evidence view ignores.
Tests: record round-trips; suppression labels and dedupe and rules
generations in the pipeline test; operator labels, policy generations and
lifecycle in the daemon test; the record fuzzer covers the new decoders.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Wire the policy, feeds, containment, exec guard, behavior, governor,
crash safety and event store into the daemon, detection pipeline, CLI
and meson build (zstd now required); Dockerfile, conan, systemd unit
(LimitCORE=0, resource limits) and installer updates; existing tests
adapted (store paths are directories now). Detections are counted and
notified even when evidence cannot be persisted (persist_failures in
status). prevention_timeout_ms is clamped and behavior dedupe handles
out-of-order events. Docs: API contract, developer guide, plan, UX,
agent rules.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>