Skip to content

Refresh Sigstore's trust root from its TUF repository - #1336

Open
tolgaergin wants to merge 5 commits into
mainfrom
fix/sigstore-trust-refresh
Open

tolgaergin wants to merge 5 commits into
mainfrom
fix/sigstore-trust-refresh

Conversation

@tolgaergin

@tolgaergin tolgaergin commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Every LPM binary held the Sigstore trust root it was built with, and nothing else. When Sigstore rotates a Fulcio certificate authority, a Rekor log key or a CT log key, every copy built before the rotation would refuse every signature that needs the new key:

  • Standalone lpm self-update would refuse every later release. That's the same lockout class Install and self-update on Macs without developer tools or Apple's services #1329 fixed for macOS. The error told users to "update lpm to refresh", which is the step that fails.
  • Install-time npm provenance checks reject a failed verification as an attack signal. So script approvals and drift checks would refuse newly published packages, on every LPM version.

Nothing is broken today: the built-in trust root still matches Sigstore's live one, which is TUF targets version 14.

Fix

LPM now does what Sigstore's own clients do. It ships Sigstore's TUF root (version 16) and refreshes the trust root from https://tuf-repo-cdn.sigstore.dev.

TUF client (sigstore_verify/tuf): a minimal TUF 1.x client for the four top-level roles and the one target LPM needs, trusted_root.json.

  • It follows signed root rotations: each new root needs a threshold of the previous root's keys and a threshold of its own.
  • It refuses an expired final root, timestamp, snapshot or targets.
  • It checks version and rollback against the last verified state, and resets that state when a root replaces the timestamp or snapshot keys.
  • It checks length and hashes, and fetches through consistent-snapshot paths.
  • It supports ECDSA P-256 and P-384 and Ed25519 keys, and signs with securesystemslib's canonical JSON. Each key counts once toward a threshold.
  • Delegated targets are not followed.

Trust store (sigstore_verify/trust_store):

  • Self-update fetches Sigstore's current trust root before it verifies a release, so keys Sigstore retired stop counting. If the fetch fails, it verifies with the trust root it holds.
  • npm provenance, relay key and --provenance-file checks fetch it only when a bundle needs a certificate authority, Rekor log or CT log that the held trust root lacks, or when a role has no active key. They fetch at most once an hour and share one fetch between concurrent checks.
  • A failed fetch keeps the held trust root, which is never older than the built-in one. The error says that the fetch failed (TrustRootNotRefreshed).
  • Cache: the verified metadata is cached in ~/.lpm/cache/metadata/sigstore-trust.json and checked again against the built-in TUF root every time it is read. A forged or changed cache is ignored, and so is a cache older than the built-in trust root.
  • Newer formats: entries of a fetched trust root that this version can't read are skipped instead of refusing the whole root.
  • LPM_SIGSTORE_TUF_URL_OVERRIDE points at a mirror (HTTPS or loopback only), or turns fetching off with off. Workflow tests set off, so they never reach the network. The shared store in unit tests is offline.

Error classes: a missing key, log or certificate authority is now VerifyError::MissingTrustMaterial. A role with no active key is still TrustRootExpired. These two are the only ones that trigger a fetch.

Release gate: lpm internal-verify-release still verifies with the trust root the release binary holds, without fetching. A release that passes it therefore verifies even on a machine that can't reach Sigstore.

Review round (Fable 5.2, Opus 5.5, Astra 6.2, Sol 6.2, Gemini 4 Neon)

The reviewers found no way for a mirror, the network or the cache to make LPM accept, or roll back to, a trust root that Sigstore's targets role didn't sign. Fixed, each test-first and mutation-checked:

  • Duplicate keys: a key listed under two IDs or in two encodings counted twice toward a threshold. Keys now count by their decoded bytes.
  • Future metadata shapes: keys, roles, files and targets that the client can't read are left out instead of refusing the whole TUF document. Version 0 is refused.
  • Unusable fetched root: a fetched or cached trust root in which a role has no usable key, because its entries are missing or unreadable, is refused and the held trust root is kept. A role whose readable keys Sigstore retired still stands.
  • Delegated roles: only targets.json is held to its stored version, so a delegated role Sigstore drops can't block refreshes. Key rotations are tracked at every root step.
  • Cache across binaries: stored roots no newer than the built-in root are skipped, and older ones are kept. An older and a newer LPM on one machine can both follow the cache.
  • Cache rollback: the cache is written under a lock, and only when nothing newer is cached. A process that can't write it keeps its last verified metadata as the rollback baseline.
  • Fetch limits: the cache records when it was fetched, and other processes reuse a fetch made within the hour. A failed fetch is retried after a minute instead of an hour.
  • Release gate: internal-verify-release now verifies with the built-in trust root only.
  • Unit tests: the shared store in unit tests reads no cache.
  • Live check: it now fails when Sigstore publishes a newer TUF root, or when the root or targets role is down to its threshold of keys LPM can verify.

Declined:

  • An LPM-held signing key as a second path. It would change who can sign a release: today only a GitHub Actions run on main can. That's for the maintainer to decide.
  • Persisting each TUF role as it is verified. The scenario it addresses can only hold the cache back, never move it below what it already holds.

Full local gate on the final top: 20,112 of 20,112.

Not in this PR

