« All posts

CosmosEscape: How a Bug Exposed Every Azure Cosmos DB Account

A Gremlin API sandbox escape in Azure Cosmos DB exposed a master key capable of compromising any database on the service, Wiz Research found.

Wiz Research disclosed CosmosEscape, a critical vulnerability in Azure Cosmos DB's Gremlin API that allowed a sandbox escape. By abusing .NET reflection, researchers achieved arbitrary code execution on the DB Gateway, the multi-tenant service that brokers queries to customer databases.

That foothold exposed a platform-wide secret dubbed the Cosmos Master Key, capable of retrieving the primary key for any Cosmos DB account across tenants, regions, and API types. Combined with the Config Store, a queryable registry of every account on the service, attackers could enumerate databases by subscription or tenant ID and then obtain full read/write access—even to network-isolated accounts, since isolation was enforced by the same compromised gateway.

Because Cosmos DB underpins internal Microsoft services such as Entra ID, Teams, and Copilot, the flaw carried cross-service risk beyond customer environments. Microsoft shipped a mitigation within 48 hours of disclosure and has since eliminated the master-key architecture entirely; no evidence of exploitation beyond the researchers' testing was found.

The case underscores a core principle for multi-tenant cloud design: tenant-controlled execution needs a tightly scoped, heavily audited isolation boundary, with everything inside treated as untrusted and privileged credentials kept firmly out of reach.