fix: prevent pod file-transfer option injection - #7964
Open
GrosQuildu wants to merge 2 commits into
Open
Conversation
GrosQuildu
marked this pull request as ready for review
June 26, 2026 15:16
GrosQuildu
requested review from
ash-thakur-rh,
manusa and
shawkins
as code owners
June 26, 2026 15:16
GrosQuildu
added a commit
to GrosQuildu/kubernetes-client
that referenced
this pull request
Jun 26, 2026
GrosQuildu
force-pushed
the
fix-pod-file-transfer-option-injection
branch
from
June 26, 2026 17:14
a954574 to
ef7da50
Compare
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.
Description
The
shellQuotemethod is used in a few functionalities to escape strings before they are used in shell commands. The method surrounds input string with single quotes chars and escapes the quotes inside the string.However, the
shellQuotedoes not account for argument injection via--prefix.The vulnerable methods are:
PodOperationsImpl.readTarPodOperationsImpl.readFileCommandPodUpload.uploadPodUpload.createExecCommandForUploadExploit Scenario
An attacker exploits an artifact-download service that uses kubernetes-client to copy one caller-selected path out of a build pod. The service intends to allow a caller to download one artifact path, possibly denylisting some files, but it passes the caller's value directly to the
dirandcopypod operation methods.The attacker creates
/tmp/fabric8-listin the pod with paths to readable files, such as a service-account token and application configuration, then requests the source path--files-from=/tmp/fabric8-list. The shell-quoted command still invokestarwith that value as one dash-prefixed argv entry, sotarreads the list and archives every named file. The service then returns files outside the intended artifact path to the attacker.The attacker's requested path then reaches the vulnerable
readTarcommand throughdir(...).copy(...):The same source path also reaches
readTarthroughdir(...).read():The following shell script demonstrates the pod-side command behavior reached by those API calls:
PoC code that demonstrates the exact single-quoted tar option injection used in the exploit scenario.
Note that more dangerous tar arguments like
--checkpoint-action=execand--use-compress-program=exist, but we were unable to exploit them.Threat Model
Inputs to the methods performing shell-quoting may or may not be untrusted, depending on the specific setup. However, the methods should not allow to execute unexpected actions via argument injections. Therefore, the fix below is recommended and no threat model notes are needed.
Paweł Płatek from Trail of Bits in collaboration with OpenAI.