Publish PGP signatures for pie.phar (vs Sigstore build provenance)
#479
Replies: 9 comments
-
|
PIE doesn't require GitHub CLI, there is a fallback mechanism built in to Practically, since the phar is only ever built in CI and attestations generated there and then, it is actually slightly more secure. In order for me to sign the phar with my GPG key, I would have to download the phar, sign it, and upload the signature; there is technically (although unlikely) possibility for vulnerabilities there. The attestation generated isn't specific to GH, it is just a Sigstore attestation anyway, but GH is just the generator. The ThePHPF/attestation library is what we're using for this, and keen to improve this library separately and address vendor lock-in concerns 👍 |
Beta Was this translation helpful? Give feedback.
-
Assuming an attacker somehow managed to tamper with the downloaded
There's indeed an ongoing universal debate about whether manual signing or fully automated CI-based signing is "more secure", but to be honest, that isn't really my concern here. Both models have Pros and Cons, and I think they are equally valid. If manual signing is undesirable, you can also generate a dedicated PGP key used exclusively for release signing, publish the public key separately (preferably also on public key servers), and store the private key as an Actions secret so it never leaves CI. This is how many projects handle fully automated PHAR or tarball signing.
Is there a way to access PIE's Sigstore attestation artifacts separately (like with PHPUnit)? I'm not very familiar with GitHub's API in this regard. That would already solve most of my concerns, assuming the artifacts can be used to verify the |
Beta Was this translation helpful? Give feedback.
-
In the So yes; it does verify the If you have downloaded a
This is something I've used before (and was automated thanks to laminas/automatic-releases); but this approach is no better or worse than using GitHub's attestation action; ultimately GitHub holds the keys, and if compromised, that will be the weak link in either case. In fact; I had originally planned to use a GPG private key in secrets in this manner, but I had discovered the Attestation feature, which has more benefits than regular GPG signing. Don't get me wrong, I'm personally a fan of GPG, but I always felt storing the private key as a secret was a less than ideal approach (since, you have to trust the host - GitHub in this case - does not somehow leak that key). That said, it was an adequate solution, assuming good faith from GitHub; but the GH Attestations functionality we felt packaged up a much more elegant solution, using open standards (Sigstore). This makes me quite reluctant to add a GPG signature to PIE, when we already have an arguably superior approach implemented.
You can download the attestation (example: https://github.com/php/pie/attestations/13387661, see also Attestations API), but it is hosted on GitHub - just like PHPUnit's is; the releases attestation (the JSON file attached to the releases page you linked to) is new, and related to Immutable releases feature, rather than verifying provenance for build artifacts (which is what PIE uses). PIE has, in fact, recently enabled Immutable releases, so the release attestation will exist on future releases (example: https://github.com/php/pie/releases/tag/1.3.0-rc.1) - but this is NOT currently checked by The GitHub Attestation feature, from the perspective of "the verifier" (rather than us, "the maintainers"), there are indeed a few GitHub specific things:
Apart from those parts (I think, off my head), the actual verification is intended to be standardised. |
Beta Was this translation helpful? Give feedback.
-
|
Oh - incidentally, as a side note, I do sign my commits and tags etc; so if you were very paranoid, you could verify with for example |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for your detailed answer! This clarifies a lot ❤️
If an attacker already tampered with the My first concern is solely focused on user experience: PIE currently requires me to install GitHub CLI to verify that a downloaded With an
My second concern is about this matter and what I call "vendor lock-in". As long as you're using GitHub's identity provider, you give GitHub full authority over PIE. GitHub decides what a genuine PIE release is - and not you (resp. the PIE team). I'm not concerned about the technology. Let's assume Microsoft shuts down GitHub tomorrow. Switching to a different hoster is easy, so you do that. But how can users verify that a With a PGP key you wouldn't do that. Yes, you trust GitHub with a private subkey, but the validity of that subkey is limited (the more limited while still being feasible the better) and you, and only you (or: "the project"), have the primary key. So, if GitHub goes away, you just sign your new As far as I understand reducing the required trust in e.g. GitHub is the whole idea of Sigstore and why the technology can indeed be considered superior, but as long as you're using GitHub's identity provider you actually make things worse than with a classic PGP key. But maybe I understand something wrong or totally miss something, I'm by far no expert in this matter, so please correct me then. |
Beta Was this translation helpful? Give feedback.
-
|
I agree with everything @PhrozenByte said. Moreover there's precedent of working this way, as both PHP and Composer have been signing their source tarballs and PHAR executables with PGP for years. This allows users to fetch, verify and store the signer public keys once and from then on do automated verification of all subsequent releases to detect compromised binaries. This sort of supply chain attack is not theoretical. In fact I started to become more conscious about this kind of attack after being impacted by the CodeCov breach. As an example from my own Dockerfiles, the following snippet downloads the latest Composer executable and the latest release signature. My repository has Composer's public key committed in it, which I thoroughly checked at the time (and the Git commits like the one that introduced this file are all signed, too). If a malicious actor ever gets hold of the getcomposer.org server or domain and manages to replace the legit composer.phar file with malware the signature verification will fail and abort the build process. ADD https://getcomposer.org/download/latest-stable/composer.phar .
ADD https://getcomposer.org/download/latest-stable/composer.phar.asc .
COPY composer-pubkey.asc .
RUN gpg --import composer-pubkey.asc \
&& gpg --verify composer.phar.asc composer.phar \
&& install -m 0755 composer.phar /usr/local/bin/composerI would very much like to be able to do the above with pie, too. |
Beta Was this translation helpful? Give feedback.
-
|
@1ma as I already pointed out; since the private key used to sign the artifact would be stored in GitHub secrets, verification using GPG is only as good as the security of GitHub. The Sigstore approach we have adopted with PIE is much more modern, and overcomes many of the downfalls of using GPG in CI to sign artifacts. One suggestion that has been made recently was that we could bundle the attestation with the release; this gives you the attestation, you can then obtain the trusted root bundle, and verify the payload anyway. FWIW, whilst the Sigstore approach is arguably superior for this particular use case (i.e. verifying the provenance of a build artifact to secure the software supply chain), I appreciate tooling and ecosystem is quite new, and options are somewhat limited. That said, it is an open standard, and I would encourage you to use this mechanism to verify and validate PIE releases. I am actually working when I can on a separate library (soon to be a CLI tool) that is written in PHP: https://github.com/ThePHPF/attestation - PIE uses this internally when running This very topic has been discussed a little on Mastodon yesterday too: https://phpc.social/@timwolla/115841642540768673 |
Beta Was this translation helpful? Give feedback.
-
Unless I'm missing something big here, due to the way PIE is currently using Sigstore, it's also only as good as the security of GitHub. Arguably, even worse actually, because it permanently depends on Github. As far as I understand (please correct me if I'm wrong), PIE needs its own trusted root first to actually make Sigstore better than PGP. GitHub attestations basically tell an user: "This artifact was created in this exact GitHub repository, through this GitHub workflow, at this exact time." This attestation builds upon the https://github.com/php/pie identity. Whoever owns this identity, owns PIE. PIE does not own this identity. GitHub does. PGP on the other hands tells an user: "This artifact was signed by this exact person/organization." If PIE wants GitHub to sign releases, PIE must indeed give GitHub access to a private key - but only to a restricted sub key, preferably as restricted as reasonably possible, especially in regards to the subkey's validity period. With PGP, whoever owns the root key, owns PIE. No matter what, only PIE owns the root key. Not GitHub. To make Sigstore actually superior to PGP, PIE must not rely on GitHub's identity, but must use its own trusted root. This can be PIE's own trusted root, or the trusted root of the PHP Foundation, or the trusted root of the PHP project. But not GitHub. |
Beta Was this translation helpful? Give feedback.
-
This is not quite true; if we were to distribute the attestation alongside the release, you would just need the trusted root (which you can save yourself, or using the https://github.com/ThePHPF/attestation library for example), you can verify the authenticity of the artifact entirely outside of GitHub. Just because the attestation was generated in GitHub, does not tie it to GitHub.
That is exactly the same verification you get with the PGP signature using a key stored in GitHub secrets. Both approaches are equivalent, but Sigstore was really a tool designed for this job; where PGP signatures are more general purpose; and arguably designed for individuals signing an artifact, rather than an automation signing an artifact. This was already alluded to on that Mastodon thread I linked to: https://phpc.social/@timwolla/115841642540768673
Indeed, I'm fully aware of this approach, and I've used it on multiple projects before - in fact this approach is used by the laminas/automatic-releases action workflow, so I am very familiar with its set up, but also with its drawbacks.
This is something that could indeed be looked into eventually; it is worth noting that there are two trusted roots in the list; the organisation I completely understand the desire to "decouple" from GitHub, just the current flow means we can concentrate on developing PIE, and continue using existing tooling. I'd be open at some point to looking into getting a Foundation or PHP Group trusted root set up, but I'm reluctant to introduce a PGP signature, given the alternative approach is, (in my opinion) superior and better suited for the purpose of verifying the authentic source of the built artifacts. The TLDR is; Sigstore is designed for this purpose, PGP signatures aren't really. I'd rather stick with Sigstore, and improve on this model, than introduce an alternative approach. FWIW, I'm going to move this to a discussion, as it is very much a discussion now :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently PIE recommends using
gh attestation verifyfrom the GitHub CLI to verify a downloadedpie.phar. However, I do not have GitHub CLI installed, nor do I wish to install it. Additionally, relying solely on GitHub attestations creates a form of vendor lock-in.A more portable and well-established alternative would be to provide a standard PGP signature alongside the release asset. Therefore, I would like to suggest publishing a public PGP key and including a
pie.phar.ascsignature file next to eachpie.pharrelease to allow independent and widely compatible verification. This is common practice for other PHAR projects, such as Composer or PHIVE.Alternatively, projects like PHPUnit use Sigstore; while I personally prefer PGP for its simplicity and wider availability, Sigstore would also be a viable option.
Besides: Great project, thank you! ❤️
Beta Was this translation helpful? Give feedback.
All reactions