LPM's verifier reads only Rekor v1 entries. Sigstore's Rekor v2 uses checkpoints and RFC 3161 timestamps instead of signed entry timestamps. Today neither Sigstore's default signing configuration nor GitHub's attestation action writes v2 entries. If npm switches, provenance verification needs v2 support. The stacked PR's gate stops an LPM release that older updaters can't verify. Rekor v2 support is proposed as a follow-up.

Tests

  • TUF client, 33 tests:
    • Against Sigstore's real metadata: a refresh from root 13 through roots 14, 15 and 16, with timestamp 844, snapshot 166 and targets 14, proves the canonical encoding matches Sigstore's signatures byte for byte. Tampered roots, a version mismatch, expiry and a changed trust root are refused.
    • Against synthetic repositories: rollback; key rotation that resets versions; a root rotation without the old keys; a duplicate key; forged targets; stored roots that don't chain from the built-in root; Ed25519 keys; no consistent snapshots; a missing target.
    • Consistency: the built-in TUF root signs the built-in trust root.
  • Trust store, 21 tests against a local mirror, with real npm and LPM release bundles:
    • a bundle from a log the held trust root lacks verifies after the fetch, and offline from the cache;
    • a failed fetch keeps the held trust root and says why;
    • a fetch before verifying falls back when the repository fails;
    • at most one fetch per hour;
    • a tampered cache, a cache older than the built-in trust root, and a repository older than the built-in trust root are all ignored;
    • a log key Sigstore retired stops counting when fetching before verifying;
    • only HTTPS or loopback overrides are accepted.
  • Mutation checks: removing the retry, either version floor, the previous-root signature check, the rollback check or the root expiry check each fails tests.
  • Ignored live test: sigstores_live_repository_serves_the_built_in_trust_root refreshes from Sigstore's live repository. The stacked PR runs it daily, and it passes today.
  • Existing tests: tests for unknown Rekor logs, unanchored chains and unknown CT logs now assert MissingTrustMaterial.

🤖 Generated with Claude Code

Every LPM binary held the Sigstore trust root it was built with and
nothing else. When Sigstore rotates a Fulcio CA, Rekor log or CT log
key, a copy built earlier would refuse every signature that needs the
new key: standalone self-update would refuse every later release, and
install-time npm provenance checks would reject new packages as an
attack.

LPM now carries Sigstore's TUF root and refreshes the trust root the
way Sigstore's own clients do: it follows the root rotations Sigstore
signed, checks timestamp, snapshot and targets signatures, versions
and expiry, and accepts only a trust root whose hash the targets role
signed. A minimal TUF 1.x client does this for the four top-level
roles, with ECDSA P-256/P-384 and Ed25519 keys and the canonical JSON
securesystemslib signs.

- Self-update fetches Sigstore's current trust root before verifying a
  release, so keys Sigstore retired stop counting. Provenance, relay
  key and publish checks fetch it when a bundle needs a key, log or CA
  the held trust root lacks, at most once an hour.
- A failed fetch keeps the held trust root, never older than the one
  built in, and the error says the fetch failed.
- The verified metadata is cached under ~/.lpm/cache/metadata and
  checked again against the built-in TUF root whenever it is read.
- LPM_SIGSTORE_TUF_URL_OVERRIDE points at a mirror (https or loopback)
  or turns fetching off with "off".
- `lpm internal-verify-release` still verifies with the trust root the
  release binary holds, without fetching.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tolgaergin and others added 3 commits November 25, 2026 12:12
…e, and never roll the cache back

- A key listed under two IDs or encodings counted twice toward a
  threshold; keys now count by their decoded bytes.
- A fetched trust root in which a role has no usable key because of
  entries this version can't read replaced a working one; it is now
  refused. A role whose readable keys Sigstore retired still stands.
- Two processes whose fetches finished out of order could write the
  older metadata last. The cache is now written under a lock and only
  when nothing newer is cached, and a process keeps its last verified
  metadata as the rollback baseline when it can't write the cache.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s, and share fetches between processes

- Keys, roles, files and targets the client can't read are left out of
  TUF metadata instead of refusing the whole document. An unreadable key
  never counts toward a threshold. Version 0 is refused.
- Only targets.json is held to its stored version, so a delegated role
  Sigstore drops no longer blocks refreshes. Key rotations are tracked at
  every root step.
- Stored roots no newer than the built-in TUF root are skipped, so a
  binary with a newer built-in root keeps a cache an older one wrote.
- A fetched or cached trust root in which a role has no usable key
  because its entries are missing or unreadable is refused, and the held
  one stays in use. A role Sigstore retired still stands.
- The cache records when it was fetched; within the hour other processes
  reuse it instead of fetching. A failed fetch is retried after a minute.
- `lpm internal-verify-release` verifies with the built-in trust root
  only, never a cached one.
- The repository URL's scheme is parsed, not prefix-matched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… before Sigstore outgrows the client

- Stored roots older than the built-in TUF root stay in the cache, so an
  older and a newer LPM on one machine can both follow it.
- The shared store in unit tests reads no cache, so they verify with the
  built-in trust root on every machine.
- The live check fails when Sigstore publishes a TUF root newer than the
  built-in one, and when the root or targets role is down to its
  threshold of keys LPM can verify.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tolgaergin
tolgaergin marked this pull request as ready for review November 25, 2026 13:28
…ckouts

A CRLF checkout rewrote them, so their lengths and hashes no longer
matched what Sigstore signed and five TUF tests failed on Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant