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

OSDOCS-2711 Information on project volume permission issues for Windows pods #37587

Closed

Conversation

@codyhoag codyhoag added this to the Next Release milestone Oct 15, 2021
@openshift-ci openshift-ci bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 15, 2021
@netlify
Copy link

netlify bot commented Oct 15, 2021

✔️ Deploy Preview for osdocs ready!

🔨 Explore the source changes: c488988

🔍 Inspect the deploy log: https://app.netlify.com/sites/osdocs/deploys/616f2d1e74efeb0008aa8f66

😎 Browse the preview: https://deploy-preview-37587--osdocs.netlify.app/openshift-enterprise/latest/nodes/containers/nodes-containers-projected-volumes

@codyhoag
Copy link
Contributor Author

@aravindhp PTAL

Copy link

@aravindhp aravindhp left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, @codyhoag

/cc @deads2k

modules/nodes-containers-projected-volumes-creating.adoc Outdated Show resolved Hide resolved
modules/nodes-containers-projected-volumes-creating.adoc Outdated Show resolved Hide resolved
modules/nodes-containers-projected-volumes-creating.adoc Outdated Show resolved Hide resolved
@openshift-ci openshift-ci bot requested a review from deads2k October 15, 2021 18:00
@codyhoag codyhoag force-pushed the windows-permission-handling-issue branch from cd869c7 to 553ece2 Compare October 15, 2021 19:19
@openshift-ci openshift-ci bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 15, 2021
@codyhoag codyhoag force-pushed the windows-permission-handling-issue branch from 553ece2 to 23590aa Compare October 15, 2021 19:20
Copy link

@aravindhp aravindhp left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 15, 2021
@codyhoag
Copy link
Contributor Author

@sgaoshang please verify from a QE perspective. Thanks!

@aravindhp
Copy link

@sgaoshang please verify from a QE perspective. Thanks!

Also adding @rrasouli

@rrasouli
Copy link

/lgtm

@codyhoag codyhoag force-pushed the windows-permission-handling-issue branch from 149b18e to 62c9f45 Compare October 18, 2021 14:44
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Oct 18, 2021
@openshift-ci
Copy link

openshift-ci bot commented Oct 18, 2021

New changes are detected. LGTM label has been removed.

@codyhoag codyhoag added the peer-review-needed Signifies that the peer review team needs to review this PR label Oct 18, 2021
Sddl : O:BAG:SYD:AI(A;ID;FA;;;SY)(A;ID;FA;;;BA)(A;ID;0x1200a9;;;BU)
----

This implies all administrator users, like someone with the `ContainerAdministrator` role, will have read, write, and execute access, while non-administrator users will have read and execute access.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/will have/has in both places.

Copy link
Contributor

Choose a reason for hiding this comment

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

s/implies/indicates

[id="file-permission-handling-for-windows-pods_{context}"]
== File permission handling for Windows pods

When the `RunAsUser` permission is set in the security context of a Linux-based pod, the projected files have the correct permissions set, including container user ownership. However, this is not the case for Windows pods when the `RunAsUsername` permission is set, due to differences in the way user accounts are managed in Windows. Windows stores and manages local user and group accounts in a database file called Security Account Manager (SAM). This database is not shared between the Windows container host and the running containers. This prevents the kubelet from setting correct ownership on the files in the projected volume.
Copy link
Contributor

Choose a reason for hiding this comment

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

Might I suggest moving the due to differences in the way user accounts are managed in Windows. Windows stores and manages local user and group accounts in a database file called Security Account Manager (SAM). This database is not shared between the Windows container host and the running containers. sentence to the end?

And going with something like However, this is not the case for Windows pods. If the RunAsUsername permission is set, the kubelet is prevented from setting correct ownership on the files in the projected volume. This is due to differences...

I wonder if a typical user would be more concerned with what happens than why?


When the `RunAsUser` permission is set in the security context of a Linux-based pod, the projected files have the correct permissions set, including container user ownership. However, this is not the case for Windows pods when the `RunAsUsername` permission is set, due to differences in the way user accounts are managed in Windows. Windows stores and manages local user and group accounts in a database file called Security Account Manager (SAM). This database is not shared between the Windows container host and the running containers. This prevents the kubelet from setting correct ownership on the files in the projected volume.

