And they had a wildcard cert too. Still feeling secure?
An astonishing piece of vulnerability probing gave infosec researchers a way into to Microsoft’s management controls for Azure Cosmos DB – with full read and write privileges over customer databases.
The so-called ChaosDB vuln gave Wiz researchers “access to the control panel of the underlying service” that hosts Azure Cosmos, Microsoft’s managed cloudy document database service, they said.
Wiz was able to obtain plaintext Primary Keys “for any Cosmos DB instance running in our cluster” as well as executing arbitrary code in any other customer’s Jupyter Notebook instances.
Worse than that, the researcher claimed: “Using just one certificate, we managed to authenticate to internal Service Fabric instances of multiple [Azure Cosmos] regions that were accessible from the internet.” Service Fabric, as Reg readers may know, is Microsoft’s home-grown microservice platform and one of the core services in Azure.
C# running as root
Thanks to a series of exploitable configuration blunders, the Wiz researchers were able to escape from their own containerised Azure Cosmos instance onto the underlying virtual machine, and then freely roam around Azure Service Fabric – Microsoft’s own Kubernetes-style service that controls Azure Cosmos.
“We were, just, like, looking for misconfigurations,” one of the Wiz team, researcher Nir Ohfeld, said during in an interview with The Register today. His fellow researcher Sagi Tzadik added: “Between us, we refer it to like escaping the Matrix. We went from being managed by the service to managing the service.”
The two described their company’s as a Holy Grail for attackers, and said the level of access they secured should have Azure customers asking Microsoft some sharp questions.
Wiz’s eye-popping blogpost details what the company found: a chain of vulnerabilities that ultimately granted them access to other users’ databases within Azure Cosmos, thanks to private keys issued by Microsoft.
The researchers started off by looking closely at Jupyter Notebook within Azure Cosmos. The open-source web app lets developers create and share live code with others, and as part of that needs to support various languages.
Wiz spotted something quite surprising: C# code was executed as root: “For some unknown reason, the host process for C# specifically was running with root privileges, which meant that any C# code would be executed as root as well. We used this misconfiguration to escalate our privileges inside the container.”
From there they decided to see what was keeping them inside the container. The answer, unbelievably, was a set of firewall rules inside the container, viewable with
iptables. Using their root privs in C# they deleted those rules. And that was all it took.
Using the IP addresses defined in the deleted firewall rules, Ohfeld and Tzadik say their team “conducted some network recon” on IP addresses specified in those rules, using the unimprovable logic:
…that if the developers went through the trouble of explicitly attempting to prevent us from accessing these addresses, then we should most definitely go through the trouble of attempting to access them.
“The output gave us a list of all Cosmos DB instances (more than 500!) that were managed by this regional cluster, including those that do not belong to our account,” says Wiz.
This got them onto the Windows-based host VM. From there they pivoted to WireServer, an extension (as in software app) manager used to administer Azure VMs. Helpfully, WireServer is an open-source project on GitHub; poking around there gave enough clues to identify some Azure Cosmos certificates in WireServer – and their private keys.
Those included a wildcard cert for notebook.cosmos.azure.com which could have, as Wiz puts it, “allowed us to intercept encrypted SSL traffic of customers’ Jupyter Notebook running on the HOST Windows VM.”
- Azure’s now-fixed Cosmos DB flaw could have been exploited to read, write any database
- We don’ need no stinkin’ bounties: VirtualBox guest-to-host escape zero-day lands at GitHub
- VMware hypervisor escape via serial port? VMware hypervisor escape via serial port.
- KVM flaw on AMD servers gave malicious VMs a route to take over the host
Ohfeld described this to El Reg as “the Holy Grail for an attacker.” Tzadik added that a malicious person with those keys could have even encrypted every single customer database within reach – potentially thousands, with a bit more lateral movement through the Azure Cosmos management layer.
Matt Yonkovit, head of open source strategy at database firm Percona, told The Register: “The report is quite an interesting read of how the attackers were able to use public information and open source to gain additional insight into the environment they were exploring. I also found it surprising that the host OS used for these Linux containers was a Windows operating system, so they were running on the Windows Subsystem for Linux (WSL).”
We have asked Microsoft for comment and will update this article if we hear back from the company. ®