Critical CosmosEscape Vulnerability in Microsoft Azure Cosmos DB Exposed Cross-Tenant Risks
Security researchers at Wiz uncovered a severe vulnerability, dubbed CosmosEscape, in Microsoft Azure Cosmos DB’s Gremlin API that could have allowed attackers to gain control over nearly all databases hosted on the service including Microsoft’s internal systems.
The flaw stemmed from Cosmos DB’s custom .NET-based Gremlin engine, which failed to properly restrict .NET reflection during query processing. This oversight enabled attackers to execute arbitrary code on the DB Gateway, a multi-tenant component handling customer queries. By crafting malicious Gremlin queries, researchers demonstrated the ability to read/write files and execute commands such as retrieving the hostname on Cosmos DB’s backend infrastructure.
The attack chain escalated further when researchers discovered the Cosmos Master Key, an unscoped signing key used by the DB Gateway to access customer databases. This key provided unrestricted access across all tenants, regions, and API formats (SQL, MongoDB, Cassandra, Gremlin) and could be used to query the Config Store, a master directory of every Cosmos DB account, including subscription IDs, tenant IDs, and network policies.
With this access, attackers could enumerate targets, generate primary keys, and gain full read-write access to any database even those in private, network-isolated environments. The vulnerability posed a systemic risk, as Cosmos DB underpins critical Microsoft services like Microsoft Entra ID, Teams, and Copilot, extending exposure to Microsoft’s own backend systems.
Wiz responsibly disclosed the flaw to Microsoft, which deployed a hotfix and later eliminated the Cosmos Master Key entirely, implementing additional safeguards. Microsoft’s investigation found no evidence of malicious exploitation, and no customer action was required.
The incident highlights architectural risks in multi-tenant cloud environments, where overprivileged service accounts and insufficient sandboxing can amplify the impact of a single vulnerability.
Source: https://cybersecuritynews.com/cosmosescape-vulnerability/
Microsoft Azure cybersecurity rating report: https://www.rankiteo.com/company/microsoft-azure
"id": "MIC1785428986",
"linkid": "microsoft-azure",
"type": "Vulnerability",
"date": "5/2025",
"severity": "100",
"impact": "5",
"explanation": "Attack threatening the organization's existence"
{'affected_entities': [{'customers_affected': 'All Cosmos DB customers '
'(potentially millions)',
'industry': 'Technology/Cloud Services',
'location': 'Global',
'name': 'Microsoft Azure Cosmos DB',
'size': 'Large',
'type': 'Cloud Database Service'},
{'industry': 'Technology/Cloud Services',
'location': 'Global',
'name': 'Microsoft Entra ID',
'size': 'Large',
'type': 'Identity and Access Management'},
{'industry': 'Technology/Cloud Services',
'location': 'Global',
'name': 'Microsoft Teams',
'size': 'Large',
'type': 'Collaboration Platform'},
{'industry': 'Technology/Cloud Services',
'location': 'Global',
'name': 'Microsoft Copilot',
'size': 'Large',
'type': 'AI Assistant'}],
'attack_vector': 'Malicious Gremlin queries via .NET reflection',
'customer_advisories': 'No customer action required (Microsoft deployed '
'fixes)',
'data_breach': {'personally_identifiable_information': 'Potential (depending '
'on customer data '
'stored in Cosmos DB)',
'sensitivity_of_data': 'High (potential access to all '
'customer databases, including PII)',
'type_of_data_compromised': ['Database records',
'Subscription IDs',
'Tenant IDs',
'Network policies']},
'description': 'Security researchers at Wiz uncovered a severe vulnerability, '
'dubbed CosmosEscape, in Microsoft Azure Cosmos DB’s Gremlin '
'API that could have allowed attackers to gain control over '
'nearly all databases hosted on the service including '
'Microsoft’s internal systems. The flaw stemmed from Cosmos '
'DB’s custom .NET-based Gremlin engine, which failed to '
'properly restrict .NET reflection during query processing, '
'enabling attackers to execute arbitrary code on the DB '
'Gateway. The attack chain escalated with the discovery of the '
'Cosmos Master Key, providing unrestricted access across all '
'tenants, regions, and API formats. This posed a systemic risk '
'to critical Microsoft services like Microsoft Entra ID, '
'Teams, and Copilot.',
'impact': {'brand_reputation_impact': 'High (critical vulnerability in a '
'major cloud service)',
'data_compromised': 'Potential full read-write access to all '
'Cosmos DB databases, including sensitive '
'customer data',
'identity_theft_risk': 'High (potential access to personally '
'identifiable information)',
'operational_impact': 'Potential unauthorized access to '
'multi-tenant databases and Microsoft '
'internal systems',
'systems_affected': 'Microsoft Azure Cosmos DB, Microsoft Entra '
'ID, Teams, Copilot, and other backend '
'systems'},
'investigation_status': 'Completed (no evidence of malicious exploitation '
'found)',
'lessons_learned': 'Architectural risks in multi-tenant cloud environments, '
'where overprivileged service accounts and insufficient '
'sandboxing can amplify the impact of a single '
'vulnerability.',
'post_incident_analysis': {'corrective_actions': 'Hotfix for Gremlin API, '
'elimination of Cosmos '
'Master Key, additional '
'safeguards',
'root_causes': 'Improper restriction of .NET '
'reflection in Gremlin API, '
'overprivileged Cosmos Master Key'},
'references': [{'source': 'Wiz Security Research'}],
'response': {'communication_strategy': 'Responsible disclosure to Microsoft, '
'public advisory after patching',
'containment_measures': 'Hotfix deployed to restrict .NET '
'reflection in Gremlin API',
'remediation_measures': 'Elimination of Cosmos Master Key, '
'implementation of additional safeguards',
'third_party_assistance': 'Wiz (security researchers)'},
'title': 'Critical CosmosEscape Vulnerability in Microsoft Azure Cosmos DB '
'Exposed Cross-Tenant Risks',
'type': 'Vulnerability Exploitation',
'vulnerability_exploited': 'CosmosEscape (improper .NET reflection '
'restriction in Gremlin API)'}