Supply Chain Security

Lockfiles and Dependency Audits in Composer, uv and npm: What Each One Actually Pins, Checks and Refuses

I built the same deliberately outdated project in Composer, uv and npm, then audited, tampered with and drifted each lockfile. Composer now refuses to resolve vulnerable versions at all, uv and npm both caught a single changed hash, and Composer's lockfile recorded no hash for any of its seven...

photo of cargo cru ship
Photo by Rinson Chory / Unsplash

Every modern package manager has a lockfile and an audit command, and every team I've seen treats them as interchangeable boxes on a checklist: lockfile committed, audit runs in CI, done. They aren't interchangeable. A lockfile can pin a version without pinning the bytes. An audit can check the lockfile or only what's installed. And one of these three tools now refuses to install a known-vulnerable package at all unless you say so.

So I built the same deliberately bad project three times, with old versions that have well-known advisories: guzzlehttp/psr7 2.4.4 and twig/twig 3.4.2 in Composer 2.11.2, requests 2.31.0 and jinja2 3.1.2 in uv 0.13.9, and lodash 4.17.20 and minimist 1.2.5 in npm 11.20.0 (the version that ships with Node 26). Then I audited each one, tampered with each lockfile, let each manifest drift from its lock, and checked what runs at install time.

Lockfiles and Dependency Audits Compared

The whole result in one table first, with the evidence below:

Composer 2.11 uv 0.13 npm 11.20
Lockfile composer.lock uv.lock (exports pylock.toml) package-lock.json
Pins exact versions Yes Yes Yes
Pins content hashes No: shasum was '' for all 7 packages sha256 for every sdist and wheel sha512 integrity per tarball
A tampered hash is caught — Yes: Hash mismatch Yes: EINTEGRITY
Manifest drift is caught — uv sync --locked errors npm ci errors
Audit command composer audit uv audit (experimental) or pip-audit npm audit
Advisory source Packagist advisories (PKSA- IDs) OSV (--service-format osv) Registry advisories (GitHub GHSA- links)
Blocks vulnerable versions at resolve time Yes, by default No No
Release cooldown policy.cooldown.period --exclude-newer "7 days" min-release-age (days)
Runs dependency code at install Plugins only, and only if allowed in allow-plugins Build backends, when it builds from an sdist install scripts, with a warning, unless --ignore-scripts or --strict-allow-scripts

The Audits, Side by Side

Composer gave the most interesting result before I even got to the audit. A plain composer update refused to resolve the project:

Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires guzzlehttp/psr7 2.4.4 (exact version match: 2.4.4 or 2.4.4.0), found guzzlehttp/psr7[2.4.4] but these were not loaded, because they are affected by security advisories ("PKSA-vznr-tgp9-fd7d", "PKSA-7qs6-zvnz-h66r", "PKSA-gm5x-j3mz-71n9", "PKSA-jj5t-2zs1-dcfm", "PKSA-hn62-zkx4-1y5q"). Go to https://packagist.org/security-advisories/ to find advisory details. To ignore the advisories, add their IDs to the "policy.advisories.ignore-id" config or add the package to "policy.advisories.ignore". To turn the feature off entirely, you can set "policy.advisories.block" to false.
  Problem 2
    - Root composer.json requires twig/twig 3.4.2 (exact version match: 3.4.2 or 3.4.2.0), found twig/twig[v3.4.2] but these were not loaded, because they are affected by security advisories ("PKSA-tfq6-ydd8-dhbf", "PKSA-v6ry-d7gg-9dnc", "PKSA-szz8-81wy-3x8z", "PKSA-hs2m-ms65-2zgg", "PKSA-hjpc-r7p2-zyfx", "PKSA-8zx5-v2nz-58pb", "PKSA-fbvq-z33h-r2np", "PKSA-g9zw-qxh8-pq8w", "PKSA-yd6k-t2gh-1m43", "PKSA-1tmc-rt7x-12w6", "PKSA-xx6c-6d96-db2w", "PKSA-sjvz-tbbr-vwth", "PKSA-h8hf-ytnd-5t9q", "PKSA-wwb1-81rc-pd65", "PKSA-kvv6-36cr-fkzb", "PKSA-n14z-jjjg-g8vd", "PKSA-3mcc-k66d-pydb", "PKSA-dpx1-78wg-1kqs", "PKSA-yhcn-xrg3-68b1", "PKSA-2wrf-1xmk-1pky", "PKSA-6319-ffpf-gx66", "PKSA-n7sg-8f52-pqtf"). Go to https://packagist.org/security-advisories/ to find advisory details. To ignore the advisories, add their IDs to the "policy.advisories.ignore-id" config or add the package to "policy.advisories.ignore". To turn the feature off entirely, you can set "policy.advisories.block" to false.

That's Composer's dependency policy at work. It treats a version with a known advisory as not installable, and the error tells you the three ways around it: ignore specific advisory IDs, ignore a package, or set policy.advisories.block to false. I used --no-security-blocking to create the lock anyway, then audited it:

Found 27 security vulnerability advisories affecting 2 packages.
Run "composer audit" for a full list of advisories.

That's 27 advisories, 5 on psr7 and 22 on Twig. Twig's split was 1 critical, 3 high, 5 medium, 6 low and 7 with no severity. The audit exits non-zero, and --locked audits the lockfile without needing vendor/, which is what you want in CI.

We recommend reading What is Supply Chain Security? Dependencies, SBOMs, and the Attack That Hit 2.6 Billion npm Downloads to continue reading our selection of content. If you want the bigger picture behind these tools, including SBOMs and how one phished maintainer reached billions of downloads, start here.

What is Supply Chain Security? Dependencies, SBOMs, and the Attack That Hit 2.6 Billion npm Downloads Your app is only as secure as its dependencies. Supply chain attacks, SBOMs, and how one phished maintainer hit npm packages with 2.6B weekly downloads. SudoSecurity · Santhdium

uv has its own uv audit now, and it flags itself as experimental every time you run it:

warning: `uv audit` is experimental and may change without warning. Pass `--preview-features audit-command` to disable this warning.
Using CPython 3.15.2
Resolved 8 packages in 1ms
Found 8 known vulnerabilities and no adverse project statuses in 7 packages

Vulnerabilities:

jinja2 3.1.2 has 5 known vulnerabilities:

- PYSEC-2026-1474: Jinja vulnerable to HTML attribute injection when passing user input as keys to xmlattr filter

  Fixed in: 3.1.4

  Advisory information: https://nvd.nist.gov/vuln/detail/CVE-2024-34064
...

Eight vulnerabilities across the two packages, five in Jinja2 and three in Requests, with fixed versions and NVD links for each. I ran pip-audit 2.10.1 against the exported requirements as a cross-check:

Found 16 known vulnerabilities in 2 packages
Name     Version ID              Fix Versions
-------- ------- --------------- ------------
jinja2   3.1.2   PYSEC-2026-1473 3.1.3
jinja2   3.1.2   PYSEC-2026-1474 3.1.4
jinja2   3.1.2   PYSEC-2026-1475 3.1.5
jinja2   3.1.2   PYSEC-2026-1472 3.1.5
jinja2   3.1.2   PYSEC-2026-1471 3.1.6
jinja2   3.1.2   PYSEC-2026-1473 3.1.3
jinja2   3.1.2   PYSEC-2026-1471 3.1.6
jinja2   3.1.2   PYSEC-2026-1474 3.1.4
jinja2   3.1.2   PYSEC-2026-1475 3.1.5
jinja2   3.1.2   PYSEC-2026-1472 3.1.5
requests 2.31.0  PYSEC-2026-1873 2.32.0
requests 2.31.0  PYSEC-2026-1872 2.32.4
requests 2.31.0  PYSEC-2026-2275 2.33.0
requests 2.31.0  PYSEC-2026-1873 2.32.0
requests 2.31.0  PYSEC-2026-1872 2.32.4
requests 2.31.0  PYSEC-2026-2275 2.33.0

Same eight advisory IDs, but reported 16 times over. Every ID is real. Some are just repeated two or three times. If you count findings for a dashboard, deduplicate by ID first.

npm grouped by package with GitHub advisory links:

# npm audit report

lodash  <=4.17.23
Severity: high
Command Injection in lodash - https://github.com/advisories/GHSA-35jh-r3h4-6jhm
Regular Expression Denial of Service (ReDoS) in lodash - https://github.com/advisories/GHSA-29mw-wpgm-hmr9
lodash vulnerable to Code Injection via `_.template` imports key names - https://github.com/advisories/GHSA-r5fr-rjxr-66jc
Lodash has Prototype Pollution Vulnerability in `_.unset`, `_.omit`, and `_.pullAt` functions - https://github.com/advisories/GHSA-xxjr-mmjv-4gpg
fix available via `npm audit fix --force`
Will install lodash@4.18.1, which is outside the stated dependency range
node_modules/lodash

minimist  1.0.0 - 1.2.5
Severity: critical
Prototype Pollution in minimist - https://github.com/advisories/GHSA-xvch-5gv4-984h
fix available via `npm audit fix --force`
Will install minimist@1.2.8, which is outside the stated dependency range
node_modules/minimist

