Repository navigation
[python] Fix Sigstore verification for Python 3.14+ - #1771
Venkumahanti Subhankar (V-Subhankar-infy) wants to merge 15 commits into
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
A human assessment is warranted because the new source-verification policy is documented in NOTES.md but not reflected in the corresponding README, leaving the user-facing documentation incomplete.
No open issues 🎉
5 resolved since last review
Review effort: Lite
| - uses: actions/checkout@v7 | ||
|
|
||
| - name: "Test Python Sigstore verification" | ||
| run: bash test/python/sigstore_verification_test.sh |
There was a problem hiding this comment.
Why does this require a separate runner and a job to test this? Couldn’t it be part of the test scenarios for python feature?
There was a problem hiding this comment.
Initially I had updated just the scenarios only but copilot had specifically asked it was not sufficient.
In case of a tampered or wrong-signer Sigstore bundle. In this case cosign must reject the Python tarball and the install must not treat it as verified.
A scenario test can't check this. It installs from the real python.org files, and those always carry a valid signature from the right signer. The scenario can't swap in a bad .sigstore bundle or a different signer identity. So it only proves verification passes when everything is genuine. It can't prove verification fails when the signature is wrong, and catching a wrong signature is the point of this fix.
| local cosign_url='https://github.com/sigstore/cosign' | ||
| local architecture=$(get_architecture) | ||
| if [ ! -s "${policy_file}" ]; then | ||
| while [ "${policy_attempt}" -le 3 ]; do |
There was a problem hiding this comment.
Can this retry limit be stored in a variable and declared upfront in the installation script?
There was a problem hiding this comment.
Yes, I have made the changes in the latest commit, pls once check now.
| rm -f "${policy_file}" | ||
| policy_attempt=$((policy_attempt + 1)) | ||
| if [ "${policy_attempt}" -le 3 ]; then | ||
| sleep 2 |
There was a problem hiding this comment.
Shouldn’t this retry happen with incremental intervals with each retries?
There was a problem hiding this comment.
Yes, I have made the changes in the latest commit, initially starts with delay of 2 seconds and increases exponentially with base 2, currently set at 3 attempts, (2,4,8 sec delay).
| # Remove 'v' prefix if present for download URL | ||
| local version_for_url="${COSIGN_VERSION#v}" | ||
| local policy | ||
| if ! policy="$(awk -v wanted_series="${series}" ' |
There was a problem hiding this comment.
Parsing an entire html web page for sigstore doesn't appear to be a good idea when it comes to code maintainability. It will break even with a minor change in the web page layout and debugging that inline a bash script will be difficult. Pls check if there is a direct download url or if at all the policy has to be parsed then if the data is available in semi structural format such as a json.
There was a problem hiding this comment.
Yes, this is a genuine roadblock, and I could not find any such source. but we could go with another alternative.
Currently the implementation is Dynamic Python signer + Dynamic Cosign, and since every python version has different signer bundle this web fetch is the. only way for dynamic python.
To prevent this, we can choose to pin a python version like 3.14 and fetch its sigstore signed bundle statically and embed it in code (1kb file), in this case the cosigner can directly perform cosign validation without the need to perform any additional downloads in runtime with a caveat that now the maintainers needs to bump the bundles whenever a new minor version of python is released and we wish to use it. ( Since the verification is fail open anyways the build would be never affected and a warning in tons of lines would go unnonticed and the whole verification system is compromised. ( in simple words when we used GPG we failed the builds as a security but Python 3.14+ discards the usage of it for another protocol and we have chosen it to continue build (makes sense because this is more complex than gpg and the network dependancy is higher)
… declared as variables.



Fix Python 3.14+ Sigstore verification
Fixes #1764
Problem and root cause
.sigand a nonexistent.peminstead of Python.org's.sigstorebundle.-fand--fail-with-bodyflags, while2>/dev/nullhid curl's diagnostic.The bottom 4 are straightforward implementation fixes. The first involves a much bigger architectural decision around security versus long-term sustainability while deciding how the cosign verifies the identity. ( cosign verifies the authenticity and integrity of downloaded Python source archives )
Approaches considered
The signer policy and Cosign verifier both need a trust decision. Dynamic lookup reduces manual maintenance but relies more on external sources; static values offer more repository control but need regular upkeep.
The practical options are:
Chosen approach
Resolve the Python release-manager identity and OIDC issuer from Python.org's published metadata, then verify the Python
.sigstorebundle against those exact values.Use Cosign v3.1.4 as a temporary, architecture-specific, checksum-verified bootstrap. Resolve the latest stable Cosign v3 release at build time and verify its binary and Sigstore bundle with the pinned bootstrap, using the Cosign release identity and issuer. Use the newer binary only after verification succeeds; otherwise retain the pinned binary. If the newer binary cannot verify the Python bundle, retry with the pinned verifier.
The pinned v3.1.4 hashes come from official GitHub release metadata. This version is newer than the one affected by GHSA-fx35-mq7g-6g98 and remains the trust anchor for updating the verifier.
Cache the binaries and Python.org signer policy across Python installations in the same build, then remove the cache on exit.
Preserve the existing non-blocking policy: if signer lookup, Cosign bootstrap/update, or Python bundle verification cannot complete, emit a warning and continue without verified source authenticity or integrity. A Python checksum fallback does not provide source authentication.
Cosign maintenance
The installer resolves the latest stable Cosign v3 release at build time, so the verifier does not need a manual version bump for every release. Review the pinned bootstrap version and hashes about quarterly (roughly 5–10 minutes per review), and update them promptly if a security advisory affects the pin or compatibility requires it. Check the Cosign security advisories and Cosign releases.
Cosign v3.1.4 is the pinned bootstrap and addresses the legacy-bundle verification issue covered by GHSA-fx35-mq7g-6g98. When updating the bootstrap, change the version and hashes for all supported architectures together.
Changes
src/python/install.sh: Add Python.org signer-policy lookup and exact-identity bundle verification; use pinned Cosign v3.1.4 to authenticate the latest stable Cosign v3 before use, with pinned-verifier fallback. Cache temporary binaries and signer metadata, retry transient downloads, and clean up on exit. Installgawkwith the required packages.src/python/devcontainer-feature.json: Bump the feature version from 1.8.1 to 1.9.0.src/python/NOTES.md: Document source verification and its failure policy.src/python/README.md: Update the generated feature documentation to match the notes.test/python/sigstore_verification_test.sh: Add mock-based checks for signer selection, Cosign arguments, supported architectures, checksum/download/signature failures, unsupported inputs, and cache cleanup.PR description.md: Record the problem, design decisions, impact, and verification status.Impact
Python 3.14+ source builds verify the release manager's identity and signature when verification succeeds. The GPG verification flow for Python versions before 3.14 remains unchanged.
The pinned bootstrap and dynamically verified Cosign binary are temporary; neither installs nor replaces a system-wide Cosign installation. The build needs GitHub access to obtain the Cosign release and Python.org access for signer metadata and bundles.
For compatibility, unsupported architectures, unknown signers, network failures, checksum mismatches, and signature failures still allow installation to continue with an explicit warning. Such builds do not have verified source authenticity or integrity.
Tests and verification
ubuntu:latest(26.04, amd64) with Python 3.14.10 completes successfully. The first.sigstoredownload times out, but the retry succeeds. Cosign reportsVerified OKwith the dynamically resolved signerhugo@python.org, and the CLI reportsoutcome: success.ubuntu:latest(26.04, amd64) with Python 3.14.10 completes successfully. The first.sigstoredownload times out, the retry succeeds, and Cosign reportsVerified OKforhugo@python.org; the CLI reportsoutcome: success.