Skip to content
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

Copy PSP hostpath warning to hostpath volume docs #28252

Merged
merged 1 commit into from
Jun 28, 2021

Conversation

tallclair
Copy link
Member

@tallclair tallclair commented Jun 3, 2021

We don't currently do a good enough job warning about the dangers of HostPaths, and some of the unintuitive ways that admission policies can be bypassed.

We have a warning on the PSP documentation (https://kubernetes.io/docs/concepts/policy/pod-security-policy/#volumes-and-file-systems), but we should also call out the risks on the hostpath volume documentation directly.

Fixes #18850

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 3, 2021
@k8s-ci-robot k8s-ci-robot requested review from saad-ali and thockin June 3, 2021 18:22
@k8s-ci-robot k8s-ci-robot added language/en Issues or PRs related to English language sig/docs Categorizes an issue or PR as relevant to SIG Docs. labels Jun 3, 2021
@netlify
Copy link

netlify bot commented Jun 3, 2021

✔️ Deploy Preview for kubernetes-io-main-staging ready!

🔨 Explore the source changes: 6d0d8c0

🔍 Inspect the deploy log: https://app.netlify.com/sites/kubernetes-io-main-staging/deploys/60d3cfeb1bfea5000778882e

😎 Browse the preview: https://deploy-preview-28252--kubernetes-io-main-staging.netlify.app

@@ -529,6 +529,15 @@ See the [GlusterFS example](https://github.com/kubernetes/examples/tree/{{< para

### hostPath {#hostpath}

{{< warning >}}
There are many ways a container with unrestricted access to the host filesystem can escalate
privileges, including reading data from other containers, and abusing the credentials of system
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's an excellent idea to add that warning here. I'd remove the comma (,) after containers, although I see it matches how it was written in the other text. So not a big deal.

@kbhawkey
Copy link
Contributor

kbhawkey commented Jun 4, 2021

@kbhawkey
Copy link
Contributor

kbhawkey commented Jun 4, 2021

Thanks @tallclair .
/approve
/sig storage

@k8s-ci-robot k8s-ci-robot added sig/storage Categorizes an issue or PR as relevant to SIG Storage. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 4, 2021
@@ -529,6 +529,15 @@ See the [GlusterFS example](https://github.com/kubernetes/examples/tree/{{< para

### hostPath {#hostpath}

{{< warning >}}
There are many ways a container with unrestricted access to the host filesystem can escalate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
There are many ways a container with unrestricted access to the host filesystem can escalate
There are many ways a container with access to the host filesystem can escalate

I feel like we could elaborate further here, but I especially feel like the word "unrestricted" here could give users a false sense of security if they have done something they think of as restricting hostPath.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention that:

  • the best restriction is not allowing folk to define a hostPath volume at all?
  • even if you restrict what host paths a Pod / entire namespace can mount, there may well be attacks / risks that require careful mitigation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good recommendations. I took a stab at re-writing this. PTAL.

@tabbysable
Copy link
Member

/sig security

@k8s-ci-robot k8s-ci-robot added the sig/security Categorizes an issue or PR as relevant to SIG Security. label Jun 12, 2021
Copy link
Contributor

@sftim sftim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 24, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kbhawkey

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Contributor

@sftim sftim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like a tech review on this from SIG Security and / or SIG Storage (feel free to use own judgement).

nit: to Kubernetes users, I believe the volume type is hostPath; have I got that right?

HostPaths when possible. When a HostPath volume must be used, it should be scoped to only the
required file or directory, and mounted as ReadOnly.

If restricting HostPath acccess to specific directories through AdmissionPolicy, `volumeMounts` MUST
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use bold:

Suggested change
If restricting HostPath acccess to specific directories through AdmissionPolicy, `volumeMounts` MUST
If restricting HostPath acccess to specific directories through AdmissionPolicy, `volumeMounts` **must**

@php-coder
Copy link
Contributor

@tallclair Thank you for the PR!

/lgtm

@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 341aeaaa702feaa019f81020f3d7104ef6f7ddd3

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 28, 2021
@k8s-ci-robot k8s-ci-robot merged commit d26f9ac into kubernetes:main Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. language/en Issues or PRs related to English language lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/docs Categorizes an issue or PR as relevant to SIG Docs. sig/security Categorizes an issue or PR as relevant to SIG Security. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hostPath volume description should mention and recommend readOnly field
7 participants