A critical vulnerability dubbed CosmosEscape could have allowed attackers to take control of virtually every instance of Azure Cosmos DB, including Microsoft’s own internal databases. The flaw broke the isolation boundary between different customers on the cloud platform.
The issue resided in the Gremlin API, which is used for graph-oriented database queries. Carefully crafted queries escaped the restricted sandbox and executed code on the infrastructure responsible for processing customer requests. Researchers chained the exploit by abusing limitations in .NET reflection protections.
Once inside the DB Gateway, the attackers developed techniques to read and write files and run arbitrary commands. Successful compromise of the gateway granted access to a global signing secret known as the Cosmos Master Key. This key enabled retrieval of the primary key for any account, providing complete read and write access.
The attack surface also included the Config Store, a directory holding account names, subscription and tenant identifiers, network rules, and other configuration data. Attackers could filter this information to target specific organizations. Even privately isolated instances remained exposed because the DB Gateway itself enforced network restrictions.
Internal Microsoft services such as Microsoft Entra ID, Teams, and Copilot rely on Cosmos DB, underscoring the broad potential reach of the vulnerability.


