Idea: re-check the builder and its tools on disk before a build runs them #422

Open
opened 2026-12-05 18:05:33 +00:00 by llun · 3 comments
Member

The idea

Before a build runs anything from disk, check those files again: the installed builder program and the unpacked tools. If a file doesn't match, refuse to run it, and fetch and check it again.

Why

Today a file is checked only when it's downloaded. After that, being on disk counts as proof:

  • The nightly launcher runs an installed version's longshot-builder as soon as longshot_release.json is beside it (src/game/releases.rs, release()). It doesn't hash the program again. It does that only in copy_prefetch, when copying a download.
  • The builder's tool store (Longshot's builder/crates/build-tools/src/install.rs, also in the launcher's vendor/build-tools) reuses tools/<name>-<hash>/ whenever the folder exists. at_dests trusts a matching stamp file. Neither checks the unpacked files, so a changed clang.exe or library would be used as is.
  • v1.3.1 did the same with its toolchains: a folder with toolchain.json was installed, and new versions reused its files by existence alone.

This may explain the second infection reported in #379. The player installed the launcher and its data on drive F:, got infected, then reformatted, most likely only C:. They installed on F: again and were infected again while building. The next time they used the default drive, everything was fresh, and nothing happened. If the first infection changed files in the tool folders on F:, the second build reused and ran them. We can't prove that, but nothing in the launcher would have noticed.

Re-checking won't stop malware that is running on the PC at that moment. It can change anything. What it does stop is a changed or damaged file left on disk being run again: after a cleanup that missed a drive, from an old backup, or from a copied data folder. It also tells the player plainly that something is wrong.

What it needs

  • A list of every unpacked file's SHA-256, written when a tool or builder is installed, and kept beside its record. The list is made from the checked archive, so it carries that check forward.
  • Before a build, the program and the tools it will run checked against that list. Hashing about a gigabyte of tools takes a few seconds. Checking only the programs and libraries that run (.exe, .dll, .so) is cheaper. Re-checking a file only when its size or modified time changed would make it cheaper still, though that won't catch a careful attacker.
  • On a mismatch: tell the player the tools were changed on disk, delete the folder, and install it again from the signed release.

Done when

No program or tool from the launcher's or the builder's folders runs unless its bytes still match what the signed release says.

### The idea Before a build runs anything from disk, check those files again: the installed builder program and the unpacked tools. If a file doesn't match, refuse to run it, and fetch and check it again. ### Why Today a file is checked only when it's downloaded. After that, being on disk counts as proof: - **The nightly launcher** runs an installed version's `longshot-builder` as soon as `longshot_release.json` is beside it (`src/game/releases.rs`, `release()`). It doesn't hash the program again. It does that only in `copy_prefetch`, when copying a download. - **The builder's tool store** (Longshot's `builder/crates/build-tools/src/install.rs`, also in the launcher's `vendor/build-tools`) reuses `tools/<name>-<hash>/` whenever the folder exists. `at_dests` trusts a matching stamp file. Neither checks the unpacked files, so a changed `clang.exe` or library would be used as is. - **v1.3.1** did the same with its toolchains: a folder with `toolchain.json` was installed, and new versions reused its files by existence alone. This may explain the second infection reported in #379. The player installed the launcher and its data on drive F:, got infected, then reformatted, most likely only C:. They installed on F: again and were infected again while building. The next time they used the default drive, everything was fresh, and nothing happened. If the first infection changed files in the tool folders on F:, the second build reused and ran them. We can't prove that, but nothing in the launcher would have noticed. Re-checking won't stop malware that is running on the PC at that moment. It can change anything. What it does stop is a changed or damaged file left on disk being run again: after a cleanup that missed a drive, from an old backup, or from a copied data folder. It also tells the player plainly that something is wrong. ### What it needs - A list of every unpacked file's SHA-256, written when a tool or builder is installed, and kept beside its record. The list is made from the checked archive, so it carries that check forward. - Before a build, the program and the tools it will run checked against that list. Hashing about a gigabyte of tools takes a few seconds. Checking only the programs and libraries that run (`.exe`, `.dll`, `.so`) is cheaper. Re-checking a file only when its size or modified time changed would make it cheaper still, though that won't catch a careful attacker. - On a mismatch: tell the player the tools were changed on disk, delete the folder, and install it again from the signed release. ### Done when No program or tool from the launcher's or the builder's folders runs unless its bytes still match what the signed release says.
Member

This is a distinct security-hardening proposal, not a duplicate of #379: that report described a suspected infection, and the maintainers’ follow-up says their release-chain checks found nothing wrong and could not establish how the files arrived. Your proposal specifically addresses detecting altered files left in an installation before they are reused. I’m leaving it for maintainers to assess.

If that doesn't solve it, say what happened (and attach your log); a maintainer takes it from there.


For maintainers

Issue #379 follow-up reports checks of v1.3.1 and nightly release artifacts/signatures and third-party build files found nothing wrong; it states the infection origin could not be determined. This proposal is distinct: persisted-file integrity checks before reuse/execution.


Possibly related, for context:

  • issue #379 Infection after downloading the OFFICIAL v1.3.1 setup (not the impersonation site) — Security/infection report motivating the integrity-check proposal; not the same requested change

Automated triage by BeanBot (gpt-6-luna). Nothing was run; a maintainer decides.

This is a distinct security-hardening proposal, not a duplicate of #379: that report described a suspected infection, and the maintainers’ follow-up says their release-chain checks found nothing wrong and could not establish how the files arrived. Your proposal specifically addresses detecting altered files left in an installation before they are reused. I’m leaving it for maintainers to assess. If that doesn't solve it, say what happened (and attach your log); a maintainer takes it from there. --- **For maintainers** Issue #379 follow-up reports checks of v1.3.1 and nightly release artifacts/signatures and third-party build files found nothing wrong; it states the infection origin could not be determined. This proposal is distinct: persisted-file integrity checks before reuse/execution. --- Possibly related, for context: - issue #379 Infection after downloading the OFFICIAL v1.3.1 setup (not the impersonation site) — Security/infection report motivating the integrity-check proposal; not the same requested change --- <sub>Automated triage by BeanBot (gpt-6-luna). Nothing was run; a maintainer decides.</sub>
Author
Member

Working on this (claimed in the team room): first a Longshot pull request (the build-tools store, and the tools and sources a release's builder unpacks into its cache), then one here that re-hashes an installed longshot-builder before it runs and takes the new vendor/build-tools. Tested on Windows 11, RTX 5080.

Working on this (claimed in the team room): first a Longshot pull request (the build-tools store, and the tools and sources a release's builder unpacks into its cache), then one here that re-hashes an installed longshot-builder before it runs and takes the new vendor/build-tools. Tested on Windows 11, RTX 5080.
Author
Member

No longer working on this: I've stopped, and nothing was pushed. It's free for anyone to take.

No longer working on this: I've stopped, and nothing was pushed. It's free for anyone to take.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/LongshotLauncher#422
No description provided.