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

Add Authorization in Kubernetes Hardening Guide #43623

Closed
wants to merge 19 commits into from

Conversation

ashish493
Copy link

This is Authorization Section of Kubernetes hardening guide which has been under discussion in SIG-Security-Docs kubernetes/sig-security#30 .

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 21, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Oct 21, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @ashish493!

It looks like this is your first PR to kubernetes/website 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/website has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 21, 2023
@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 Oct 21, 2023
@netlify
Copy link

netlify bot commented Oct 21, 2023

Pull request preview available for checking

Built without sensitive environment variables

Name Link
🔨 Latest commit b8fc1e8
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-io-main-staging/deploys/65edc6ae2c8282000822813f
😎 Deploy Preview https://deploy-preview-43623--kubernetes-io-main-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Oct 21, 2023
ashish493 and others added 14 commits October 21, 2023 09:57
Copy link
Member

@aj11anuj aj11anuj left a comment

Choose a reason for hiding this comment

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

Some minor suggestions from my side

@ashish493
Copy link
Author

@aj11anuj Thanks, I've made some changes by checking with grammarly.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 22, 2024
@divya-mohan0209
Copy link
Contributor

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 25, 2024
Copy link
Contributor

@divya-mohan0209 divya-mohan0209 left a comment

Choose a reason for hiding this comment

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

Overarching concerns here:

  • Is this still being worked upon @ashish493? I see a lot of deviations from the Kubernetes style guide here & would recommend that you read through the style guide and make necessary changes.
  • Can we please get a technical review from SIG Security? @kubernetes/sig-security-pr-reviews ?

