Moderate severityNVD Advisory· Published Dec 7, 2020· Updated Sep 16, 2024
Docker config secrets leaked when file is malformed and loglevel >= 4
CVE-2020-8564
Description
In Kubernetes clusters using a logging level of at least 4, processing a malformed docker config file will result in the contents of the docker config file being leaked, which can include pull secrets or other registry credentials. This affects < v1.19.3, < v1.18.10, < v1.17.13.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
github.com/kubernetes/kubernetesGo | >= 1.19.0, < 1.19.3 | 1.19.3 |
github.com/kubernetes/kubernetesGo | >= 1.18.0, < 1.18.10 | 1.18.10 |
github.com/kubernetes/kubernetesGo | < 1.17.13 | 1.17.13 |
k8s.io/kubernetesGo | < 1.20.0-alpha.1 | 1.20.0-alpha.1 |
Affected products
1- Range: < 1.19.3
Patches
111793434dac9Merge pull request #94712 from droslean/cred-leak
2 files changed · +102 −7
pkg/credentialprovider/config.go+9 −7 modified@@ -117,10 +117,14 @@ func ReadDockercfgFile(searchPaths []string) (cfg DockerConfig, err error) { continue } cfg, err := readDockerConfigFileFromBytes(contents) - if err == nil { - klog.V(4).Infof("found .dockercfg at %s", absDockerConfigFileLocation) - return cfg, nil + if err != nil { + klog.V(4).Infof("couldn't get the config from %q contents: %v", absDockerConfigFileLocation, err) + continue } + + klog.V(4).Infof("found .dockercfg at %s", absDockerConfigFileLocation) + return cfg, nil + } return nil, fmt.Errorf("couldn't find valid .dockercfg after checking in %v", searchPaths) } @@ -230,17 +234,15 @@ func ReadDockerConfigFileFromURL(url string, client *http.Client, header *http.H func readDockerConfigFileFromBytes(contents []byte) (cfg DockerConfig, err error) { if err = json.Unmarshal(contents, &cfg); err != nil { - klog.Errorf("while trying to parse blob %q: %v", contents, err) - return nil, err + return nil, errors.New("error occurred while trying to unmarshal json") } return } func readDockerConfigJSONFileFromBytes(contents []byte) (cfg DockerConfig, err error) { var cfgJSON DockerConfigJSON if err = json.Unmarshal(contents, &cfgJSON); err != nil { - klog.Errorf("while trying to parse blob %q: %v", contents, err) - return nil, err + return nil, errors.New("error occurred while trying to unmarshal json") } cfg = cfgJSON.Auths return
pkg/credentialprovider/config_test.go+93 −0 modified@@ -309,3 +309,96 @@ func TestDockerConfigEntryJSONCompatibleEncode(t *testing.T) { } } } + +func TestReadDockerConfigFileFromBytes(t *testing.T) { + testCases := []struct { + id string + input []byte + expectedCfg DockerConfig + errorExpected bool + expectedErrorMsg string + }{ + { + id: "valid input, no error expected", + input: []byte(`{"http://foo.example.com":{"username": "foo", "password": "bar", "email": "foo@example.com"}}`), + expectedCfg: DockerConfig(map[string]DockerConfigEntry{ + "http://foo.example.com": { + Username: "foo", + Password: "bar", + Email: "foo@example.com", + }, + }), + }, + { + id: "invalid input, error expected", + input: []byte(`{"http://foo.example.com":{"username": "foo", "password": "bar", "email": "foo@example.com"`), + errorExpected: true, + expectedErrorMsg: "error occurred while trying to unmarshal json", + }, + } + + for _, tc := range testCases { + cfg, err := readDockerConfigFileFromBytes(tc.input) + if err != nil && !tc.errorExpected { + t.Fatalf("Error was not expected: %v", err) + } + if err != nil && tc.errorExpected { + if !reflect.DeepEqual(err.Error(), tc.expectedErrorMsg) { + t.Fatalf("Expected error message: `%s` got `%s`", tc.expectedErrorMsg, err.Error()) + } + } else { + if !reflect.DeepEqual(cfg, tc.expectedCfg) { + t.Fatalf("expected: %v got %v", tc.expectedCfg, cfg) + } + } + } +} + +func TestReadDockerConfigJSONFileFromBytes(t *testing.T) { + testCases := []struct { + id string + input []byte + expectedCfg DockerConfig + errorExpected bool + expectedErrorMsg string + }{ + { + id: "valid input, no error expected", + input: []byte(`{"auths": {"http://foo.example.com":{"username": "foo", "password": "bar", "email": "foo@example.com"}, "http://bar.example.com":{"username": "bar", "password": "baz", "email": "bar@example.com"}}}`), + expectedCfg: DockerConfig(map[string]DockerConfigEntry{ + "http://foo.example.com": { + Username: "foo", + Password: "bar", + Email: "foo@example.com", + }, + "http://bar.example.com": { + Username: "bar", + Password: "baz", + Email: "bar@example.com", + }, + }), + }, + { + id: "invalid input, error expected", + input: []byte(`{"auths": {"http://foo.example.com":{"username": "foo", "password": "bar", "email": "foo@example.com"}, "http://bar.example.com":{"username": "bar", "password": "baz", "email": "bar@example.com"`), + errorExpected: true, + expectedErrorMsg: "error occurred while trying to unmarshal json", + }, + } + + for _, tc := range testCases { + cfg, err := readDockerConfigJSONFileFromBytes(tc.input) + if err != nil && !tc.errorExpected { + t.Fatalf("Error was not expected: %v", err) + } + if err != nil && tc.errorExpected { + if !reflect.DeepEqual(err.Error(), tc.expectedErrorMsg) { + t.Fatalf("Expected error message: `%s` got `%s`", tc.expectedErrorMsg, err.Error()) + } + } else { + if !reflect.DeepEqual(cfg, tc.expectedCfg) { + t.Fatalf("expected: %v got %v", tc.expectedCfg, cfg) + } + } + } +}
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
9- github.com/advisories/GHSA-8mjg-8c8g-6h85ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2020-8564ghsaADVISORY
- github.com/kubernetes/kubernetes/commit/11793434dac97a49bfed0150b56ac63e5dc34634ghsaWEB
- github.com/kubernetes/kubernetes/issues/95622ghsax_refsource_CONFIRMWEB
- github.com/kubernetes/kubernetes/pull/94712ghsaWEB
- groups.google.com/g/kubernetes-security-discuss/c/vm-HcrFUOCs/m/36utxAM5CwAJghsamailing-listx_refsource_MLISTWEB
- pkg.go.dev/vuln/GO-2021-0066ghsaWEB
- security.netapp.com/advisory/ntap-20210122-0006ghsaWEB
- security.netapp.com/advisory/ntap-20210122-0006/mitrex_refsource_CONFIRM
News mentions
0No linked articles in our index yet.