Repository navigation
Conversation
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
Every short-lived process (hook-augment in particular) learned its own build fingerprint by hashing its whole ~300 MB executable. On CPUs without SHA instructions that is ~1.9 s per hook call, past the 2000 ms hook deadline, so hooks returned nothing (DeusData#2683). Define the fingerprint as the SHA-256 of the image with a 32-byte stamp payload read as zeros. The payload sits right after a 16-byte magic in a static slot. scripts/build-stamp.py computes that digest and writes it into the payload without executing the image; build.sh stamps ELF builds, and prepare-release-candidates.sh re-stamps each Linux candidate after strip, so no candidate runs before VirusTotal selection. A process with a non-zero payload uses it as its fingerprint and does not read its own image at all. On an unstamped image the payload is already zero, so the fingerprint is exactly the plain SHA-256 used today: Mach-O and PE builds (which are signed after linking, so stamping would need the signature excluded) keep the current behaviour, as do test runners. The verification side is unchanged and still hashes: the daemon checks its own image against the stamp at startup (stage active_image_identity), and a peer running a different file is hashed and compared. A binary modified after stamping is therefore refused both as daemon and as peer. Refs DeusData#2683 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Alex MKX <25821291+AlexMKX@users.noreply.github.com>
3955667 to
592be44
Compare
|
Hi @AlexMKX, thank you for this, and especially for the measurements. About 1.9 s per hook call on a Broadwell CPU without SHA instructions, and thousands of We would like to take #2683 in a different direction, though, and want to say why before you put more time into this approach:
Our preference is option 1 from #2683. The daemon verifies the connecting hook's image (since #2335 it already holds a verified handle for peers), and the hook process stops hashing itself. That works the same way on all three platforms and leaves the release bytes untouched. If you would like to build that, we would be glad to review it, and your measurement setup would be the perfect check for it. If not, we will pick it up ourselves and credit your measurements. We'll keep this PR open until that is settled. One small note for a follow-up PR: please leave out the |
Refs #2683 — not
Closes: this covers ELF only; Mach-O and PE keep the full hash (see below).Problem
hook-augment(and every other short-lived CBM process) learns its own build fingerprint by hashing its whole executable (~300 MB). On CPUs without SHA instructions this is the portable path from #2683: measured ~1.9 s per hook call on an Intel Xeon E5-2690 v4 (Broadwell, nosha_ni), Linux, v0.12.1 release binary, warm permanent daemon — against the 2000 ms hook deadline.hook-augment-timeouts.logon that machine had 3,640deadline_exceededlines, a second identical machine 9,575.Change (option 3 of #2683, embedded instead of an install-time file)
src/foundation/build_stamp.c). The magic exists as a literal only in the slot initializer; the hasher compares against the slot's own bytes, so an image holds it once.cbm_daemon_build_fingerprint_native_file(POSIX and Windows) streams throughcbm_build_stamp_hasher_*, which zeroes the payload after each magic in stream order, so the digest does not depend on read sizes. Daemon self-check (active_image_identity), peer verification andcbm_daemon_build_fingerprint_fileall go through it.scripts/build-stamp.py <file>(stdlib only) hashes the file, requires exactly one slot, writes the digest into the payload,fsyncs and re-verifies.scripts/build.shstamps ELF builds (Linux/FreeBSD/NetBSD; withoutpython3it warns and leaves the build unstamped, which is still correct).scripts/ci/prepare-release-candidates.sh(already requirespython3) re-stamps every Linux candidate after strip and before provenance hashing, so the "no candidate runs before VirusTotal selection" rule holds.tests/test_release_candidate_derivation_contract.sh: the stub gets a slot, and every Linux candidate must hold exactly one slot whose payload equals the SHA-256 of the candidate with the payload zeroed. Verified to fail when the stamper is replaced by a no-op.cbm_index_supervisor_capture_build_fingerprintuses a non-zero payload as the process's fingerprint and does not read its image.Why not Mach-O / PE in this PR
They are signed after linking (
codesigninprepare-release-candidates.sh, re-signed byinstall.shon macOS). Stamping before signing would make the stamp disagree with the signed file; supporting them needs the signature region excluded from the digest. Not attempted here and not tested — I have no macOS/Windows hosts. They keep the current full hash.Evidence (Linux x86_64, Xeon E5-2690 v4, gcc 15.2, this branch on
4f8b66e)scripts/build.shoutput, slot checked independently (find magic, zero payload,hashlib.sha256)prepare-release-candidates.sh linux amd64on that buildbuild: 0.12.1-pr (dcbf30f1d00d…)— the two implementations agreehook-augmentPreToolUse Grep from that candidate, indexed project, daemon runningstrace -f -y -e trace=pread64,readonhook-augmentpread64calls over the image)stage=active_image_identity/client_image_rejected reason=fingerprint_mismatchscripts/test.sh(ASan+UBSan)cliinstall/update tests failing withinstall_dir_group_or_world_writable (mode 0775): my checkout lives under a group-writable directory.daemon_version17 (2 new),daemon,daemon_runtime,index_supervisorgreenclang-format20.1.8 on touched C files;make lint-no-suppress lint-memory-core lint-vendored-scanners;scripts/security-audit.shNew C tests (
tests/test_daemon_version.c): digest equals plain SHA-256 without a stamp; digest ignores the payload and is identical for every chunk size 1…51 (magic and payload straddle every boundary) while a byte outside the payload still changes it.Not run locally:
cppcheck2.20 andclang-tidy(not installed here), macOS/Windows builds, the release workflow itself.pair_verification: same-linker-output-v1is a manifest label only, so per-variant stamps do not conflict with it.Notes for review
build.shandprepare-release-candidates.sh, which CONTRIBUTING lists as needing design discussion — happy to adjust or split (mechanism vs. pipeline step) if you prefer a different place for stamping.codebase-memory-mcp build-stamp); Step 0q rightly rejected that, and it would also have executed the unscanned build inbuild.shon the release runners. The subcommand is gone.fingerprint_mismatch), the client keeps retrying and finally reports "answered no rendezvous within 30000 ms; the daemon runtime is likely dead" instead of the rejection reason; (2)tests/test_venue_parity_contract.shrunsbash scripts/ci/generate-sbom.py --helpbefore the*.pybranch re-runs it withpython3; on a desktop with ImageMagick andDISPLAYset,import datetimebecomes a screen grab that waits for a click and hangs the run.This PR was written with Claude Code (Claude Opus 5.5) on behalf of the account owner, who directed the change and signs off the DCO.
🤖 Generated with Claude Code