Verify downloaded toolchain archives against sha256 checksums
Context
erlef/setup-beam downloads OTP, Elixir, Gleam, and rebar3 via tc.downloadTool without verifying checksums. Flagged during ASF allowlist review for an Apache incubating project:
- INFRA: https://issues.apache.org/jira/browse/INFRA-27826
- ASF PR: https://github.com/apache/infrastructure-actions/pull/751
ASF maintainers agreed to allow the current SHA conditional on raising this issue.
Proposal
Two options:
A. Fetch-at-install. At download time, fetch the checksum upstream publishes (builds.txt for hex.pm, .sha256 sibling for Gleam) and verify. Same-origin, so doesn't beat a fully-compromised mirror, but catches corruption and partial tampering. Covers OTP linux + Elixir + Gleam (3 of 6 paths). Darwin can be covered with sig-store potentially. No ongoing maintenance.
B. Pinned KNOWN_CHECKSUMS (à la astral-sh/setup-uv). Pin hashes in source via a committed map + weekly regeneration workflow. Cross-origin, covers all 6 paths. ~300 entries for supported versions.
Questions
- Which direction fits the project?
- Concerns about maintenance for option B?
For option B the action can always add a checksum input that will allow users to provide a checksum for versions that were not yet embedded into the action.
Some of the artifacts, published to GitHub Releases, have SigStore signatures. For those it might be enough to check those signatures.
Related: https://github.com/hexpm/bob/issues/237
I agree option A. is Ok but incomplete, given same-origin concerns. Option B. is difficult to maintain, and I didn't understand @ppkarwasz' suggestion.
@maennchen, do you have concrete ideas on what we should do here?
For option B the action can always add a checksum input that will allow users to provide a checksum for versions that were not yet embedded into the action.
While this approach eliminates the burden of maintaining a list of checksums on us, the side effect is that this responsibility is transferred to users. This should probably be fine if things like dependabot or renovate can correctly update the sums. However, I suspect that this will affect either the freshness since or the security (i.e. users opting out of verifying checksums at all) of downstream repositories.
Nevertheless, I think a checksum option should be implemented anyway, since it allows a user to independently verify any artifacts if they choose so.
Some of the artifacts, published to GitHub Releases, have SigStore signatures. For those it might be enough to check those signatures.
I'm not too familiar with the SigStore verification flow, but from what I understand, we can fetch both the artifact and the signature at install and verify without the same-origin issues? If so, this might be a better option than A or B.
For context, I recently started maintaining some Erlang code for an Apache project as well. I'm surprised that setup-beam was only added to the allowlist now. I thought that the CouchDB folks would have proposed setup-beam ages ago.
Option B. is difficult to maintain, and I didn't understand @ppkarwasz' suggestion.
Sorry, I meant you can have a series of checksums hardcoded in the actions and a checksum input to the setup-beam action. If a user wants a version that has not been yet added to the hardcoded list, he can provide the missing input via the checksum input.
I suggest starting with checksum support. We need both sigstore support and checksum support IMHO. I also think providing users a way to pin to very specific releases is a good thing as well (similar to pinning of github actions using sha, which I think both @maennchen and I recommend).
The pinning to sha is a nice idea, we can probably implement that one.
What would be "the checksum support" in this case, Bryan? I mean, I understand the context but wanna dig into your idea, of how you'd implement it, high-level.