←back to thread

61 points harporoeder | 4 comments | | HN request time: 0s | source
1. woodruffw ◴[] No.41874435[source]
This is slightly old news. For those curious, PGP support on the modern PyPI (i.e. the new codebase that began to be used in 2017-18) was always vestigial, and this change merely polished off a component that was, empirically[1], doing very little to improve the security of the packaging ecosystem.

Since then, PyPI has been working to adopt PEP 740[2], which both enforces a more modern cryptographic suite and signature scheme (built on Sigstore, although the design is adaptable) and is bootstrapped on PyPI's support for Trusted Publishing[3], meaning that it doesn't have the fundamental "identity" problem that PyPI-hosted PGP signatures have.

The hard next step from there is putting verification in client hands, which is the #1 thing that actually makes any signature scheme actually useful.

[1]: https://blog.yossarian.net/2023/05/21/PGP-signatures-on-PyPI...

[2]: https://peps.python.org/pep-0740/

[3]: https://docs.pypi.org/trusted-publishers/

replies(1): >>41875939 #
2. westurner ◴[] No.41875939[source]
It's good that PyPI signs whatever is uploaded to PyPI using PyPI's key now.

GPG ASC support on PyPI was nearly as useful as uploading signatures to sigstore.

1. Is it yet possible to - with pypa/twine - sign a package uploaded to PyPI, using a key that users somehow know to trust as a release key for that package?

2. Does pip check software publisher keys at package install time? Which keys does pip trust to sign which package?

3. Is there any way to specify which keys to trust for a given package in a requirements.txt file?

4. Is there any way to specify which keys to trust for a version of a given package with different bdist releases, with Pipfile.lock, or pixi or uv?

People probably didn't GPG sign packages on PyPI because it wasn't easy or required to sign a package using a registered key/DID in order to upload.

Anyone can upload a signature for any artifact to sigstore. Sigstore is a centralized cryptographic signature database for any file.

Why should package installers trust that a software artifact publisher key [on sigstore or the GPG keyserver] is a release key?

gpg --recv-key downloads a public key for a given key fingerprint over HKP (HTTPS with the same CA cert bundle as everything else).

GPG keys can be wrapped as W3C DIDs FWIU.

W3C DIDs can optionally be centrally generated (like LetsEncrypt with ACME protocol).

W3C DIDs can optionally be centrally registered.

GPG or not, each software artifact publisher key must be retrieved over a different channel than the packages.

If PYPI acts as the (package,release_signing_key) directory and/or the keyserver, is that any better than hosting .asc signatures next to the downloads?

GPG signatures and wheel signatures were and are still better than just checksums.

Why should we trust that a given key is a release signing key for that package?

Why should we trust that a release signing key used at the end of a [SLSA] CI build hasn't been compromised?

How do clients grant and revoke their trust of a package release signing key with this system?

... With GPG or [GPG] W3C DIDs or whichever key algo and signed directory service.

replies(1): >>41876012 #
3. woodruffw ◴[] No.41876012[source]
> It's good that PyPI signs whatever is uploaded to PyPI using PyPI's key now.

You might have misunderstood -- PyPI doesn't sign anything with PEP 740. It accepts attestations during upload, which are equivalent to bare PGP signatures. The big difference between the old PGP signature support and PEP 740 is that PyPI actually verifies the attestations on uploads, meaning that everything that gets stored and re-served by PyPI goes through a "can this actually be verified" sanity check first.

I'll try to answer the others piecewise:

1. Yes. You can use twine's `--attestations` flag to upload any attestations associated with distributions. To actually generate those attestations you'll need to use GitHub Actions or another OIDC provider currently supported as a Trusted Publisher on PyPI; the shortcut for doing that is to enable `attestations: true` while uploading with `gh-action-pypi-publish`. That's the happy path that we expect most users to take.

2. Not yet; the challenge there is primarily technical (`pip` can only vendor pure Python things, and most of PyCA cryptography has native dependencies). We're working on different workarounds for this; once they're ready `pip` will know which identity - not key - to trust based on each project's Trusted Publisher configuration.

3. Not yet, but this is needed to make downstream verification in a TOFU setting tractable. The current plan is to use the PEP 751 lockfile format for this, once it's finished.

4. That would be up to each of those tools to implement. They can follow PEP 740 to do it if they'd like.

I don't really know how to respond to the rest of the comment, sorry -- I find it a little hard to parse the connections you're drawing between PGP, DIDs, etc. The bottom line for PEP 740 is that we've intentionally constrained the initial valid signing identities to ones that can be substantiated via Trusted Publishing, since those can also be turned into verifiable Sigstore identities.

replies(1): >>41876434 #
4. westurner ◴[] No.41876434{3}[source]
So PyPI acts as keyserver, and basically a CSR signer for sub-CA wildcard package signing certs, and the package+key mapping trusted authority; and Sigstore acts as signature server; and both are centralized?

And something has to call cosign (?) to determine what value to pass to `twine --attestations`?

Blockcerts with DID identities is the W3C way to do Software Supply Chain Security like what SLSA.dev describes FWIU.

And then now it's possible to upload packages and native containers to OCI container repositories, which support artifact signatures with TUF since docker notary; but also not yet JSON-LD/YAML-LD that simply joins with OSV OpenSSF and SBOM Linked Data on registered (GitHub, PyPI, conda-forge, deb-src,) namespace URIs.

GitHub supports requiring GPG signatures on commits.

Git commits are precedent to what gets merged and later released.

A rough chronology of specs around these problems: {SSH, GPG, TLS w/ CA cert bundles, WebID, OpenID, HOTP/TOTP, Bitcoin, WebID-TLS, TOTP, OIDC OpenID Connect, TUF, Uptane, CT Logs, WebAuthn, W3C DID, Blockcerts, SOLID-OIDC, Shamir Backup, transferable passkeys, }

For PyPI: PyPI.org, TLS, OIDC OpenID Connect, twine, pip, cosign, and Sigstore.dev.

Sigstore Rekor has centralized Merkle hashes like google/trillian which centralizedly hosts Certificate Transparency logs of x509 certs grants and revocations by Certificate Authorities.

W3C DID Decentralized Identifiers [did-core] > 9.8 Verification Method Revocation : https://www.w3.org/TR/did-core/#verification-method-revocati... :

> If a verification method is no longer exclusively accessible to the controller or parties trusted to act on behalf of the controller, it is expected to be revoked immediately to reduce the risk of compromises such as masquerading, theft, and fraud