Package Manager Security
This skill helps you harden npm, pnpm, and bun against supply chain attacks. It provides configuration guides, best practices, and troubleshooting for all three package managers.
How to use this skill
- Identify which package manager(s) the user's query is about (npm, pnpm, bun, or multiple)
- If they ask about npm → read
references/npm.md
- If they ask about pnpm → read
references/pnpm.md
- If they ask about bun → read
references/bun.md
- If they ask about multiple or general concepts (lockfiles, CI/CD, version pinning) → read all relevant files
- Answer concisely and directly. Provide configuration snippets and commands the user can copy/paste.
Common concepts (apply to all three)
These security practices apply regardless of package manager. Mention them when relevant.
Lockfile enforcement
- Always commit the lockfile:
package-lock.json (npm), pnpm-lock.yaml (pnpm), bun.lock (bun)
- In CI/CD, use the frozen-lockfile equivalent:
- npm:
npm ci
- pnpm:
pnpm install --frozen-lockfile
- bun:
bun install --frozen-lockfile
- Review lockfile changes in PRs — unexpected additions can indicate compromised deps
Version pinning
- Prefer exact versions (
"axios": "1.12.0") over ranges ("axios": "^1.12.0")
- Tilde ranges (
"axios": "~1.12.0") are safer than caret ranges for production
- Never use
"*" or "latest" in production
Supply chain monitoring
npm audit signatures — verify package provenance
- Integrate SCA (Software Composition Analysis) tools for vulnerability scanning
- Block known C2 domains at the firewall/DNS level
Audit existing setup
Run python scripts/audit.py to check global security settings (npmrc, pnpm config, bunfig).
Run python scripts/audit-project.py from your project root to check project-level settings (package.json: overrides, engines, packageManager, pnpm config).
Run python scripts/scan-exotic.py to scan lockfiles for dependencies from exotic sources (git repos, tarballs, local paths). Use --ci to fail in CI if any exotic deps found.
Output format
When providing configuration:
- Show the exact file content (with file path comment)
- Explain what each setting does
- Provide the command to apply it
- If troubleshooting, explain the root cause
References
references/npm.md — npm-specific security configuration
references/pnpm.md — pnpm-specific security configuration
references/bun.md — bun-specific security configuration
references/cross-cutting.md — Registries, overrides, engines, SBOM, lockfile review, git deps
scripts/audit.py — Audit script that checks all global security settings
scripts/audit-project.py — Project-level audit (package.json checks)
scripts/scan-exotic.py — Lockfile scanner for exotic dependency sources
1---2name: 010101-package-security3description: Secures npm, pnpm, and bun against supply chain attacks — lockfile enforcement, provenance, version pinning, dependency audit, and script blocking.4license: MIT5---67# Package Manager Security89This skill helps you harden npm, pnpm, and bun against supply chain attacks. It provides configuration guides, best practices, and troubleshooting for all three package managers.1011## How to use this skill12131. Identify which package manager(s) the user's query is about (npm, pnpm, bun, or multiple)142. If they ask about **npm** → read `references/npm.md`153. If they ask about **pnpm** → read `references/pnpm.md`164. If they ask about **bun** → read `references/bun.md`175. If they ask about multiple or general concepts (lockfiles, CI/CD, version pinning) → read all relevant files186. Answer concisely and directly. Provide configuration snippets and commands the user can copy/paste.1920## Common concepts (apply to all three)2122These security practices apply regardless of package manager. Mention them when relevant.2324### Lockfile enforcement25- Always commit the lockfile: `package-lock.json` (npm), `pnpm-lock.yaml` (pnpm), `bun.lock` (bun)26- In CI/CD, use the frozen-lockfile equivalent:27 - npm: `npm ci`28 - pnpm: `pnpm install --frozen-lockfile`29 - bun: `bun install --frozen-lockfile`30- Review lockfile changes in PRs — unexpected additions can indicate compromised deps3132### Version pinning33- Prefer exact versions (`"axios": "1.12.0"`) over ranges (`"axios": "^1.12.0"`)34- Tilde ranges (`"axios": "~1.12.0"`) are safer than caret ranges for production35- Never use `"*"` or `"latest"` in production3637### Supply chain monitoring38- `npm audit signatures` — verify package provenance39- Integrate SCA (Software Composition Analysis) tools for vulnerability scanning40- Block known C2 domains at the firewall/DNS level4142## Audit existing setup4344Run `python scripts/audit.py` to check global security settings (npmrc, pnpm config, bunfig).4546Run `python scripts/audit-project.py` from your project root to check project-level settings (package.json: overrides, engines, packageManager, pnpm config).4748Run `python scripts/scan-exotic.py` to scan lockfiles for dependencies from exotic sources (git repos, tarballs, local paths). Use `--ci` to fail in CI if any exotic deps found.4950## Output format5152When providing configuration:531. Show the exact file content (with file path comment)542. Explain what each setting does553. Provide the command to apply it564. If troubleshooting, explain the root cause5758## References5960- `references/npm.md` — npm-specific security configuration61- `references/pnpm.md` — pnpm-specific security configuration62- `references/bun.md` — bun-specific security configuration63- `references/cross-cutting.md` — Registries, overrides, engines, SBOM, lockfile review, git deps64- `scripts/audit.py` — Audit script that checks all global security settings65- `scripts/audit-project.py` — Project-level audit (package.json checks)66- `scripts/scan-exotic.py` — Lockfile scanner for exotic dependency sources