Read the attestation#
npm's documentation lists what the package page shows for a version with provenance: the build environment, a build summary linking the workflow run, the source commit, the build file and a public ledger entry. Viewing package provenance The same data is in the registry. This fixture reads it for semver@7.8.6 (npm 11.19.1, Node.js 24.22.3):
$ npm view semver@7.8.6 dist.attestations --json
{
"url": "https://registry.npmjs.org/-/npm/v1/attestations/semver@7.8.6",
"provenance": {
"predicateType": "https://slsa.dev/provenance/v1"
}
}
Decoding the SLSA provenance statement at that URL and selecting fields with jq gives the following. workflow is predicate.buildDefinition.externalParameters.workflow, resolvedDependencies sits under predicate.buildDefinition, and the fixture's builder and invocationId are predicate.runDetails.builder.id and predicate.runDetails.metadata.invocationId.
[…]
"workflow": {
"ref": "refs/heads/main",
"repository": "https://github.com/npm/node-semver",
"path": ".github/workflows/release.yml"
},
"resolvedDependencies": [
{
"uri": "git+https://github.com/npm/node-semver@refs/heads/main",
"digest": {
"gitCommit": "b37b033b585ad5e575afeccadb426ea41bc6cea4"
}
}
],
"builder": "https://github.com/actions/runner/github-hosted",
"invocationId": "https://github.com/npm/node-semver/actions/runs/41486847600/attempts/1"
[…]
The statement's subject is pkg:npm/semver@7.8.6 with a SHA-512 digest. Converted to base64, it equals the version's dist.integrity, sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==, so the attestation describes the tarball npm installs. The commit equals the one the repository's v7.8.6 tag names: gh api repos/npm/node-semver/commits/v7.8.6 --jq .sha returned b37b033b585ad5e575afeccadb426ea41bc6cea4.
Count what npm audit signatures verified#
The command verifies registry signatures and, where present, provenance attestations. npm audit, Audit Signatures With semver@7.8.6 and ms@2.1.3, which has no provenance, it reported:
audited 2 packages in 1s
2 packages have verified registry signatures
1 package has a verified attestation
(use --json --include-attestations to view attestation details)
exit 0
The missing attestation is visible only as the difference between 2 and 1. A pipeline that relies on the exit status cannot tell a package without provenance from one with it.
What it does not establish#
npm states that provenance does not show that a package is free of malicious code. It links the package to its source and build instructions, which you can then audit. Generating provenance statements
| Question | Answered by provenance? |
|---|---|
| Which repository, workflow file, ref and commit built this tarball | Yes |
| Which run published it | Yes, runDetails.metadata.invocationId |
| Whether tests passed on that commit | No. Read the commit's checks or the run's other jobs |
| Whether the workflow is the one you expect | Only if you compare path with the expected file |
| Whether the package's dependencies have provenance | No. Each version has its own attestation, or none |
Publishers add provenance with npm publish --provenance from a supported cloud CI provider. With trusted publishing, npm generates it automatically. Generating provenance statements · Trusted publishing
Worked example#
This example is fictional. After an incident, Dara needs to know which commit produced version 4.2.1 of an internal package. The attestation names release.yml on main and commit c7e0…. The package's v4.2.1 tag points to a91d…, the commit the team tested. The workflow had been dispatched from main an hour after the tag, so it published a later commit under the tested version number. Dara reports the commit from the attestation, not the tag, as the code that ran.
For the same check on other artifacts, read build provenance attestations. For how CI installs dependencies, read npm install versus the lockfile in CI.