Wiz Research disclosed a critical vulnerability, dubbed CosmosEscape, in Azure Cosmos DB, Microsoft’s flagship NoSQL database service.
The flaw resided in the service’s Gremlin API and could have allowed attackers to compromise any database on the platform, including Microsoft’s own internal Cosmos DB instances powering services like Microsoft Entra ID, Microsoft Teams, and Microsoft Copilot.
CosmosEscape Flaw Enabled Cross-Tenant
Researchers noticed a suspicious .NET exception while running Gremlin graph queries against Cosmos DB, an unusual signal since most open-source Gremlin implementations run on the Java Virtual Machine (JVM).
This hinted that Cosmos DB used a custom, .NET-based Gremlin engine that compiled queries into executable code within a sandboxed environment.
That sandbox didn’t adequately restrict .NET reflection. Wiz exploited this gap to build file read, file write, and eventually arbitrary code execution primitives, achieving remote code execution on the DB Gateway the multi-tenant Service Fabric component that processes customer queries.
Automated code vulnerability detection routines often struggle with custom reflection vectors in compiled query engines.

From the compromised DB Gateway, researchers found credentials for a signing key used to retrieve any Cosmos DB account’s primary key, the credential granting full read/write access to that account’s data.
Critically, this signing key wasn’t scoped to a single tenant. It worked across accounts, regions, and API types (SQL, MongoDB, Cassandra, Gremlin), earning it the name Cosmos Master Key.
This key also unlocked access to the Config Store, a regional directory listing every Cosmos DB account along with subscription IDs, tenant IDs, and network configuration data.
Because the Config Store was itself a Cosmos DB database, attackers could query it using standard SQL syntax to enumerate accounts platform-wide or filter by tenant to target specific organizations.
As detailed in the Wiz Blog analysis, chaining multi-tenant signing keys with administrative metadata endpoints creates a catastrophic blast radius across cloud infrastructure.
Such cross-tenant risks parallel recent authentication bypass vulnerabilities where over-privileged architectural keys bypass standard perimeter controls.

Chained together, the two capabilities created a precision attack path:
- Target Enumeration: Query the Config Store to enumerate or target accounts by tenant or subscription ID.
- Data Compromise: Use the Master Key to retrieve that account’s primary key for full data access.

The flaw also affected private, network-isolated Cosmos DB instances, since the compromised DB Gateway enforced network isolation rules. Write access to the Config Store further suggested attackers could potentially alter isolation settings entirely.
These infrastructure exposure vectors mirror risks observed in severe microsoft zero day flaws where underlying administrative roles bypass tenant boundary controls.
| Attack Lifecycle Stage | Exploit Primitives & Mechanisms | Technical Operational Impact |
| Sandbox Escape | Unrestricted .NET reflection in Gremlin engine | Remote Code Execution on multi-tenant DB Gateway |
| Credential Harvesting | Unscoped DB Gateway signing key extraction | Access to global Cosmos Master Key |
| Target Discovery | Querying regional Config Store directory | Enumeration of subscription IDs, tenant IDs, and network settings |
| Cross-Tenant Access | Primary key generation via DB Gateway | Full read/write data compromise across all regions and APIs |
Wiz reported CosmosEscape to Microsoft on November 20, 2025. Microsoft deployed a hotfix within 48 hours and spent the following months migrating to a hardened architecture, ultimately eliminating the Cosmos Master Key design pattern altogether.
The rollout completed in July 2026, with public disclosure following on July 30.
Microsoft Statement: Internal log reviews found no evidence of exploitation beyond Wiz’s authorized security testing, and no customer data was accessed. No customer action is required.
CosmosEscape underscores a recurring cloud security lesson: infrastructure-tier services need tightly scoped isolation boundaries around tenant-controlled execution. When a shared credential or signing key spans multiple tenants, a single sandbox escape can cascade into a platform-wide compromise.
Full technical details, including the exploit chain, will be presented at Black Hat USA in the talk “One Key to Rule Them All: Taking Over a Flagship Cloud Service.”