fix: reject symlinks in ConfigMap file entries - #7966
Open
GrosQuildu wants to merge 2 commits into
Open
Conversation
Contributor
Author
|
Note that the proposed patch may be wrong, and correct idea is to just remove |
GrosQuildu
marked this pull request as ready for review
June 26, 2026 15:42
GrosQuildu
requested review from
ash-thakur-rh,
manusa and
shawkins
as code owners
June 26, 2026 15:42
GrosQuildu
added a commit
to GrosQuildu/kubernetes-client
that referenced
this pull request
Jun 26, 2026
GrosQuildu
force-pushed
the
ptp-41-configmap-symlink
branch
from
June 26, 2026 17:15
eaf70a8 to
d45fc7b
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
createConfigMapFromDirOrFilesusesNOFOLLOW_LINKSonly to decide whether a path is a directory, then reads non-directory entries withFiles.readAllBytes(file). A symlink to a regular file is accepted and the target bytes are embedded into the returned ConfigMap.The kubernetes-client does follow symlinks in general. The explicit use of
NOFOLLOW_LINKSin this single case raises a question of the expected kubernetes-client behavior in regards to symbolic links.Exploit Scenario
A low privileged user creates a symlink
staging/app.properties -> /etc/shadow.The symlink is resolved by kubernetes-client. Unexpected file is leaked.
Threat Model
Should kubernetes-client not follow symlinks? Or should this behavior be configurable?
Note that the scope of the question is huge:
PodUpload.uploadandPodOperationsImpl.copymay resolve symlinks on remote podsFOLLOW_LINKSFix
If the client is supposed to follow symbolic links, then removing
NOFOLLOW_LINKSfromcreateConfigMapFromDirOrFilesis recommended for consistency, and an entry to threat model is recommended.If client should not follow symlinks, then harden
createConfigMapFromDirOrFilesand plan to harden other functionalities around symbolic links handling.Note that the proposed fix still have race condition (time-of-check-time-of-use) issues.
Paweł Płatek from Trail of Bits in collaboration with OpenAI.