cc: @savitharaghunathan {Sorry, in advance, if this doesn't fall within your remit}

@k8s-ci-robot k8s-ci-robot added the sig/security Categorizes an issue or PR as relevant to SIG Security. label Jan 25, 2024
@ashish493
Copy link
Author

@divya-mohan0209 Yeah I'm currently working on the Resource Limits topic for the Hardening Guide. Thanks for the pointing out the Kubernetes style guide . I will make the changes in this doc according to it.

@divya-mohan0209
Copy link
Contributor

Hello @ashish493, checking in on the updates for the PR. Is this still being worked upon?

@ashish493
Copy link
Author

Hi @divya-mohan0209
Yeah, I've made the changes locally and will update this PR within this weekend. Sorry for the delay, was occupied in the release for my company.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign katcosgrove for approval. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ashish493
Copy link
Author

ashish493 commented Mar 10, 2024

Thanks @reylejano for reviewing, I've updated the changes according to it.

@divya-mohan0209 I've also updated the content according to Kubernetes style guide.

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.

Thanks @ashish493

We've got some quite good documentation already, which sets a bar for quality. I'd only be happy to merge this if you:

  • remove the implication that RBAC mode is always active
  • fix the snag around recommending admission controllers, rather than authz webhooks
    (it's OK to mention admission control as further reading)

and please also consider

  • fix the wrapping for the Markdown source, so that lines are typically 100 characters of fewer


<!-- body -->

### Role based access control(RBAC)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
### Role based access control(RBAC)
## Role based access control (RBAC) {#hardening-rbac}

- It is crucial to refrain from using the AlwaysAllow value in the --authorization-mode flag. This value effectively disables all authorization modes, compromising the ability to enforce the principle of least privilege.
- Assigning rights using the `system:masters` group should always be avoided, as it possesses hardcoded cluster-admin rights. These rights cannot be revoked due to their hardcoded nature in the source code. Users with `system:masters` rights will always have administrative privileges. The groups who genuinely require cluster-admin rights should be provided a binding to the cluster-admin clusterrole.

### Resources to restrict to prevent privilege escalation
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
### Resources to restrict to prevent privilege escalation
## Resources to restrict to prevent privilege escalation {#hardening-components}


To prevent privilege escalation, specific measures should be taken to restrict access to critical resources within the Kubernetes environment:

- *etcd*: A crucial component storing state information and cluster Secrets, requires careful access control. Roles should be defined for users with access limited to specific keys to prevent unauthorized access, safeguarding the entire cluster.
Copy link
Contributor

Choose a reason for hiding this comment

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

Make it clear that these aren't roles in the RBAC sense


- *etcd*: A crucial component storing state information and cluster Secrets, requires careful access control. Roles should be defined for users with access limited to specific keys to prevent unauthorized access, safeguarding the entire cluster.

- *kubelet*: The primary node agent operating on every node, necessitates secure configuration. The kubelet service should run with --anonymous-auth=false to enhance security. The node/proxy right should be granted judiciously, ensuring only necessary users have access to the Kubelet API and preventing evasion of Kubernetes admission control.
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Put command line arguments inside backticks.


- *kubelet*: The primary node agent operating on every node, necessitates secure configuration. The kubelet service should run with --anonymous-auth=false to enhance security. The node/proxy right should be granted judiciously, ensuring only necessary users have access to the Kubelet API and preventing evasion of Kubernetes admission control.

- *Kubernetes Dashboard* : a web-based UI for cluster interaction, poses a security risk if accessed by attackers. Users with elevated access to the dashboard can exploit vulnerabilities, including opening shell connections to pods and viewing Secrets. In the cluster role, grant users read-only permission to the dashboard, minimizing write access to mitigate the risk of cryptojacking attacks.
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, reword this to be good advice whether or not the cluster in question uses Kubernetes RBAC.


- *Kubernetes Secret* : An object containing sensitive information like passwords and tokens, demand controlled access. Unrestricted access to Secrets should be avoided to limit exposure to potential attackers. Admission controllers should be used to restrict access to only for necessary components.

- *Kubernetes API* : It is an HTTP API for querying and modifying cluster objects, is critical for communication. Unrestricted access to the API poses risks, including resource modifications, data breaches, and potential cluster takeovers. Implement RBAC policies with minimal verbs, ensuring that users have only the necessary permissions to interact with the Kubernetes API securely.
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, reword this to be good advice whether or not the cluster in question uses Kubernetes RBAC.


- *Kubernetes API* : It is an HTTP API for querying and modifying cluster objects, is critical for communication. Unrestricted access to the API poses risks, including resource modifications, data breaches, and potential cluster takeovers. Implement RBAC policies with minimal verbs, ensuring that users have only the necessary permissions to interact with the Kubernetes API securely.

### Admission controllers
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
### Admission controllers
## Admission control {#hardening-admission-control}


### Admission controllers

You can extend the built-in RBAC policies using the validation admission webhooks to strengthen the authorization design.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is poor advice; if you want custom authz, you should use an authorization callout: https://kubernetes.io/docs/reference/access-authn-authz/webhook/

A Kubernetes admission controller is a component of code that analyzes requests made to the Kubernetes API server and decides whether to approve them or deny them. The request gets evaluated after it has been verified and authorized by the API server before it is granted and implemented.
This is an optional feature that may only be required for large-scale clusters or where complex security is required. They can be adjustable for many different user-specific scenarios and environments. There are many open source and commercial implementations from which organizations can choose and enforce their specific restrictions.

### Auditing RBAC policies
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
### Auditing RBAC policies
## Policy review

@divya-mohan0209
Copy link
Contributor

@ashish493 : Please could you advise if you're able to address the suggestions made by @sftim in this review?

@ashish493
Copy link
Author

@divya-mohan0209 need some more time for those changes. We have sig-security-docs meeting this thursday. I will ask for some help for proceeding further. After that I will update my progress here.

@dipesh-rawat
Copy link
Member

@ashish493 What's the plan for this PR moving forward? Does it require more refinement, is it ready for review (pending review comments), or are we at the stage where this can be closed?

@ashish493
Copy link
Author

@dipesh-rawat Yeah, it needs a little refinement. I couldn't give much time to it because of some personal issues. I will definitely try to do it soon. If it comes to a point where I won't be able to do it, then I will definitely pass this on to sig-security-docs for further enhancement.

@divya-mohan0209
Copy link
Contributor

@ashish493 Thank you for your efforts! Since there has been no progress on this PR, I'll be closing it out. In the event that you'd like to pass it on to SIG Security Docs and reopen it, please feel free to do so whenever you have the bandwidth.

/close

@k8s-ci-robot
Copy link
Contributor

@divya-mohan0209: Closed this PR.

In response to this:

@ashish493 Thank you for your efforts! Since there has been no progress on this PR, I'll be closing it out. In the event that you'd like to pass it on to SIG Security Docs and reopen it, please feel free to do so whenever you have the bandwidth.

/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. language/en Issues or PRs related to English language sig/docs Categorizes an issue or PR as relevant to SIG Docs. sig/security Categorizes an issue or PR as relevant to SIG Security. 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.

9 participants