2 vulnerabilities (1 high, 1 critical)

To address all issues, run:
  npm audit fix --force

Look at the fix line: "Will install lodash@4.18.1, which is outside the stated dependency range." npm audit fix --force would change your declared dependency to fix this, which can mean a major version bump. Treat --force as a code change that needs review, not a button.

Hashes: Who Pins the Bytes

A version number tells you what you asked for. A hash tells you whether you got it. I changed four characters of one hash in each lockfile and reinstalled with caches cleared.

uv, changing the last four characters of the requests wheel's sha256 in uv.lock:

Using CPython 3.15.2
Creating virtual environment at: .venv
Resolved 8 packages in 1ms
error: Failed to download `requests==2.31.0`
  cause: Hash mismatch for `requests==2.31.0`

         Expected:
           sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e0130000

         Computed:
           sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f

hint: `requests` (v2.31.0) was included because `lockdemo` (v0.1.0) depends on `requests`

npm, changing the first four characters of lodash's integrity in package-lock.json:

npm error code EINTEGRITY
npm error sha512-AAAAFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== integrity checksum failed when using sha512: wanted sha512-AAAAFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== but got sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==. (316680 bytes)

Both refused, and both printed the expected and actual hashes. npm also tried the download twice first ("seems to be corrupted. Trying again.") before giving up. That's the right call for a flaky network and slightly noisy for a real attack.

Composer was a different story:

guzzlehttp/psr7 2.4.4 dist.type= zip shasum= '' https://api.github.com/repos/guzzle/psr7/zipball/3cf1b6d4f0c
psr/http-factory 1.1.0 dist.type= zip shasum= '' https://api.github.com/repos/php-fig/http-factory/zipball/2b
psr/http-message 1.1 dist.type= zip shasum= '' https://api.github.com/repos/php-fig/http-message/zipball/cb
ralouphie/getallheaders 3.0.3 dist.type= zip shasum= '' https://api.github.com/repos/ralouphie/getallheaders/zipball
symfony/polyfill-ctype v1.37.0 dist.type= zip shasum= '' https://api.github.com/repos/symfony/polyfill-ctype/zipball/
symfony/polyfill-mbstring v1.43.3 dist.type= zip shasum= '' https://api.github.com/repos/symfony/polyfill-mbstring/zipba
twig/twig v3.4.2 dist.type= zip shasum= '' https://api.github.com/repos/twigphp/Twig/zipball/e07cdd3d43
content-hash 8de00128b1abd9277c6613f410871a85

All seven packages in composer.lock have an empty shasum. The dist URLs point at GitHub's zipball API, which generates archives on the fly, so there's no stable file hash for Packagist to publish. In practice, composer.lock pins a commit reference and a URL, and trusts the transport (HTTPS to GitHub) for the rest. The commit ref is a strong pin for the source tree. It's not the same thing as verifying the bytes you downloaded, and nothing in the lockfile lets you check a mirror or cache against it.

(I couldn't finish composer install in my sandbox, because its network proxy blocks GitHub's API, which is where these dists live. That's worth knowing on its own: Composer installs depend on GitHub being reachable, unless you run a private mirror like Private Packagist or Satis.)

Provenance: Checking Who Built the Tarball

Hashes prove you got the bytes the lockfile recorded. They don't say anything about who published those bytes. npm has a second check for that, npm audit signatures, which verifies the registry's signature on every installed package and any provenance attestations, statements of which CI workflow built a release. On the demo project:

audited 2 packages in 1s

2 packages have verified registry signatures

And after adding Express 5 to a copy of the project, to see a realistic tree:

audited 67 packages in 1s

67 packages have verified registry signatures

6 packages have verified attestations
(use --json --include-attestations to view attestation details)

All 67 packages carried valid registry signatures, but only 6 had provenance attestations. That ratio is the honest state of the ecosystem: registry signatures are universal because npm adds them, while attestations depend on each maintainer publishing from CI with provenance turned on. The npm docs note that verifying attestations "often means updating npm beyond the version that ships with Node.js," so pin a recent npm in CI if you rely on this.

PyPI has the equivalent, attestations under PEP 740, published by trusted-publishing workflows. I couldn't find any equivalent signature check in Composer's install path, which fits the hash finding above: the PHP chain of trust is GitHub's commit and HTTPS.

Drift: When the Manifest and Lock Disagree

The CI commands are supposed to refuse to "fix" a lockfile silently. I bumped one dependency in the manifest without re-locking:

npm error code EUSAGE
npm error
npm error `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
npm error
npm error Invalid: lock file's minimist@1.2.5 does not satisfy minimist@1.2.8
Using CPython 3.15.2
Creating virtual environment at: .venv
Resolved 8 packages in 68ms
error: The lockfile at `uv.lock` needs to be updated, but `--locked` was provided.

hint: To update the lockfile, run `uv lock`.

Both did the right thing. The trap is using the wrong command. npm install and plain uv sync will quietly update the lockfile to match the manifest. In CI and in Dockerfiles, it's always npm ci, uv sync --locked and composer install, never npm install, uv sync or composer update.

What Runs When You Install

The audit catches known-bad versions. It does nothing about a malicious new version published an hour ago, and that's how most real attacks have landed. What protects you there is what each tool will execute during install.

npm runs lifecycle scripts by default. I packed a test package whose postinstall writes a marker file:

{
  "name": "scripty",
  "version": "1.0.0",
  "scripts": { "postinstall": "node -e \"require('fs').writeFileSync('/tmp/postinstall-ran', 'yes')\"" }
}
npm install:                 postinstall ran = yes
npm install --ignore-scripts: postinstall ran = no
11.20.0

The script ran with a plain npm install and was skipped with --ignore-scripts. That's the short version. npm 11.20 also has a new install-script policy, and it's worth seeing in full:

#!/bin/bash
# npm 11.20 install-script policy: default, strict, and approved via package.json allowScripts.
cd /w/app
reset() { rm -rf node_modules package-lock.json /tmp/postinstall-ran; echo '{"name":"app","private":true}' > package.json; }
ran() { echo "postinstall ran = $(cat /tmp/postinstall-ran 2>/dev/null || echo no)"; }
echo "## npm $(npm --version)"
reset; echo "-- default:";                 npm install --no-fund --no-audit ../pkg/scripty-1.0.0.tgz 2>&1 | grep -iE 'script|warn|error' | head -4; ran
reset; echo "-- --strict-allow-scripts:";  npm install --no-fund --no-audit --strict-allow-scripts ../pkg/scripty-1.0.0.tgz 2>&1 | grep -iE 'script|error' | head -4; ran
reset; echo "-- --ignore-scripts:";        npm install --no-fund --no-audit --ignore-scripts ../pkg/scripty-1.0.0.tgz 2>&1 | grep -iE 'script|warn|error' | head -4; ran
reset; echo '{"name":"app","private":true,"allowScripts":{"scripty":false}}' > package.json
echo "-- allowScripts {scripty: false}:"; npm install --no-fund --no-audit ../pkg/scripty-1.0.0.tgz 2>&1 | grep -iE 'script|warn|error' | head -4; ran
## npm 11.20.0
-- default:
npm warn install-scripts 1 package has install scripts not yet covered by allowScripts:
npm warn install-scripts   scripty@1.0.0 (postinstall: node -e "require('fs').writeFileSync('/tmp/postinstall-ran', 'yes')")
npm warn install-scripts
npm warn install-scripts Run `npm install-scripts ls` to review, or `npm install-scripts approve <pkg>` to allow.
postinstall ran = yes
-- --strict-allow-scripts:
npm error code ESTRICTALLOWSCRIPTS
npm error --strict-allow-scripts: 1 package(s) have install scripts not covered by allowScripts:
npm error   scripty@1.0.0 (postinstall: node -e "require('fs').writeFileSync('/tmp/postinstall-ran', 'yes')")
npm error Approve them with `npm install-scripts approve`, deny them with `npm install-scripts deny`, or bypass this check with `--dangerously-allow-all-scripts`.
postinstall ran = no
-- --ignore-scripts:
postinstall ran = no
-- allowScripts {scripty: false}:
npm warn install-scripts 1 package has install scripts not yet covered by allowScripts:
npm warn install-scripts   scripty@1.0.0 (postinstall: node -e "require('fs').writeFileSync('/tmp/postinstall-ran', 'yes')")
npm warn install-scripts
npm warn install-scripts Run `npm install-scripts ls` to review, or `npm install-scripts approve <pkg>` to allow.
postinstall ran = yes
  • By default, npm now warns that a package "has install scripts not yet covered by allowScripts," and then runs the script anyway. The docs describe it as "running with a notice."
  • --strict-allow-scripts (or strict-allow-scripts=true in .npmrc) turns that warning into a hard error, ESTRICTALLOWSCRIPTS, and the script never ran. This is the setting to turn on.
  • Approving and denying is done with npm install-scripts approve and npm install-scripts deny, which write an allowScripts field into package.json. My hand-written name-only deny entry didn't match a local tarball, because the docs say entries are "matched against a dependency's resolved identity, not against the package's self-reported name." Use the commands rather than editing the field by hand.

So the npm row in the table above needs an asterisk: scripts still run by default, but npm 11.20 can now enforce an allow-list. My recommendation is strict-allow-scripts=true in the project's .npmrc, approve the handful of packages that need native builds, and keep ignore-scripts=true for CI jobs that only need to run tests.

Composer is stricter by design. Its docs say: "Only scripts defined in the root package's composer.json are executed." Dependency scripts never run. Plugins can run code, but since 2.2, allow-plugins "defaults to {} which does not allow any plugins to be loaded" until you list them.

uv and pip run code when they build from a source distribution, because building an sdist means executing its build backend. uv has --no-build (and pip has --only-binary :all:) to refuse that and install wheels only.

We recommend reading Your npm Install Just Ran Someone Else's Code: Why Dependency Security Has to Start Before CI to continue reading our selection of content. CI is where most of these commands run, and it's also where the trust problems start.

Your npm Install Just Ran Someone Else's Code: Why Dependency Security Has to Start Before CI A pull request checkout, a poisoned GitHub Actions cache, and an OIDC token pulled straight out of runner memory. SudoSecurity · Santhdium

Cooldowns: The Defense Against Brand-New Malware

All three tools can now refuse versions newer than a set age, which buys time for malicious releases to be spotted and yanked. Composer's docs explain the reasoning: "many malicious versions are identified and removed within hours or days of being published."

  • Composer: "config": {"policy": {"cooldown": {"period": "7 days"}}}, measured from Packagist's published-time, "as package authors cannot influence it." It defaults to null, meaning no cooldown.
  • uv: --exclude-newer "7 days" (or UV_EXCLUDE_NEWER). On my test project it reported "Resolving despite existing lockfile due to addition of global exclude newer 2026-11-18T02:27:31Z" and resolved fine.
  • npm: min-release-age=7 in .npmrc, measured in days and defaulting to null. The npm docs have a catch: when the window blocks npm audit fix from installing a recently published patch, npm "keeps the package at its vulnerable version, warns that the fix was blocked, and exits with a non-zero code." Cooldowns and urgent security fixes pull in opposite directions, so all three tools have a way to exempt specific packages (min-release-age-exclude in npm).

The CI Baseline I'd Use

Step Composer uv npm
Install exactly the lock composer install --no-dev uv sync --locked --no-dev npm ci --omit=dev
Fail on known advisories composer audit --locked uv audit (or pip-audit) npm audit --audit-level=high
Don't run dependency code default (no dependency scripts; review allow-plugins) --no-build where possible strict-allow-scripts=true, or ignore-scripts=true
Cooldown new releases policy.cooldown.period exclude-newer min-release-age
Verify bytes rely on HTTPS, or run a mirror default default, plus npm audit signatures

What This Doesn't Cover

  • pnpm, Yarn, Poetry and PDM. All have their own lockfile semantics. pnpm in particular changes the install-script defaults.
  • Private registries and mirrors. Artifactory and friends change both the hash story and where advisories come from.
  • SBOM generation. CycloneDX and SPDX exports from these lockfiles are their own topic.
  • Reachability. All three audits flag vulnerable versions, not vulnerable code paths you actually call. A finding isn't proof of exposure.
  • Provenance and signatures. npm audit signatures and PyPI's attestations deserve a full test of their own.

The Actual Point

The three ecosystems have converged on the vocabulary and diverged on the details that matter. uv and npm pin and verify bytes, and Composer pins a commit and trusts the transport. Composer blocks known-vulnerable versions by default, and the other two only report them. npm still runs dependency install scripts by default (with a warning now, and an opt-in strict mode), and Composer never runs dependency scripts at all. Know which guarantees your tool actually gives, use the locked install command in CI, add a cooldown, and treat an audit as one layer of defense, not the whole thing.

Sources: the Composer CLI, config and scripts documentation at getcomposer.org; the npm v11 audit, ci and config documentation at docs.npmjs.com; uv's built-in help and sync documentation; and PEP 751. All audits, tampering and drift tests were run by me with Composer 2.11.2, uv 0.13.9, pip-audit 2.10.1 and npm 11.20.0 on node:26-slim. Every output block is reproduced verbatim from those runs, and the test package.json is original. The JSON cooldown snippet is quoted from Composer's docs, and the CI table is guidance, not something I ran as one pipeline.

$ tail -f /forums

Discussion

Comments live on the community forums — sign in there to reply.