feat(verify): pin signer identity via --san-uri on verify certificate#649
Open
jzeng4 wants to merge 1 commit into
Open
feat(verify): pin signer identity via --san-uri on verify certificate#649jzeng4 wants to merge 1 commit into
jzeng4 wants to merge 1 commit into
Conversation
Adds --san-uri (repeatable) to `model_signing verify certificate` and an equivalent `expected_san_uris` kwarg on `use_certificate_verifier`. When set, verification additionally requires that every listed URI appear in the leaf certificate's SubjectAlternativeName. The check runs on the leaf embedded in the Sigstore bundle, after chain-of-trust verification succeeds. Default behavior is unchanged when the flag is omitted. Motivation: SPIFFE SVIDs carry the workload identity in the URI SAN (X509-SVID spec requires exactly one URI SAN, and it MUST be the SPIFFE ID). Chain-of-trust alone proves the CA vouched for *some* leaf, not *which* leaf. Without a URI-SAN check, any certificate issued by the SPIRE trust bundle (or by a shared internal PKI) can produce accepted signatures. This flag turns the SPIFFE-required verification step into a single CLI option, so callers no longer have to write ad-hoc post-verify scripts that re-parse the bundle. Signed-off-by: Junyuan Zeng <juzeng@linkedin.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
--san-uri(repeatable) tomodel_signing verify certificateand anequivalent
expected_san_uriskwarg onverifying.Config.use_certificate_verifier. When set, verificationadditionally requires that every listed URI appear in the leaf certificate’s
SubjectAlternativeName. The check runs on the leaf embedded in theSigstore bundle, after chain-of-trust verification succeeds. If the flag is
omitted, behavior is unchanged.
Motivation — SPIFFE SVIDs carry identity in the URI SAN
Today,
verify certificatevalidates only two things:That is necessary but not sufficient for SPIFFE deployments (and more
generally for any internal PKI where multiple workloads share a CA).
Per the SPIFFE X509-SVID spec:
(
URI:spiffe://<trust-domain>/<path>).ignored by SPIFFE-aware verifiers.
Chain-of-trust alone proves the SPIRE trust bundle vouched for some
workload; it does not tell the verifier which workload. Without a URI-SAN
check, any SVID issued by the same trust domain — a different team’s job, a
different service, a compromised sibling workload — produces signatures that
verify certificatewill silently accept.The same footgun applies outside SPIFFE:
code-signing certs from the same corporate CA. Team A wants to verify a
model was signed by Team A’s releaser, not any job in the company.
cert for any subject under the trusted root can produce signatures that
chain-verify. Pinning the expected identity turns "silently accepts" into
"rejects with a clear error".
verify sigstore. The Fulcio path already requires--identity(a SAN URI). The certificate path — used by users runningtheir own PKI or SPIRE — offered no equivalent, which is a footgun for
anyone migrating between the two.
Today the workaround is an ad-hoc post-verify script that re-parses the
bundle, base64-decodes the leaf, and checks the SAN. That is error-prone
(easy to skip on missing SAN, easy to forget entirely, easy to run before
chain verification) and each user reinvents it. Moving the check into
use_certificate_verifiermakes it atomic with chain verification andimpossible to forget.
Design
bundle.verification_material.x509_certificate_chain.certificates[0]— theexact same bytes the chain verifier just validated. Never a local file.
and signature verification. Reversing the order would let an attacker
present a self-crafted cert with the "right" SAN and skip trust.
--san-uripassed, the leaf’s SAN mustcontain that exact string. Multiple flags form a conjunction. Case-sensitive;
no wildcards. This mirrors sigstore-python and avoids the well-known
pitfalls of pattern-based identity checks.
no SAN extension at all, verification fails with a clear error rather than
silently accepting.
frozenset(). No behavior change for existing users.Non-goals
the primary use case; the others can follow up if requested).
CVEs get filed).
verify sigstore, not this command.Changes
src/model_signing/_signing/sign_certificate.py:Verifier.__init__gainsexpected_san_uris. New_verify_san_identity()runs after the existingKeyUsage/ExtendedKeyUsage checks.
src/model_signing/verifying.py:use_certificate_verifiergainsexpected_san_uris, plumbed straight through.src/model_signing/_cli.py: new--san-urioption onverify certificate(repeatable), documented in the command help with the SPIFFE rationale.
tests/_signing/certificate_test.py(new): five tests covering match,mismatch, missing SAN, back-compat, and the sibling-cert attack.
Test plan
Example rejection:
Checklist
hatch fmt --checkclean