Skip to content

feat(pal)!: declarative typed verify checks, no shell execution (1.4.0) - #3

Merged
sandstream merged 1 commit into
mainfrom
feat/pal-declarative-verify
Jun 17, 2026
Merged

sandstream merged 1 commit into
mainfrom
feat/pal-declarative-verify

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Why

kit is agent-native. The old PAL verify_cmd stored a raw shell command and ran it via execSync in palAutoVerify. That is a persistence / deferred-execution primitive: a prompt-injected low-trust agent session could pal add a command that detonated later when a more-trusted session (or a human) ran kit memory pal verify. Socket's AI flagged exactly this on memory/pal.js.

A human-in-the-loop gate (confirm / elevate) would close it but break autonomous agent jobs (no human in an L6 stack). So the fix is structural, not a gate.

What

  • Verify is now a declarative typed check, executed natively, never via a shell:
    • http-status (kit makes the request via fetch, compares status)
    • file-exists (kit checks the path via fs)
  • A defensive parser rejects any unknown/injected shape, so a planted or imported value is inert. No arbitrary-command-execution sink remains.
  • Autonomy-friendly: auto-verify needs no human gate; autonomous jobs keep working, a planted command cannot.

Surface changes

  • CLI: --verify-http <url> [--expect <code>] / --verify-file <path> replace --verify "<shell>".
  • DB: new pending_actions.verify_check (JSON), migrated via ensureColumn. Legacy verify_cmd is kept (so kit memory scan still finds secrets in old rows) but is never auto-executed (verify_check IS NULL rows are skipped).
  • For checks the typed model does not cover: run it yourself, close the item manually. pal stays a ledger.

Tests

Declarative pass / fail / regress, plus two SECURITY regressions: a verify imported from a legacy ledger, and a directly-injected {type:"shell",...} row, both never execute. Full suite 2219 green, tsc + build clean.

Note

Conventional-commit ! marks the CLI flag change. Shipped as minor 1.4.0 (security-driven behavior change) with this CHANGELOG note; bump to 2.0.0 at merge if you prefer strict SemVer.

🤖 Generated with Claude Code

palAutoVerify no longer runs a stored shell string via execSync. A verify is now
a typed check (http-status via fetch, file-exists via fs) executed natively,
never through a shell and never by interpolating a stored value into a command.
A defensive parser rejects any unknown/injected shape, so a planted or imported
verify is inert.

Why: kit is agent-native. The old verify_cmd was a persistence/deferred-exec
primitive: a prompt-injected low-trust session could store a command that later
detonated when a more-trusted session ran `kit memory pal verify`. The typed
model removes the sink at the root while staying autonomy-friendly (auto-verify
needs no human gate, so autonomous agent jobs do not break).

CLI: --verify-http <url> [--expect <code>] / --verify-file <path> replace
--verify "<shell>". DB: new pending_actions.verify_check (JSON); legacy
verify_cmd kept for kit memory scan but never auto-executed. Tests: declarative
pass/fail/regress + two SECURITY regressions (imported and injected shapes never
execute). 2219 green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

✅ Docker image built successfully

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

@sandstream sandstream mentioned this pull request Jun 17, 2026
@sandstream
sandstream merged commit 0ab7323 into main Jun 17, 2026
17 checks passed
@sandstream
sandstream deleted the feat/pal-declarative-verify branch June 20, 2026 05:36
sandstream pushed a commit that referenced this pull request Jun 29, 2026
Pull recall can't guarantee you see a settled decision — a bad query misses
it. The guardrail must be PUSH: touch files under an area and kit
deterministically surfaces that area's ACTIVE decisions.

- src/memory/clusters.ts: committed `.kit/shared/clusters.json` maps
  area→globs; zero-dep globToRegExp (** spans segments, * within one),
  clustersForPaths, decisionsForPaths (active only — superseded/reversed
  never resurface), changedPaths (git diff vs HEAD).
- `kit memory context [paths…|--changed]`: prints active decisions for the
  touched areas (--json for tools).
- UserPromptSubmit reminder appends a bounded (≤2 areas × ≤2 decisions)
  notice for the area(s) your working-tree changes fall into — deterministic
  "touch area X ⇒ see X's decisions", not a query lottery. Fail-open.
- Seeded .kit/shared/clusters.json for kit (dogfood: memory/identity/
  install-gate/ci-audit/secrets areas). Public surface regenerated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
sandstream added a commit that referenced this pull request Jun 29, 2026
…r push-surfacing (#168)

Three additive, backward-compatible changes:

1. fix(check): degraded (no-trufflehog) secrets-scan fallback no longer cries
   high-severity on test fixtures / env-var names; unverified ⇒ medium, skips
   those FP classes. Authoritative trufflehog + CI gitleaks unchanged.
2. feat(panic): kit panic — rotate identity + signed append-only revocation
   (asymmetric) + identity.panic audit event + platform-revocation checklist;
   audit verify surfaces revoked-key signatures. recordRevocation/loadRevocations/
   isRevoked/revocationStatement.
3. feat(memory): path→cluster push-surfacing (gap #3) — .kit/shared/clusters.json
   area→globs, kit memory context, UserPromptSubmit push of touched areas' active
   decisions.

1900 tests pass; security-check PASS (19 ok).
sandstream pushed a commit that referenced this pull request Jul 5, 2026
…found false green)

Adversarial verify found the mandate was a false green: KIT_REQUIRE_HARDWARE_IDENTITY
was enforced ONLY in `kit policy sign`, while audit-chain entries, shared-memory notes,
and revocations kept signing with the same-UID-readable file key — and `init` still minted
a file key that coexists. So a mandate operator got a green light over a key an attacker
could still read and use. Fixed so NO file-key signature escapes under the mandate.

- Universal backstop: signWithIdentity() (the file-key primitive) now FAILS CLOSED under
  KIT_REQUIRE_HARDWARE_IDENTITY — every caller that reaches it (revocations, elevation,
  any un-routed signer) refuses the file key. mandate.js is a zero-import module so
  identity.ts can guard without an import cycle.
- loadOrCreateIdentity refuses to MINT a file key under the mandate (Finding #4: no
  coexisting same-UID key to steal).
- Routed the audit-chain signer (audit.ts) and shared-memory signer (memory/shared.ts)
  through the keystore: a `command` backend now signs them via hardware, and under a
  mandate with only a file key they fall back to KEYLESS (chain still protects them)
  rather than emitting a forbidden file-key signature. Also unifies the signing kid.
- Command signer no longer receives kit's env wholesale (Finding #3): minimal allowlist
  (PATH/HOME/KIT_SIGN_ALGO), so KIT_* secrets/vault tokens aren't exposed to the signer
  subprocess — the comment now matches the code.
- Honesty (Findings #2/#6): the command backend and `kit identity keystore` no longer
  claim "hardware-rooted" (kit can't attest the operator's command fronts a secure
  element) — labeled "external key — operator-fronted" with an explicit caveat.

Regression tests: comprehensive-mandate suite (signWithIdentity / loadOrCreate /
recordRevocation fail closed; audit falls back to keyless) + signer env-isolation.
Full suite green (2261 tests).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
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.

1 participant