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
validate host paths on the kubelet for backsteps #47290
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ import ( | |
"k8s.io/kubernetes/pkg/util" | ||
"k8s.io/kubernetes/pkg/volume" | ||
"k8s.io/kubernetes/pkg/volume/util/volumehelper" | ||
volumevalidation "k8s.io/kubernetes/pkg/volume/validation" | ||
"k8s.io/kubernetes/third_party/forked/golang/expansion" | ||
) | ||
|
||
|
@@ -138,6 +139,15 @@ func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, h | |
return nil, err | ||
} | ||
if mount.SubPath != "" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jhorwit2 did you ever track down whether we need to be concerned with traversals in mount.MountPath? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't feel like that's a concern. That's the path within the container where the volume is mounted. Escaping out of that directory only yields you directories in the container you can already access; not extra info on the host. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. conceptually, that's what I would expect, but I don't know enough about the implementation to know if that is actually the case. would like an ack on that from @kubernetes/sig-storage-pr-reviews There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This question is also outstanding, correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jhorwit2 is right, |
||
if filepath.IsAbs(mount.SubPath) { | ||
return nil, fmt.Errorf("error SubPath `%s` must not be an absolute path", mount.SubPath) | ||
} | ||
|
||
err = volumevalidation.ValidatePathNoBacksteps(mount.SubPath) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to provision SubPath `%s`: %v", mount.SubPath, err) | ||
} | ||
|
||
fileinfo, err := os.Lstat(hostPath) | ||
if err != nil { | ||
return nil, err | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function should be uppercase, as being called in other package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is, there is a similar method in the volume package that is getting called