Harden bin/example-image and bin/load against shell injection - #76
Merged
Merged
Conversation
`bin/example-image` ran `git ls-files` through a shell with the checkout path in the command string, and `bin/load` put its scenario, duration and thread count into a `bash -c` string run in the driver container. A value containing shell syntax ran as a command. Pass these values to the commands as arguments. [Fix #33]
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.
Motivation
bin/example-imagebuilds the example cell image.bin/loadboots a cell image and drives a load scenario against it from a second container, the driver. They are developer and CI helpers. Neither is on the production conversion path.Each passed an input through a shell:
bin/example-imagelisted each gem's files withgit -C #{REPO} ls-files #{gem}in backticks (bin/example-image:60).REPOis the checkout path. A path that contained shell syntax such as$(...)ran as a command on the host, and a path with a space broke the listing.bin/loadbuilt the driver'sbash -cstring with$SCENARIO $SECONDS_ARG $THREADSinside it (bin/load:62-66). Shell syntax in any of those arguments ran as a command in the driver container.The person running the script supplies these values, so the impact is low. The purple-team assessment of 2026-08-22 rated it Low (
HC-PT-014).Details
bin/example-imagerunsgitthroughIO.popenwith an argument array.bin/loadpasses the values as positional parameters to a fixedbash -cprogram, which hands them toexamples/loadas"$@".examples/gateruns each script against a fakedockerwith$(touch injected)in its inputs. Each check fails if the file appears, and fails against the scripts onmaster.Additional information
The issue also suggests validating the numeric inputs in
bin/loadand pinning the driver image. This PR does neither.examples/loadalready rejects a non-numeric duration or thread count withFloat()andInteger().bin/conformanceuses the same unpinnedruby:3.4driver default, so pinning belongs in a separate change that covers both scripts.Fixes #33