Skip to main content
MediumSupply chainOWASP A05:2021CWE-200

How to fix: npm/yarn Lock File Exposed

A package-lock.json or yarn.lock file was found accessible at a public URL. Lock files contain the exact dependency tree including all transitive dependencies and their versions, enabling an attacker to identify vulnerable packages.

Why it matters

Exposed lock files allow attackers to build a precise vulnerability map: exact dependency versions, dependency tree structure, and package registry sources. Combined with public CVE databases, this turns reconnaissance from hours to minutes.

Lock files are essential for reproducible builds but should not be publicly accessible. They contain enough information to identify every package version installed, including vulnerable transitive dependencies that don't appear in package.json.

How to fix it

  1. 1Add /package-lock.json, /yarn.lock, /pnpm-lock.yaml to your web server's deny list.
  2. 2In Nginx: location ~* /(package-lock\.json|yarn\.lock|pnpm-lock\.yaml) { deny all; }
  3. 3In Next.js: add a redirect or rewrite to return 404 for these paths.
  4. 4Ensure your build process doesn't copy lock files to the public output directory.

Code examples

Next.js rewrites to block lock files

JavaScript
// next.config.js
module.exports = {
  async rewrites() {
    return [
      { source: '/package-lock.json', destination: '/api/not-found' },
      { source: '/yarn.lock', destination: '/api/not-found' },
    ];
  }
};

References

Detected automatically by VulnRadar. The check id is supply-chain-lockfile-exposed, stable across every scan so you can filter or diff on it.

See every supply chain check

Questions

How severe is npm/yarn Lock File Exposed?
VulnRadar rates this medium severity in the supply chain category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id supply-chain-lockfile-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does npm/yarn Lock File Exposed map to?
It maps to CWE-200. In the OWASP Top 10 it falls under A05:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for npm/yarn lock file exposed

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: npm/yarn Lock File Exposed | VulnRadar