A vulnerability in Microsoft Azure Cosmos DB that has now been fully patched could have allowed attackers to gain extensive access to databases across customer tenants, according to cloud security company Wiz. The vulnerability, codenamed CosmosEscape, enabled attackers to escape the Gremlin query sandbox and potentially obtain full read and write access to customer databases. Microsoft confirmed that the issue has been fully addressed and stated that its investigation found no evidence of customer impact, no unauthorized access to customer data, and no action is required from customers.
According to Wiz, the exploit chain began with a specially crafted query executed against a Gremlin database controlled by the attacker. Successful exploitation allowed code execution on a multi tenant gateway, exposing a platform wide signing secret together with a regional account directory. Using this information, researchers demonstrated that it was possible to identify target Cosmos DB accounts and retrieve their primary account keys. Wiz explained that only a standard Azure account with a Cosmos DB Gremlin database under the attacker’s control was required to begin the attack. No elevated privileges, insider access, or previous compromise of Azure infrastructure was necessary. Researchers stated that the exploit operated entirely through the attacker’s own database query interface. Microsoft responded quickly after receiving the vulnerability report in November 2025, disabling the vulnerable Gremlin entry point within 48 hours. According to Wiz, Microsoft completed a permanent fix across all Azure regions in July 2026 by removing the platform wide signing key that enabled the attack path.
Wiz technical analysis explained that Cosmos DB custom Gremlin engine converts Gremlin queries into .NET code before executing them in a restricted environment. Researchers found that the sandbox restrictions did not adequately prevent the use of .NET reflection, allowing them to build file read and file write capabilities before ultimately achieving arbitrary code execution. The researchers demonstrated the exploit by executing a hostname command on the Cosmos DB backend but did not publicly disclose the crafted query itself. They indicated that the complete technical details of the exploit chain will be presented during a Black Hat USA briefing scheduled for August 6. After gaining code execution, the researchers reached a component identified as the DB Gateway, which processes customer queries on multi tenant Azure Service Fabric clusters. Although customer databases were not stored on those clusters, the gateway had permission to retrieve primary account keys for Cosmos DB accounts. Microsoft documentation states that these primary keys provide full administrative control over all resources within an account.
According to Wiz, credentials available to the gateway also provided access to a platform wide signing secret referred to as the Cosmos Master Key. Researchers stated that they tested the key across multiple Cosmos DB application programming interfaces, including SQL, MongoDB, Cassandra, and Gremlin, and in several Azure regions. They reported that the signing key successfully retrieved primary account keys for every account tested across different tenants and regions. Wiz also stated that the same secret allowed access to a regional Config Store containing account names, tenant and subscription identifiers, network configuration details, and resource tags. The researchers said this information could enable attackers to identify target organizations before requesting account keys. While the report indicated that services such as Microsoft Teams and Microsoft Copilot store certain information within Cosmos DB, Wiz emphasized that it did not access customer data associated with those services. Microsoft stated that its internal review identified no unauthorized activity beyond the controlled research environment and confirmed that no customer information was compromised. The disclosure does not include a Common Vulnerabilities and Exposures identifier or severity score, and Wiz noted that CosmosEscape is separate from the previously disclosed ChaosDB and CosMiss vulnerabilities that affected Cosmos DB in 2021 and 2022.
Follow the SPIN IDG WhatsApp Channel for updates across the Smart Pakistan Insights Network covering all of Pakistan’s technology ecosystem.





