-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix tar extraction add path validation to prevent escape from destination #4020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: odaysec The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @odaysec! |
Hi @odaysec. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/ok-to-test |
@odaysec: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Do you see a way where this is exposed in a way that could be exploited? Or was this just an AI recommendation? |
Description
This fixes addresses path traversal vulnerabilities in tar archive extraction within the
kind
codebase. Without proper validation, specially crafted tar entries could escape the intended extraction directory and overwrite arbitrary files on the host system. This PR introduces safeguards to ensure that extracted files remain confined to the target directory.kind/pkg/cluster/internal/logs/logs.go
Lines 77 to 97 in f20102c
Issue: Tar archive entries are written to paths derived directly from the archive without validation. Attackers could craft entries with
..
or absolute paths to escape the destination directory.filepath.Abs
andfilepath.Clean
.os.Create
,os.MkdirAll
).kind/pkg/build/nodeimage/internal/kube/tar.go
Lines 44 to 49 in f20102c
untar
, the function does not validatehdr.Name
, allowing malicious tar entries to escape the intended destination.hdr.Name
with the target directory, normalize the path usingfilepath.Clean
...
segments that lead outside the extraction directory.strings.HasPrefix(cleanedPath, cleanedDestDir + string(os.PathSeparator))
to enforce confinement.Notes Refferences
filepath
,os
, andstrings
packages.