A recently patched vulnerability in Azure Cosmos DB posed a significant security risk, potentially allowing unauthorized access to customer databases. Discovered by cloud security firm Wiz, the flaw could have enabled attackers to bypass the service’s Gremlin query sandbox, thereby gaining full read and write access to databases across different customer tenants.
Details of the CosmosEscape Exploit
Wiz, which identified and named the exploit chain as ‘CosmosEscape’, revealed that the attack could commence with a specially crafted query targeting a Gremlin database under the attacker’s control. This breach allowed code execution on a multi-tenant gateway, revealing a platform-wide signing secret and a regional account directory. These vulnerabilities facilitated the identification of target databases and the extraction of their primary account keys.
Microsoft responded promptly by blocking the vulnerable Gremlin entry point within 48 hours following Wiz’s report in November 2025. A comprehensive fix was implemented by July 2026, effectively removing the platform-wide key. Notably, Microsoft confirmed that there was no unauthorized data access beyond the researchers’ controlled testing, assuring users that no further action was required.
Technical Insights into the Vulnerability
The technical analysis by Wiz highlights that the Cosmos DB’s custom Gremlin engine translates queries into .NET code, executing them in a restricted environment. However, the imposed restrictions did not adequately prevent .NET reflection, which allowed researchers to execute arbitrary code by constructing file-read and file-write operations. The execution occurred on a component termed the DB Gateway, responsible for processing queries on multi-tenant Azure Service Fabric clusters.
Significantly, the DB Gateway was equipped with credentials that provided access to what Wiz dubbed the ‘Cosmos Master Key’. This key could extract the primary key for any account, spanning multiple tenants, regions, and APIs, including SQL, MongoDB, Cassandra, and Gremlin. Furthermore, access to a regional database named the Config Store was possible, which contained essential account details and network settings.
Future Implications and Security Measures
Despite the potential for widespread access, Wiz confirmed that no private or network-isolated accounts were compromised. The researchers did suggest that network settings could be altered, though such actions were not demonstrated against other customer accounts. Microsoft’s documentation notes that Cosmos DB holds critical data for products like Microsoft Teams and Copilot, although no unauthorized access to such data was reported.
The specific timeline for the vulnerability’s presence in production remains unclear, as does the complete scope of Microsoft’s log review. However, the security flaw, identified separately from past issues like ChaosDB and CosMiss, was effectively closed, mitigating further risk. This incident underscores the critical importance of robust security practices in cloud services and the swift action required to address vulnerabilities.
