Azure Cosmos DB Flaw Exposed Platform-Wide Key That Could Access Any Database
A critical vulnerability in Azure Cosmos DB, dubbed "CosmosEscape," allowed attackers to escape the Gremlin query sandbox and gain full read/write access across customer tenants. The exploit chain leveraged a crafted Gremlin query to execute code on a multi-tenant gateway, exposing a platform-wide signing key (Cosmos Master Key) that could retrieve primary keys for any account across regions and APIs. Microsoft patched the vulnerable Gremlin entry point within 48 hours of reporting and completed
Analysis
TL;DR
- A critical vulnerability in Azure Cosmos DB, dubbed "CosmosEscape," allowed attackers to escape the Gremlin query sandbox and gain full read/write access across customer tenants.
- The exploit chain leveraged a crafted Gremlin query to execute code on a multi-tenant gateway, exposing a platform-wide signing key (Cosmos Master Key) that could retrieve primary keys for any account across regions and APIs.
- Microsoft patched the vulnerable Gremlin entry point within 48 hours of reporting and completed a long-term fix by eliminating the platform-wide key in July 2026, with no evidence of customer data exposure.
- The flaw highlighted risks in multi-tenant cloud database architectures, particularly around isolation boundaries and secret management in shared infrastructure components.
- Wiz plans to disclose the complete technical chain at Black Hat USA, emphasizing the need for rigorous sandboxing and least-privilege design in managed services.
Why It Matters
This vulnerability underscores the high stakes of secure sandboxing in multi-tenant cloud databases, where a single flaw can cascade into cross-tenant privilege escalation. For AI practitioners and cloud security teams, it reinforces the importance of scrutinizing managed service internals—especially when they handle sensitive data like Teams messages or Copilot logs stored in Cosmos DB. The incident also highlights how seemingly isolated components (e.g., query gateways) can become attack vectors if secrets are improperly scoped or exposed.
Technical Details
- Exploit Chain: Attacker-controlled Gremlin database → crafted query triggers .NET reflection bypass → arbitrary code execution on multi-tenant DB Gateway → extraction of Cosmos Master Key → access to Config Store directory → retrieval of target account primary keys.
- Sandbox Failure: Cosmos DB’s Gremlin engine translated queries into .NET code but failed to restrict reflection APIs, enabling file I/O and command execution outside the intended sandbox.
- Platform-Wide Key Risk: The Cosmos Master Key, used internally by the gateway to sign requests, inadvertently granted ability to fetch primary keys for any Cosmos DB account across SQL, MongoDB, Cassandra, and Gremlin APIs.
- Config Store Exposure: This regional directory contained metadata (account names, tenant IDs, network settings), allowing attackers to map targets and potentially modify network configurations (though not demonstrated against victim accounts).
- Network Isolation Bypass: Compromised gateway enforced network policies from within, meaning even private or VNet-isolated accounts were reachable via the exploit.
Industry Insight
Cloud providers must audit internal secret propagation paths in multi-tenant services, especially when shared components (like query gateways) interact with customer data planes. The elimination of platform-wide keys should become a standard practice in managed database architectures to limit blast radius of sandbox escapes. Additionally, coordinated vulnerability disclosure programs—like Wiz’s partnership with Microsoft—are critical for rapid remediation, though organizations should assume zero-day exposure until patches are universally deployed and validated.
Disclaimer: The above content is generated by AI and is for reference only.