github.com/k3s-io/k3s
Affected
- introduced
0, fixed1.24.17(semver)
Fixed versions
1.24.17
Fix
- Fixed version
1.24.17go get github.com/k3s-io/[email protected]
Advisory
Also known as: CVE-2023-32187
K3s apiserver port is vulnerable to unauthenticated remote denial-of-service (DoS) attack via TLS SAN stuffing attack
Impact
An issue was found in K3s where an attacker with network access to K3s servers' apiserver/supervisor port (TCP 6443) can force the TLS server to add entries to the certificate's Subject Alternative Name (SAN) list, through a stuffing attack, until the certificate grows so large that it exceeds the maximum size allowed by TLS client implementations. OpenSSL for example will raise an excessive message size error when this occurs. No authentication is necessary to perform this attack, only the ability to perform a TLS handshake against the apiserver/supervisor port (TCP 6443).
Affected servers will continue to operate, but clients (including both external administrative access with kubectl and server or agent nodes) will fail to establish new connections, thus leading to a denial of service (DoS) attack.
Remediation
Upgrade to a fixed release:
If you are using K3s 1.27 or earlier, you must also add the parameter tls-san-security: true to the K3s configuration to enable enhanced security for the supervisor's TLS SAN list. This option defaults to true starting with K3s 1.28.
Note that this flag changes the behavior of K3s servers. You should ensure that you configure node-external-ip on servers that will be connected to via an external IP, and add tls-san entries for any load-balancers or VIP addresses that will be associated with the supervisor port. External IPs and load-balancer/VIP addresses will no longer be added to the supervisor certificate's SAN list unless explicitly configured.
Mitigation
If you cannot upgrade to a fixed release, the certificate can be "frozen" by running the following command against the cluster:
kubectl annotate secret -n kube-system k3s-serving listener.cattle.io/static=true
⚠️ IMPORTANT CAUTION: Note that this mitigation will prevent the certificate from adding new SAN entries when servers join the cluster, and automatically renewing itself when it is about to expire. If you do this, you should delete the annotation when adding new servers to the cluster, or when the certificate is within 90 days of expiring, so that it can be updated. Once that is done, you can freeze it again.
Affected certificates can be reset by performing the following steps:
kubectl --server https://localhost:6444 delete secret -n kube-system k3s-serving/var/lib/rancher/k3s/server/tls/dynamic-cert.json from all servers, and restart the k3s service.Background
The K3s apiserver/supervisor listener on port TCP 6443 and uses the rancher/dynamiclistener library to dynamically generate TLS certificates that contain TLS Subject Alternative Names (SAN) for any host name or IP address requested by a client. This is done to allow servers and external load-balancers to be added to the cluster without the administrator having to explicitly know and configure in advance a fixed list of endpoints that the supervisor may be hosted at.
The library allows the embedding application to configure a callback that is used to filter addresses requested by clients; but this was not previously implemented in K3s.
For more information
If you have any questions or comments about this advisory:
High Basis: The source's own band: HIGH
0, fixed 1.24.17 (semver)1.24.17
1.24.17go get github.com/k3s-io/[email protected]1.25.0, fixed 1.25.13 (semver)1.25.13
1.25.13go get github.com/k3s-io/[email protected]1.26.0, fixed 1.26.8 (semver)1.26.8
1.26.8go get github.com/k3s-io/[email protected]1.27.0, fixed 1.27.5 (semver)1.27.5
1.27.5go get github.com/k3s-io/[email protected]1.28.0, fixed 1.28.1 (semver)1.28.1
1.28.1go get github.com/k3s-io/[email protected]Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0