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
npmrcto always use internal registry for internal packages - Use
package-lock.jsonintegrity checks - Add
publishConfigto prevent accidental public publishing