Skip to content

feat(airgap): verified offline threat-data bundle (signed manifest) - #84

Closed
sandstream wants to merge 1 commit into
feat/air-gap-offline-scan-modefrom
feat/air-gap-threat-data-bundle
Closed

sandstream wants to merge 1 commit into
feat/air-gap-offline-scan-modefrom
feat/air-gap-threat-data-bundle

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Third step of the no-egress roadmap (#80) — the "bundled, signed offline threat data" item.

Gives the threat-data sync-in a trust chain that's fully offline-verifiable (no Fulcio/Rekor):

  • A bundle = manifest.json (artifacts + SHA-256, each with optional env) + detached manifest.json.sig (Ed25519 over the manifest).
  • verifyThreatData() (pure, node:crypto, DI for tests): verify signature against KIT_THREAT_DATA_PUBKEY → SHA-256 every artifact → return env wiring. Any failure rejects the whole bundle (fail-closed). Manifest paths validated against ../absolute escape.
  • kit scan (air-gap): with KIT_THREAT_DATA_DIR set, verifies before scanning and refuses to run on failure; else injects the verified env so scanners use the local DBs.
  • docs/AIR_GAP.md documents the bundle format + build steps.

Tests: signed round-trip, tamper, wrong-key, missing artifact, missing manifest/sig, shape/escape validation.

⚠️ Stacked on #83 (base = feat/air-gap-offline-scan-mode, which is stacked on #73). Merge order: #73 → #83 → this.


Generated by Claude Code

Third step of the no-egress roadmap (#80). In an enclave the scanners' vuln DBs
(and the bumblebee catalog) are synced in from a connected host; stale or
tampered threat data silently degrades every verdict. This adds a trust chain
that is FULLY OFFLINE-VERIFIABLE (no Fulcio/Rekor):

- New `src/airgap/threat-data.ts`: a bundle = `manifest.json` (artifacts +
  SHA-256, each with an optional `env` to wire a scanner) + a detached
  `manifest.json.sig` (Ed25519 over the manifest). `verifyThreatData()` verifies
  the signature against a trusted key (KIT_THREAT_DATA_PUBKEY), then SHA-256s
  every artifact, then returns the env wiring. Any failure rejects the whole
  bundle (fail-closed). Manifest paths are validated against `..`/absolute escape.
- `kit scan` (air-gap): when `KIT_THREAT_DATA_DIR` is set it verifies the bundle
  before scanning and REFUSES to run on any failure, else injects the verified
  env so scanners use the local DBs. node:crypto only; deterministic.
- Tests cover signed round-trip, tamper, wrong-key, missing artifact, missing
  manifest/sig, and manifest shape/escape validation.
- docs/AIR_GAP.md documents the bundle format + build steps.

Stacked on the offline-scan-mode branch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
@sandstream
sandstream deleted the branch feat/air-gap-offline-scan-mode June 24, 2026 04:13
@sandstream sandstream closed this Jun 24, 2026
sandstream added a commit that referenced this pull request Jun 24, 2026
…#80) (#106)

* feat(scan): offline air-gap mode (KIT_AIRGAP=1) for `kit scan`

Second step of the no-egress roadmap (#80), building on the configurable triage
mirrors. With `KIT_AIRGAP=1`, `kit scan` runs entirely against pre-synced local
databases:

- `airGapScanners()` (pure, tested) drops cloud-only scanners (snyk, semgrep)
  and folds each remaining scanner's offline flags/env in: trivy gains
  `--offline-scan --skip-db-update`, osv-scanner gains `--offline`, grype gets
  `GRYPE_DB_AUTO_UPDATE=false`.
- `isAirGap()` reads the toggle; `cmdScan` applies the plan, injects the offline
  env into each scanner run, and prints which cloud-only scanners were skipped.
- `docs/AIR_GAP.md` §2 documents the toggle + per-scanner behavior and how to
  pre-sync each DB on a connected host.

Local-ruleset support for semgrep offline is a tracked follow-up. No behavior
change when KIT_AIRGAP is unset (transform is a no-op).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg

* feat(airgap): verified offline threat-data bundle for kit scan

Third step of the no-egress roadmap (#80). In an enclave the scanners' vuln DBs
(and the bumblebee catalog) are synced in from a connected host; stale or
tampered threat data silently degrades every verdict. This adds a trust chain
that is FULLY OFFLINE-VERIFIABLE (no Fulcio/Rekor):

- New `src/airgap/threat-data.ts`: a bundle = `manifest.json` (artifacts +
  SHA-256, each with an optional `env` to wire a scanner) + a detached
  `manifest.json.sig` (Ed25519 over the manifest). `verifyThreatData()` verifies
  the signature against a trusted key (KIT_THREAT_DATA_PUBKEY), then SHA-256s
  every artifact, then returns the env wiring. Any failure rejects the whole
  bundle (fail-closed). Manifest paths are validated against `..`/absolute escape.
- `kit scan` (air-gap): when `KIT_THREAT_DATA_DIR` is set it verifies the bundle
  before scanning and REFUSES to run on any failure, else injects the verified
  env so scanners use the local DBs. node:crypto only; deterministic.
- Tests cover signed round-trip, tamper, wrong-key, missing artifact, missing
  manifest/sig, and manifest shape/escape validation.
- docs/AIR_GAP.md documents the bundle format + build steps.

Stacked on the offline-scan-mode branch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg

* feat(airgap): declarative [air_gap] config in .kit.toml

Fourth step of the no-egress roadmap (#80). The air-gap posture (mirrors, offline
mode, threat-data bundle) was env-only; this lets it be checked in so an enclave
config is reproducible and versioned.

- New `[air_gap]` section in the config schema (interface + zod): `enabled`,
  `npm_registry`/`pypi_index`/`github_api`/`docker_registry`,
  `threat_data_dir`/`threat_data_pubkey`.
- `resolveAirGap(config, env)` (pure, tested) merges config + env with **env
  taking precedence**; `airGapTriageEnv()` emits the mirror vars to inject.
- `kit scan` resolves the posture from config+env (so `enabled = true` in
  `.kit.toml` turns on offline mode without an env var) and reads the threat-data
  dir/pubkey from the resolved settings.
- `runTriage` injects config-declared mirror env into the triage subprocess
  (best-effort; real env still wins), so a `.kit.toml` mirror is honored without
  exporting `KIT_*`.
- docs/AIR_GAP.md documents the declarative block.

Stacked on the threat-data-bundle branch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg

* feat(airgap): offline provenance verification — `kit verify-provenance`

Closes the headline remaining air-gap gap (#80): verify cosign/SLSA provenance
in a no-egress enclave. kit does NOT reimplement Sigstore — it orchestrates
cosign fully OFFLINE:

  cosign verify-blob --offline --trusted-root <shipped-in trusted_root.json>
    --bundle <b> --certificate-identity <id> --certificate-oidc-issuer <iss> <artifact>

`--offline` uses the bundle's inclusion proof (no Rekor); `--trusted-root` is the
operator-distributed trust anchor (no Fulcio/Rekor egress).

- `src/airgap/provenance.ts`: pure `buildCosignArgs` + `missingField`, and
  `verifyProvenance` (injectable deps) that is **fail-closed** — missing input,
  missing cosign, or any non-zero cosign exit ⇒ NOT verified. kit never prints
  "verified" unless cosign returned success.
- `kit verify-provenance <artifact> --bundle <f> [--trusted-root/--identity/--issuer]`,
  with defaults from `.kit.toml [air_gap].provenance_*` or `KIT_PROVENANCE_*`.
- `[air_gap]` config + resolver gain the three provenance fields.
- docs/AIR_GAP.md §4 rewritten from "known limitation" to the offline flow +
  the operator's trust-root-distribution responsibility (the model you OK'd).

Full suite 1467/0. Stacked on the .kit.toml-config branch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg

* docs(airgap): document memory classification posture (system-high)

Add §5 to AIR_GAP.md explaining that the memory store inherits the
machine's classification rather than tagging rows individually. Under
system-high a per-row column is redundant, and kit cannot enforce
multi-level separation anyway — that is the OS/MLS reference monitor's
job, not a CLI managing its own SQLite. Documents the operational
posture (whole-DB level, 0o600 handling, purge = delete, capture-time
redaction, procedural spill response) and is explicit that kit does not
claim to separate classification levels internally.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg

* chore(release): 1.27.0 — reconstruct the air-gap stack onto main (#98, #80)

Rebased the full stacked-PR chain (#83 KIT_AIRGAP + #84 signed threat-bundle +
#85 [air_gap] config + #93 offline provenance) onto current main, resolving the
triage.ts conflict (kept both verdictPassed #70 and airGapMirrorEnv #85). The
stack had squash-merged out of order and landed incompletely; this makes the
no-egress enclave story actually present on main. 33 airgap+triage tests green.

Closes #98

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
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