{"id":102658,"date":"2019-10-16T05:40:08","date_gmt":"2019-10-16T12:40:08","guid":{"rendered":"https:\/\/www.paloaltonetworks.com\/blog\/?p=102658"},"modified":"2021-01-15T14:51:04","modified_gmt":"2021-01-15T22:51:04","slug":"cloud-kubernetes-vulnerabilities","status":"publish","type":"post","link":"https:\/\/www2.paloaltonetworks.com\/blog\/2019\/10\/cloud-kubernetes-vulnerabilities\/","title":{"rendered":"Analysis of Two Newly Patched Kubernetes Vulnerabilities"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">By Ariel Zelivansky and Aviv Sasson<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">The Kubernetes Patch Release Team on Tuesday released new builds that patch Kubernetes vulnerabilities CVE-2019-16276 and CVE-2019-11253, which have been publicly disclosed over the past month. These vulnerabilities have the potential to be highly dangerous under some Kubernetes configurations.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">We highly recommend <\/span><a href=\"https:\/\/github.com\/kubernetes\/kubernetes\/blob\/master\/CHANGELOG.md\" rel=\"nofollow,noopener\" ><span style=\"font-weight: 400;\">upgrading to Kubernetes builds<\/span><\/a><span style=\"font-weight: 400;\"> 1.14.8, 1.15.5 or 1.16.2, regardless of your Kubernetes configuration.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Here is an overview of the now-resolved issues:<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><b>CVE-2019-16276, or HTTP Protocol Violation in Go\u2019s net\/http Library<\/b><\/p>\n<p><span style=\"font-weight: 400;\">This vulnerability has its roots in the Go language\u2019s standard HTTP library, net\/http. The library is used for HTTP request parsing in Kubernetes. Its implementation normalized invalid HTTP requests in a way that caused a potential danger for Kubernetes.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">HTTP requests are comprised of a field-name, followed by a colon, then its value. Per the HTTP\/1.1 <\/span><a href=\"https:\/\/tools.ietf.org\/html\/rfc7230\" rel=\"nofollow,noopener\" ><span style=\"font-weight: 400;\">specification<\/span><\/a><span style=\"font-weight: 400;\">, no whitespace is allowed between the header\u2019s field-name and colon. As mentioned in the <\/span><a href=\"https:\/\/github.com\/golang\/go\/issues\/34540\" rel=\"nofollow,noopener\" ><span style=\"font-weight: 400;\">GitHub issue<\/span><\/a><span style=\"font-weight: 400;\"> of this problem, the net\/http library interpreted headers with this whitespace the same as valid headers, in violation of the HTTP RFC.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This seemingly innocent problem becomes dangerous when a Go server relying on the library is used in combination with a reverse proxy that filters request headers. The proxy may ignore invalid headers, but forward them to the Go server, which would interpret these headers as valid.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For example, if a reverse proxy server is used for authentication, attackers could exploit this bug to authenticate as any user by crafting an invalid header that would go through to the server.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This scenario is not at all hypothetical. The Kubernetes API server can be configured to work with an <\/span><a href=\"https:\/\/kubernetes.io\/docs\/reference\/access-authn-authz\/authentication\/#authenticating-proxy\" rel=\"nofollow,noopener\" ><span style=\"font-weight: 400;\">Authenticating Proxy<\/span><\/a><span style=\"font-weight: 400;\"> and identify users through request headers. Such a proxy may be used to allow users to authenticate to the API server using an existing SSO scheme, or other access control configurations.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To exploit the attack, assuming <\/span><span style=\"font-weight: 400;\">X-Remote-User<\/span><span style=\"font-weight: 400;\"> is used as the identifying user field for the API server, an attacker may send the following request to the proxy:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">X-Remote-User : admin<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If the proxy is designed to filter <\/span><span style=\"font-weight: 400;\">X-Remote-User<\/span><span style=\"font-weight: 400;\"> headers but doesn\u2019t recognize the header because it\u2019s invalid and forwards it to the Kubernetes API server, the attacker would successfully pass the API request with the roles of the \u201cadmin\u201d user.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The diagram below demonstrates how such an attack may take place.<\/span><\/p>\n<p><div style=\"max-width:100%\" data-width=\"1734\"><span class=\"ar-custom\" style=\"padding-bottom:40.02%;\"><img loading=\"lazy\" decoding=\"async\"  class=\"aligncenter size-full wp-image-102660 lozad\"  data-src=\"https:\/\/www.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image1-1.png\" alt=\"This shows one of two recently patched Kubernetes vulnerabilities.\" width=\"1734\" height=\"694\" srcset=\"https:\/\/www2.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image1-1.png 1734w, https:\/\/www2.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image1-1-230x92.png 230w, https:\/\/www2.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image1-1-768x307.png 768w, https:\/\/www2.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image1-1-500x200.png 500w, https:\/\/www2.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image1-1-510x204.png 510w, https:\/\/www2.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image1-1-100x40.png 100w, https:\/\/www2.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image1-1-650x260.png 650w, https:\/\/www2.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image1-1-874x350.png 874w\" sizes=\"auto, (max-width: 1734px) 100vw, 1734px\" \/><\/span><\/div><\/p>\n<p><span style=\"font-weight: 400;\">In this case, the proxy is highly naive. It both accepts anonymous connections and forwards invalid headers. The attacker sends a malicious request with an invalid header with including a whitespace. The API server accepts this header and performs the attacker\u2019s requests with Bob\u2019s roles. Of course, the details of an actual exploit would rely on the implementation of the proxy server.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">On the bright side, we were unable to find any open-source authenticating proxy that is commonly used. Using an authenticating proxy is a niche configuration, and special flags need to be passed to the API server to enable it. If your Kubernetes setup does use an Authenticating Proxy, make sure to upgrade immediately, especially because exploitation of this problem is very simple.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">CJ Cullen from the Kubernetes Security Committee published a <\/span><a href=\"https:\/\/groups.google.com\/forum\/?utm_medium=email&amp;utm_source=footer#!topic\/kubernetes-security-announce\/PtsUCqFi4h4\" rel=\"nofollow,noopener\" ><span style=\"font-weight: 400;\">security advisory<\/span><\/a><span style=\"font-weight: 400;\"> on this issue. The new releases were built with the fixed Go version (Go 1.12.10), rendering them immune to this attack.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><b>CVE-2019-11253, or Kubernetes YAML Parsing Vulnerable to DoS<\/b><\/p>\n<p><span style=\"font-weight: 400;\">In an unusual manner, the discovery of this vulnerability was made by a curious Kubernetes user over a <\/span><a href=\"https:\/\/stackoverflow.com\/questions\/58129150\/security-yaml-bomb-user-can-restart-kube-api-by-sending-configmap\/\" rel=\"nofollow,noopener\" ><span style=\"font-weight: 400;\">Stack Overflow question<\/span><\/a><span style=\"font-weight: 400;\">. The user found that the Kubernetes API server was vulnerable to a specific kind of attack on YAML parsers called YAML bomb attack. The attack, sometimes dubbed \u201c<\/span><a href=\"https:\/\/en.wikipedia.org\/wiki\/Billion_laughs_attack\" rel=\"nofollow,noopener\" ><span style=\"font-weight: 400;\">Billion laughs attack<\/span><\/a><span style=\"font-weight: 400;\">\u201d for historical reasons, intends to crash the YAML parser by exponentially loading it with references. The user worried how such an attack could be prevented to protect his API server.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The original exploit attached to the question is shown below.<\/span><\/p>\n<p><div style=\"max-width:100%\" data-width=\"1412\"><span class=\"ar-custom\" style=\"padding-bottom:42.49%;\"><img loading=\"lazy\" decoding=\"async\"  class=\"aligncenter size-full wp-image-102673 lozad\"  data-src=\"https:\/\/www.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image2-1.png\" alt=\"This illustrates an exploit involved in one of two recently patched Kubernetes vulnerabilities.\" width=\"1412\" height=\"600\" srcset=\"https:\/\/www2.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image2-1.png 1412w, https:\/\/www2.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image2-1-230x98.png 230w, https:\/\/www2.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image2-1-768x326.png 768w, https:\/\/www2.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image2-1-500x212.png 500w, https:\/\/www2.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image2-1-510x217.png 510w, https:\/\/www2.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image2-1-94x40.png 94w, https:\/\/www2.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image2-1-650x276.png 650w, https:\/\/www2.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/image2-1-874x371.png 874w\" sizes=\"auto, (max-width: 1412px) 100vw, 1412px\" \/><\/span><\/div><\/p>\n<p><span style=\"font-weight: 400;\">Rory McCune, a Stack Overflow user, realized that the fact this attack works is a potentially dangerous vulnerability in Kubernetes, and directed it to the Kubernetes security team. The security team suggested publishing the details of this vulnerability on its own <\/span><a href=\"https:\/\/github.com\/kubernetes\/kubernetes\/issues\/83253\" rel=\"nofollow,noopener\" ><span style=\"font-weight: 400;\">GitHub issue<\/span><\/a><span style=\"font-weight: 400;\">, since the details of this attack were already public.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Although the CVE was assigned to Kubernetes, and a <\/span><a href=\"https:\/\/github.com\/kubernetes\/kubernetes\/pull\/83261\" rel=\"nofollow,noopener\" ><span style=\"font-weight: 400;\">patch<\/span><\/a><span style=\"font-weight: 400;\"> was released to its source, the real culprit of this vulnerability is the YAML parser library that enabled this attack. Fortunately, another <\/span><a href=\"https:\/\/github.com\/go-yaml\/yaml\/commit\/f221b8435cfb71e54062f6c6e99e9ade30b124d5\" rel=\"nofollow,noopener\" ><span style=\"font-weight: 400;\">patch<\/span><\/a><span style=\"font-weight: 400;\"> was written to resolve this problem at the go-yaml library level, preventing this attack in other projects that rely on its code.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">After we experimented with exploitation of this vulnerability, we determined it should be considered high severity. Any user or container with roles that allow delivering YAML to the API server may crash it. Although it may be brought up depending on its restart policy and restart limit, the attacker may abuse the attack and deliver it continuously.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">We recommend reviewing each role given to users, pods or anonymous users to determine if it is required, especially if it allows sending POST requests with a YAML file.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><b>Fixed Releases<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Kubernetes releases <\/span><a href=\"https:\/\/github.com\/kubernetes\/kubernetes\/blob\/master\/CHANGELOG-1.14.md#downloads-for-v1148\" rel=\"nofollow,noopener\" ><span style=\"font-weight: 400;\">1.14.8<\/span><\/a><span style=\"font-weight: 400;\">, <\/span><a href=\"https:\/\/github.com\/kubernetes\/kubernetes\/blob\/master\/CHANGELOG-1.15.md#downloads-for-v1155\" rel=\"nofollow,noopener\" ><span style=\"font-weight: 400;\">1.15.5<\/span><\/a><span style=\"font-weight: 400;\"> and <\/span><a href=\"https:\/\/github.com\/kubernetes\/kubernetes\/blob\/master\/CHANGELOG-1.16.md#changelog-since-v1161\" rel=\"nofollow,noopener\" ><span style=\"font-weight: 400;\">1.16.2<\/span><\/a><span style=\"font-weight: 400;\"> include the fixes to these issues. We recommend that you update clusters to the safe versions regardless of your configuration.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">We would like to thank Jordan Liggitt from the Kubernetes release team for directing us to the correct releases.<\/span><\/p>\n<p>Learn more about our previous research on <a href=\"https:\/\/www.paloaltonetworks.com\/blog\/2019\/08\/cloud-kubernetes-vulnerable-denial-service-attacks\/\">Kubernetes vulnerabilities<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We highly recommend upgrading to Kubernetes builds 1.14.8, 1.15.5 or 1.16.2 to address two recently patched Kubernetes vulnerabilities. <\/p>\n","protected":false},"author":663,"featured_media":102691,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6768],"tags":[6731,515],"coauthors":[6875,6869],"class_list":["post-102658","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-secure-the-cloud","tag-kubernetes","tag-vulnerabilities"],"jetpack_featured_media_url":"https:\/\/www2.paloaltonetworks.com\/blog\/wp-content\/uploads\/2019\/10\/Possible-Kubernetes-image.1.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www2.paloaltonetworks.com\/blog\/wp-json\/wp\/v2\/posts\/102658","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www2.paloaltonetworks.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www2.paloaltonetworks.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www2.paloaltonetworks.com\/blog\/wp-json\/wp\/v2\/users\/663"}],"replies":[{"embeddable":true,"href":"https:\/\/www2.paloaltonetworks.com\/blog\/wp-json\/wp\/v2\/comments?post=102658"}],"version-history":[{"count":5,"href":"https:\/\/www2.paloaltonetworks.com\/blog\/wp-json\/wp\/v2\/posts\/102658\/revisions"}],"predecessor-version":[{"id":102690,"href":"https:\/\/www2.paloaltonetworks.com\/blog\/wp-json\/wp\/v2\/posts\/102658\/revisions\/102690"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www2.paloaltonetworks.com\/blog\/wp-json\/wp\/v2\/media\/102691"}],"wp:attachment":[{"href":"https:\/\/www2.paloaltonetworks.com\/blog\/wp-json\/wp\/v2\/media?parent=102658"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www2.paloaltonetworks.com\/blog\/wp-json\/wp\/v2\/categories?post=102658"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www2.paloaltonetworks.com\/blog\/wp-json\/wp\/v2\/tags?post=102658"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www2.paloaltonetworks.com\/blog\/wp-json\/wp\/v2\/coauthors?post=102658"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}