Skip to content
Info disclosure Disclosed report Beginner CVE-2020-8563

secret leaks in vsphere cloud controller manager log

The vSphere cloud provider logs secret contents in the cloud controller manager log at logging level 4 or above. A user with log read access in kube-system could view sensitive data and may escalate privileges.

derek0405 Follow

Originally disclosed on HackerOne

Bounty$500 Medium 6.2 View original
  • Triaged in 21 days
  • Fixed in 53 days
  • Paid in 38 days
  • Disclosed after 3 months

Report Submission Form

Summary:

When create k8s cluster over vsphere and enable vsphere as cloud provider. With logging level set to 4 or above, secret information will be printed out in the cloud controller manager's log.

Kubernetes Version:

1.18.6

Component Version:

legacy cloud provider

Steps To Reproduce:

[add details for how we can reproduce the issue, including relevant cluster setup and configuration]

  1. Configure vsphere as cloud provider and set logging level to 4 or above (https://cloud-provider-vsphere.sigs.k8s.io/tutorials/kubernetes-on-vsphere-with-kubeadm.html)
  2. Check vsphere cloud provider log when a secret is created or udpated as the secret informer is registered with and will be print out when the logging level set to 4 or above.

Supporting Material/References:

[list any additional material (e.g. screenshots, logs, etc.)] Source codes that print out the secret info: https://github.com/kubernetes/kubernetes/blob/6d0f4749a59099171540d4fd7c9523b029e71ceb/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go#L1503

https://github.com/kubernetes/kubernetes/blob/6d0f4749a59099171540d4fd7c9523b029e71ceb/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go#L1527

Calling code path: 1.cmd/kube-controller-manager/app/controllermanager.go -> Run() 2.cmd/kube-controller-manager/app/controllermanager.go -> CreateControllerContext() 3. cmd/kube-controller-manager/app/cloudproviders.go -> createCloudProvider() 4. vendor/k8s.io/cloud-provider/cloud.go ->SetInformers() 5. staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go -> func (vs *VSphere) SetInformers(informerFactory informers.SharedInformerFactory)

  • [attachment / reference]

Impact

If any kubernetes users or service accounts has privileges (e.g. GET pods/log in the kube-system namespace), he will be able to view all the secrets data when a secret is created or updated which may contain sensitive data such as password or private key. Further, is the secret is a service account token, then the user may escalate his privileges.

The original report as published on HackerOne, by derek0405. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

Kubernetes can run on top of VMware vSphere, and when it does, the cluster can use vSphere as its cloud provider. In the legacy cloud provider implementation, the vSphere provider registers informers so that it is notified about cluster objects it cares about. One of those informers watches Secrets.

The report concerns the vSphere cloud controller manager log. When the logging level is set to 4 or above, the provider prints the contents of the objects it receives from the secret informer, so secret data ends up in the log in cleartext. The affected component is the legacy cloud provider, and the reporter tested Kubernetes version 1.18.6.

Setup

The preconditions are a Kubernetes cluster created on vSphere with vSphere configured as the cloud provider, and the logging level set to 4 or above. The reporter points to the vSphere provider tutorial for the cluster setup:

Text
https://cloud-provider-vsphere.sigs.k8s.io/tutorials/kubernetes-on-vsphere-with-kubeadm.html

No special account or tooling is needed to trigger the logging itself; the exposure happens as part of normal operation once the log level is raised.

Finding it

The reporter found that the vSphere provider registers a secret informer, and that the secret is printed when the logging level is 4 or above. Because the informer fires whenever a Secret is created or updated, any such event causes the secret to be written to the cloud controller manager log.

The reporter cites the source lines that print the secret information, at commit [redacted]:

Text
https://github.com/kubernetes/kubernetes/blob/[redacted]/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go#L1503
Text
https://github.com/kubernetes/kubernetes/blob/[redacted]/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go#L1527

The reporter also traced the calling code path that leads to the informer being registered:

  1. cmd/kube-controller-manager/app/controllermanager.go -> Run()
  2. cmd/kube-controller-manager/app/controllermanager.go -> CreateControllerContext()
  3. cmd/kube-controller-manager/app/cloudproviders.go -> createCloudProvider()
  4. vendor/k8s.io/cloud-provider/cloud.go -> SetInformers()
  5. staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go -> func (vs *VSphere) SetInformers(informerFactory informers.SharedInformerFactory)

So the chain runs from the controller manager startup, through cloud provider creation, into the vSphere provider's SetInformers, which is where the secret informer is wired up.

Exploitation

Step 1: Configure vSphere as the cloud provider and raise the log level

Configure vSphere as the cloud provider and set the logging level to 4 or above, following the tutorial linked above. At this level the provider's verbose logging is active.

Step 2: Create or update a Secret

Check the vSphere cloud provider log when a Secret is created or updated. The secret informer is registered, and its handler prints the object when the logging level is 4 or above. The secret data therefore appears in the cloud controller manager log.

No request or payload is shown in the report; the trigger is the ordinary creation or update of a Secret in the cluster.

Root cause

The vSphere legacy cloud provider registers an informer for Secrets and logs the received object at a verbosity of 4 or above. The logged object includes the secret data, so the log becomes a cleartext copy of every Secret that is created or updated while the provider is running at that log level. The mistake is in the logging in the informer handler in vsphere.go (lines 1503 and 1527 at the cited commit), reached through SetInformers as described in the calling path above.

Existing defences did not stop it because the data is written by the component itself at a log level an operator can enable; the report does not describe any additional control that would have prevented the write.

Impact

Any Kubernetes user or service account with privileges such as GET pods/log in the kube-system namespace can read the cloud controller manager log. That gives them access to all secret data logged when a Secret is created or updated, which may contain sensitive data such as passwords or private keys. If the logged Secret is a service account token, the user may escalate their privileges.

The exposure depends on the log level being set to 4 or above and on Secrets being created or updated while it is. The report rates the issue medium severity with a CVSS score of 6.2, classified as cleartext storage of sensitive information, and a bounty of 500.00 USD was awarded.

Fix

The report does not describe a fix. The change needed is to stop logging the Secret object contents in the vSphere provider's informer handler, so that secret data is never written to the cloud controller manager log regardless of the log level.

Variants to test

  • Other cloud providers and controllers that register informers for Secrets: check whether their handlers log the full object at verbose levels. A positive result is secret data appearing in a component log after a Secret is created or updated.
  • Other log levels and components in the same cluster: raise verbosity on controllers that watch Secrets and look for object dumps. A positive result is any cleartext secret value in the log.
  • Access paths to the log: check which roles and service accounts can read logs in namespaces where controllers run. A positive result is a low-privileged identity that can read a log containing secret data.

Hunting notes

This kind of bug hides in verbose logging inside controllers and cloud providers, particularly informer handlers that print the whole object they receive. During recon, look for components that watch Secrets and for documentation or configuration that encourages raising the log level for troubleshooting. The report connects the logged data to an access path: a user or service account with GET pods/log in kube-system can read the log, and a logged service account token may lead to privilege escalation.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 12 min read.

What happened, in plain words

Kubernetes is a system for running software in containers across a group of machines. It can be installed on top of VMware vSphere, which is software for running virtual machines on physical servers. When Kubernetes runs on vSphere, it can be told to use vSphere as its "cloud provider", meaning the part of Kubernetes that talks to the underlying infrastructure.

That cloud provider has a habit: when it is told to be very chatty in its logs (logs are the diary files where software writes down what it is doing), it writes down the full contents of certain objects it is watching. One of the objects it watches is a Secret. A Secret is a Kubernetes object that holds sensitive data, such as a password, a private key or a token. Because the provider writes the whole object into its log, the sensitive data ends up in a plain text file that other people may be able to read.

The reporter found this in the legacy cloud provider component of Kubernetes version 1.18.6. The bug is classified as "cleartext storage of sensitive information": sensitive data stored somewhere without any protection, readable by anyone who can reach that place. The report rates it medium severity with a CVSS score of 6.2, and a bounty of 500.00 USD was awarded.

Context

Some words first, because they come up constantly below.

  • Cluster: a group of machines that Kubernetes manages together as one system.
  • Cloud provider: the piece of Kubernetes that knows how to talk to the outside infrastructure, here VMware vSphere. It can create and manage things like load balancers or storage on that infrastructure.
  • Controller manager: a Kubernetes program that runs background loops, called controllers, which keep the cluster in the state it should be in. The cloud controller manager is the part that runs the cloud provider.
  • Informer: a subscription mechanism inside Kubernetes. A component tells Kubernetes "let me know whenever an object of this kind is created or changed", and Kubernetes calls it back each time. Think of a news alert service: you subscribe to a topic and get a message for every new article, instead of checking the website yourself.
  • Secret: a Kubernetes object for sensitive values. Applications read Secrets to get passwords, keys or tokens without those values being written into their configuration files.
  • Log level (verbosity): a number that controls how much detail a program writes to its log. A low level records only important events; a high level records lots of internal detail, which is useful when troubleshooting but can be noisy and revealing.
  • Cleartext: data stored or sent in a form anyone can read, with no encryption.

In the legacy cloud provider implementation, the vSphere provider registers informers so that it is notified about the cluster objects it cares about. One of those informers watches Secrets. The report concerns the vSphere cloud controller manager log. When the logging level is set to 4 or above, the provider prints the contents of the objects it receives from the secret informer, so secret data ends up in the log in cleartext. The affected component is the legacy cloud provider, and the reporter tested Kubernetes version 1.18.6.

Setup

The preconditions are a Kubernetes cluster created on vSphere with vSphere configured as the cloud provider, and the logging level set to 4 or above. The reporter points to the vSphere provider tutorial for the cluster setup:

Text
https://cloud-provider-vsphere.sigs.k8s.io/tutorials/kubernetes-on-vsphere-with-kubeadm.html

This is a web address for a step by step guide that explains how to build a Kubernetes cluster on vSphere using a tool called kubeadm. You open it in a browser and follow the instructions.

No special account or tooling is needed to trigger the logging itself; the exposure happens as part of normal operation once the log level is raised. In other words, nobody has to break in. The cluster does this to itself as soon as an administrator turns up the verbosity, which people often do while investigating a problem.

Finding it

The reporter found that the vSphere provider registers a secret informer, and that the secret is printed when the logging level is 4 or above. A handler is simply the piece of code that runs when the subscription fires, the same way a phone rings and you answer it. Because the informer fires whenever a Secret is created or updated, any such event causes the secret to be written to the cloud controller manager log.

The reporter cites the source lines that print the secret information, at commit [redacted]:

Text
https://github.com/kubernetes/kubernetes/blob/[redacted]/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go#L1503
Text
https://github.com/kubernetes/kubernetes/blob/[redacted]/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go#L1527

These two links point at specific lines in the Kubernetes source code, which is the human written text that the program is built from. A commit is a saved snapshot of that code at a particular moment; the long string of letters and digits identifies exactly which snapshot the reporter looked at, so anyone can open the same version and see the same lines. The #L1503 and #L1527 endings mean "jump to line 1503" and "jump to line 1527" in the file vsphere.go, which lives in the folder for the legacy vSphere cloud provider. Those are the lines that write the secret information out.

The reporter also traced the calling code path that leads to the informer being registered:

  1. cmd/kube-controller-manager/app/controllermanager.go -> Run()
  2. cmd/kube-controller-manager/app/controllermanager.go -> CreateControllerContext()
  3. cmd/kube-controller-manager/app/cloudproviders.go -> createCloudProvider()
  4. vendor/k8s.io/cloud-provider/cloud.go -> SetInformers()
  5. staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go -> func (vs *VSphere) SetInformers(informerFactory informers.SharedInformerFactory)

This list is a trail of breadcrumbs through the code, from the moment the controller manager starts up to the moment the secret subscription is set up. Each line names a file and then a function inside it. A function is a named block of code that does one job, like a recipe with a name. The arrow means "this function calls that function next".

  1. Run() is the entry point: the controller manager starts here.
  2. CreateControllerContext() builds the shared context, the bundle of settings and connections the controllers need.
  3. createCloudProvider() creates the cloud provider, which is where vSphere gets involved.
  4. SetInformers() is the generic hook that lets a cloud provider subscribe to the objects it wants.
  5. The vSphere provider's own SetInformers is the concrete implementation, and this is where the secret informer is wired up. The parameter informerFactory informers.SharedInformerFactory is the factory, a shared object that hands out subscriptions; asking it for a Secret informer is what creates the subscription.

So the chain runs from the controller manager startup, through cloud provider creation, into the vSphere provider's SetInformers, which is where the secret informer is wired up.

Exploitation

Step 1: Configure vSphere as the cloud provider and raise the log level

Configure vSphere as the cloud provider and set the logging level to 4 or above, following the tutorial linked above. At this level the provider's verbose logging is active. Verbose means it records far more than usual, including the internal objects it handles.

Step 2: Create or update a Secret

Check the vSphere cloud provider log when a Secret is created or updated. The secret informer is registered, and its handler prints the object when the logging level is 4 or above. The secret data therefore appears in the cloud controller manager log.

No request or payload is shown in the report; the trigger is the ordinary creation or update of a Secret in the cluster. A request is a message one program sends to another, and a payload is the data carried inside it. Here there is nothing to send by hand: creating or changing a Secret is something applications and administrators do all the time, and each time it happens the informer fires and the log gets a copy.

Root cause

The vSphere legacy cloud provider registers an informer for Secrets and logs the received object at a verbosity of 4 or above. The logged object includes the secret data, so the log becomes a cleartext copy of every Secret that is created or updated while the provider is running at that log level. The mistake is in the logging in the informer handler in vsphere.go (lines 1503 and 1527 at the cited commit), reached through SetInformers as described in the calling path above.

A useful comparison: it is as if a receptionist, told to keep a detailed diary, wrote down every visitor's name and the password they whispered at the desk. The diary is not secret, and the receptionist was only doing what the detailed mode asked for. The fault is in what the detailed mode was told to record.

Existing defences did not stop it because the data is written by the component itself at a log level an operator can enable; the report does not describe any additional control that would have prevented the write.

Impact

Any Kubernetes user or service account with privileges such as GET pods/log in the kube-system namespace can read the cloud controller manager log. A user is a person with an account in the cluster. A service account is an account for a program rather than a person. A namespace is a labelled area inside the cluster where objects live; kube-system is the one where Kubernetes' own components, including the controller manager, usually run. A privilege is a permission, and GET pods/log is the permission to fetch the log of a pod, a pod being the smallest unit Kubernetes runs, a wrapper around one or more containers.

That gives them access to all secret data logged when a Secret is created or updated, which may contain sensitive data such as passwords or private keys. A private key is the secret half of a cryptographic key pair; whoever holds it can prove they are the rightful owner of the matching public identity. If the logged Secret is a service account token, the user may escalate their privileges. A token here is a string that proves an identity, like a wristband at an event: showing it gets you in without a password. Privilege escalation means using a small permission to gain a bigger one, for example reading a log to obtain a token that belongs to a more powerful account.

The exposure depends on the log level being set to 4 or above and on Secrets being created or updated while it is. The report rates the issue medium severity with a CVSS score of 6.2, classified as cleartext storage of sensitive information, and a bounty of 500.00 USD was awarded. CVSS is a standard scoring system for how serious a security flaw is; 6.2 sits in the medium band.

Fix

The report does not describe a fix. The change needed is to stop logging the Secret object contents in the vSphere provider's informer handler, so that secret data is never written to the cloud controller manager log regardless of the log level.

Variants to test

  • Other cloud providers and controllers that register informers for Secrets: check whether their handlers log the full object at verbose levels. A positive result is secret data appearing in a component log after a Secret is created or updated.
  • Other log levels and components in the same cluster: raise verbosity on controllers that watch Secrets and look for object dumps. A positive result is any cleartext secret value in the log.
  • Access paths to the log: check which roles and service accounts can read logs in namespaces where controllers run. A positive result is a low-privileged identity that can read a log containing secret data.

Hunting notes

This kind of bug hides in verbose logging inside controllers and cloud providers, particularly informer handlers that print the whole object they receive. During recon, look for components that watch Secrets and for documentation or configuration that encourages raising the log level for troubleshooting. Recon means the early exploration phase, where you map out what a system contains before testing anything. The report connects the logged data to an access path: a user or service account with GET pods/log in kube-system can read the log, and a logged service account token may lead to privilege escalation.

Glossary

  • API: a defined way for one program to ask another program to do something or give it information, like a menu of allowed requests.
  • Bounty: a payment made to someone who reports a security flaw responsibly.
  • Cleartext: data stored or transmitted in readable form, with no encryption.
  • Cleartext storage of sensitive information: a weakness where secrets are kept somewhere unprotected, readable by anyone who can reach that place.
  • Cloud controller manager: the Kubernetes component that runs the cloud provider and its background loops.
  • Cloud provider: the part of Kubernetes that talks to the underlying infrastructure, here VMware vSphere.
  • Cluster: a group of machines managed together by Kubernetes as one system.
  • Commit: a saved snapshot of source code at a particular moment, identified by a long string.
  • Controller manager: the Kubernetes program that runs background loops keeping the cluster in its intended state.
  • CVSS: a standard scoring system for the severity of a security flaw.
  • Function: a named block of code that performs one job.
  • Handler: the code that runs when a subscription or event fires.
  • Informer: a subscription inside Kubernetes that notifies a component whenever an object of a given kind is created or changed.
  • kube-system: the namespace where Kubernetes' own system components usually run.
  • Kubernetes: a system for running and managing software in containers across many machines.
  • Log: a file where a program records what it did, for later inspection.
  • Log level (verbosity): a number controlling how much detail a program writes to its log.
  • Namespace: a labelled area inside a cluster used to group objects.
  • Payload: the data carried inside a request.
  • Pod: the smallest unit Kubernetes runs, a wrapper around one or more containers.
  • Privilege: a permission to perform an action in the cluster.
  • Privilege escalation: using a small permission to obtain a larger one.
  • Private key: the secret half of a cryptographic key pair, used to prove ownership of the matching public identity.
  • Recon: the early exploration phase of a security test, mapping out what a system contains.
  • Request: a message one program sends to another asking it to do something.
  • Secret: a Kubernetes object holding sensitive values such as passwords, keys or tokens.
  • Service account: an account in Kubernetes used by a program rather than a person.
  • Source code: the human written text a program is built from.
  • Token: a string that proves an identity, so the holder can act without a password.
  • User: a person with an account in the cluster.
  • vSphere: VMware software for running virtual machines on physical servers.
  • Verbose: recording much more detail than usual.

More from Kubernetes

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.