lockfile-provenance-gate
v0.3.0
Published
Gate npm lockfiles on provenance bound to the repo you actually trust.
Maintainers
Readme
lockfile-provenance-gate
Gate npm lockfiles on Sigstore provenance bound to the repository and workflow you actually trust.
For each dependency your policy covers, provenance-gate answers three questions from a plain terminal:
- Is there a build provenance attestation for this exact version?
- Does the signed subject digest match the tarball integrity in
package-lock.json? - Was the attestation signed by the upstream repository and workflow named in the policy?
It reads the lockfile and registry metadata only. It never installs or executes the packages it audits.
Who it is for
Maintainers of devcontainers, Helm charts, and CLI wrappers who vendor someone else's npm package and need CI to prove that the tarball came from the expected upstream repo and workflow, not just from some registry uploader. It is also useful for pinning provenance requirements to a short list of security-sensitive dependencies instead of demanding it for the whole tree.
Why not npm audit signatures?
npm audit signatures verifies registry signatures and attestation bundles for the packages already installed. It is all-or-nothing over that installed tree, has no notion of an expected source repository or workflow path, cannot scope the requirement to the handful of packages you actually vendor, and emits a pass/fail count rather than a machine-readable receipt. The cosign/Sigstore CLI can verify a bundle you already have, but it will not resolve a package-lock.json, match the attestation subject to a lockfile integrity hash, or apply a repository allowlist.
This tool checks the lockfile before install and binds each verdict to the repository and workflow you name.
Install
Requires Node.js 18 or newer. There are no runtime dependencies.
npm install --global lockfile-provenance-gate
lockfile-provenance-gate --versionOr run it without a global install:
npx lockfile-provenance-gate --helpBoth lockfile-provenance-gate and the shorter provenance-gate are installed and invoke the same CLI. Examples below use provenance-gate.
Runnable examples
examples/ contains three self-contained, offline walkthroughs: one package that passes, one installed under an npm alias that passes because the policy names the real package, and one whose validly signed publish attestation is not build provenance (exit 1). From a clone, with no install and no network:
npm run exampleThe runner asserts every documented exit code, so the examples cannot silently drift. Each directory has its own lockfile, policy, and cache; see examples/README.md for the full output and how to adapt the policy to your own lockfile. The bundles are generated test data, not real registry attestations, and the fixture trust root must not be used in production.
Quick start: a real check session
The repository ships generated, Sigstore-style test bundles signed by a throwaway fixture PKI. They are test data, not real registry attestations. From a clone of this repository, this succeeds offline:
$ node bin/provenance-gate.js check test/fixtures/offline/package-lock.json \
--policy test/fixtures/offline/policy.json \
--cache test/fixtures/bundles \
--offline
PACKAGE VERSION INTEGRITY STATUS REASON
------------ ------- ----------------------------------------------------------------------------------------------- -------- -------------------
@acme/widget 1.2.3 sha512-W3ZDqfRmYOYhjOasZ3pSvK6VJJL9dhNSPAmgtAF51MTLW88dnoGyNVrO6bsw8Ju46DepNLq2admJQKeVbDcNRw== verified provenance verified
1 required, 1 verified, 0 missing, 0 mismatch, 0 error
$ echo $?
0A validly signed attestation is not enough if it is the wrong kind of attestation. npm's publish attestation has a different predicate and does not satisfy a build-provenance policy:
$ node bin/provenance-gate.js check test/fixtures/publish-only/package-lock.json \
--policy test/fixtures/publish-only/policy.json \
--cache test/fixtures/bundles \
--offline
PACKAGE VERSION INTEGRITY STATUS REASON
------------ ------- ----------------------------------------------------------------------------------------------- -------- --------------------------------------------------------------------------
publish-only 1.0.0 sha512-W3ZDqfRmYOYhjOasZ3pSvK6VJJL9dhNSPAmgtAF51MTLW88dnoGyNVrO6bsw8Ju46DepNLq2admJQKeVbDcNRw== mismatch no verifiable Sigstore provenance attestation found for [email protected]
1 required, 0 verified, 0 missing, 1 mismatch, 0 error
$ echo $?
1A git, file:, or link: dependency cannot be bound to a registry attestation. It is not skipped: the entry is selected, reported as unverifiable, and fails the gate unless the policy exempts it explicitly:
$ node bin/provenance-gate.js check test/fixtures/unverifiable-git/package-lock.json \
--policy test/fixtures/unverifiable-git/policy.json \
--cache test/fixtures/bundles \
--offline
PACKAGE VERSION INTEGRITY STATUS REASON
--------- ------- --------- ------------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
loud-cron 0.1.0 - unverifiable lockfile entry [email protected] cannot be verified: it is a git dependency resolved from git+ssh://[email protected]/WJDdidi-1/loud-cron.git#f8c54287bfb916d083f8e814a086f1a83aee26c3 and has no registry integrity hash or provenance
1 required, 0 verified, 0 missing, 0 mismatch, 0 error, 1 unverifiable
$ echo $?
1For a real project, point it at your own lockfile and policy:
# First run: fetch missing bundles and the Sigstore trust root into the cache.
provenance-gate check package-lock.json --policy provenance.json --cache .provenance-cache
# Later runs, including CI: verify hermetically with no registry access.
provenance-gate check package-lock.json --policy provenance.json --cache .provenance-cache --offlinePolicy format
--policy is required. The canonical minimal allowlist policy is:
{
"mode": "allowlist",
"sourceRepository": "https://github.com/acme/widget",
"workflow": ".github/workflows/release.yml",
"allowlist": [
{ "name": "@acme/widget", "version": "1.2.3" }
]
}There are two modes:
"mode": "all"requires every selected lockfile entry to carry provenance matching the expected source. Registry packages must be attested; git (github:/git+ssh:),file:, andlink:dependencies have no registry tarball or integrity hash to bind an attestation to, so they are reported asunverifiableand fail with exit 1 instead of being dropped from the requirement set. Use it when the whole tree comes from one trusted upstream, or pair it withexemptionsfor the remainder."mode": "allowlist"requires provenance only for the named packages. Packages outside the allowlist are not checked. Use per-package overrides when the allowlisted packages come from different repositories.
A fuller allowlist policy, including a per-package override and an explicit exemption:
{
"mode": "allowlist",
"sourceRepository": "https://github.com/acme/widget",
"workflow": ".github/workflows/release.yml",
"registry": "https://registry.npmjs.org",
"allowlist": [
{ "name": "@acme/widget", "version": "1.2.3" },
{
"name": "beta",
"version": "0.9.0",
"sourceRepository": "https://github.com/acme/beta",
"workflow": ".github/workflows/build.yml"
}
],
"exemptions": [
{
"package": "internal-tool",
"version": "4.2.0",
"reason": "Vendored tarball; upstream publishes no provenance as of 2026-01-15"
}
]
}An exemption is the only way to make a required package pass without provenance, and it must give a reason. The reason is not just documentation: a policy that exempts a package without one is rejected. The same explicit exemption is how you accept a git, file:, or link: dependency that cannot carry registry provenance.
Policy fields
| Field | Required | Meaning |
| --- | --- | --- |
| mode | yes | "all" or "allowlist". |
| sourceRepository | strongly recommended | Expected upstream repository. Accepts normalized forms such as https://github.com/org/repo, git+https://github.com/org/repo.git, and [email protected]:org/repo.git. If omitted, the gate checks the subject digest and signature but cannot bind the attestation to a repository you trust. |
| workflow | strongly recommended | Expected workflow path, for example .github/workflows/release.yml. Matched against both the SLSA statement and the signing certificate's identity. |
| ref | no | Expected git ref, for example refs/heads/main. When set, the attestation and certificate identity must agree. |
| allowlist | in allowlist mode | Array of package names or objects. Prefer the published package name; for an aliased install the local alias is also accepted (see Do npm aliases work?). An object may set name (or package), version, integrity, and per-package sourceRepository, workflow, and ref overrides. |
| exemptions | no | Array of { "package": "...", "version": "...", "reason": "..." }. package and reason are required; version is optional. |
| integrity | no | In an allowlist entry, pins the exact SRI hash. A lockfile entry whose integrity differs fails with exit 1. |
| trustRoot | no | Path to a Sigstore trusted_root.json/PEM file, or an inline trust-root object. Relative paths resolve from the policy file. Defaults to the built-in public-good trust root. |
| registry | no | npm registry base URL. --registry overrides it. |
| includeDev | no | Include dev dependencies. Defaults to true. |
| includeOptional | no | Include optional dependencies. Defaults to true. |
| includePeer | no | Include peer dependencies. Defaults to true. |
The policy is validated strictly: a malformed URL, an empty allowlist, an unknown mode, or an exemption without a reason is an error rather than a silently weaker gate. Common alternate spellings are accepted for compatibility, but the canonical form above is what the examples and tests use.
If an explicitly allowlisted package is present in the lockfile but excluded by a dependency-type filter (includeDev, includeOptional, or includePeer set to false), the check still exits 1, but the receipt says the package was excluded by that filter instead of claiming it is not in the lockfile.
What a run verifies
For every selected lockfile entry, the tool:
- Parses
package-lock.jsonv1, v2, or v3. Registry packages are checked for provenance. Git (github:,git+ssh:),file:, andlink:dependencies have no registry tarball or integrity hash; they are selected and reported asunverifiablerather than skipped, sonpm cicannot install code the receipt never mentions. An npm alias is resolved to the real package recorded inpackages[*].name(v2/v3) or in thenpm:version spec (v1), so an entry installed atnode_modules/cvfor"cv": "npm:[email protected]"is checked ascache-verdict. - Resolves the package's npm attestation document, from
--cachefirst and otherwise from the registry's attestations endpoint (falling back to a bundle advertised in the package metadata). - Requires a build-provenance predicate. A validly signed npm publish attestation is ignored for this policy.
- Verifies the DSSE signature over the in-toto statement.
- Builds an X.509 chain to a configured trust root and checks certificate validity at the transparency-log integration time.
- Verifies the Rekor signed entry timestamp (SET) and, when present, its payload hash against the DSSE payload. It does not fetch or verify a full Merkle inclusion proof.
- Matches the signed subject name, version, and digest against the lockfile entry and its integrity hash.
- Matches the attestation source repository and workflow against the policy, and requires the signing certificate's URI identity to agree.
A git, file:, or link: entry stops at step 1 with status unverifiable: there is no registry tarball, integrity hash, or attestation to bind, and the receipt names the resolved source instead. That is a policy failure (exit 1), not an execution error, and an exemption with a reason is the explicit way to accept it.
A mismatch in any of these steps is a policy failure (exit 1), while malformed input, an unreadable cache, an unreachable registry, or a signature/certificate verification failure is an error (exit 2). The distinction matters in CI: exit 1 means "this package does not meet the policy"; exit 2 means "the gate could not complete its work."
Cache and offline verification
--cache <dir> is a hermetic store. An online run writes each fetched attestation document to the cache, plus the exact trust root used for the run as trusted-root.json. A later run with the same cache and --offline never contacts the network:
provenance-gate check package-lock.json --policy provenance.json --cache .provenance-cache --offlineIf a required bundle is absent from the cache while offline, the result is missing (exit 1), not a network fetch. A cache entry that exists but is corrupt is an error (exit 2), never a pass. Cache filenames use the safe package id: @scope/[email protected] becomes [email protected].
A committed cache is reproducible only if you also commit the trust root it contains. If you supply your own --trust-root, you are trusting that material explicitly.
JSON receipt
Add --json to get a machine-readable receipt on stdout:
{
"schemaVersion": 1,
"tool": "lockfile-provenance-gate",
"version": "0.3.0",
"generatedAt": "2026-01-15T12:00:00.000Z",
"ok": true,
"exitCode": 0,
"offline": true,
"summary": {
"required": 1,
"verified": 1,
"missing": 0,
"mismatch": 0,
"unverifiable": 0,
"error": 0,
"exempt": 0
},
"packages": [
{
"package": "@acme/widget",
"version": "1.2.3",
"integrity": "sha512-...",
"commit": "1111111111111111111111111111111111111111",
"sourceRepository": "github.com/acme/widget",
"workflow": ".github/workflows/release.yml",
"verified": true,
"status": "verified",
"reason": "provenance verified"
}
]
}The receipt also carries lockfile, policy, registry, and lockfileVersion. Each package row includes status, verified, reason, and the cache provenance fields when applicable.
Package statuses
| status | Meaning |
| --- | --- |
| verified | A build-provenance attestation matched the lockfile subject digest, expected source repository, and expected workflow. |
| mismatch | A bundle was found, but its digest, source repository, workflow, or policy integrity pin did not match. |
| missing | No attestation bundle was available, or a required package was absent from the lockfile. |
| unverifiable | A git (github:/git+ssh:), file:, or link: dependency with no registry tarball or integrity hash to bind provenance to. The row names the resolved source in sourceType and resolved. |
| error | The gate could not complete verification: a corrupt cache, a bad signature or certificate chain, an unsupported digest, or a registry failure. |
summary.required counts every selected entry, including unverifiable ones. summary.unverifiable counts the git, file:, and link: entries the gate could not bind to a registry tarball, and summary.exempt counts entries the policy explicitly excused. The run returns ok: true and exit 0 only when every selected entry is verified or exempted.
A git-only lockfile therefore produces a failing receipt instead of an empty passing one:
{
"ok": false,
"exitCode": 1,
"summary": {
"required": 1,
"verified": 0,
"missing": 0,
"mismatch": 0,
"unverifiable": 1,
"error": 0,
"exempt": 0
},
"packages": [
{
"package": "loud-cron",
"version": "0.1.0",
"integrity": null,
"status": "unverifiable",
"verified": false,
"sourceType": "git",
"resolved": "git+ssh://[email protected]/WJDdidi-1/loud-cron.git#f8c54287bfb916d083f8e814a086f1a83aee26c3",
"reason": "lockfile entry [email protected] cannot be verified: it is a git dependency resolved from git+ssh://... and has no registry integrity hash or provenance"
}
]
}Exit codes
| Code | Meaning |
| --- | --- |
| 0 | Every required entry verified against the policy, or was explicitly exempted. |
| 1 | Policy failure: missing attestation, an unverifiable git/file:/link: entry, digest mismatch, integrity-pin mismatch, or source repository/workflow mismatch. |
| 2 | The check could not complete: malformed input, corrupt cache, unreachable registry, or signature/certificate verification failure. |
FAQ
Which lockfiles can it read?
package-lock.json v1, v2, and v3 only. yarn.lock, pnpm-lock.yaml, and a bare node_modules tree are not supported. Pass the lockfile explicitly:
provenance-gate check package-lock.json --policy provenance.json --cache .provenance-cacheDo npm aliases work?
Yes. An npm alias installs a package under a different local name:
{
"dependencies": {
"cv": "npm:[email protected]"
}
}package-lock.json records that alias at node_modules/cv, but the entry's name field is the real published package (cache-verdict). The gate resolves the alias before doing anything else, then looks up the attestation, matches the subject, and reports cache-verdict:
{
"mode": "allowlist",
"sourceRepository": "https://github.com/WJDdidi-1/cache-verdict",
"workflow": ".github/workflows/publish.yml",
"allowlist": [
{ "name": "cache-verdict", "version": "0.7.0" }
]
}Prefer the real package name in the policy. Naming the local alias (cv) also selects the aliased entry, but the receipt and the attestation always use the real package (cache-verdict), so the real name is clearer and survives an alias rename. Either way, the integrity hash binds the verdict to the exact tarball installed under the alias, so a wrong or tampered hash is a mismatch (exit 1). Both package-lock.json v1 aliases (where the npm: spec is in version) and v2/v3 aliases (where packages[*].name carries the real name) are handled. The packed-tarball test checks both policy spellings against a clean install, and examples/alias-check exercises the real-package spelling offline.
Does it need network access?
With --cache, an online run fetches attestations that are not already cached and writes the exact Sigstore trust root it used into the cache directory. Later runs with --offline and the same cache make no network calls. From a clone, this succeeds offline against the checked-in example and exits 0:
node bin/provenance-gate.js check examples/offline-check/package-lock.json \
--policy examples/offline-check/provenance.json \
--cache examples/offline-check/cache \
--offlineIf a required bundle is absent from the cache, --offline reports missing (exit 1) instead of fetching it.
Why does a package fail even though npmjs.com shows a provenance badge?
The badge reflects npm's provenance check for that version. It does not answer whether the attestation names the upstream repository and workflow your policy trusts, or whether its subject digest matches your lockfile entry. Add --json to see the per-package status and reason:
provenance-gate check package-lock.json --policy provenance.json --cache .provenance-cache --offline --jsonA validly signed npm publish attestation is not build provenance and also cannot satisfy the policy; only SLSA/provenance predicates can.
How do I exempt a package that has no provenance?
Add an exemption with a non-empty reason. In allowlist mode, list the package in allowlist too so it is selected:
{
"mode": "allowlist",
"sourceRepository": "https://github.com/acme/widget",
"workflow": ".github/workflows/release.yml",
"allowlist": [
{ "name": "@acme/widget", "version": "1.2.3" },
{ "name": "legacy-tool", "version": "4.2.0" }
],
"exemptions": [
{
"package": "legacy-tool",
"version": "4.2.0",
"reason": "Upstream publishes no provenance; tarball reviewed 2026-01-15"
}
]
}Exempt requirements count in summary.exempt and exit 0; they do not print a verdict row.
A git, file:, or link: dependency is selected as unverifiable and exits 1 even in mode: "all". Exempt it by name; the written reason is the explicit record of that risk decision:
{
"mode": "all",
"exemptions": [
{
"package": "loud-cron",
"reason": "Pinned git checkout; commit f8c5428 reviewed 2026-11-26"
}
]
}That receipt has no verdict rows, summary.exempt: 1, and exit 0. The packed-tarball test pins this path alongside the failing git-only and mixed lockfiles.
Can it block npm ci?
Not through an npm lifecycle hook. It is a separate CLI, so run it as a step before install, or chain it so the exit code stops the job:
provenance-gate check package-lock.json --policy provenance.json --cache .provenance-cache --offline && npm ciExit 1 means an entry does not meet the policy, including an unverifiable git/file:/link: entry; exit 2 means the gate could not complete. The gate never installs, unpacks, or executes the audited packages.
Does it verify a full Rekor inclusion proof?
No. It verifies the Rekor signed entry timestamp (SET) and, when present, its payload hash against the DSSE payload, but it does not fetch or verify a Merkle inclusion proof. See What a run verifies.
Security notes
- Provenance is only as strong as the trust root and policy you supply. Set
sourceRepositoryandworkflow; without them the gate still verifies that a valid attestation covers the lockfile digest, but it cannot tell you who built it. - The bundle must chain to a configured Sigstore root. The package ships the public-good root; the test fixture trust root is test-only and must never be used in production.
- The tool does not install, execute, or unpack the audited tarballs. It does read registry attestation metadata for the exact lockfile version.
- npm provenance is not universal. Required registry packages without it fail, and git,
file:, andlink:entries fail asunverifiable; exempt them deliberately with a reason if that is the right risk decision for your project.
Development
npm testThe suite uses Node's built-in test runner and generated fixtures, including a local HTTP server for cache tests. It does not require network access. It also runs the checked-in examples, so their documented exit codes are part of npm test, packs the tarball, installs it in a clean directory, and has the installed CLI verify an aliased project (exit 0) both when the policy names the real package and when it names the local alias, then report a tampered integrity hash as a mismatch (exit 1). The packed CLI is also run on a git-only lockfile (one unverifiable row and exit 1), a mixed registry-plus-git lockfile (a verified row beside an unverifiable row, exit 1), a registry-only control (exit 0), and a git-only lockfile with an exemption (exit 0), and each receipt is compared with the checkout's receipt on the same fixtures. CI runs on Ubuntu, macOS, and Windows with Node 18, 20, and 22, then packs the tarball and installs it in a clean directory to run both binaries with --version and --help.
Status
Early MVP. The features above are the scope; anything not listed is not built yet.
License
Apache-2.0. See LICENSE.
