Skip to content

Commit 6069d6e

Browse files
chore(kubernetes): enhance metadata for apiserver service (#9674)
Co-authored-by: Daniel Barranquero <danielbo2001@gmail.com>
1 parent 9a4167d commit 6069d6e

File tree

30 files changed

+466
-328
lines changed

30 files changed

+466
-328
lines changed

prowler/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to the **Prowler SDK** are documented in this file.
44

5+
## [5.20.0] (Prowler UNRELEASED)
6+
7+
### 🔄 Changed
8+
9+
- Update Kubernetes API server checks metadata to new format [(#9674)](https://github.com/prowler-cloud/prowler/pull/9674)
10+
11+
---
12+
513
## [5.19.0] (Prowler v5.19.0)
614

715
### 🚀 Added

prowler/providers/kubernetes/services/apiserver/apiserver_always_pull_images_plugin/apiserver_always_pull_images_plugin.metadata.json

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
{
22
"Provider": "kubernetes",
33
"CheckID": "apiserver_always_pull_images_plugin",
4-
"CheckTitle": "Ensure that the admission control plugin AlwaysPullImages is set",
4+
"CheckTitle": "API server pod has AlwaysPullImages admission control plugin enabled",
55
"CheckType": [],
66
"ServiceName": "apiserver",
77
"SubServiceName": "",
88
"ResourceIdTemplate": "",
99
"Severity": "medium",
10-
"ResourceType": "KubernetesAPIServer",
10+
"ResourceType": "Pod",
1111
"ResourceGroup": "container",
12-
"Description": "This check verifies that the AlwaysPullImages admission control plugin is enabled in the Kubernetes API server. This plugin ensures that every new pod always pulls the required images, enforcing image access control and preventing the use of possibly outdated or altered images.",
13-
"Risk": "Without AlwaysPullImages, once an image is pulled to a node, any pod can use it without any authorization check, potentially leading to security risks.",
14-
"RelatedUrl": "https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#alwayspullimages",
12+
"Description": "**Kubernetes API server** admission configuration includes **AlwaysPullImages**, which mutates new Pods to set `imagePullPolicy=Always` so container images are fetched from the registry at startup using the pod's credentials.",
13+
"Risk": "Without **AlwaysPullImages**, nodes can run cached images without a fresh registry pull, bypassing credential checks.\n- Unauthorized use of private images (confidentiality)\n- Stale or tampered images deployed (integrity)\n- Vulnerable images persist, widening attack surface (availability)",
14+
"RelatedUrl": "",
15+
"AdditionalURLs": [
16+
"https://cjyabraham.gitlab.io/docs/reference/command-line-tools-reference/kube-apiserver/",
17+
"https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers",
18+
"https://blog.codefarm.me/2021/12/15/kubernetes-admission-controllers/",
19+
"https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#alwayspullimages"
20+
],
1521
"Remediation": {
1622
"Code": {
17-
"CLI": "--enable-admission-plugins=...,AlwaysPullImages,...",
18-
"NativeIaC": "https://docs.prowler.com/checks/kubernetes/kubernetes-policy-index/ensure-that-the-admission-control-plugin-alwayspullimages-is-set#kubernetes",
19-
"Other": "",
23+
"CLI": "",
24+
"NativeIaC": "",
25+
"Other": "1. SSH to a control-plane node\n2. Edit /etc/kubernetes/manifests/kube-apiserver.yaml\n3. In spec.containers[0].command or args, ensure the flag includes AlwaysPullImages, e.g.: --enable-admission-plugins=<existing>,AlwaysPullImages\n4. Save the file; the kubelet will automatically restart the API server with the updated flag",
2026
"Terraform": ""
2127
},
2228
"Recommendation": {
23-
"Text": "Configure the API server to use the AlwaysPullImages admission control plugin to ensure image security and integrity.",
24-
"Url": "https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers"
29+
"Text": "Enable `AlwaysPullImages` on the API server.\n\nApply defense in depth: restrict pulls to trusted registries, enforce least-privilege image pull secrets, sign and scan images, and prefer immutable digests to prevent drift and ensure verified content.",
30+
"Url": "https://hub.prowler.com/check/apiserver_always_pull_images_plugin"
2531
}
2632
},
2733
"Categories": [

prowler/providers/kubernetes/services/apiserver/apiserver_anonymous_requests/apiserver_anonymous_requests.metadata.json

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
11
{
22
"Provider": "kubernetes",
33
"CheckID": "apiserver_anonymous_requests",
4-
"CheckTitle": "Ensure that the --anonymous-auth argument is set to false",
4+
"CheckTitle": "API server pod has anonymous-auth disabled",
55
"CheckType": [],
66
"ServiceName": "apiserver",
77
"SubServiceName": "",
88
"ResourceIdTemplate": "",
99
"Severity": "high",
10-
"ResourceType": "KubernetesAPIServer",
10+
"ResourceType": "Pod",
1111
"ResourceGroup": "container",
12-
"Description": "Disable anonymous requests to the API server. When enabled, requests that are not rejected by other configured authentication methods are treated as anonymous requests, which are then served by the API server. Disallowing anonymous requests strengthens security by ensuring all access is authenticated.",
13-
"Risk": "Enabling anonymous access to the API server can expose the cluster to unauthorized access and potential security vulnerabilities.",
14-
"RelatedUrl": "https://kubernetes.io/docs/admin/authentication/#anonymous-requests",
12+
"Description": "**Kubernetes API server** anonymous authentication configuration, identified by `--anonymous-auth=true`. With this setting, unauthenticated requests are mapped to `system:anonymous` and processed by the server.",
13+
"Risk": "**Anonymous API access** exposes cluster details for **reconnaissance** and enumeration, eroding confidentiality.\n\nIf **RBAC** is misconfigured, unauthenticated users may read sensitive data or trigger actions, impacting integrity. Floods of anonymous requests can also reduce **availability**.",
14+
"RelatedUrl": "",
15+
"AdditionalURLs": [
16+
"https://cloud.hacktricks.wiki/en/pentesting-cloud/kubernetes-security/pentesting-kubernetes-services/index.html",
17+
"https://docs.kics.io/develop/queries/kubernetes-queries/1de5cc51-f376-4638-a940-20f2e85ae238/",
18+
"https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/"
19+
],
1520
"Remediation": {
1621
"Code": {
17-
"CLI": "--anonymous-auth=false",
18-
"NativeIaC": "https://docs.prowler.com/checks/kubernetes/kubernetes-policy-index/ensure-that-the-anonymous-auth-argument-is-set-to-false-1#kubernetes",
19-
"Other": "",
22+
"CLI": "",
23+
"NativeIaC": "",
24+
"Other": "1. SSH to the control plane node\n2. Edit the API server static Pod manifest:\n sudo vi /etc/kubernetes/manifests/kube-apiserver.yaml\n3. In spec.containers[].command or args, remove \"--anonymous-auth=true\" or replace it with:\n ```\n - --anonymous-auth=false\n ```\n4. Save the file; the kubelet will automatically restart the API server with the updated flag",
2025
"Terraform": ""
2126
},
2227
"Recommendation": {
23-
"Text": "Ensure the --anonymous-auth argument in the API server is set to false. This will reject all anonymous requests, enforcing authenticated access to the server.",
24-
"Url": "https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/"
28+
"Text": "Require **authenticated access** for all API requests and avoid reliance on anonymous users. Enforce **least privilege RBAC** for explicit principals only. *If health checks must be public*, restrict to minimal paths and methods. Add **network segmentation**, mutual TLS, and **audit logging** for defense in depth.",
29+
"Url": "https://hub.prowler.com/check/apiserver_anonymous_requests"
2530
}
2631
},
2732
"Categories": [
28-
"trustboundaries"
33+
"cluster-security",
34+
"identity-access"
2935
],
3036
"DependsOn": [],
3137
"RelatedTo": [],

prowler/providers/kubernetes/services/apiserver/apiserver_audit_log_maxage_set/apiserver_audit_log_maxage_set.metadata.json

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
11
{
22
"Provider": "kubernetes",
33
"CheckID": "apiserver_audit_log_maxage_set",
4-
"CheckTitle": "Ensure that the --audit-log-maxage argument is set to 30 or as appropriate",
4+
"CheckTitle": "API server pod has --audit-log-maxage set to 30 (or the cluster-configured value)",
55
"CheckType": [],
66
"ServiceName": "apiserver",
77
"SubServiceName": "",
88
"ResourceIdTemplate": "",
99
"Severity": "medium",
10-
"ResourceType": "KubernetesAPIServer",
10+
"ResourceType": "Pod",
1111
"ResourceGroup": "container",
12-
"Description": "This check ensures that the Kubernetes API server is configured with an appropriate audit log retention period. Setting --audit-log-maxage to 30 or as per business requirements helps in maintaining logs for sufficient time to investigate past events.",
13-
"Risk": "Without an adequate log retention period, there may be insufficient audit history to investigate and analyze past events or security incidents.",
14-
"RelatedUrl": "https://kubernetes.io/docs/concepts/cluster-administration/audit/",
12+
"Description": "**Kubernetes API server** audit logging retention is governed by `--audit-log-maxage`. This evaluates whether the configured value (e.g., `30` days) is set consistently across API server containers to retain audit events for a sufficient period.",
13+
"Risk": "**Short audit retention** limits visibility into historical API actions. Credential abuse, privilege escalation, or cluster tampering may evade detection, and investigations lack evidence for timeline reconstruction-degrading data **integrity** and confidentiality through undetected unauthorized changes and exfiltration.",
14+
"RelatedUrl": "",
15+
"AdditionalURLs": [
16+
"https://rke.docs.rancher.com/config-options/audit-log",
17+
"https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/",
18+
"https://kubernetes.io/docs/concepts/cluster-administration/audit/",
19+
"https://kubernetes.io/docs/tasks/debug/debug-cluster/audit/"
20+
],
1521
"Remediation": {
1622
"Code": {
17-
"CLI": "--audit-log-maxage=30",
18-
"NativeIaC": "https://docs.prowler.com/checks/kubernetes/kubernetes-policy-index/ensure-that-the-audit-log-maxage-argument-is-set-to-30-or-as-appropriate#kubernetes",
19-
"Other": "",
23+
"CLI": "",
24+
"NativeIaC": "",
25+
"Other": "1. SSH to a control plane node\n2. Edit the API server static pod manifest: /etc/kubernetes/manifests/kube-apiserver.yaml\n3. Under spec.containers[0].command add:\n - --audit-log-maxage=30\n (Use your cluster-required value instead of 30 if different.)\n4. Save the file; the kubelet will restart the API server automatically",
2026
"Terraform": ""
2127
},
2228
"Recommendation": {
23-
"Text": "Configure the API server audit log retention period to retain logs for at least 30 days or as per your organization's requirements.",
24-
"Url": "https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/"
29+
"Text": "Set `--audit-log-maxage` to at least `30` days (or your policy) to support **forensics**. Align rotation with `--audit-log-maxbackup` and `--audit-log-maxsize`. Forward logs to a tamper-resistant central store, enforce **least privilege** on access, and periodically validate retention coverage.",
30+
"Url": "https://hub.prowler.com/check/apiserver_audit_log_maxage_set"
2531
}
2632
},
2733
"Categories": [
28-
"logging"
34+
"logging",
35+
"forensics-ready"
2936
],
3037
"DependsOn": [],
3138
"RelatedTo": [],

prowler/providers/kubernetes/services/apiserver/apiserver_audit_log_maxbackup_set/apiserver_audit_log_maxbackup_set.metadata.json

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
11
{
22
"Provider": "kubernetes",
33
"CheckID": "apiserver_audit_log_maxbackup_set",
4-
"CheckTitle": "Ensure that the --audit-log-maxbackup argument is set to 10 or as appropriate",
4+
"CheckTitle": "API server pod has --audit-log-maxbackup set to 10 or the configured value",
55
"CheckType": [],
66
"ServiceName": "apiserver",
77
"SubServiceName": "",
88
"ResourceIdTemplate": "",
99
"Severity": "medium",
10-
"ResourceType": "KubernetesAPIServer",
10+
"ResourceType": "Pod",
1111
"ResourceGroup": "container",
12-
"Description": "This check ensures that the Kubernetes API server is configured with an appropriate number of audit log backups. Setting --audit-log-maxbackup to 10 or as per business requirements helps maintain a sufficient log backup for investigations or analysis.",
13-
"Risk": "Without an adequate number of audit log backups, there may be insufficient log history to investigate past events or security incidents.",
14-
"RelatedUrl": "https://kubernetes.io/docs/concepts/cluster-administration/audit/",
12+
"Description": "**Kubernetes API server audit logging** uses `--audit-log-maxbackup` to set how many rotated audit log files are kept. This evaluates whether that value is explicitly configured as `10` or an approved organizational setting across API server containers.",
13+
"Risk": "Insufficient **audit log retention** reduces **accountability** and hampers **forensics**. Limited backups cause older events to be overwritten, letting attackers hide activity until rotation. This undermines the **confidentiality**, **integrity**, and **availability** of evidence needed for incident response.",
14+
"RelatedUrl": "",
15+
"AdditionalURLs": [
16+
"https://kubernetes.io/docs/concepts/cluster-administration/audit/",
17+
"https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/",
18+
"https://docs.kics.io/2.0.0/queries/kubernetes-queries/768aab52-2504-4a2f-a3e3-329d5a679848/"
19+
],
1520
"Remediation": {
1621
"Code": {
17-
"CLI": "--audit-log-maxbackup=10",
18-
"NativeIaC": "https://docs.prowler.com/checks/kubernetes/kubernetes-policy-index/ensure-that-the-audit-log-maxbackup-argument-is-set-to-10-or-as-appropriate#kubernetes",
19-
"Other": "",
22+
"CLI": "",
23+
"NativeIaC": "",
24+
"Other": "1. SSH to each control plane node\n2. Edit the static Pod manifest: /etc/kubernetes/manifests/kube-apiserver.yaml\n3. Under spec.containers[0].command, add or update this flag:\n - --audit-log-maxbackup=10\n4. Save the file; the kubelet will restart the API server automatically",
2025
"Terraform": ""
2126
},
2227
"Recommendation": {
23-
"Text": "Configure the API server audit log backup retention to 10 or as per your organization's requirements.",
24-
"Url": "https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/"
28+
"Text": "Establish explicit **audit log retention**. Set `--audit-log-maxbackup` to `10` or higher based on data sensitivity, and align with `--audit-log-maxsize` and `--audit-log-maxage`. Forward logs to centralized, immutable storage, restrict access, and monitor rotation. Apply **defense in depth** and **least privilege** to audit systems.",
29+
"Url": "https://hub.prowler.com/check/apiserver_audit_log_maxbackup_set"
2530
}
2631
},
2732
"Categories": [

prowler/providers/kubernetes/services/apiserver/apiserver_audit_log_maxsize_set/apiserver_audit_log_maxsize_set.metadata.json

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
{
22
"Provider": "kubernetes",
33
"CheckID": "apiserver_audit_log_maxsize_set",
4-
"CheckTitle": "Ensure that the --audit-log-maxsize argument is set to 100 or as appropriate",
4+
"CheckTitle": "API server pod has --audit-log-maxsize set to 100 MB or the configured value",
55
"CheckType": [],
66
"ServiceName": "apiserver",
77
"SubServiceName": "",
88
"ResourceIdTemplate": "",
99
"Severity": "medium",
10-
"ResourceType": "KubernetesAPIServer",
10+
"ResourceType": "Pod",
1111
"ResourceGroup": "container",
12-
"Description": "This check ensures that the Kubernetes API server is configured with an appropriate audit log file size limit. Setting --audit-log-maxsize to 100 MB or as per business requirements helps manage the size of log files and prevents them from growing excessively large.",
13-
"Risk": "Without an appropriate audit log file size limit, log files can grow excessively large, potentially leading to storage issues and difficulty in log analysis.",
14-
"RelatedUrl": "https://kubernetes.io/docs/concepts/cluster-administration/audit/",
12+
"Description": "**Kubernetes API server** uses `--audit-log-maxsize` to cap audit log files. The check expects `100 MB` or a policy-approved value, indicating rotation occurs when a log reaches that size.",
13+
"Risk": "Absent a proper cap, audit logs can grow unchecked, exhausting disk and degrading API server **availability**. Oversized or unbounded logs impede **forensics** and may overwrite recent events during rotation, undermining **integrity** and accountability of audit evidence.",
14+
"RelatedUrl": "",
15+
"AdditionalURLs": [
16+
"https://kubernetes.io/docs/concepts/cluster-administration/audit/",
17+
"https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/",
18+
"https://docs.rke2.io/security/cis_self_assessment124",
19+
"https://kubernetes.io/docs/tasks/debug/debug-cluster/audit/"
20+
],
1521
"Remediation": {
1622
"Code": {
17-
"CLI": "--audit-log-maxsize=100",
18-
"NativeIaC": "https://docs.prowler.com/checks/kubernetes/kubernetes-policy-index/ensure-that-the-audit-log-maxsize-argument-is-set-to-100-or-as-appropriate#kubernetes",
19-
"Other": "",
23+
"CLI": "",
24+
"NativeIaC": "",
25+
"Other": "1. SSH to the control plane node\n2. Edit the API server static pod manifest: sudo vi /etc/kubernetes/manifests/kube-apiserver.yaml\n3. In spec.containers[0].command add (or set) this flag:\n - --audit-log-maxsize=100\n4. Save and exit; the kubelet will restart the API server automatically\n5. Verify: ps aux | grep kube-apiserver | grep -- \"--audit-log-maxsize=100\"",
2026
"Terraform": ""
2127
},
2228
"Recommendation": {
23-
"Text": "Configure the API server audit log file size limit to 100 MB or as per your organization's requirements.",
24-
"Url": "https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/"
29+
"Text": "Set `--audit-log-maxsize` to `100 MB` or your approved baseline to ensure predictable rotation.\n\nPair with sensible retention (`--audit-log-maxage`, `--audit-log-maxbackup`), forward to a central store, and monitor capacity. This enforces **defense in depth** and preserves reliable auditability.",
30+
"Url": "https://hub.prowler.com/check/apiserver_audit_log_maxsize_set"
2531
}
2632
},
2733
"Categories": [

prowler/providers/kubernetes/services/apiserver/apiserver_audit_log_path_set/apiserver_audit_log_path_set.metadata.json

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
11
{
22
"Provider": "kubernetes",
33
"CheckID": "apiserver_audit_log_path_set",
4-
"CheckTitle": "Ensure that the --audit-log-path argument is set",
4+
"CheckTitle": "API server pod has --audit-log-path set",
55
"CheckType": [],
66
"ServiceName": "apiserver",
77
"SubServiceName": "",
88
"ResourceIdTemplate": "",
99
"Severity": "high",
10-
"ResourceType": "KubernetesAPIServer",
10+
"ResourceType": "Pod",
1111
"ResourceGroup": "container",
12-
"Description": "This check verifies that the Kubernetes API server is configured with an audit log path. Enabling audit logs helps in maintaining a chronological record of all activities and operations which can be critical for security analysis and troubleshooting.",
13-
"Risk": "Without audit logs, it becomes difficult to track changes and activities within the cluster, potentially obscuring the detection of malicious activities or operational issues.",
14-
"RelatedUrl": "https://kubernetes.io/docs/concepts/cluster-administration/audit/",
12+
"Description": "**Kubernetes API server** uses an **audit log path** configured via `--audit-log-path` on its containers to persist API request events",
13+
"Risk": "Without a configured audit log path, API requests may not be recorded, weakening **accountability**. Gaps in logs hinder detection of unauthorized changes (**integrity**) and data access (**confidentiality**), and impede **forensics** and incident response.",
14+
"RelatedUrl": "",
15+
"AdditionalURLs": [
16+
"https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/",
17+
"https://kubernetes.io/docs/concepts/cluster-administration/audit/"
18+
],
1519
"Remediation": {
1620
"Code": {
17-
"CLI": "--audit-log-path=/var/log/apiserver/audit.log",
18-
"NativeIaC": "https://docs.prowler.com/checks/kubernetes/kubernetes-policy-index/ensure-that-the-audit-log-path-argument-is-set#kubernetes",
19-
"Other": "",
21+
"CLI": "",
22+
"NativeIaC": "",
23+
"Other": "1. SSH to the control plane node\n2. Edit /etc/kubernetes/manifests/kube-apiserver.yaml\n3. Under the kube-apiserver container command args, add this line:\n ```\n - --audit-log-path=/var/log/apiserver/audit.log\n ```\n4. Save the file; the kubelet will automatically restart the API server",
2024
"Terraform": ""
2125
},
2226
"Recommendation": {
23-
"Text": "Enable audit logging in the API server by specifying a valid path for --audit-log-path to ensure comprehensive activity logging within the cluster.",
24-
"Url": "https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/"
27+
"Text": "Enable and harden **audit logging** by setting `--audit-log-path`. *If centralizing*, use a webhook backend. Define a focused audit policy, enforce **least privilege** to logs, rotate/retain them, forward to centralized monitoring, and regularly review events for **defense in depth**.",
28+
"Url": "https://hub.prowler.com/check/apiserver_audit_log_path_set"
2529
}
2630
},
2731
"Categories": [
28-
"logging"
32+
"logging",
33+
"forensics-ready"
2934
],
3035
"DependsOn": [],
3136
"RelatedTo": [],

0 commit comments

Comments
 (0)