Full Report
A critical vulnerability chain in Azure Cosmos DB enabled full read and write access to every Cosmos DB database.
Analysis Summary
# Vulnerability: CosmosEscape - Cross-Tenant Access in Azure Cosmos DB
## CVE Details
- **CVE ID**: Not yet assigned (Cloud vulnerability - documented as "CosmosEscape")
- **CVSS Score**: 10.0 (Calculated estimate - Critical)
- **CWE**: CWE-94 (Improper Control of Generation of Code) / CWE-693 (Protection Mechanism Failure)
## Affected Systems
- **Products**: Microsoft Azure Cosmos DB
- **Versions**: All versions utilizing the Gremlin (Graph) API prior to July 2026.
- **Configurations**: Instances where the Gremlin API was enabled.
## Vulnerability Description
CosmosEscape is a vulnerability chain originating in the Cosmos DB Gremlin engine. Unlike standard JVM-based Gremlin stacks, Azure utilized a custom .NET-based engine that translated Gremlin queries into executable code. The sandbox intended to restrict this code failed to adequately account for .NET reflection.
Researchers were able to use reflection via query inputs to achieve:
1. **Local File Read/Write**: Accessing files on the underlying DB Gateway.
2. **Remote Code Execution (RCE)**: Executing arbitrary commands (e.g., `hostname`) on the DB Gateway.
3. **Privilege Escalation**: By gaining RCE on the multi-tenant DB Gateway cluster, researchers accessed internal credentials, specifically the "Cosmos Master Key." This key allowed the retrieval of any customer account's Primary Key and the enumeration of all databases across the platform.
## Exploitation
- **Status**: PoC available (demonstrated by Wiz Research); No evidence of exploitation in the wild.
- **Complexity**: Low (once the reflection bypass is identified).
- **Attack Vector**: Network (unauthenticated/authenticated via standard Gremlin query endpoint).
## Impact
- **Confidentiality**: Total (Full read access to all customer databases, including Microsoft internal services like Teams and Entra ID).
- **Integrity**: Total (Full write access to every database on the service).
- **Availability**: High (Ability to modify or delete data across the platform).
## Remediation
### Patches
- **Vendor Fix**: Microsoft has applied service-side remediations. The "Cosmos Master Key" architecture has been eliminated, and new guardrails have been implemented for the Gremlin engine.
### Workarounds
- **No customer action required**: As this is a PaaS (Platform as a Service) vulnerability, the fix was applied globally by Microsoft.
## Detection
- **Indicators of Compromise**: Historically, suspicious Gremlin queries involving .NET reflection patterns or unexpected `System.Reflection` calls.
- **Detection Methods**: Microsoft conducted a retrospective investigation and found no unauthorized access beyond the research team. Customers can monitor for unusual data egress or unexpected primary key rotations in their own audit logs.
## References
- **Vendor Advisories**: [Microsoft Security Response Center (MSRC)](https://msrc.microsoft[.]com/)
- **Relevant Links**: [Wiz Blog: CosmosEscape](https://www.wiz[.]io/blog/cosmosescape-taking-over-every-database-in-azure-cosmos-db)