fix(security): command injection in registry.testRegistry / testRegistryById#4875
Merged
Conversation
…yById remote path
The remote (execAsyncRemote) path built `echo ${password} | docker ${args.join(" ")}`
with the password, registryUrl and username interpolated unescaped, so a password
like `pw; whoami` ran arbitrary commands as root on the target server. Reuse
safeDockerLoginCommand (already used by create/update), which shell-escapes each
field and feeds the password via --password-stdin. The local argv+stdin path was
already safe.
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.
Fixes GHSA-w6r4-f26v-8g36.
Problem
The remote (
execAsyncRemote) path of bothregistry.testRegistryandregistry.testRegistryByIdbuilt the docker login command by interpolating the password directly into a shell string:`echo ${input.password} | docker ${args.join(" ")}`password(andregistryUrl/username, which flow intoargs) were onlyz.string().min(1), so a password likepw; whoami; #executed arbitrary commands as root on the target server via SSH. Any user withregistry:readcould trigger it.Fix
Reuse
safeDockerLoginCommand(already used bycreateRegistry/updateRegistry), which shell-escapes registry/user/password and feeds the password through--password-stdin. The local path already usedexecFileAsyncwith an argv array + stdin and was safe.Verification
safeDockerLoginCommandoutput: every payload (; whoami,$(), backtick,' && rm) collapses to a single literalprintf %sargument; legit login command unchanged.testRegistrywith an injected password did not execute the payload (no marker file created).Closes GHSA-w6r4-f26v-8g36.