mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1218] [CLOSED] Check the ready-made engine against GitHub's SHA-256 before installing it #3316
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#3316
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/1218
Author: @demetree
Created: 10/6/2026
Status: ❌ Closed
Base:
main← Head:verify-engine-download📝 Commits (3)
3ebbdcbCheck the ready-made engine against GitHub's SHA-256 before installing it5c9ee37An adversarial pass: a refusal killed the engine update, and a local folder was checked against the wrong release53b1a5fTrust a local folder, and drop the "already checked" mark📊 Changes
6 files changed (+699 additions, -4 deletions)
View changed files
📝
docs/DETAILS.md(+52 -0)📝
docs/TROUBLESHOOTING.md(+26 -0)📝
setup.py(+179 -0)➕
tools/test_setup_engine_hash.py(+403 -0)📝
tools/test_setup_pins.py(+25 -4)📝
tools/test_setup_strix_halo.py(+14 -0)📄 Description
Check the ready-made engine against GitHub's SHA-256 before installing it
get_prebuilt()installed the engine on nothing but the byte count matching the server'sContent-Length. A file of the same length but different bytes passed that, and the engine directory thenheld code that nothing had checked. This is the install-path half of the hash check the update path already
does (#1162); it is a different code path, so it is a separate change.
What it does. Reads the asset's size and SHA-256 from the releases API — a different origin from the
download — and hashes the file setup just downloaded. It happens before the archive is opened, so a file
that does not match never reaches
_unpack, let aloneengine/. Reusesverify_sha256(), the function theUnsloth shards already use, so the idiom and the finish mark are the ones the project has.
Measured, not asserted. On v0.1.40's
strata-windows-x64.zip: the API reported 131,707,082 bytes andcd264b2125fdb85e84a8264da2ab2343463e6c7f9a12f317d4ce7192cd2c6b33. The download hashed to the same andinstalled. A file of exactly 131,707,082 bytes with different content — which the old size check cannot see —
was refused and deleted, leaving the engine directory empty.
The tag comes out of the URL, so the exact release the bytes claim to come from is the one that is
checked, not "latest" (#214 tries the checkout's own release first). And the hash is read from
api.github.comeven when--prebuiltpoints the download somewhere else, which is the point: acompromised mirror cannot supply bytes with a matching digest.
A wrong file is deleted, so the next run downloads the published one again, and the verified hash is kept
in the download's
.donemark so the ~190 MB is not hashed twice.If GitHub will not answer, setup stops rather than install unchecked. The usual cause is the anonymous
rate limit — 60 requests an hour, per internet address, so a shared or office connection runs out — and
docs/TROUBLESHOOTING.mdnow says so.STRATA_ALLOW_UNVERIFIED_ENGINE=1is the explicit, recorded way toaccept an unverified engine, for an air-gapped or mirrored install. Nothing is silent either way.
What this does not cover, because the limit should be written down rather than implied: it proves the
bytes are the ones GitHub published for that asset. That catches a corrupted transfer, a substituted or
mirrored download, a TLS-terminating proxy and a hostile network. It does not make a malicious release
safe — if whoever can publish a release publishes a hostile engine, the published hash matches it. Only a
hash pinned in the source closes that, at the cost of a reviewed commit per release.
get_prebuilt()had nocheck at all before this, so this is strictly more than the install path did; pinning remains strictly more
than this does.
tools/test_setup_engine_hash.py— 16 tests, no network. Covers the tag/latest/mirror URL shapes, no digest,a non-SHA-256 digest, a missing asset, GitHub unreachable, the match, the wrong hash (refused and
deleted), the wrong size, the hash not being repeated on a second run, the refusal when there is no digest,
and the opt-in escape hatch. Two of them assert the ordering — that the check runs before
ZipFileandbefore
_unpack— so moving it later fails the suite rather than quietly weakening it.tools/test_setup_pins.py: the five tests that mock the download now supply a digest, which is what atest mocking the download has to do once the download path verifies it. Their subject is unchanged — which
release and which asset are chosen.
python -m unittest tools.test_setup_pins18 pass.tools/: 23 of 24 files pass;test_setup_choicesfails on this machine both before and after this change, in
build_engine_hip, because it wants a C++compiler (
cl.exe/hipcc) that is not installed — verified against pristine upstreamsetup.py.pytest serve444 passed, 8 skipped.Note this is a behaviour change on the install path: a machine that cannot reach the API now stops rather
than installing, and the message says why.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.