Skip to content

Sign the distribution channel: verify release tags before self-update applies them - #29

Draft
konjoinfinity wants to merge 2 commits into
mainfrom
claude/sign-distribution-channel-heg41d
Draft

Sign the distribution channel: verify release tags before self-update applies them#29
konjoinfinity wants to merge 2 commits into
mainfrom
claude/sign-distribution-channel-heg41d

Conversation

@konjoinfinity

Copy link
Copy Markdown
Contributor

Summary

kiban self-distributes its own gate code and agent instructions to every consuming repo via lib/self_update.sh. merge --ff-only stops a divergent history but does nothing against a malicious, fast-forwardable commit pushed straight to the tracked upstream — exactly the case where an attacker with push access (or a compromised token) appends rather than rewrites. This PR closes that gap.

Pre-flight (see LEDGER.md's Sign-Distribution-1 entry) confirmed nothing was signed today: release tags (v0.4.0v1.6.0) were all lightweight tags created server-side by gh release create, and individual commits carried no signature (the only "signature" anywhere was GitHub's own auto-signing of web-UI merge commits — not a maintainer policy, and it doesn't cover tags at all). Per the sprint brief's hard gate, that finding meant the honest scope was "establish signing, then verify" — a decision reserved for the repo owner, not the agent. Asked directly, the owner chose the full scope with ssh-format git signing (no keyserver, no bespoke PKI — verifies against a flat security/allowed_signers file via git's native gpg.ssh.allowedSignersFile).

  • security/allowed_signers: the trust anchor (git ssh-signing format, principal release@kiban).
  • lib/self_update.sh: unpinned updates now resolve to the newest signed release tag reachable from the tracking branch (not the raw branch tip — verifying every commit on main would mean signing every commit, out of scope) and verify it, read from the pre-update working tree, before merging. A pinned ref is verified before checkout and refused if unsigned, invalidly signed, or a mutable ref (a branch). Verification failures are logged to ~/.konjo/security.log, classified (unsigned / invalid_signature / unresolvable_ref / unverifiable) so a real tamper signal is distinguishable from a transient/no-op case. Every existing failure-safe property — throttling, silent no-op, ff-only, single-remote fetch — is unchanged.
  • .github/workflows/release.yml: cuts and pushes a signed, annotated tag itself (git tag -s -a, ssh format, RELEASE_SIGNING_KEY secret) instead of relying on gh release create's unsigned, lightweight tag creation.
  • docs/DISTRIBUTION.md, README.md: recommend pinning to a signed tag (never main or another branch), document how to cut a signed release and rotate the key.
  • CHANGELOG.md, LEDGER.md (two entries), NEXT_SESSION_PROMPT.md, VERSION (1.6.0 → 1.7.0): the verification requirement and the establish-signing decision are both one-way doors, logged as such. NEXT_SESSION_PROMPT.md scopes the follow-up: migrating existing consuming-repo pins (lopi, miru, ...) from mutable refs to signed tags.

Out of scope, deliberately: no change to the ff-only stance or the failure-safe model; no signing of every historical or future commit (only release tags); no bespoke key-management platform.

Setup required before the next release

A fresh, dedicated release-signing ed25519 keypair was generated for this sprint (not the repo owner's personal key). The public half is committed in security/allowed_signers. The private half was not committed or pasted anywhere in git history/PR text — it was handed to the repo owner out-of-band. It needs to be added as the RELEASE_SIGNING_KEY GitHub Actions secret before release.yml can cut a signed release (see docs/DISTRIBUTION.md for the manual fallback if it isn't set yet).

Test plan

  • bash tests/test_self_update.sh — 11 cases (up from 6): valid-signed applies, unsigned no-op + logged, invalid-signature no-op + logged (distinct from unsigned), recovery once a valid tag supersedes, signed-tag pin checks out, unsigned-tag pin refused + logged, branch pin refused + logged, plus the pre-existing skip/throttle/failure-safety/C2-reattach cases.
  • ruff check . — all checks passed.
  • mypy lib ledger evals packages/konjo-gates-py/src/konjo_gates_py — no issues.
  • pytest -q — 199 passed.

🤖 Generated with Claude Code

https://claude.ai/code/session_0147TLzhpqLH7bDvCfGj1znJ


Generated by Claude Code

claude added 2 commits July 25, 2026 23:21
… applies them

self_update.sh's fast-forward-only merge stops a divergent history but does nothing
against a malicious, fast-forwardable commit pushed straight to the tracked upstream --
and kiban self-distributes its own gate code and agent instructions to every consuming
repo. Pre-flight found nothing was signed today (release tags were all lightweight,
commits unsigned save for GitHub's own unrelated merge-commit auto-signing), so this
establishes a dedicated release-signing key and ssh-based tag verification together.

- security/allowed_signers: the trust anchor (git ssh-signing format).
- lib/self_update.sh: unpinned updates now resolve to the newest signed tag reachable
  from the tracking branch (not the raw branch tip) and verify it before merging; a
  pinned ref is verified before checkout and refused if unsigned/invalid/mutable.
  Verification failures log to ~/.konjo/security.log, classified so a real tamper
  signal (invalid_signature) is distinguishable from an unsigned/no-op case. Every
  existing failure-safe property (throttling, silent no-op, ff-only, single-remote
  fetch) is unchanged.
- .github/workflows/release.yml: cuts and pushes a signed annotated tag itself instead
  of relying on gh release create's unsigned, lightweight one.
- docs/DISTRIBUTION.md, README.md: recommend pinning to a signed tag, document how to
  cut a signed release and rotate the key.
- CHANGELOG.md, LEDGER.md (two entries), NEXT_SESSION_PROMPT.md, VERSION: the
  verification requirement and the establish-signing decision are both one-way doors,
  logged as such; NEXT_SESSION_PROMPT.md scopes the follow-up pin migration for
  existing consuming repos.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0147TLzhpqLH7bDvCfGj1znJ
…ion-channel-heg41d

# Conflicts:
#	CHANGELOG.md
#	LEDGER.md
#	NEXT_SESSION_PROMPT.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants