# NPM Dependency Confusion Attack

> Detects package.json configurations vulnerable to dependency confusion attacks where internal package names could be hijacked via public npm registry.

- Skill: `zakirkun/npm-dependency-confusion-attack` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add zakirkun/npm-dependency-confusion-attack`
- Raw SKILL.md: https://api.skillmd.com/api/skills/zakirkun/npm-dependency-confusion-attack/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: zakirkun (https://skillmd.com/u/zakirkun)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/zakirkun/npm-dependency-confusion-attack

---


# NPM Dependency Confusion Attack

## Overview
Dependency confusion exploits package manager precedence: if an internal package is published to the public npm registry with a higher version, it gets installed instead of the internal one. Attackers scan job postings and error messages for internal package names.

## Remediation
- Use scoped packages: `@company/internal-package` (scoped packages can only conflict in the same scope)
- Configure `npmrc` to always use internal registry for internal packages
- Use `package-lock.json` integrity checks
- Add `publishConfig` to prevent accidental public publishing

