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

[PSUPCLPL-13377] - Restrictive File permission for kubelet configuration file #640

Closed
wants to merge 1 commit into from

Conversation

pranavcracker
Copy link
Collaborator

Description

  • This change is to modify the file permission for kubelet configuration file (/var/lib/kubelet/config.yaml)

Fixes # (issue)
kube-bench identifier 4.1.9

Solution

  • Set file permission for /var/lib/kubelet/config.yaml as 600 or more restrictive

Test Cases

TestCase 1

Steps:

  1. Install kubenernetes cluster or run migrate_kubemarine on existing k8s cluster with latest kubemarine distribution
  2. Download and install latest kube-bench on master and worker nodes -
  • Download kube-bench_0.7.2_linux_amd64 package from https://github.com/aquasecurity/kube-bench
  • Install downloaded pkg using sudo dpkg -i kube-bench_0.7.2_linux_amd64.deb
  1. Run kube-bench

Results:

Before After
[FAIL] 4.1.9 If the kubelet config.yaml configuration file is being used validate permissions set to 600 or more restrictive (Automated) [PASS] 4.1.9 If the kubelet config.yaml configuration file is being used validate permissions set to 600 or more restrictive (Automated)

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • Integration CI passed
  • There is no merge conflicts

Unit tests

Indicate new or changed unit tests and what they do, if any.

@pranavcracker pranavcracker changed the title [PSUPCLPL-14236] - Restrictive File permission for kubelet configuration file [PSUPCLPL-13377] - Restrictive File permission for kubelet configuration file Apr 15, 2024
@pranavcracker pranavcracker added the improvement New feature or request label Apr 15, 2024
Comment on lines +385 to +386
# modifies file permissions for kubelet configuration file
node.sudo("chmod 600 /var/lib/kubelet/config.yaml")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Although /var/lib/kubelet/config.yaml currently has 644 permissions, /var/lib/kubelet has 700. So the "effective" permissions for /var/lib/kubelet/config.yaml is 700 & 644 = 600. In particular, no user apart from root can read the file.
Can the above statement not always be true in our installation?

@pranavcracker
Copy link
Collaborator Author

Issue with inaccurate assessment for file permissions has been raised with kube-bench
aquasecurity/kube-bench#1598

@pranavcracker
Copy link
Collaborator Author

Closing this PR as we are not going to implement it at this moment.
We have raised an issue with kube-bench and we will track for it's status through aquasecurity/kube-bench#1598

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants