Skip to content

feat: add pre-install security scanning#644

Open
elliotllliu wants to merge 1 commit intovercel-labs:mainfrom
elliotllliu:feat/pre-install-security-scan
Open

feat: add pre-install security scanning#644
elliotllliu wants to merge 1 commit intovercel-labs:mainfrom
elliotllliu:feat/pre-install-security-scan

Conversation

@elliotllliu
Copy link
Contributor

Summary

Implements #613

Adds optional security scanning before skill installation to detect potential risks.

Usage

# Scan before installing
npx skills add owner/repo --scan

# Auto-accept (skip confirmation prompt)
npx skills add owner/repo --scan -y

What It Detects

High Risk

  • eval() / exec() usage
  • child_process imports
  • Sensitive path access (~/.ssh/, ~/.aws/, .env)
  • Hidden HTML comments (prompt injection vector)

Medium Risk

  • Network requests (fetch, HTTP URLs)
  • File system reads/writes
  • Environment variable access

Architecture

  • Agent Shield first — Uses @elliotllliu/agent-shield when available (30+ rules, cross-file analysis)
  • Built-in fallback — Lightweight pattern matching when Agent Shield isn't installed
  • Non-blocking — Scan failures don't prevent installation
  • Opt-in — Only runs with --scan flag

Changes

  • src/security-scan.ts — Scanning module (built-in patterns + Agent Shield integration)
  • src/add.ts--scan flag in options and pre-install hook
  • tests/security-scan.test.ts — 6 tests

Testing

  • pnpm build
  • pnpm test ✅ (381/381 tests pass, +6 new)

Add optional security scanning before skill installation:

- `npx skills add <source> --scan` runs a security check before installing
- Detects high-risk patterns (eval, exec, credential theft, HTML comments)
- Detects medium-risk patterns (network requests, file system access)
- Uses Agent Shield (`@elliotllliu/agent-shield`) when available,
  falls back to built-in pattern matching
- Prompts user to confirm when high-risk findings are detected
- Skippable with `--yes` flag

New files:
- `src/security-scan.ts` — scanning module with built-in + agent-shield support
- `tests/security-scan.test.ts` — 6 tests covering clean/risky/skip cases

Implements vercel-labs#613
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