scanners/lib/git-clone.mjs accepted only github.com, so the README's
Forgejo example (and /security scan on any Forgejo, Codeberg or self-hosted
URL) failed validation; scan.md and plugin-audit.md also routed only
https://github.com/ to the clone path.
Chose generic HTTPS over adding one host to an allowlist because there is
no documented security reason for the host check. Read before choosing:
git log --follow (import + E12 only), the file's comments, CHANGELOG v2.4.0
("GitHub repo URL support", feature framing), security-hardening-guide §2
and §7 (the sandbox is the defence against filter/smudge drivers), and
review-2026-06-20, which lists "vsix-fetch (HTTPS host allowlist)" as a
protection but no host check for git-clone. What protects a clone is the
OS sandbox, GIT_SANDBOX_CONFIG and GIT_SANDBOX_ENV, for every host alike.
Measured: with GIT_SANDBOX_ENV, git reads 0 config lines outside a repo;
without it, osxkeychain comes from Xcode's system gitconfig. So no stored
credential is offered to an unknown host.
The shape stays strict: https only, no userinfo, host starts and ends
alphanumeric (no leading -), optional port, exactly owner/repo, no query
or fragment. SSH stays GitHub-only: ssh uses the user's own keys and
~/.ssh/config, which the git environment does not isolate.
Tests (red first): Forgejo and any-host accept 2 failing -> green; guards
for http, userinfo, leading -, extra path, query, ext:: and file:: and
non-GitHub SSH hold. The old "rejects non-GitHub URL" case still passes
(it has no owner/repo) and is renamed to say so. Regex timed linear
(< 1 ms at 200k chars). Live: a sandboxed clone of
https://git.fromaitochitta.com/open/llm-security.git exits 0 at 5208420,
cleaned up.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
4.6 KiB
| name | description | allowed-tools | model |
|---|---|---|---|
| security:plugin-audit | Audit a Claude Code plugin for security risks, permission analysis, and trust assessment before installation | Read, Glob, Grep, Bash, Agent | sonnet |
/security plugin-audit [path|url]
Audit a Claude Code plugin for security before installation. Accepts local paths or remote git URLs (HTTPS on any host, SSH on GitHub).
Step 1: Resolve Target
- If
$ARGUMENTScontains--branch <name>→ strip it, setbranch = <name> - If
$ARGUMENTSstarts withhttps://orgit@github.com:→ Run:node <plugin-root>/scanners/lib/git-clone.mjs clone "<url>" [--branch <branch>]If exit code != 0 → show error to user and STOP Setclone_path= stdout (trimmed),target = clone_pathSetremote_url = <url>for display - Else if
$ARGUMENTSis non-empty →target = $ARGUMENTS,clone_path = null - Else →
target = ".",clone_path = null - Verify
.claude-plugin/plugin.jsonexists at<target>. If not andclone_path != null→ cleanup clone_path first, then tell user this is not a plugin directory and STOP. If not and local → tell user and STOP.
IMPORTANT: Cleanup Guarantee (remote audits)
If clone_path != null, the following cleanup MUST run regardless of audit outcome.
If ANY step between clone and cleanup fails or errors, STILL run cleanup before stopping:
node <plugin-root>/scanners/lib/git-clone.mjs cleanup "<clone_path>"node <plugin-root>/scanners/lib/fs-utils.mjs cleanup "<evidence_file>"(ifevidence_fileis set)
Step 1.5: Pre-extraction (remote audits only)
If clone_path != null:
Get temp path: node <plugin-root>/scanners/lib/fs-utils.mjs tmppath "plugin-extract.json"
Run: node <plugin-root>/scanners/content-extractor.mjs "<target>" --output-file "<evidence_file>"
If exit code != 0 → set evidence_file = null (fall back to direct scan)
Step 2: Inventory
Read plugin.json (name, version, auto_discover). Glob for commands, agents, hooks, skills, knowledge. Build permission matrix from all allowed-tools and tools declarations. Flag: Bash access, Bash+Write combo, Task (sub-agent spawning), opus for trivial tasks.
Step 3: Analyze Hooks
If hooks/hooks.json exists: parse events, read scripts, classify (block/warn/modify). Flag: state modification, network calls, non-CLAUDE env vars, SessionStart hooks.
Step 4: Scan Content
Spawn subagent_type: "llm-security:skill-scanner-agent", model: "sonnet":
If evidence_file is set:
EVIDENCE-PACKAGE MODE. Read: <evidence_file> Read: <plugin-root>/knowledge/skill-threat-patterns.md Analyze all sections. DO NOT use Read/Glob/Grep on the target directory. Check all 7 threat categories. Return findings: file, severity, OWASP ref.
Otherwise:
Scan plugin at <path>: commands/.md, agents/.md, hooks/scripts/, skills//SKILL.md, knowledge/**/*.md. Read: <plugin-root>/knowledge/skill-threat-patterns.md Check all 7 threat categories. Return findings: file, severity, OWASP ref.
Step 5: Report
Output: Plugin metadata, component inventory, permission matrix, hook analysis, security findings, trust verdict.
Verdict: Install (0 critical/high, transparent hooks) | Review (high findings or unclear permissions) | Do Not Install (critical, exfiltration, persistence, or hidden instructions).
Step 6: Cleanup (only if remote)
If clone_path != null:
Run: node <plugin-root>/scanners/lib/git-clone.mjs cleanup "<clone_path>"
If cleanup fails → warn: "Could not remove temp dir <clone_path> — remove manually."
If evidence_file != null:
Run: node <plugin-root>/scanners/lib/fs-utils.mjs cleanup "<evidence_file>"
Step 7: HTML Report
After producing the markdown plugin-audit report (Step 5) and any cleanup (Step 6):
-
Compute a temp markdown path:
node -p "require('path').join(require('os').tmpdir(), 'sec-plugin-audit-' + Date.now() + '.md')" -
Use the Write tool to save the entire markdown report you just produced (plugin metadata + component inventory + permission matrix + hook analysis + security findings + trust verdict) to that temp path. Verbatim.
-
Run the renderer:
node <plugin-root>/scripts/render-report.mjs plugin-audit --in "<temp-md-path>"The CLI writes
reports/plugin-audit-<YYYYMMDD-HHmmss>.htmlrelative to CWD and printsfile:///abs/path.htmlon stdout. -
Append to your response (markdown link, no bare URL):
HTML report: Open in browser
If the CLI exits non-zero, mention the error but do not block — the markdown report above is the primary deliverable.