Ensure that the Auto-Upgrade feature is enabled for all the nodes running within your Google Kubernetes Engine (GKE) clusters. This feature helps you keep your cluster nodes up to date with the latest supported version of Kubernetes, automatically applying security fixes and new functionalities.
PoC代码[已公开]
id: gcloud-gke-auto-upgrade-disabled
info:
name: GKE Node Pools Without Auto-Upgrade Enabled
author: princechaddha
severity: medium
description: |
Ensure that the Auto-Upgrade feature is enabled for all the nodes running within your Google Kubernetes Engine (GKE) clusters. This feature helps you keep your cluster nodes up to date with the latest supported version of Kubernetes, automatically applying security fixes and new functionalities.
impact: |
Without auto-upgrades enabled, cluster nodes may run outdated Kubernetes versions, missing critical security patches and feature updates, which could expose your clusters to known vulnerabilities.
remediation: |
Enable auto-upgrade for your GKE cluster node pools using:
gcloud container node-pools update POOL_NAME --cluster=CLUSTER_NAME --region=REGION --enable-autoupgrade
reference:
- https://cloud.google.com/kubernetes-engine/docs/how-to/node-auto-upgrades
- https://www.trendmicro.com/cloudoneconformity/knowledge-base/gcp/GKE/enable-auto-upgrade.html
tags: cloud,devops,gcp,gcloud,gke,kubernetes,security,updates,maintenance,gcp-cloud-config
flow: |
code(1)
for(let projectId of iterate(template.projectIds)){
set("projectId", projectId)
code(2)
for(let cluster of iterate(template.clusters)){
cluster = JSON.parse(cluster)
set("clusterName", cluster.name)
set("location", cluster.location)
code(3)
for(let nodePool of iterate(template.nodePools)){
nodePool = JSON.parse(nodePool)
set("nodePoolName", nodePool.name)
code(4)
}
}
}
self-contained: true
code:
- engine:
- sh
- bash
source: |
gcloud projects list --format="json(projectId)"
extractors:
- type: json
name: projectIds
internal: true
json:
- '.[].projectId'
- engine:
- sh
- bash
source: |
gcloud container clusters list --project $projectId --format="json(name,location)"
extractors:
- type: json
name: clusters
internal: true
json:
- '.[]'
- engine:
- sh
- bash
source: |
gcloud container node-pools list --cluster $clusterName --location $location --project $projectId --format="json(name)"
extractors:
- type: json
name: nodePools
internal: true
json:
- '.[]'
- engine:
- sh
- bash
source: |
gcloud container node-pools describe $nodePoolName --cluster $clusterName --location $location --project $projectId --format="yaml(management.autoUpgrade)"
matchers:
- type: word
words:
- "management: {}"
- "null"
condition: or
extractors:
- type: dsl
dsl:
- '"Node pool " + nodePoolName + " in GKE cluster " + clusterName + " (" + location + ") of project " + projectId + " does not have auto-upgrade enabled"'
# digest: 490a004630440220700f02c7f46cd893d2c350339f69038c82b95ec459197553400b3c9ae36a7a5c022017f38313e61466940c8968ad08c60f7db19c39f299c9f68fccdc28f1633f1645:922c64590222798bb761d5b6d8e72950