top of page
perceptive_background_267k.jpg

CosmosEscape: Taking Over Every Database in Azure Cosmos DB

Published:

30 July 2026 at 12:00:01

Alert date:

30 July 2026 at 13:00:57

Source:

wiz.io

Click to open the original link from this advisory

Cloud & Virtualization, Database & Storage, Zero-Day Vulnerabilities, Identity & Access

Wiz researchers discovered a critical vulnerability chain named CosmosEscape in Azure Cosmos DB that enabled full read and write access to every Cosmos DB database. The vulnerability chain allowed attackers to escape tenant isolation and take over any database hosted on the platform. This represents a severe cloud security risk affecting all Azure Cosmos DB customers. The flaw was responsibly disclosed to Microsoft and details were published by Wiz. The vulnerability highlights systemic risks in multi-tenant cloud database services where a single exploit chain can compromise all customers. No specific CVE identifiers were mentioned in the summary, but the impact is classified as critical due to its cross-tenant, platform-wide scope.

Technical details

CosmosEscape is a critical vulnerability in Azure Cosmos DB's Gremlin API that allowed sandbox escape and arbitrary code execution. The Cosmos DB Gremlin engine translated Gremlin graph queries into .NET code and enforced restrictions to prevent queries from escaping Gremlin operations. However, these restrictions failed to account for .NET reflection, enabling attackers to craft malicious Gremlin queries that achieved file read, file write, and arbitrary code execution on the DB Gateway backend. The DB Gateway runs on multi-tenant Azure Service Fabric clusters and executes customer queries on their behalf. By exploiting the sandbox escape, attackers gained access to credentials on the cluster, including a platform-wide signing key dubbed the 'Cosmos Master Key.' This key was not scoped to any single account — it worked across all tenants, regions, and API types (SQL, MongoDB, Cassandra, Gremlin) and could retrieve the primary key (granting full read/write access) for any Cosmos DB account on the service via publicly accessible endpoints. Additionally, the Cosmos Master Key unlocked access to the 'Config Store,' a regional Cosmos DB database serving as a directory of all Cosmos DB accounts, containing account names, subscription IDs, tenant IDs, network settings, and tags. Since the Config Store was itself a Cosmos DB database, it could be queried with full SQL flexibility. This enabled attackers to enumerate all accounts in a region or filter by tenant/subscription ID to target specific organizations. The attack chain: (1) Craft a malicious Gremlin query to escape the sandbox and execute arbitrary code on the DB Gateway, (2) Extract the Cosmos Master Key from cluster credentials, (3) Query the Config Store to enumerate or target specific Cosmos DB accounts, (4) Use the Cosmos Master Key to retrieve any account's primary key and gain full read/write access. The vulnerability also bypassed network isolation since the DB Gateway enforces network controls, and write access to the Config Store could allow overwriting network isolation settings. Microsoft internal services using Cosmos DB — including Microsoft Entra ID, Microsoft Teams, and Microsoft Copilot — were also potentially exposed.

Mitigation steps:

No customer action is required. Microsoft has fully remediated the vulnerability. Specific remediation actions taken by Microsoft include: (1) A hot fix was deployed within 48 hours of disclosure (November 22, 2025) to block the Gremlin API entry point for this attack vector; (2) The Cosmos Master Key was eliminated; (3) New guardrails were introduced in Cosmos DB to prevent similar attacks; (4) A long-term architectural migration was completed across all regions by July 2026, strengthening service-to-service authentication; (5) Additional network protections, monitoring, and detection capabilities were added. Organizations using Azure Cosmos DB should be aware that Microsoft found no evidence of exploitation beyond the researcher's testing activity and no customer data was accessed. As general best practices, organizations should monitor Cosmos DB access logs for anomalous activity, apply the principle of least privilege for Cosmos DB account keys, use network isolation and private endpoints where possible, and rotate primary keys periodically. Security teams should also be aware of sandbox escape risks in cloud database services that compile and execute customer-supplied query languages, and ensure that any credentials accessible within multi-tenant compute environments are scoped as narrowly as possible.

Affected products:

Azure Cosmos DB (Gremlin API)
Azure Cosmos DB (SQL API)
Azure Cosmos DB (MongoDB API)
Azure Cosmos DB (Cassandra API)
Azure Service Fabric (multi-tenant DB Gateway clusters)

Related links:

Related CVE's:

Related threat actors:

IOC's:

This article was created with the assistance of AI technology by Perceptive.

© 2025 by Perceptive Security. All rights reserved.

email: info@perceptivesecurity.com

Disclaimer: Deze website toont informatie afkomstig van externe bronnen. Perceptive aanvaardt geen verantwoordelijkheid voor de inhoud, juistheid of volledigheid van deze informatie.

bottom of page