Kubernetes cluster has Log Service enabled
Alibaba Cloud Log Service supports collection, search, storage, and analysis for container and audit logs in Kubernetes Engine clusters. When enabled, it automatically collects kube-apiserver audit logs, ingress logs, and stdout/stderr from containers. These logs are stored persistently and are essential for operational visibility, security monitoring, and compliance auditing.
Risk
Without Log Service, there is no centralized collection of container logs or cluster events, impairing incident investigation, compliance auditing, and security monitoring. Attackers could operate undetected with no audit trail of API server calls or pod events, impacting cluster confidentiality and integrity.
Run this check with Prowler
Run in Prowler Cloudprowler alibabacloud --checks cs_kubernetes_log_service_enabledRecommendation
Enable Log Service during cluster creation by setting Enable Log Service to Enabled. For existing clusters, verify that AuditProjectName is configured in the cluster metadata.
Remediation
CLI
aliyun cs GET /clusters/<cluster_id> --header 'Content-Type=application/json' | jq '.meta_data' | jq -r 'fromjson | .AuditProjectName'Other
Check Code
from prowler.lib.check.models import Check, CheckReportAlibabaCloud
from prowler.providers.alibabacloud.services.cs.cs_client import cs_client
class cs_kubernetes_log_service_enabled(Check):
"""Check if Log Service is enabled on Kubernetes Engine Clusters."""
def execute(self) -> list[CheckReportAlibabaCloud]:
findings = []
for cluster in cs_client.clusters:
report = CheckReportAlibabaCloud(metadata=self.metadata(), resource=cluster)
report.region = cluster.region
report.resource_id = cluster.id
report.resource_arn = f"acs:cs:{cluster.region}:{cs_client.audited_account}:cluster/{cluster.id}"
if cluster.log_service_enabled:
report.status = "PASS"
report.status_extended = f"Kubernetes cluster {cluster.name} has Log Service enabled with project: {cluster.audit_project_name}."
else:
report.status = "FAIL"
report.status_extended = f"Kubernetes cluster {cluster.name} does not have Log Service enabled."
findings.append(report)
return findings