Skip to content

feat(security): policy-distributed hardware mandate (require_hardware_identity) - #236

Merged
sandstream merged 3 commits into
mainfrom
claude/web-kit-status-sync-p6fg9a
Jul 5, 2026
Merged

sandstream merged 3 commits into
mainfrom
claude/web-kit-status-sync-p6fg9a

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Description

Wires the fleet-wide hardware mandate that Pillar 1 (#235) documented as not-yet-wired. An org can now set require_hardware_identity = true in .kit-policy.toml to mandate a hardware/externally-held signing identity across every repo that commits the policy — no per-machine env var required.

Type of Change

  • New feature (non-breaking change that adds functionality)

Changes Made

  • Schema: PolicyDoc.require_hardware_identity (validated boolean).
  • Effective mandate: hardwareRequired(root) = hardwareRequiredByEnv() || policyRequiresHardware(root). Tightening-only by construction (an OR): a false/absent policy value can never relax an environment mandate; a repo-local policy can only add the requirement — the fail-closed, safe direction (worst case is a DoS on a box lacking hardware, never a silent downgrade).
  • Enforcement now honors the effective mandate at every routed site: kit policy sign, audit-chain signing, shared-memory signing, keystore-routed revocation, and kit identity init/rotate (refuse to mint a file key under a policy mandate too).
  • Surfacing: kit identity keystore shows whether the mandate is from env or policy.
  • signWithIdentity stays the env-only backstop (identity.ts must remain import-cycle-free); the routed sites enforce the policy mandate before any file signing can occur.

Testing

Test Coverage

  • Added new tests
  • All tests pass (npm test)

New regression tests: a policy-only mandate (no env) forces audit entries keyless; tightening-only semantics (hardwareRequired on a dir without the policy is false); schema validation of the new field. Full suite green: 2266 tests.

Breaking Changes

None / N/A — default behavior is unchanged (no policy field, no env var → signs with the file key exactly as before). The mandate only ever adds strictness.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2


Generated by Claude Code

…_identity)

Wires the fleet-wide hardware mandate the previous PR documented as not-yet-wired: an
org can now set `require_hardware_identity = true` in `.kit-policy.toml` to mandate a
hardware/externally-held signing identity across every repo that commits the policy —
no per-machine env var needed.

- Schema: PolicyDoc.require_hardware_identity (validated boolean).
- Effective mandate: hardwareRequired(root) = hardwareRequiredByEnv() || policy value.
  TIGHTENING-ONLY by construction (an OR): a false/absent policy value can never relax an
  environment mandate; a repo-local policy can only ADD the requirement (fail-closed, the
  safe direction).
- Enforcement sites now honor the effective mandate: policy sign, audit-chain signing,
  shared-memory signing, keystore-routed revocation, and `kit identity init/rotate`
  (refuse to mint a file key under a policy mandate too). `kit identity keystore` surfaces
  whether the mandate comes from env or policy.
- signWithIdentity stays the env-only backstop (identity.ts must remain import-cycle-free);
  the routed sites enforce the policy mandate before any file signing can occur.

Regression tests: policy-only mandate forces audit keyless (no env), tightening-only
semantics, schema validation. Full suite green (2266 tests).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

Pre-empting the verify pass on the two gaps I flagged in the new policy mandate:

- cwd-vs-root: policyRequiresHardware now walks UP to the nearest ancestor holding
  .kit-policy.toml (cheap fs walk, no git exec — safe on the audit hot path). A root-level
  require_hardware_identity now applies when kit is invoked from any subdirectory, instead
  of being silently skipped (which would have let audit signing emit a file-key signature
  despite the org policy).
- Attestation: loadOrCreateEd25519Key is now guarded by hardwareRequired(cwd) (env OR
  policy), not env-only — so under a policy-only mandate the attestation receipt no longer
  mints/uses the same-UID Ed25519 file key either.

Regression tests: subdir upward-walk, attestation under a policy-only mandate.
Full suite green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

…tgun (verify round 2)

The verify pass confirmed the cwd-vs-root gap and attestation gap were already closed
(subdir upward-walk + policy-aware attestation guard, with tests). Two residuals remained:

- Finding 2 (HIGH): `kit panic` calls rotateIdentity() directly, whose guard is env-only,
  so a POLICY-only mandate let panic re-mint the same-UID file key the mandate forbids
  (cwd-independent). Added the effective-mandate guard (env OR policy, via
  getCurrentProjectRoot) before panic rotates — fail closed.
- Finding 7 (footgun): a present-but-non-boolean require_hardware_identity (`= 1`,
  `= "true"`) is a validate error but was silently treated as "not mandated".
  policyRequiresHardware now fail-closes ON for any present non-false value; only a strict
  false/absent means not-mandated.

Verify also confirmed SOLID (no change): the OR truly prevents policy-relax of an env
mandate; no standalone signWithIdentity bypass; no import cycle.

Regression tests: panic refuses under a policy-only mandate (identity unrotated, no
revocation); non-boolean mandate value → ON. Full suite green (2270 tests).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream
sandstream merged commit 4f37c37 into main Jul 5, 2026
17 checks passed
@sandstream
sandstream deleted the claude/web-kit-status-sync-p6fg9a branch July 5, 2026 08:49
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