fix: run the binary that was verified, not whatever PATH resolves - #21
Open
bradAGI wants to merge 2 commits into
Open
fix: run the binary that was verified, not whatever PATH resolves#21bradAGI wants to merge 2 commits into
bradAGI wants to merge 2 commits into
Conversation
The scanner is the whole product here — it resolves a release, verifies it, runs the engine, scales the score, and decides whether the build fails — and until now nothing checked any of it. A regression in the gate logic or in the jq that reads the engine's ScanResult would ship silently. The suite drives the real scan/trustabl-scan.sh. Each test builds an actual gzipped release tarball containing a stub engine and a real checksums.txt over it, then puts a stub curl on PATH that serves that directory by URL basename. The download, sha256 verification, extraction and invocation therefore all run unmodified; only the network and the engine binary are substituted. The fixtures are unmodified output from a real `trustabl scan` (engine v0.1.7), so the assertions pin the scanner against the ScanResult shape the engine actually emits rather than a hand-written approximation of it.
Nothing checked that the extracted archive actually contained `trustabl`. The script untarred, prepended the directory to PATH, and invoked the bare name. That makes the checksum verification conditional on something it does not check. If the archive is missing the binary — a renamed asset, a truncated upload, a substituted tarball — the name resolves against the rest of PATH instead. In a CodeBuild image with no trustabl installed that is a "command not found" and a scan reporting whatever the fallback path produces; in an image that carries one, it silently runs a different binary. Either way the checksum attests to a file nobody executed. The extracted binary is now asserted present and executable before anything runs, and both scans invoke it by absolute path rather than by name, so PATH resolution cannot substitute another. Exit 2: no scan happened. This also makes the invocation independent of where $DEST sits on PATH, which matters if the PATH prepend is ever narrowed.
Collaborator
|
Thanks @bradAGI. Approving, and this is complementary to #7 rather than overlapping it. Verifying the archive only means something if the binary that runs is the one that came out of it. Without this check, an archive missing One note on sequencing: this and #7 touch adjacent lines in the same region, so whichever lands second needs a rebase. Not a problem with the change, just the shape of this queue. |
sairenchristianbuerano
approved these changes
Aug 27, 2026
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.
The gap
Untar, prepend to
PATH, invoke the bare name. Nothing checks that the archive actually containedtrustabl.That makes the checksum verification conditional on something it does not verify. The script confirms the archive hashes correctly, then runs a binary it located by name. If the archive is missing the binary — a renamed asset, a truncated upload, a substituted tarball — the name resolves against the rest of
PATHinstead:command not found, and the scan proceeds to report whatever the fallback produces.Either way the checksum attests to a file nobody executed.
Demonstrated with an archive that extracts to
trustabl-linuxinstead oftrustabl:Exit 0, a full readiness report, and
trustabl.envpublished — from a binary that was never in the verified archive.The fix
Two halves, and the second is the one that matters:
PATHresolution cannot substitute another.Exit
2— no scan happened, so perdocs/EVALUATION.mdthe output should not be trusted.The absolute-path invocation also decouples this from where
$DESTsits onPATH, which matters if that prepend is ever narrowed — as #8 proposes, for good reasons.Verification
all 16 test(s) passed, and the normal path still works end to end against the real engine binary — real tarball, real sha256 check, real extraction:Relationship to #7
#7 makes checksum verification mandatory. This closes the other half: verification is only worth having if the verified file is the one that runs. They are independent and can merge in either order.