Skip to content

yarn.lock vulnerability scanner

Free, no sign-up

Scan a yarn.lock from Yarn 1 or Yarn Berry for known vulnerabilities. See each affected package, its CVE, severity and fixed version, right in your browser.

The file is read in your browser. Only package names and versions are sent to OSV when you scan.

This tool asks the OSV.dev vulnerability database directly from your browser. It sends the name, version and ecosystem of each package in the file, and then the IDs of the advisories that matched. The file itself, its paths, URLs and hashes stay in your browser, and nothing is sent to HardenKit.

How to use the yarn.lock vulnerability scanner

  1. Drop your yarn.lock on the page, or paste its contents.
  2. Press the scan button to send the package names and versions to OSV.dev.
  3. Read the table, worst first.
  4. Upgrade with yarn up package (Berry) or yarn upgrade package (Classic); for a nested package, add a “resolutions” entry in package.json.

About this tool

yarn.lock pins every package of a Yarn project to one version. There are two formats that share the file name. Yarn 1, called Classic, writes its own format with lines such as lodash@^4.17.20: followed by a version. Yarn 2 and later, called Berry, write a YAML-like file that starts with a __metadata block and gives each package a resolution such as lodash@npm:4.17.21. This scanner reads both.

Each block of the file is one installed version, however many ranges point at it. The scanner takes the name and version of each block, drops the duplicates and asks OSV.dev which of them have a published advisory. Aliases are looked up under the real package name. Workspace packages, links, files and git sources are not registry packages; they are listed as not checked.

A result is a list of advisories, not a verdict on your application: whether a flaw can be reached depends on how the package is used. Start with the rows marked Critical and High that have a fixed version, since those cost one upgrade. Where “Fixed in” says no fix is listed, look for a replacement or check that the vulnerable function is not called.

Sources

Questions

Does this work with Yarn 2, 3 and 4?

Yes. Those versions write the Berry format, which the scanner recognizes by its __metadata block. It reads the resolution line of each entry, so aliased and patched packages are looked up under their real name and version.

How is this different from yarn audit?

yarn audit (Classic) and yarn npm audit (Berry) need Yarn and the project on your machine and ask the npm registry. This page needs only the lockfile and asks OSV.dev, which carries the same GitHub advisories for npm packages.

How do I fix a vulnerable transitive dependency in Yarn?

First try upgrading the direct dependency that brings it in. If its range does not allow the fixed version, add a “resolutions” field to package.json that forces the nested package to the fixed version, run yarn install, and test: a forced version can break the parent.

What leaves my browser when I scan?

Package names, versions and the ecosystem name “npm” go to OSV.dev. The lockfile itself, its registry URLs and its checksums do not. Private package names are among the names sent.

Related tools