Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,7 @@ For Cline, add the same config to your `cline_mcp_settings.json`.
- 📚 **Plugin Development**: [docs/PLUGIN_DEVELOPMENT.md](docs/PLUGIN_DEVELOPMENT.md), [docs/ADAPTER_GUIDE.md](docs/ADAPTER_GUIDE.md), [docs/MCP_TOOLS_GUIDE.md](docs/MCP_TOOLS_GUIDE.md)
- 🔤 **Acronyms & terms**: [docs/GLOSSARY.md](docs/GLOSSARY.md) — what SBOM, MCP, PAL, SLSA, … mean in kit
- 📐 **Standards coverage & gaps**: [docs/STANDARDS.md](docs/STANDARDS.md) — which security standards kit maps to (OWASP, ASVS, SLSA, …) and which it doesn't yet
- 🧭 **What kit is**: [docs/ENFORCEMENT_AND_AUDIT.md](docs/ENFORCEMENT_AND_AUDIT.md) — kit as both a deterministic enforcement "grinder" and an audit tool, and the "no false green" loop between them
- 💬 **Discussions**: [github.com/sandstream/kit/discussions](https://github.com/sandstream/kit/issues)
- 🐛 **Issues**: [github.com/sandstream/kit/issues](https://github.com/sandstream/kit/issues)
- 🤝 **Contributing**: [CONTRIBUTING.md](CONTRIBUTING.md), [COMMUNITY.md](COMMUNITY.md)
Expand Down
64 changes: 64 additions & 0 deletions docs/ENFORCEMENT_AND_AUDIT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# What kit is — enforcement *and* audit

> **One line:** kit is a deterministic **meat grinder** that forces a specific, secure way
> of building software through gates — and it also prints a **signed receipt** of what came
> out, while refusing to claim the meat is ground if the grinder wasn't provably on.

Most people meet kit as the grinder (the gates you can't get around) and miss the second half.
kit is two things in one, and they reinforce each other.

## Mode 1 — the grinder: enforcement (real-time, preventive)

Gates that force the process **at the moment an action happens**, before anything can go wrong.
Deterministic, fail-closed, zero-LLM:

- **PreToolUse gates** — `gate-bash`, `gate-env` block un-triaged installs and plaintext-secret
writes *before* they land.
- **Capture-time gates** — the memory write-gate (G1), install-gate, slopsquat scoring (G4).
- **Commit/CI chokepoints** — `kit triage check-deps` (pre-commit), branch-protected checks.
- **`warn → enforce` ramp** — a new gate warns first, then fails once enforced.

This is the "gravitation": you *can't* do X. It shapes **how** software gets built.

## Mode 2 — the receipt: audit (point-in-time + after-the-fact, evidential)

kit also **produces and verifies proof** — of what happened and what's covered:

- **Tamper-evident audit log** — `.kit-audit.jsonl`, HMAC-anchored, hash-chained, Ed25519-signed
(`verifyAuditChain` / `verifyAuditSignatures`); see `docs/AUDIT_ATTESTATION.md`.
- **`kit self-audit`** — deterministic check of kit's own source against its bug-classes.
- **`kit coverage`** — an OWASP ASVS L2 *evidence map* for GRC (`--json`).
- **`kit sbom`** — component inventory (incl. the agent toolchain, G5); **SARIF** emit feeds
external audit tooling.
- **verified-forget tombstones** (G1) — deletion you can *prove*; **triage logs** — proof a
dependency was evaluated.
- **`kit check` / `check-security`** — point-in-time repo audit.
- **`docs/STANDARDS.md`** — an honest map of which standards kit aligns to (and which it doesn't).

This is the "label + receipt": proof of **what** was produced, and to which standard.

## The loop — why they're one tool, not two

The two modes are wired together, and that wiring is kit's thesis:

1. **The grinder produces the evidence** — every gate decision can be logged and attested.
2. **The audit proves the grinder was on** — gate-liveness and hook-liveness checks, and
self-audit rule **R13 (catch-false-green)**, fail if enforcement isn't actually installed.

That closed loop is **"no false green"**: kit will not report a clean result it cannot prove.
An audit tool that can't confirm its own controls are live is just theater; kit's audit side
exists partly to keep its enforcement side honest.

## An honest boundary (same no-false-green spirit)

As an audit tool kit is strong on **integrity evidence**, but its trust anchor is
**machine-local**: everything is tamper-*evident* against someone who can write the log, not
tamper-*resistant* against a same-UID principal who can read a `0600` file. Closing that gap is
the point of hardware-rooted identity (TPM/HSM) on the kit 5.0 roadmap. Until then: kit is
excellent proof of what **you** did under enforcement — not forensic proof against an attacker
who already owns your user account.

## The formula

> **kit = a deterministic grinder that forces the secure way of building — and prints a signed
> receipt of what came out, refusing to call it done unless the grinder was provably running.**
69 changes: 37 additions & 32 deletions docs/STANDARDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,34 @@

## 1. Standards kit takes into account today

| Standard | How kit engages it | Where |
|---|---|---|
| **OWASP Top 10 (2025)** | Per-category mapping of kit's shipped controls | `docs/OWASP_2025.md` |
| **OWASP ASVS 4.0.3 (L2)** | Deterministic **evidence map** (auto-verified / gap / manual / n-a) | `kit coverage [--json]` |
| **SLSA** | Build provenance / integrity framing | attestation + `docs/AUDIT_ATTESTATION.md` |
| **Sigstore / cosign** | Signature verification of artifacts | supply-chain paths |
| **OpenSSF Scorecard** | Repo-posture scoring in CI | `.github/workflows/scorecard.yml` |
| **CycloneDX + SPDX** | SBOM emit (incl. `--agent` toolchain) | `kit sbom` |
| **CVE / CWE / OSV / SARIF** | Vuln IDs, weakness taxonomy, findings interchange | `kit scan`, findings `rule` field |
| **EU CRA** | SBOM-mandate driver | `kit sbom` rationale |
| **GDPR** | PII redaction / memory handling | redaction + memory layer |
| Standard | How kit engages it | Where |
| ----------------------------------------------- | ------------------------------------------------------------------- | ----------------------------------------- |
| **OWASP Top 10 (2025)** | Per-category mapping of kit's shipped controls | `docs/OWASP_2025.md` |
| **OWASP ASVS 4.0.3 (L2)** | Deterministic **evidence map** (auto-verified / gap / manual / n-a) | `kit coverage [--json]` |
| **SLSA** | Build provenance / integrity framing | attestation + `docs/AUDIT_ATTESTATION.md` |
| **Sigstore / cosign** | Signature verification of artifacts | supply-chain paths |
| **OpenSSF Scorecard** | Repo-posture scoring in CI | `.github/workflows/scorecard.yml` |
| **CycloneDX + SPDX** | SBOM emit (incl. `--agent` toolchain) | `kit sbom` |
| **CVE / CWE / OSV / SARIF** | Vuln IDs, weakness taxonomy, findings interchange | `kit scan`, findings `rule` field |
| **OWASP Top 10 for LLM Applications (2025)** | Evidence map of LLM01–LLM10 → kit controls | `kit coverage --standard=llm-top10` |
| **NIST SSDF (SP 800-218 / 218A GenAI profile)** | Evidence map of the practices kit speaks to (PO/PS/PW/RV) | `kit coverage --standard=ssdf` |
| **EU CRA** | SBOM-mandate driver | `kit sbom` rationale |
| **GDPR** | PII redaction / memory handling | redaction + memory layer |

## 2. Standards kit does NOT yet take into account (ranked by fit)

Each of these is a genuine gap. Most are standards kit **already has controls for** but has
not **mapped** — the cheap, honest fix is to extend the `kit coverage` evidence-map machine,
not to invent new controls.

| # | Standard | Why it fits kit | Planned home |
|---|---|---|---|
| 1 | **NIST SSDF — SP 800-218** + **800-218A** (SSDF for generative AI) | The canonical "build software securely" framework; **218A is literally SSDF for GenAI** — the exact space kit occupies. Biggest gap. | `kit coverage` mapping + this doc |
| 2 | **OWASP Top 10 for LLM Applications (2025)** | kit maps the *web* Top 10 but not the *LLM* one, despite being an AI-agent tool. Prompt injection, tool poisoning, supply-chain are already shipped controls — just unmapped. | `kit coverage` mapping |
| 3 | **NIST AI RMF (AI 100-1) + Generative AI Profile (600-1)** | AI-specific risk framework; natural parallel to the OWASP mapping. | mapping doc |
| 4 | **MITRE ATLAS** | Adversarial-AI TTP matrix (ATT&CK for ML) — the vocabulary for the agent threats kit gates. | threat-model cross-ref |
| 5 | **OpenSSF S2C2F** (Secure Supply Chain **Consumption** Framework) | Near-perfect fit for install-triage / slopsquat / consumer-side verification — currently only referenced in passing, not mapped. | `kit coverage` mapping |
| 6 | **ISO/IEC 42001** (AI management system) | Certification track for AI governance (the ISO references in-repo are ISO-8601 dates, not 42001/27001). | evidence map (GRC) |
| # | Standard | Why it fits kit | Planned home |
| -------- | ----------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ---------------------- |
| ~~1~~ ✅ | **NIST SSDF — SP 800-218 / 218A** | **Now mapped** at the practice level 218A profiles — `kit coverage --standard=ssdf` (see §1). | done |
| ~~2~~ ✅ | **OWASP Top 10 for LLM Applications (2025)** | **Now mapped** — `kit coverage --standard=llm-top10` (see §1). | done |
| 3 | **NIST AI RMF (AI 100-1) + Generative AI Profile (600-1)** | AI-specific risk framework; natural parallel to the OWASP mapping. | `kit coverage` mapping |
| 4 | **MITRE ATLAS** | Adversarial-AI TTP matrix (ATT&CK for ML) — the vocabulary for the agent threats kit gates. | threat-model cross-ref |
| 5 | **OpenSSF S2C2F** (Secure Supply Chain **Consumption** Framework) | Near-perfect fit for install-triage / slopsquat / consumer-side verification — currently only referenced in passing, not mapped. | `kit coverage` mapping |
| 6 | **ISO/IEC 42001** (AI management system) | Certification track for AI governance (the ISO references in-repo are ISO-8601 dates, not 42001/27001). | evidence map (GRC) |

**Secondary / weaker fit:** OWASP **SAMM** & **BSIMM** (maturity models, not control checklists);
**EU AI Act** (regulatory, vs the CRA already covered); **CIS Benchmarks** (hadolint covers the
Expand All @@ -42,16 +44,19 @@ Docker slice); **SOC 2 / PCI-DSS / HIPAA** (compliance regimes — served indire

## 3. Why "map", not "add"

The top three (SSDF/800-218A, OWASP LLM Top 10, S2C2F) are the highest-value because kit
*already ships* the controls they ask for — write-gate, injection quarantine, install-triage,
slopsquat scoring, deterministic gates. What's missing is the **crosswalk** from control →
standard clause, exactly what `kit coverage` already does for ASVS. So the plan is:

1. Extend `kit coverage` with pinned, curated mappings for **OWASP LLM Top 10** and **SSDF
800-218A**, bucketed the same way (auto-verified / gap / manual / n-a).
2. Add **S2C2F** and **NIST AI RMF** as further evidence maps.
3. Before mapping, run a **verification pass** on the exact control IDs so kit never cites a
clause number it hasn't confirmed (no false green).

Until then, this doc is the honest record: kit aligns to the §1 set and **does not yet
account for** the §2 set.
The top ones are highest-value because kit _already ships_ the controls they ask for —
write-gate, injection quarantine, install-triage, slopsquat scoring, deterministic gates.
What was missing was the **crosswalk** from control → standard clause, exactly what
`kit coverage` already does for ASVS. Status:

1. ✅ **Done:** `kit coverage --standard=llm-top10` and `--standard=ssdf` — pinned, curated
maps bucketed the same way (auto / gap / manual / n-a), built on a generic evidence-map
engine (`src/coverage/standard.ts`). Control IDs were verified (a source-run confirmed the
LLM01–LLM10 titles and the PO/PS/PW/RV practices) before mapping — no invented clause numbers.
Caveat carried into the disclaimer: IDs were confirmed via search index, not first-party
fetch (egress-blocked), and kit does not enumerate 218A's specific AI task augmentations.
2. **Next:** add **S2C2F** and **NIST AI RMF** as further evidence maps (same engine).
3. Every mapping stays behind the "no false green" rule — a clause kit can't confirm is not cited.

This doc is the honest record: kit aligns to the §1 set (now including OWASP LLM Top 10 + NIST
SSDF) and **does not yet account for** the remaining §2 set.
37 changes: 29 additions & 8 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ import { parsePkgSpec, installPkg } from "./pkg.js";
import { cmdMemory } from "./commands/memory.js";
import { resolveKitRoot, runSelfAudit, SELF_AUDIT_RULES } from "./self-audit.js";
import { buildCoverageReport, formatCoverageText, type Bucket } from "./coverage/coverage.js";
import { buildStandardReport, formatStandardText } from "./coverage/standard.js";
import { OWASP_LLM_TOP10 } from "./coverage/owasp-llm-top10.js";
import { SSDF_218A } from "./coverage/ssdf-218a.js";
import { escapeWorkflowCmd, xmlEscape } from "./utils/ci-escape.js";

// Re-exported for tests + downstream emitters (ci-escaping.test.ts imports these
Expand Down Expand Up @@ -3900,13 +3903,6 @@ async function cmdCoverage(): Promise<boolean> {
results = [...security, ...selfAudit, ...commandEvidence];
}

const report = buildCoverageReport(results);

if (jsonMode) {
console.log(JSON.stringify(report, null, 2));
return true;
}

const colorBucket = (bucket: Bucket, label: string): string => {
const tint =
bucket === "auto"
Expand All @@ -3919,6 +3915,31 @@ async function cmdCoverage(): Promise<boolean> {
return `${tint}${label}${c.reset}`;
};

// --standard selects which pinned standard to map against (default ASVS, the
// original path). llm-top10 / ssdf route through the generic evidence-map engine.
const standard = args.find((a) => a.startsWith("--standard="))?.split("=")[1] ?? "asvs";
const STANDARDS = { "llm-top10": OWASP_LLM_TOP10, ssdf: SSDF_218A } as const;
if (standard !== "asvs") {
const descriptor = STANDARDS[standard as keyof typeof STANDARDS];
if (!descriptor) {
console.error(
`${c.red}unknown --standard '${standard}' (use: asvs | llm-top10 | ssdf)${c.reset}`,
);
process.exitCode = 1;
return false;
}
const stdReport = buildStandardReport(descriptor, results);
console.log(
jsonMode ? JSON.stringify(stdReport, null, 2) : formatStandardText(stdReport, colorBucket),
);
return true;
}

const report = buildCoverageReport(results);
if (jsonMode) {
console.log(JSON.stringify(report, null, 2));
return true;
}
console.log(formatCoverageText(report, colorBucket));
return true;
}
Expand Down Expand Up @@ -5430,7 +5451,7 @@ export const COMMAND_HELP: Record<string, string> = {
"self-audit":
"Audit kit's own source against its 12 self-hardening rules (--list-rules, --only=<ids>, --format)",
coverage:
"Evidence map: which OWASP ASVS L2 controls kit's deterministic checks auto-verify vs gap/manual/n-a (NOT a compliance attestation; --json for GRC tools)",
"Evidence map: which standard's controls kit's deterministic checks auto-verify vs gap/manual/n-a — OWASP ASVS L2 (default), OWASP LLM Top 10, or NIST SSDF via --standard=asvs|llm-top10|ssdf (NOT a compliance attestation; --json for GRC tools)",
identity:
"Manage this machine/agent's Ed25519 identity (init/show/rotate) — asymmetric, attributable signing for audit/policy (experimental)",
panic:
Expand Down
2 changes: 1 addition & 1 deletion src/coverage/coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export interface CoverageReport {
}

/** Resolve catalog citations for a set of check ids, deduped by citation id. */
function citationsFor(checks: string[]): RuleRef[] {
export function citationsFor(checks: string[]): RuleRef[] {
const out: RuleRef[] = [];
const seen = new Set<string>();
for (const id of checks) {
Expand Down
Loading
Loading