Repository navigation
feat: agent hardening: DPAPI and TPM keys, signed self-update in rings, quiet agent and sensor alerts, code signing prep - #68
Conversation
Migration 0007 adds the clean shutdown notice, update ring and state columns, release ring columns and a per-sensor status table. - jobs/agent_alerts.zig: an agent offline without a clean shutdown notice raises Agent silent (never for revoked agents); the next heartbeat closes it. A sensor that was running and stops, or a continuous sensor quiet for 15 minutes, raises Sensor silent; delivery closes it. Every agent_tamper event raises Agent tamper. - Heartbeat accepts shutdown and shutdown_reason. Ingest feeds sensor_health and agent_health into sensor status and records key_protection and update state. - agent_tamper schema; agent_health gains key_protection, sensors and update. New types appended to the backup and sink name lists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- GET /api/releases/latest takes an optional ring query. - POST /api/agent/update-check returns the signed manifest, signature and download URL when the latest release is open to the agent's ring (update_ring override, else sha256(agent_id) mod 100). - The release sync stores published .manifest.json and .minisig assets and starts new releases in canary. promote() widens a ring after a 24 hour soak while no more than 5% of reporting agents rolled back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- windows_dpapi backend: CryptProtectData machine scope with fixed entropy, one <state dir>\\<secret>.dpapi file per secret, protected DACL for SYSTEM and Administrators set before the rename. - When the Microsoft Platform Crypto Provider opens, the DPAPI blob is wrapped with RSA-OAEP SHA-256 under a non-exportable machine key and checked by unwrapping before it is trusted; otherwise DPAPI alone. TAWNY_KEYSTORE_TPM=off turns the wrap off. - Existing migration moves plaintext JWT and seed in, reads back, then deletes. Store.protection() reports keychain, dpapi, tpm or file. - --keystore-selftest for CI. Link crypt32 and ncrypt. Constants pinned against windows-rs in a test that runs on every OS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- minisign.zig verifies ED (BLAKE2b-512 prehashed) and legacy Ed signatures and the trusted comment's global signature. Cross-checked against a signature made by an independent implementation. - update_key.zig holds an obvious placeholder; the updater refuses every update while it is there (state disabled_no_release_key). - updater.zig: decide (platform, ring, min_from, downgrade refused unless a signed rollback, never retry a rolled-back version), verify size and SHA-256, stage, swap with .previous (rename the running exe), restart through the service manager, 5 minute health window, commit or roll back. Tests sign with a key made inside the test. - --update-selftest runs the same scenarios through real file renames. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… DACL - lifecycle: stop reasons from the SCM handler and signals; on a clean stop the agent flushes, sends a shutdown heartbeat and writes <state>.clean. A start without it sends agent_tamper unexpected_stop. - tamper.zig: binary hash (against the signed manifest after an update), config and identity file changes outside the agent, Sysmon service stopped, Defender Operational 5007 exclusions covering Tawny paths. - agent_health carries key_protection, sensors and update state. - Run loop checks for signed updates every 6 hours (off while the release key is the placeholder) and exits non-zero after a swap so the service manager starts the new binary. - install.ps1 sets a service DACL so only SYSTEM and Administrators can stop, reconfigure or delete TawnyAgent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n Windows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…without secrets sign-windows, notarize-macos and release-manifests each gate on a job-level env flag set from their secrets, so releases still publish unsigned binaries when none are configured. The minisign key is read only from the protected release-signing environment. docs/code-signing.md lists the Windows and macOS options to choose from, without prices. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #58 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
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. |
|
Status: all 11 CI checks pass on Windows runner, live: So DPAPI round-trips, a plaintext seed is migrated and removed, and the service stop and delete DACL is in place. Hosted runners have no TPM, so Self-update is built and tested with a throwaway in-test key, but it's off in practice: Decisions for Justin are on #58: #58 (comment) (Windows signing option, Apple Developer enrolment, the release key and protected environment, and the promotion soak and threshold). Stacked on #67. Merge order: #62 to #67, then this. #59 and #60 will stack on this one. |
Closes #58
Stacked on #67 (base
feat/windows-response). Merge #67 and the stack below it first.This PR adds quiet agent and quiet sensor alerts, tamper checks, DPAPI keys on Windows with an optional TPM wrap, and minisign-verified self-update in rings. It also prepares code signing. Nothing was bought or registered, and no real release key exists. The compiled-in release key is a placeholder, so agents refuse every update until Justin provides one.
Decisions for Justin are in the issue comment: #58 (comment)
Acceptance criteria
keystore.zignow has awindows_dpapibackend (platform/windows/dpapi.zig):CryptProtectDatawithCRYPTPROTECT_LOCAL_MACHINEand fixed entropy, one<state dir>\<secret>.dpapifile per secret, and a protected DACL for SYSTEM and Administrators applied before the rename. When the Microsoft Platform Crypto Provider opens, the blob is wrapped with RSA-OAEP SHA-256 under a non-exportable machine key, and the wrap is checked by unwrapping before it is trusted. Otherwise it falls back to DPAPI alone. The existing migration path (move, read back, scrub, delete) is reused.--keystore-selftestcovers the round trip, the plaintext seed being migrated and removed, and no plaintext in the blob. The TPM wrap has not run live, because hosted runners have no usable TPM, so it is compiled and falls back cleanly. Linux stays on a 0600 file; tpm2-tss is not done (documented).minisign.zigverifiesED(BLAKE2b-512 prehashed) and legacyEdsignatures plus the trusted comment's global signature. I also checked it once against a signature made by an independent implementation (Pythoncryptographyplus hashlib).updater.zigdoes decide, verify size and SHA-256, stage, swap with.previous(renames the running exe), exit non-zero so the service manager restarts, open a 5 minute health window, then commit or roll back. It refuses a downgrade except through a signedrollback, and never retries a version it rolled back from. Tests and--update-selftestcover a good update, bad signature, bad hash, refused downgrade and failed-health rollback through real renames, in CI on all three OSes. A live restart through SCM, systemd or launchd after a swap has not run.update_ringoverride; rings canary, internal, 10, 50, 100.POST /api/agent/update-checkpicks the ring on the server, and/api/releases/latesttakesring=. New releases start in canary. Promotion needs a 24 h soak with 5% or less rolled back or failed. DB test covers ring gating and override.<state>.clean) and a finalshutdownheartbeat are sent on SCM stop or shutdown and on SIGTERM/SIGINT. A start without the marker sendsagent_tamperunexpected_stop.jobs/agent_alerts.zigraisesAgent silentwith the hostname and last heartbeat. The next heartbeat closes it, and revoked agents are skipped.Sensor silentfires when a running sensor stops, fails, or (Sysmon, Security) goes 15 minutes without events. Delivering again closes it. Tamper checks cover the binary hash, config and identity changes, Sysmon stopping, and Defender 5007 exclusions over Tawny paths.install.ps1runssc.exe sdset, and the Windows CI step applies the same SDDL to a probe service and reads it back. DB tests cover all three alert kinds.docs/code-signing.mdlists options; nothing boughtsign-windows(signtool),notarize-macos(codesign plus notarytool) andrelease-manifests(minisign, protectedrelease-signingenvironment) each gate on a job-level env flag. The doc gives no prices. It names the vendor pages to check.No mTLS. The decision is recorded in
docs/threat-model.md.Not done
agent_healthCPU, RSS, disk, per-priority queues, and ahealthy/degraded/silent/tamperedverdict.What ran where
Mac (macOS arm64, Zig 0.17.0):
/tmp/run-e2e.shon the Mac got toheartbeat_ok,event_ok=system_infoandschema_v2_ok. It then hittimeout waiting for isolate resultbecauseci/agent_e2e.pyexpects the Linux "not supported on linux" message. The base commit5bd105agives the same result on this Mac, and the Linuxagent-e2eCI job is the one that counts.Linux container (ubuntu:26.04, aarch64):
CI only: the Windows DPAPI keystore self-test and service DACL step, and the update self-test on Linux, macOS and Windows.
🤖 Generated with Claude Code