Verify SHA256 of downloaded LuaRocks tarball#29
Open
potiuk wants to merge 1 commit intoleafo:masterfrom
Open
Conversation
The action currently downloads luarocks-$version.tar.gz from luarocks.org and immediately extracts and builds it, with no integrity check. A compromised mirror, on-path TLS attack against an outdated runner, or accidental URL drift would silently install unverified code into a CI environment that often has package-publishing tokens. Add a `known-checksums.json` file mapping each supported LuaRocks version to its source-tarball SHA256, and verify the download against that map before extracting. An unknown version is rejected with a clear message pointing at the file to update. Why a dict and not a sidecar fetch: the upstream luarocks.org release page only publishes detached PGP signatures (`.tar.gz.asc`), and verifying those at runtime would require importing and trusting a key inside the action. A static dict committed to the action repo is simpler, doesn't introduce a key-trust step, and lets reviewers check exactly which versions this action will accept by reading one file. New versions are added by maintainers in a follow-up PR. Preseeded versions (downloaded from luarocks.org and verified by hand): 3.13.0, 3.12.2, 3.12.1, 3.12.0, 3.11.1, 3.11.0, 3.10.0, 3.9.2. Closes the "unverified binary download" finding raised by Apache Infrastructure's verify-action-build tool on the v6.0.0 → v6.1.0 bump (apache/infrastructure-actions PR #769).
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.
Context
This action currently runs:
with no integrity check on the downloaded tarball. A compromised mirror, an on-path TLS attack against an outdated runner, or accidental URL drift would silently install unverified code into a CI environment that often has package-publishing tokens, repository write tokens, or release-signing material in scope.
What this PR does
known-checksums.jsonmapping each supported LuaRocks version to its source-tarball SHA256.verifyTarball()step inmain.jsthat runs immediately aftertc.downloadTooland beforetc.extractTar. If the downloaded SHA256 matches the recorded one, the action proceeds and prints a confirmation line. If it doesn't, or if the requestedluaRocksVersionisn't in the dict, the action fails with a clear message pointing the user at the file to update.luaRocksVersionmust be listed inknown-checksums.jsonand that adding a new version is a one-line PR.Preseeded versions (each downloaded from
https://luarocks.org/releases/andsha256sum'd by hand):3.13.0,3.12.2,3.12.1,3.12.0,3.11.1,3.11.0,3.10.0,3.9.2.Why a static dict, not a sidecar fetch
https://luarocks.github.io/luarocks/releases/publishes detached PGP signatures (.tar.gz.asc) but no SHA256 sidecars. Two options were considered:gpgon every supported runner OS. Adds a key-trust step that's hard to review.I went with (2) for simplicity. It's also the pattern used by similar setup-tool actions (e.g.
actions/setup-node'smanifest.json).Why now
Apache Infrastructure runs an automated verifier (
verify-action-build) on every Dependabot bump of a GitHub Action used across ASF projects. On thev6.0.0 → v6.1.0bump (apache/infrastructure-actions#769) the verifier flagged this exact issue:That blocked auto-approval of an otherwise-valid bump, and the same pattern would re-block every future bump until the action gains some form of download verification.
Test plan
node --check main.jspasses (syntax).luarocks-3.13.0.tar.gzfromluarocks.org— match..github/workflows/test.yml) on this PR — the defaultluaRocksVersion3.13.0is in the dict, so the test matrix should pass with the new check enabled.Generated-by: Claude Opus 4.7 (1M context)