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

Overhaul of K3s scans #1659

Merged
merged 10 commits into from
Sep 25, 2024
Merged

Overhaul of K3s scans #1659

merged 10 commits into from
Sep 25, 2024

Conversation

dereknola
Copy link
Contributor

Background

Changes

  • Overhaul existing K3s v1.24 and v1.7 scans, ensuring that
    • All checks have proper remeditation sections that give specific details on K3s, not just the general CIS scans
    • All checks use the Automated and Manual correctly, identifiying what K3s by default will handle, and when user action in needed.
    • All checks have proper audit sections that work. Several were written wrong.
  • Add K3s cis 1.8 scan with the same overhaul

Verification

k3s-cis-1.24

Tested on v1.24.17+k3s1 with the following config.yaml (standard hardening config from docs)

#/etc/rancher/k3s/config.yaml
cluster-init: true
protect-kernel-defaults: true
secrets-encryption: true
kube-controller-manager-arg:
  - 'terminated-pod-gc-threshold=10'
kubelet-arg:
  - 'streaming-connection-idle-timeout=5m'
  - 'make-iptables-util-chains=true'
  - 'event-qps=0'
  - "tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305"
kube-apiserver-arg:
  - 'audit-log-path=/var/lib/rancher/k3s/server/logs/audit.log'
  - 'audit-policy-file=/var/lib/rancher/k3s/server/audit.yaml'
  - 'audit-log-maxage=30'
  - 'audit-log-maxbackup=10'
  - 'audit-log-maxsize=100'
  - 'enable-admission-plugins=NodeRestriction,NamespaceLifecycle,ServiceAccount,PodSecurityPolicy'
Master PR
image image

k3s-cis-1.7

Tested on v1.25+k3s4 with the following config.yaml (standard hardening config from docs)

cluster-init: true
protect-kernel-defaults: true
secrets-encryption: true
kube-controller-manager-arg:
  - 'terminated-pod-gc-threshold=10'
kubelet-arg:
  - 'streaming-connection-idle-timeout=5m'
  - 'make-iptables-util-chains=true'
  - 'event-qps=0'
  - "tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305"
kube-apiserver-arg:
  - 'audit-log-path=/var/lib/rancher/k3s/server/logs/audit.log'
  - 'audit-policy-file=/var/lib/rancher/k3s/server/audit.yaml'
  - 'audit-log-maxage=30'
  - 'audit-log-maxbackup=10'
  - 'audit-log-maxsize=100'
  - 'admission-control-config-file=/var/lib/rancher/k3s/server/psa.yaml'
Master PR
image image

k3s-cis-1.8

Tested on v1.28.11+k3s1 with the same config as k3s-cis-1.7
image

Note: CIS-1.9 scans are on the TODO for RKE2 and K3s, they should be incoming within the next month or two.

Signed-off-by: Derek Nola <derek.nola@suse.com>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Copy link
Collaborator

@mozillazg mozillazg 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 your contribution! I've added some comments. Please check them when you get a chance. Thanks!

cfg/k3s-cis-1.8/policies.yaml Outdated Show resolved Hide resolved
Signed-off-by: Derek Nola <derek.nola@suse.com>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Signed-off-by: Derek Nola <derek.nola@suse.com>
@dereknola dereknola requested a review from mozillazg August 27, 2024 17:53
Copy link
Collaborator

@mozillazg mozillazg left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks for your contribution!

@dereknola
Copy link
Contributor Author

@chen-keinan can I get a review/merge on this when you have time.

@mozillazg
Copy link
Collaborator

@chen-keinan can I get a review/merge on this when you have time.

@dereknola Unfortunately, Chen is no longer working on aquasecurity. We are waiting for a new aquasecurity team member who has permission to review/merge PRs. That may take more than one week.

@deven0t
Copy link
Contributor

deven0t commented Sep 24, 2024

Hi @itaysk
can you help merging this PR.
Thanks
cc @sm171190

@deven0t
Copy link
Contributor

deven0t commented Sep 24, 2024

@dereknola we need to rebase this branch.
Please do it, so it can be merged

@itaysk
Copy link
Contributor

itaysk commented Sep 24, 2024

@afdesk can you please look at this and merge?

@afdesk
Copy link
Collaborator

afdesk commented Sep 24, 2024

yes, sure. I took a look at this PR.

@afdesk afdesk merged commit a9422a6 into aquasecurity:main Sep 25, 2024
5 checks passed
deebhatia pushed a commit to VoerEirAB/kube-bench that referenced this pull request Oct 14, 2024
* Overhaul K3s 1.X checks

Signed-off-by: Derek Nola <derek.nola@suse.com>

* Overhaul K3s 2.X Checks

Signed-off-by: Derek Nola <derek.nola@suse.com>

* Overhaul K3s 4.X checks

Signed-off-by: Derek Nola <derek.nola@suse.com>

* Overhaul K3s 5.X checks

Signed-off-by: Derek Nola <derek.nola@suse.com>

* Add K3s cis-1.8 scan

Signed-off-by: Derek Nola <derek.nola@suse.com>

* Fix K3s 1.1.10 check

Signed-off-by: Derek Nola <derek.nola@suse.com>

* Merge journalctl checks for K3s

Signed-off-by: Derek Nola <derek.nola@suse.com>

* Matched Manual/Automated to correct scoring (false/true)

Signed-off-by: Derek Nola <derek.nola@suse.com>

* Remove incorrect use of check_for_default_sa.sh script

Signed-off-by: Derek Nola <derek.nola@suse.com>

---------

Signed-off-by: Derek Nola <derek.nola@suse.com>
Co-authored-by: afdesk <work@afdesk.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants