Skip to content

composer.lock vulnerability scanner

Free, no sign-up

Scan a composer.lock for PHP packages with known vulnerabilities. Covers packages and packages-dev and shows the CVE, severity and fixed version of each.

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 composer.lock vulnerability scanner

  1. Drop your composer.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 composer update vendor/package --with-dependencies, then run your tests and scan again.

About this tool

composer.lock is the JSON file Composer writes after it resolves composer.json. It lists every installed package with its exact version in two arrays: “packages” for what the application needs to run and “packages-dev” for tools such as PHPUnit. composer install reproduces exactly these versions, so this is the file that describes what is deployed.

This scanner reads both arrays and asks OSV.dev about each package under the ecosystem name Packagist. OSV.dev serves GitHub’s reviewed advisories for Composer packages, which include those from the FriendsOfPHP security advisories database. Composer stores a version the way its tag is written, so v6.0.1 is looked up as 6.0.1. Branch versions such as dev-main are listed as not checked.

Findings in “packages-dev” do not reach production when you deploy with composer install --no-dev, but they still run on developer machines and in CI. The table does not separate the two arrays, so look a package up in the lockfile when that difference matters. PHP itself and its extensions are platform requirements, not packages, and are not part of the scan.

Sources

Questions

Is this the same as composer audit?

composer audit, built into Composer since version 2.4, checks installed packages against the advisories Packagist publishes. This page checks the lockfile against OSV.dev and needs neither PHP nor Composer. Both draw on the GitHub and FriendsOfPHP advisory data.

Should composer.lock be committed?

For an application, yes. Without it every install resolves the ranges of composer.json again, so production can run versions nobody tested, and no scanner can tell you what is installed. For a library it is optional, since projects that require the library ignore its lockfile.

How do I update one vulnerable package?

Run composer update vendor/package --with-dependencies. Composer moves that package and, where needed, its dependencies, and leaves the rest of the lockfile alone. Use composer why vendor/package to find out which of your requirements brings in a nested package.

Why is a dev-main version not checked?

A version that starts with dev- is a branch, pinned in the lockfile by a commit hash. Advisories are written for released versions, so a branch cannot be placed inside or outside an affected range.

Related tools