This problem can get exacerbated when used in conjunction with a hostPath volume where best practices are not followed. For example, giving a pod access to the `C:\var\lib\kubelet\pods\` folder results in that pod being able to access service account tokens from other pods.
Copy link
Contributor

@mburke5678 mburke5678 Oct 18, 2021

Choose a reason for hiding this comment

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

I like the wording in the upstream issue. Very simple and clear: _In addition, if a Windows pod is created with a Projected Volume and RunAsUser set, the Pod will be stuck at the ContainerCreating phase. (As much as I like the word exacerbate!)

Copy link
Contributor Author

@codyhoag codyhoag Oct 19, 2021

Choose a reason for hiding this comment

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

These are two separate problems:

  1. A security risk is exposed with a hostPath volume
  2. When a Windows pod is created with a PV and RunAsUser permission, pod gets stuck.

So I don't think we want to replace one with the other. Item 2 is expressed in the next paragraph.


This implies all administrator users, like someone with the `ContainerAdministrator` role, will have read, write, and execute access, while non-administrator users will have read and execute access.

Creating a Windows pod with the `RunAsUser` and `RunAsUsername` permissions in its security context results in the pod being stuck in the `ContainerCreating` phase. To handle this scenario, a workaround provided in link:https://bugzilla.redhat.com/show_bug.cgi?id=1971745[BZ#1971745] has been introduced in {product-title}. This forces the file permission handling in projected service account volumes set in the security context of the pod to not be honored for projected volumes on Windows. Note that this workaround for Windows pods is how file permission handling used to work for all pod types prior to {product-title} 4.7.
Copy link
Contributor

Choose a reason for hiding this comment

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

To handle this scenario, a workaround provided in BZ#1971745

I read this to mean that there is a manual workaround, steps that the user needs to perform, in BZ#1971745. But I don't see one. Is there anything the user needs to do here?


This implies all administrator users, like someone with the `ContainerAdministrator` role, will have read, write, and execute access, while non-administrator users will have read and execute access.

Creating a Windows pod with the `RunAsUser` and `RunAsUsername` permissions in its security context results in the pod being stuck in the `ContainerCreating` phase. To handle this scenario, a workaround provided in link:https://bugzilla.redhat.com/show_bug.cgi?id=1971745[BZ#1971745] has been introduced in {product-title}. This forces the file permission handling in projected service account volumes set in the security context of the pod to not be honored for projected volumes on Windows. Note that this workaround for Windows pods is how file permission handling used to work for all pod types prior to {product-title} 4.7.
Copy link

@aravindhp aravindhp Oct 19, 2021

Choose a reason for hiding this comment

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

@codyhoag I realize this issue can happen by just setting RunAsUser. So we should remove and RunAsUsername.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aravindhp we state this sentence earlier:

When the Windows equivalent RunAsUsername permission is set, the kubelet is prevented from setting correct ownership on the files in the projected volume.

Can we center this issue around OpenShift auto-applying the RunAsUser to Windows pods? It seems that's the main reason for this.

I'm beginning to lean towards making this a known issue only. We're providing a lot of background info that I'm not sure a regular user is interested in. It may make more sense to simply state the current behavior and brief implemented workaround in OCP, and let the linked BZ do any deep dive into the nitty gritty details.

Would something like this in the known issues be acceptable?

{product-title} applies the `RunAsUser` security context to all pods irrespective of its
operating system. This means Windows pods automatically have the `RunAsUser`
permission applied to its security context. When the `RunAsUser` permission is set
in the security context of a Linux-based pod, the projected files have the correct
permissions set, including container user ownership. However, when the `RunAsUser`
permission is set in a Windows pod, the kubelet is prevented from setting correct
ownership on the files in the projected volume. In addition, if a Windows pod is created
with a projected volume and the `RunAsUser` permission set, the pod gets stuck in the
`ContainerCreating` phase.

This problem can get exacerbated when used in conjunction with a hostPath volume
where best practices are not followed. For example, giving a pod access to the
`C:\var\lib\kubelet\pods\` folder results in that pod being able to access service account
tokens from other pods.

To handle this issue, {product-title} forces the file permission handling in projected
service account volumes set in the security context of the pod to not be honored for
projected volumes on Windows (link:https://bugzilla.redhat.com/show_bug.cgi?id=1971745[BZ#1971745]).
Note that this behavior for Windows pods is how file permission handling used to work for
all pod types prior to {product-title} 4.7.

Choose a reason for hiding this comment

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

Can we center this issue around OpenShift auto-applying the RunAsUser to Windows pods? It seems that's the main reason for this.

OpenShift having an admission controller that auto applied RunAsUser was the only reason we discovered the main underlying security issue i.e. RunAsUsername for Windows Pods are not honored. So we really need to make the user aware of what the result of using RunAsUsername in conjunction to a projected volume. This is also why we need to explain what the default permission model is for projected volumes for Windows Pods. We don't want users thinking that they are getting the same behavior as with Linux Pods and `RunAsUser. But I am fine if you want to pare down the technical details.

@codyhoag
Copy link
Contributor Author

codyhoag commented Nov 2, 2021

This has been split up across several PRs (e.g., #38157, #37811, and #37061). Because of this, I'm closing this PR.

@codyhoag codyhoag closed this Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch/enterprise-4.7 branch/enterprise-4.8 branch/enterprise-4.9 branch/enterprise-4.10 peer-review-needed Signifies that the peer review team needs to review this PR size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants