Open Source Provenance Verification

Dylan Reyes 8 min read

A package can survive every behavioral scan and still ship malicious code, because the injection point sits outside the artifact. Consider version 2.1.4: the maintainer publishes it to a registry on Monday, you pull it on Thursday, and what arrives is not what was uploaded. Every check you run on the downloaded tarball inspects the altered copy and announces it clean.

Post-publish tampering has occurred at registries, at CDN edge caches, and through compromised distribution infrastructure. Catching it takes cryptographic proof about where an artifact came from, which is a different question from what the artifact contains.

Where content inspection stops

Behavioral tooling asks what a package does when it runs: install scripts, outbound connections, obfuscated modules, entropy readings. Each of those matters, and each is measured on the bytes that reached you.

An attacker editing a published package does not need to add anything obviously hostile. A few lines gated on an operating system, an environment variable, or a delay change nothing visible in ordinary scanning. The modified package sails through behavioral analysis, because the malicious branch never fires under scan conditions.

The missing control is proof of equality: that the bytes you hold are the bytes the maintainer published. Establishing it needs a cryptographic link between the artifact and its origin.

Checksums, the baseline

Registry checksums are the plainest provenance check available. Publish a package and the registry hashes the tarball, filing the digest next to the package metadata. Download it, and the package manager recomputes the hash and compares.

npm stores SHA-512 digests in package-lock.json. Running npm ci verifies each downloaded package against the digest recorded when the dependency tree was last resolved. A mismatch stops the install.

That catches tampering in the distribution layer: if the tarball changes between your last npm install and the next npm ci in CI, the check fails. What it cannot catch is tampering that predates the lock file. Lock a dependency whose registry copy was already altered, and the bad digest is the one written down. Every later npm ci happily authenticates the tampered artifact against it.

Transparency logs and Sigstore

Sigstore closes the registry-side gap with a transparency log that captures signing events at publish time. A maintainer who signs a release with Sigstore creates an entry in Rekor, a public append-only log, recording the artifact hash, the signer's identity, and a timestamp.

Verifying against that log answers two questions. Does the artifact's hash appear in a log entry? And do the entry's timestamp and signer identity line up with the maintainer's established release pattern?

Neither answer can be forged after the fact. An attacker who swaps a tarball at a CDN or registry cannot backfill a Rekor entry for it, since the log only appends and anyone watching can audit what gets added. A fraudulent entry would be visible to every party monitoring the log.

npm added Sigstore provenance attestations in 2023, letting publishers tie a release to its source repository and build workflow. Where such an attestation exists, verification establishes more than a signature: it establishes that this artifact came out of a specific commit in a specific repository, built by a specific CI workflow. The anchor moves from the publisher's key to the source itself.

SLSA and build integrity

Supply chain Levels for Software Artifacts (SLSA) gives teams a vocabulary and a verification model for build integrity. Its four levels each demand stronger evidence about how an artifact was produced and from which source.

Level 1 requires a signed provenance document describing the build inputs and process. Level 2 requires provenance generated by an authenticated build service rather than a developer's laptop. Level 3 tightens the build service's security requirements and demands non-forgeable provenance. Level 4 adds hermetic, reproducible builds and review by two parties.

For someone installing open-source packages, the levels function as a measure of how much trust the install extends. A Level 2 or Level 3 attestation means a CI system built the package from a known commit, and the claim can be checked cryptographically. No attestation means the build process went undocumented.

Most open-source packages today carry no SLSA attestation; the ecosystem is young in this respect. For critical dependencies in a security-sensitive application, looking for attestations and favoring packages that have them shrinks the trust placed in unverified builds.

How HuntedIabs runs the check

In the HuntedIabs pipeline integration, provenance verification runs beside behavioral scanning rather than replacing it. The layers answer separate questions.

A scan checks:

  • Does the tarball hash match the hash in the registry metadata?
  • Does the registry metadata match the hash in your lock file?
  • Does the package have a Sigstore provenance attestation, and if so, does the attestation verify?
  • If a SLSA attestation is present, what level does it claim, and does the claim verify against the transparency log?

Any hash failure produces a critical flag before installation finishes. Missing attestation does not fail a package by default, given how common its absence is, but the scan report surfaces it, weighted by download volume and position in the dependency graph. A heavily used package with no provenance sitting at a critical node in the tree is a different exposure than a barely used utility with the same gap.

Reproducible builds, the independent check

Attestations state where an artifact came from. Reproducible builds let you confirm that statement yourself.

In a reproducible build, the same source compiled under the same environment yields bit-for-bit identical output. Anyone can then build the source, hash the result, and compare it with the published tarball. A difference points either to a build that is not reproducible, which some language ecosystems still produce, or to tampering.

Fully reproducible builds remain rare among npm and PyPI packages. Debian has advanced far under the Reproducible Builds project, and Go modules enjoy strong guarantees because the toolchain was designed around reproducibility. For security-critical packages, checking whether the build is reproducible and matching the hash against an independent build gives the strongest supply chain assurance available, paid for with substantial verification infrastructure.

Starting before the infrastructure exists

No team has to stand up the whole provenance stack in a week. The sensible order for most:

  • Enforce lock files and use npm ci (or equivalent) in every CI run, ensuring hash verification is active for every install
  • Monitor for packages in your dependency tree that have published Sigstore provenance attestations and verify those attestations automatically
  • For newly added critical dependencies, check manually whether SLSA attestations are available and what level they claim
  • For the highest-criticality packages, consider checking against the Rekor transparency log to verify the publish history is consistent with the maintainer's known release pattern

The change provenance verification makes is a change in the claim you can support. "This package looks clean" describes what you observed. "This package traces to a known build process from a known commit" rests on a cryptographic chain running back to origin, independent of what the artifact itself shows.

For teams laying down their first formal verification layer, the article on fitting scan gates into a software pipeline covers where hash verification and provenance checks belong in the wider pipeline architecture.

Back to Security Insights