Critical severityNVD Advisory· Published Dec 5, 2018· Updated Aug 5, 2024
CVE-2018-1002105
CVE-2018-1002105
Description
In all Kubernetes versions prior to v1.10.11, v1.11.5, and v1.12.3, incorrect handling of error responses to proxied upgrade requests in the kube-apiserver allowed specially crafted requests to establish a connection through the Kubernetes API server to backend servers, then send arbitrary requests over the same connection directly to the backend, authenticated with the Kubernetes API server's TLS credentials used to establish the backend connection.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
github.com/kubernetes/kubernetesGo | < 1.10.11 | 1.10.11 |
github.com/kubernetes/kubernetesGo | >= 1.11.0, < 1.11.5 | 1.11.5 |
github.com/kubernetes/kubernetesGo | >= 1.12.0, < 1.12.3 | 1.12.3 |
Affected products
1- Range: v1.0.x
Patches
12257c1ecbe3cMerge pull request #71412 from liggitt/backend-error
1 file changed · +37 −0
staging/src/k8s.io/apimachinery/pkg/util/proxy/upgradeaware.go+37 −0 modified@@ -17,6 +17,7 @@ limitations under the License. package proxy import ( + "bufio" "bytes" "context" "fmt" @@ -271,6 +272,18 @@ func (h *UpgradeAwareHandler) tryUpgrade(w http.ResponseWriter, req *http.Reques } defer backendConn.Close() + // determine the http response code from the backend by reading from rawResponse+backendConn + rawResponseCode, headerBytes, err := getResponseCode(io.MultiReader(bytes.NewReader(rawResponse), backendConn)) + if err != nil { + klog.V(6).Infof("Proxy connection error: %v", err) + h.Responder.Error(w, req, err) + return true + } + if len(headerBytes) > len(rawResponse) { + // we read beyond the bytes stored in rawResponse, update rawResponse to the full set of bytes read from the backend + rawResponse = headerBytes + } + // Once the connection is hijacked, the ErrorResponder will no longer work, so // hijacking should be the last step in the upgrade. requestHijacker, ok := w.(http.Hijacker) @@ -295,6 +308,17 @@ func (h *UpgradeAwareHandler) tryUpgrade(w http.ResponseWriter, req *http.Reques } } + if rawResponseCode != http.StatusSwitchingProtocols { + // If the backend did not upgrade the request, finish echoing the response from the backend to the client and return, closing the connection. + klog.V(6).Infof("Proxy upgrade error, status code %d", rawResponseCode) + _, err := io.Copy(requestHijackedConn, backendConn) + if err != nil && !strings.Contains(err.Error(), "use of closed network connection") { + klog.Errorf("Error proxying data from backend to client: %v", err) + } + // Indicate we handled the request + return true + } + // Proxy the connection. This is bidirectional, so we need a goroutine // to copy in each direction. Once one side of the connection exits, we // exit the function which performs cleanup and in the process closes @@ -356,6 +380,19 @@ func (h *UpgradeAwareHandler) DialForUpgrade(req *http.Request) (net.Conn, error return dial(updatedReq, h.UpgradeTransport) } +// getResponseCode reads a http response from the given reader, returns the status code, +// the bytes read from the reader, and any error encountered +func getResponseCode(r io.Reader) (int, []byte, error) { + rawResponse := bytes.NewBuffer(make([]byte, 0, 256)) + // Save the bytes read while reading the response headers into the rawResponse buffer + resp, err := http.ReadResponse(bufio.NewReader(io.TeeReader(r, rawResponse)), nil) + if err != nil { + return 0, nil, err + } + // return the http status code and the raw bytes consumed from the reader in the process + return resp.StatusCode, rawResponse.Bytes(), nil +} + // dial dials the backend at req.URL and writes req to it. func dial(req *http.Request, transport http.RoundTripper) (net.Conn, error) { conn, err := DialURL(req.Context(), req.URL, transport)
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
31- www.exploit-db.com/exploits/46052/mitreexploitx_refsource_EXPLOIT-DB
- www.exploit-db.com/exploits/46053/mitreexploitx_refsource_EXPLOIT-DB
- lists.opensuse.org/opensuse-security-announce/2020-04/msg00041.htmlmitrevendor-advisoryx_refsource_SUSE
- access.redhat.com/errata/RHSA-2018:3537ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2018:3549ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2018:3551ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2018:3598ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2018:3624ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2018:3742ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2018:3752ghsavendor-advisoryx_refsource_REDHATWEB
- access.redhat.com/errata/RHSA-2018:3754ghsavendor-advisoryx_refsource_REDHATWEB
- github.com/advisories/GHSA-579h-mv94-g4gpghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2018-1002105ghsaADVISORY
- www.openwall.com/lists/oss-security/2019/06/28/2mitremailing-listx_refsource_MLIST
- www.openwall.com/lists/oss-security/2019/07/06/3mitremailing-listx_refsource_MLIST
- www.openwall.com/lists/oss-security/2019/07/06/4mitremailing-listx_refsource_MLIST
- www.securityfocus.com/bid/106068mitrevdb-entryx_refsource_BID
- github.com/kubernetes/kubernetes/commit/2257c1ecbe3c0cf71dd50b82752ae189c94ec905ghsaWEB
- github.com/kubernetes/kubernetes/issues/71411ghsax_refsource_CONFIRMWEB
- groups.google.com/forum/ghsaWEB
- groups.google.com/forum/mitrex_refsource_CONFIRM
- lists.opensuse.org/opensuse-security-announce/2020-04/msg00041.htmlghsaWEB
- security.netapp.com/advisory/ntap-20190416-0001ghsaWEB
- security.netapp.com/advisory/ntap-20190416-0001/mitrex_refsource_CONFIRM
- www.coalfire.com/The-Coalfire-Blog/December-2018/Kubernetes-Vulnerability-What-You-Can-Should-Doghsax_refsource_MISCWEB
- www.exploit-db.com/exploits/46052ghsaWEB
- www.exploit-db.com/exploits/46053ghsaWEB
- www.openwall.com/lists/oss-security/2019/06/28/2ghsaWEB
- www.openwall.com/lists/oss-security/2019/07/06/3ghsaWEB
- www.openwall.com/lists/oss-security/2019/07/06/4ghsaWEB
- www.securityfocus.com/bid/106068ghsaWEB
News mentions
0No linked articles in our index yet.