CosmosEscape flaw let attackers seize Azure Cosmos DB

A vulnerability called CosmosEscape let researchers obtain a platform-wide signing key and any account’s primary key, enabling full read and write access across Azure Cosmos DB.

Security firm Wiz reported a vulnerability in Microsoft’s Azure Cosmos DB that could let an attacker obtain a platform‑wide signing key and then retrieve the primary key for any Cosmos DB account, giving full read and write access across the service. Wiz referred to the flaw as CosmosEscape.

Wiz researchers said the issue could be exploited through the Gremlin API, which runs graph queries on a custom engine that compiles queries into .NET code and executes them in a sandbox. The engine enforced restrictions on standard Gremlin operations but did not block .NET reflection. Researchers used reflection to build primitives for arbitrary code execution and to bypass the Gremlin sandbox.

Bypassing the sandbox allowed code execution on the DB Gateway, the component that executes customer queries on multi‑tenant Service Fabric clusters. Wiz found the gateway used a signing key to request customers’ primary keys and that the signing key functioned across tenants, regions and APIs. The researchers called that credential the “Cosmos Master Key.” Using the master key, they accessed a configuration store that contained details for every Cosmos DB account, including account names, subscription IDs, tenant IDs and other configuration data.

The configuration store was itself a Cosmos DB database and could be queried with Cosmos DB’s SQL engine. Wiz reported that the master key could retrieve the configuration store’s primary key, which in turn would allow an attacker to list all accounts in a region or query by tenant ID to identify a particular organization’s databases. An attacker who then retrieved a target account’s primary key would have the same read and write privileges as the account owner. Wiz said the same exploit chain could be used against private and network‑isolated Cosmos DB accounts and Microsoft’s internal databases.

Wiz disclosed the vulnerability to Microsoft in November 2025. Microsoft deployed a hotfix within two days to block the attack vector and completed a long‑term architectural fix across all regions in July. Microsoft reviewed access logs and reported no evidence of unauthorized activity beyond the researchers’ testing and no customer data accessed. Microsoft added that no customer action is required.

Wiz highlighted that Microsoft stores data for services such as Entra ID, Teams and Copilot in Cosmos DB, and that the chain of vulnerabilities could allow identification and compromise of specific organizations’ databases from publicly accessible endpoints. Both Wiz and Microsoft published technical accounts of the discovery and the fixes for operators and researchers.

Articles by this author