/harness-claude:harness:security-craft runs instead · from harness-claude
LLM-judgment critique of security posture for TS/JS source code. Threat-models trust boundaries, privilege escalation, defense in depth, and least authority beyond CVE/OWASP scanning.
This skill never runs in Claude Code
It ships in harness-claude at agents/, but /harness-claude:harness:security-craft (a command, or a skill Claude Code finds first) has the same name: typing it, or Claude choosing it, runs that one instead.
LLM-judgment critique of security posture for TS/JS source — the ceiling counterpart to
harness-security-scan(CVE/OWASP rule-based floor) andharness-security-reviewer(procedural review). Threat-modeling-as-skill rather than pattern-matching. Critiques whether trust boundaries are respected, where implicit privilege escalation lurks, whether the code defends in depth or just at the gate, whether principle of least authority is honored. Sixth non-design member of the craft-pipeline initiative (the final sub-project). Emits 3-axis findings (tier × impact × confidence per ADR 0019).
harness-security-scan — rule-based floor)harness-security-reviewer)align-security with aggressive safeguards)packages/cli/src/shared/craft/) — LlmProvider + finding/axes schema + run store — shared across all *-craft skills. This skill implements, and does not own, that contract.packages/cli/src/security-craft/).craft-fleet (the craft-pipeline elevation sweep) and the harness natural-language router, which invoke every *-craft provider uniformly through the shared critique/finding shapepackages/*/src/ recursively; with no packages/ directory, walk src/ and app/ (the roots shared with code-craft).*.{ts,tsx,js,jsx,mjs,cjs}; exclude test files (*.test.*, *.spec.*, tests/, __tests__/).node_modules, dist, build, coverage, .next, .turbo, __snapshots__).--packages for explicit package scoping; --files overrides discovery.For each source file, the TS Compiler API walks the AST once and emits SecuritySignals. Files with zero signals are skipped entirely — this is the FP-management strategy from the spec (no path-heuristic fallback).
Detected signal kinds:
| Kind | What it matches |
|---|---|
http-handler | (req, res) / (req, res, next) shapes; app.get/post/...; @Get/@Post/... |
middleware | (req, res, next) => arrow / (ctx, next) shapes |
auth-api | jwt.{sign,verify}, bcrypt.{hash,compare}, argon2.*, passport.*, req.session.*, res.cookie |
privileged-op | child_process.{exec,spawn,...}, eval, new Function, vm.runIn*, fs.{writeFile,unlink,chmod,...} |
data-egress | fetch, axios.*, http.request, https.request, net.connect |
raw-query | *.query(\...${x}...`), *.raw(...), $queryRaw, $executeRaw` with SQL-shaped argument |
secret-handling | Secret-named variable (token, password, apiKey, …) flowing into console.*, logger.*, JSON.stringify, template-literal sink |
AST awareness (not regex) avoids common false positives: exec in a comment, eval as a variable name, token in a CSS property name.
8 seed rubrics, each declaring appliesToSignals so per-signal pre-filtering minimizes LLM cost:
| Rubric | Title | Applies to signals |
|---|---|---|
SEC-R001 | Trust boundary respected | http-handler, middleware, raw-query, privileged-op |
SEC-R002 | Principle of least authority honored | auth-api, privileged-op, http-handler |
SEC-R003 | Defense in depth (not gate-only) | auth-api, http-handler |
SEC-R004 | Assumed adversary realistic for the deployment | http-handler, middleware, auth-api |
SEC-R005 | Data flow across trust boundaries is visible | http-handler, raw-query, data-egress, privileged-op |
SEC-R006 | Fail closed, not open | auth-api, middleware, http-handler |
SEC-R007 | Secrets carried in a shape that resists leakage | secret-handling |
SEC-R008 | Authorization check happens before the action | http-handler, privileged-op |
For each (signal, rubric) pair where the rubric applies:
medium confidence by default; high requires a specific, named anti-pattern or visible missing guard.null (rubric doesn't apply / code is fine) OR { tier, impact, confidence, message }.SecurityFinding with cite.rubricId populated for ADR 0020 traceability.Emit SecurityCraftOutput:
{
findings: SecurityFinding[];
summary: {
phaseRun: ['critique'];
mode: 'fast';
durationMs: number;
llmCalls: { provider, model, count, costUsd };
catalog: { rubricsApplied: string[] };
counts: { candidateFiles, filesScanned, filesSkippedNoSignal, signalsDetected };
abstention?: { reason: 'no-candidate-files'; message: string };
runId: string;
}
}
filesSkippedNoSignal is tracked separately so report consumers can see how aggressively the AST pre-filter trimmed the corpus.
candidateFiles is the denominator. When it is 0 the run examined nothing and summary.abstention is set: report it as abstained, never as a clean pass. The in-session collect step carries the same candidateFiles / abstention fields.
harness security-craft — CLI entry. --files <glob> / --packages <names> / --max-files <n> / --max-signals-per-file <n> / --json / --verbose.mcp__harness__security_craft — MCP tool. Same input/output. Consumed by agents.critiqueSecurityInFile(file, opts) exported from packages/cli/src/security-craft/index.ts. Returns [] for files with no security signals (consistent with the orchestrator's FP-management strategy).LlmProvider, MockLlmProvider, derivePriority, 3-axis types all live in packages/cli/src/shared/craft/.security-craft auto-activates as an advisory review hook whenever a diff touches the surface it
owns — harness-autopilot at after:REVIEW / after:FINAL_REVIEW, and harness-code-review at
after:mechanical. The domain table is CRAFT_REVIEW_DOMAINS and the per-host events are
CRAFT_REVIEW_EVENTS_BY_HOST, both in packages/core/src/hooks/craft-review-hooks.ts. The host
forwards the subset of the diff this domain owns:
files — this domain's owned subset of the changed files, as ABSOLUTE paths. The host
reads it from plan.files["security-craft"], which holds repo-relative POSIX paths, and resolves each
entry against the project root before calling mcp__harness__security_craft. Absolute is the
recommended form, not a correctness requirement for this domain: its collector resolves a
relative entry against the tool's path (never the process CWD), so a repo-relative entry
forwarded unresolved still reads the in-diff file (pinned by
packages/cli/tests/shared/craft/relative-files-scope.test.ts). Only
mcp__harness__design_craft still requires absolute paths.promptBudget — accepted; raises the prompt ceiling for the forwarded scope when the diff subset is large.Findings from a hook-triggered run are advisory: reported, never blocking, never counted toward review severity, and never entered into a host's mechanical exclusion set. A hook-triggered run that fails is a missing opinion, not a broken gate.
See docs/changes/craft-pipeline/security-craft/proposal.md for the full 29 success criteria. Highlights:
catalog/rubrics/<id>.ts (file-per-rubric)filesSkippedNoSignal tracked)appliesToSignals pre-filter avoids irrelevant LLM callscite.rubricId populated on every finding (ADR 0020)critiqueSecurityInFile cross-cutting API works on a single fileThese are common rationalizations that sound reasonable but lead to incorrect results. When you catch yourself thinking any of these, stop and follow the documented process instead.
| Rationalization | Why It Is Wrong |
|---|---|
"harness-security-scan found no CVEs, so this handler is secure." | That scanner is the rule-based floor. Security-craft critiques shape: a CVE-clean handler can still load a document before authorizing (SEC-R008) or fail open on error (SEC-R006). |
"The file contains the words exec and token, so I'll critique it even with no signal." | Detection is AST-driven, not regex. exec in a comment or token as a CSS property name emits no SecuritySignal; zero-signal files are skipped by design. Do not critique a string match. |
| "This looks dangerous but I can't name the exploit, so I'll mark it high confidence anyway." | The system prompt biases to medium by default; high requires a specific named anti-pattern or a visibly missing guard. "Feels risky" without a named sink is medium at most. |
| "An auth check exists in the handler, so SEC-R003 (defense in depth) passes." | A single check at the entrance is exactly gate-only defense. SEC-R003 asks whether the code defends in depth — one authz gate with no downstream validation is what the rubric flags. |
| "It's an internal-only endpoint, so the adversary model is moot and SEC-R004 passes." | Assumed-adversary-realistic-for-the-deployment is not "internal, therefore trusted". SSRF, compromised neighbours, and confused-deputy paths all reach internal endpoints. State the realistic adversary; don't assume one away. |
Input: packages/api/src/handlers/run-script.ts:
import { exec } from 'child_process';
import type { Request, Response } from 'express';
export function runScript(req: Request, res: Response): void {
const userScript = req.body.script;
exec(`bash -c "${userScript}"`, (err, stdout) => {
res.json({ output: stdout });
});
}
Output (mock LLM):
SEC-R001 [foundational/large/high] child_process.exec:5
User-controlled `req.body.script` flows directly into `bash -c "${userScript}"`.
This is a textbook command-injection sink. Either reject the entire pattern
(no user-supplied shell strings) or move to `execFile` with an allowlist of
binaries and pre-validated arg arrays. Never templated into a shell.
SEC-R005 [foundational/large/high] child_process.exec:5
Untrusted input (`req.body.script`) crosses the trust boundary into a
privileged sink without any visible validation or escaping step. The crossing
is invisible — the variable is named generically and goes straight to exec.
Input: packages/api/src/handlers/get-doc.ts:
export async function getDoc(req: Request, res: Response) {
const doc = await db.docs.findOne({ id: req.params.id });
if (doc.ownerId !== req.user.id) return res.status(403).send();
return res.json(doc);
}
Output:
SEC-R008 [foundational/medium/medium] req,res:1
The document is loaded BEFORE the authorization check. Even though the
response is denied, the load has already executed — observable side effects
(audit logs, rate-limit counters, cache populations) leak existence
information about documents the caller can't access. Authorize against the
identifier first (`req.params.id` + `req.user.id`), then load.
Input: A pure utility file with no http/auth/exec/fs/network constructs.
Output:
No security findings.
Summary: 0 findings across 0 files (12 skipped, 0 signals, 8 rubrics, 0 LLM calls, $0.0000, 4ms)
The 12 files were scanned for signals but skipped because none had security-relevant AST constructs — exactly the FP-management strategy at work.
align-security deferred to v2 with aggressive FP safeguards (security rewrites have asymmetric downside).harness-security-scan is the floor.maxFiles to 50 or maxSignalsPerFile to 5, or scope explicitly with --packages <name>. Per-file cost = (signals × applicable rubrics × per-call); typical handler fires ~3-5 rubrics, not 8.craft.security.disabledRubrics: ['SEC-R004']. Until then: filter findings by cite.rubricId downstream.signals.ts. Track as v1.x.craft.security.confidenceFloor to tighten further. Loosening below medium is intentionally not exposed.suppressedAt entry on the rubric for future catalog evolution.v1 — in implementation. See:
docs/changes/craft-pipeline/security-craft/proposal.mdcraft-pipeline initiative (the final sub-project; the craft-pipeline initiative completes with this PR)naming-craft, spec-craft, copy-craft, test-craft, knowledge-craft, harness-design-craft (design-pipeline)packages/cli/src/shared/craft/align-security (FIX side; aggressive safeguards), IaC critique, multi-file auth-flow tracing, test-file security, framework expansions (tRPC / Convex / Cloudflare Workers / Hono RPC).What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claude793 skills in this plugin
/a11y-aria-patternsARIA Patterns> Apply ARIA roles, states, and properties correctly to enhance assistive technology support for custom widgets/a11y-color-contrastColor Contrast and Color Independence> Ensure sufficient color contrast ratios and never use color as the sole means of conveying information/a11y-form-patternsAccessible Form Patterns> Build accessible forms with proper labeling, grouped controls, inline validation, and clear error communicationOther plugins' skills for the same job