Repository navigation
feat: Windows response, signed actions, process control, quarantine, WFP plan - #67
Conversation
Fold the #56 rule-pack key into a single Ed25519 server action key (TAWNY_ACTION_SIGNING_KEY, 64 hex) that signs both response actions and YARA rule packs. TAWNY_RULE_SIGNING_KEY keeps working as a deprecated alias. When neither is set the key is derived from the agent JWT seed with HKDF and a domain-separated label, matching how #66 derived the rule key, so existing deployments keep booting. The public key is returned in the enrol reply and in every heartbeat for trust-on-first-use pinning of agents enrolled before this change. The server signs the canonical string tawny-action-v1\n<action_id>\n<agent_id>\n<action_type>\n<expires_at>\n<sha256 of payload> and adds "signature" to each action in the heartbeat. The agent verifies it in response_actions before anything runs, refusing unsigned, expired, tampered and wrong-key actions and reporting failed with a reason. A local action journal at <state_dir>/actions/<id>.json dedupes by action_id, replays unfinished actions on restart, and keeps results until the server acks them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent: - platform/windows/process_control.zig: kill (already-gone is success), suspend and resume via NtSuspendProcess/NtResumeProcess, an identity guard (image path plus start time) so Windows no longer fails closed, and a critical-process refusal list tested on every OS. - quarantine.zig: encode the file with a fixed XOR key so it cannot run, hash and verify the copy, delete the original, write a sidecar, and restore. Windows keeps the ACL as SDDL; POSIX restores owner-only permissions. Round-trips on Linux and macOS. - platform/windows/wfp.zig: a pure filter-building plan with a fixed sublayer GUID, an auto-release deadline check, and the break-glass release code (HMAC of agent id and nonce), all tested on every OS. The live FwpmEngine calls are stubs behind the Windows target for now. - response_actions dispatches kill, suspend, resume, quarantine, restore, and reports isolate_host as not supported on this build. Server: - migration 0006 adds suspend_process, resume_process, quarantine_file, restore_file and release action types. - the SPA agent page lists recent actions and lets an admin create one. - a contract test verifies the action signature with openssl; the Linux e2e now expects the new isolate_host message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add agent debug subcommands (--kill-pid, --suspend-pid, --resume-pid, --quarantine, --restore) that drive the response actions from CI without a server, following the --eventlog-dump pattern. A new Windows CI step starts ping, kills it by PID and start time and checks it is gone, suspends and resumes a child, refuses lsass, and quarantines then restores a temp file comparing hashes. Document the action signing scheme and the new action types in docs/api.md, TAWNY_ACTION_SIGNING_KEY and the trust-on-first-use window in docs/production.md, the §9 status and the merged key in docs/architecture/target-edr.md, and the signed-action and PID-reuse rows in docs/threat-model.md. Closes #57 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Apply the restrictive ACL to the quarantine copy and sidecar only after the read-back verification, so a SYSTEM-only DACL never blocks the agent's own verify or a later restore. Widen the Windows DACL to SYSTEM plus local Administrators, so an agent not running as SYSTEM (CI, or a service misconfiguration) can still read the copy back; normal users still cannot run it. Compute the Windows CI ping start time with DateTimeOffset instead of Get-Date -UFormat %s, avoiding a double UTC offset and locale parsing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rence PowerShell 7.4 on the hosted runner propagates a native command's non-zero exit as a terminating error by default, which would throw on the agent's intentional refusal of a critical process before the explicit exit-code check. Disable that for the step. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Status: all 11 CI checks pass on
Still in progress on this branch: live WFP isolation (fwpuclnt calls, reconcile at start, break-glass Open for Justin, from the PR body:
|
Link fwpuclnt (Windows only) and implement the live WFP engine in platform/windows/wfp.zig: FwpmEngineOpen0, a transaction, the Tawny provider and fixed-GUID sublayer, persistent filters built from the pure plan (permit loopback, resolved server IPs, DNS resolvers and an optional admin allowlist on the four ALE layers, block everything else), and delete by sublayer on release. A TCP verify probe reports the server reachable and a blocked address unreachable. Wire isolate_host and release to it on Windows; Linux and macOS keep a clear "not supported on <os>" failure. Isolation state is persisted to <state_path>.wfp so the agent reconciles filters with the journal at start and releases itself when the deadline (default 24 h) passes, checked on each heartbeat and at start. Break-glass `tawny-agent release --code <code>` verifies the HMAC of the agent id and nonce with TAWNY_ISOLATION_SECRET. CI: a safe live WFP step runs `tawny-agent --wfp-selftest`, which adds a single TEST-NET block filter (never a block-all, so it can't cut the runner off), confirms it is present and that a routable address stays reachable, then releases and confirms the sublayer is empty. Docs: target-edr §9 and api.md updated for live isolation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lter by id The Windows self-test added its filter but countFilters found nothing. countFilters read only the first page of up to 256 filters per layer, with a provider-key template, and a busy layer on the runner can hide ours past that page. It now pages through every entry and matches on the Tawny sublayer. The self-test also checks the filter directly with FwpmFilterGetById0 and prints the WFP status on failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Windows CI: filter enumeration failed with 0x80320004 (FWP_E_LAYER_NOT_FOUND). The last eight bytes of the RECV_ACCEPT_V6 layer GUID were wrong, so every enumeration over the layer list failed and the self-test saw zero filters. The filter add itself succeeded (found by id). The layer and condition GUIDs now sit at the top level with a test pinning them to the SDK values (fwpmu.h as published in microsoft/windows-rs), so it runs on every OS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Status: all 11 CI checks pass on Windows runner self-test output: So a filter is added in the Tawny sublayer, the TEST-NET address is blocked, a routable address still connects, and release leaves no filters. Fixed on the way: the Not shown by CI: full block-all isolation (it would cut the runner off) and surviving a reboot. Needs a manual test on a spare Windows VM. Open for Justin, from the PR body:
|
Closes #57
Stacked on #66 (base
feat/detection-engine). Merge the stack below #66 first.Windows can now respond: signed response actions, a durable action journal, Windows process control (kill, suspend, resume) with an identity guard, cross-platform quarantine and restore, and live WFP network isolation that undoes itself. The server signs every action with one Ed25519 action key that also signs YARA rule packs (folding in #66's rule-pack key).
Key decisions for Justin
TAWNY_ACTION_SIGNING_KEY(64 hex) signs both response actions and YARA rule packs.TAWNY_RULE_SIGNING_KEYkeeps working as a deprecated alias. When neither is set the key is derived from the agent JWT seed with HKDF and the labeltawny-action-key-v1, matching how feat: detection engine, Sigma compiler, sequence and threshold rules, YARA via libyara #66 already derived the rule key, so existing deployments keep booting. It is never the JWT key.state.rulePackKeynow forwards tostate.actionKey.TAWNY_ISOLATION_SECRET; the server-side UI that shows that secret is not in this change.Acceptance criteria
tawny-action-v1\n<action_id>\n<agent_id>\n<action_type>\n<expires_at>\n<sha256 of payload>; the agent verifies before anything runs. Tests both sides: good, tampered, expired, wrong key, plus an openssl contract test.isolate_hostopens the engine (fwpuclnt), adds persistent filters in the fixed Tawny sublayer (permit loopback, resolved server IPs, DNS resolvers, optional admin allowlist; block all else on the four ALE layers), then probes the server and a blocked address.releasedeletes the sublayer, filters and provider. The deadline (default 24 h) is stored and enforced at start and on each heartbeat; filters are reconciled with the journal at start. Break-glasstawny-agent release --code <code>. The pure plan, deadline and release-code logic are tested on every OS; the live engine is exercised by a safe CI self-test (see below). The live block/permit behaviour against real traffic and reboot persistence are not asserted by a test.action_journal.zig, tested.Live WFP in CI
tawny-agent --wfp-selftestadds one block filter for a TEST-NET address (192.0.2.1), never a block-all, so it cannot cut the runner off. It confirms the filter is present, that a routable address (1.1.1.1:443) stays reachable (no over-block), then releases and confirms the sublayer is empty. Full isolation with a block-all is not run in CI, because it could cut the runner off from GitHub; the self-test does add, probe and delete of real WFP filters under the sublayer and fails if the engine over-blocks or leaves filters behind. The TEST-NET block is reported, not asserted, because it is indistinguishable from an unroutable baseline.What ran where
Mac (macOS arm64, Zig 0.17.0):
Linux container (ubuntu:26.04, aarch64):
Windows CI only: a response-actions step (kill by PID and start time, already-gone kill, suspend and resume, refuse lsass, quarantine and restore comparing hashes) and a live WFP step (
--wfp-selftest: add a TEST-NET block, confirm present and no over-block, release, confirm empty). Both run through the agent's debug subcommands.New Zig 0.17 gotchas
"ab" ** 32and[_]u8{0} ** Nstyle repeats don't parse next to}; usestd.mem.zeroes([N]u8).suspendandresumeare reserved words; an enum can't use them as field names.std.crypto.timing_safe.eql(notstd.crypto.utils.timingSafeEql).Io.Filehas nochmod; usesetPermissions(io, @enumFromInt(0o600)).std.posix.SIG.*is an enum on Linux, not au8.std.json.parseFromSlicekeeps string slices into the input unless you pass.allocate = .alloc_always; free the input only after that.std.Io.net.IpAddressis aunion(enum)ofip4/ip6with.bytes, not a POSIX sockaddr.🤖 Generated with Claude Code