Skip to navigation

Threat reportVulnerabilityTL-2026-1802

CosmosEscape: Gremlin API Sandbox Escape Exposed Platform-Wide Key for Every Azure Cosmos DB Database

criticalPATCHED

Wiz Research discovered CosmosEscape, a vulnerability chain in Azure Cosmos DB's Gremlin API that used unrestricted .NET reflection to escape the query sandbox, achieve arbitrary code execution on the multi-tenant DB Gateway, and retrieve a platform-wide 'Cosmos Master Key' capable of unlocking any customer's Cosmos DB account across every API surface.

By

Key facts

IdentifiersTL-2026-1802
Also known asCosmosEscape
SeverityCRITICAL
Affected productsMicrosoft Azure Cosmos DB (Gremlin API); Microsoft Azure Cosmos DB (SQL, MongoDB, Cassandra APIs)
Weaknesses (CWE)CWE-470, CWE-284, CWE-668, CWE-269
ToolsApache TinkerPop Gremlin
MITRE ATT&CK techniquesT1059 Command and Scripting Interpreter, T1068 Exploitation for Privilege Escalation, T1190 Exploit Public-Facing Application, T1210 Exploitation of Remote Services, T1213 Data from Information Repositories, T1526 Cloud Service Discovery, T1528 Steal Application Access Token, T1530 Data from Cloud Storage, T1552 Unsecured Credentials, T1565 Data Manipulation, T1580 Cloud Infrastructure Discovery, T1585 Establish Accounts and 3 more in the attack flow
MotivationUNKNOWN
Target sectorstechnology, cloud-services, government administration, finance, health, enterprise-saas, cross-sector
Target regionsGlobal
Detection rules9 (1 shown free)
Sources13 cited sources

Detection coverage

As of 2026-07-31, Threadlinqs Intelligence publishes 9 detection rule(s) for TL-2026-1802 across Splunk SPL, Microsoft KQL and Sigma, covering 24 indicator(s) of compromise. The whole corpus is readable without an account. Every threat comes with one complete detection in Splunk SPL, Microsoft KQL and Sigma, free for everyone; a free account adds daily TL Creds to unlock the rest. Paid plans add a larger daily allowance, correlation and the MCP server. Threadlinqs MCP server · View plans.

Free detection: CosmosEscape — Gremlin Diagnostic-Log Reflection-Pattern Exploit Query

Detects Azure Cosmos DB Gremlin API diagnostic-log query text referencing .NET reflection APIs (System.Reflection, GetMethod, Invoke, Assembly.Load) that should never appear in legitimate graph-traversal Gremlin syntax — the query-text signature of the CosmosEscape sandbox-escape technique that let Wiz Research reach an arbitrary code-execution primitive on the multi-tenant DB Gateway.

  • Languages: Splunk SPL, Microsoft KQL, Sigma
  • ATT&CK: T1190, T1059, T1611
  • Data sources: azure_cosmosdb_diagnostic_logs (GremlinRequests category)
  • Severity: critical
  • Confidence: high

Splunk SPL

index=azure sourcetype="azure:monitor:diagnostics" category=GremlinRequests
| rex field=query_text "(?i)(?<reflection_hit>System\.Reflection|GetMethod\(|\.Invoke\(|Assembly\.Load)"
| where isnotnull(reflection_hit)
| stats count min(_time) as first_seen max(_time) as last_seen values(query_text) as sample_queries by accountName_s, databaseName_s, collectionName_s, clientIpAddress_s, subscriptionId_s
| where count > 0
| sort - count

Microsoft KQL

AzureDiagnostics
| where TimeGenerated > ago(24h)
| where Category == "GremlinRequests"
| where query_text_s has_any ("System.Reflection", "GetMethod(", ".Invoke(", "Assembly.Load")
| summarize Count=count(), FirstSeen=min(TimeGenerated), LastSeen=max(TimeGenerated), SampleQueries=make_set(query_text_s) by AccountName_s, DatabaseName_s, CollectionName_s, ClientIpAddress_s, SubscriptionId
| where Count > 0
| sort by Count desc

Sigma

title: Cosmos DB Gremlin Query Containing .NET Reflection API Reference
id: 8f3b1c2a-6e4d-4a7f-9c1e-2b7a9d5f3e01
status: experimental
description: Detects Azure Cosmos DB Gremlin API diagnostic-log query text referencing .NET reflection APIs (System.Reflection, GetMethod, Invoke, Assembly.Load) — a signature of the CosmosEscape sandbox-escape technique, since legitimate Gremlin graph-traversal syntax never contains these tokens.
references:
    - https://www.wiz.io/blog/cosmosescape-taking-over-every-database-in-azure-cosmos-db
author: Threadlinqs Team
date: 2026/07/31
tags:
    - attack.initial_access
    - attack.t1190
    - attack.execution
    - attack.t1059
    - attack.privilege_escalation
    - attack.t1611
logsource:
    category: application
    service: azure_cosmosdb_diagnostics
detection:
    selection:
        query_text|contains:
            - 'System.Reflection'
            - 'GetMethod('
            - '.Invoke('
            - 'Assembly.Load'
    condition: selection
falsepositives:
    - Internally authorized security-research/pentesting engagements probing Cosmos DB Gremlin sandbox boundaries
level: critical

Known false positives:

  • Authorized red-team/Wiz-style research testing Gremlin sandbox boundaries with reflection payloads
  • Third-party Gremlin tooling that legitimately logs .NET type names in diagnostic output (rare)

Tuning notes: Enable Cosmos DB diagnostic settings to stream the GremlinRequests category to the SIEM if not already configured; whitelist known internal security-testing subscription IDs to avoid alerting on authorized assessments.

8 more detection rules (Splunk SPL, Microsoft KQL, Sigma) · unlock with TL Creds. Sign up free to unlock the detection rules or query them with the Threadlinqs MCP server (Purple and Gold in full, 2 calls a day on a free account)
  • CosmosEscape — Reflection Invocation Immediately Followed by Recon Command (Host+Cloud Correlation) · unlock with TL Creds
  • Control-Plane Key Retrieval Correlated with Local Keystore Artifact Write · unlock with TL Creds
  • Config-Store-Style Enumeration Filtered by SubscriptionId/TenantId (Targeted Takeover Recon) · unlock with TL Creds
  • CosmosEscape — Sandbox-Escape Reflection Pattern (Sigma Process-Creation) · unlock with TL Creds
  • Master/Signing-Key-Style Artifact Written to Disk or Registry by Non-Database-Service Process · unlock with TL Creds
  • Config-Store-Style File Modification Immediately Following Subscription/Tenant Enumeration · unlock with TL Creds
  • CosmosEscape — Anomalous Cosmos DB Key-Retrieval / RegenerateKey Control-Plane Calls · unlock with TL Creds
  • CosmosEscape — Single Credential Reused Across Multiple Cosmos DB API Surfaces · unlock with TL Creds

Indicators of compromise

As of 2026-07-31, Threadlinqs Intelligence tracks 24 indicators of compromise for TL-2026-1802.

24 indicators of compromise · unlock with TL Creds. Compare plans

Technical analysis

Microsoft hotfixed the entry point within 48 hours of the November 2025 report and completed an architectural fix eliminating the master key across all regions by July 2026, with no evidence of exploitation beyond Wiz's own testing.

CosmosEscape is a multi-stage vulnerability chain disclosed by Wiz Research in a July 30, 2026 blog post ('CosmosEscape: Taking Over Every Database in Azure Cosmos DB'), affecting Microsoft Azure Cosmos DB — Microsoft's flagship globally-distributed NoSQL database service. The chain began when Wiz researchers, experimenting with Cosmos DB's Gremlin graph-query API using only a standard, self-provisioned Azure account, noticed an unusual .NET exception. This revealed that unlike typical Gremlin implementations (which run atop the Java Virtual Machine using Apache TinkerPop), Cosmos DB compiles Gremlin queries into .NET code executed inside a sandbox intended to restrict operations to graph-traversal semantics. That sandbox enforced restrictions on Gremlin operations but did not adequately account for .NET reflection, letting the researchers craft queries against their own database that built file-read, file-write, and ultimately arbitrary code-execution primitives — demonstrated by executing the `hostname` OS command on Cosmos DB backend infrastructure.

This sandbox escape gave the researchers code execution on the DB Gateway, the multi-tenant service that executes every customer's queries on Azure Service Fabric clusters shared across tenants and regions. From that foothold, they found that the DB Gateway itself held credentials to a signing key — which Wiz dubbed the 'Cosmos Master Key' — used to retrieve any account's primary key. Critically, this key was not scoped to a single tenant, region, or API flavor: it worked across SQL, MongoDB, Cassandra, and Gremlin APIs platform-wide, and could be invoked through publicly accessible endpoints. Because compromise occurred inside the shared gateway rather than at any individual tenant boundary, even privately-networked and network-isolated Cosmos DB accounts were exposed — the isolation controls that were supposed to protect them did not extend to the gateway layer itself.

Using the master key, the researchers additionally accessed the Config Store, a regional directory recording every Cosmos DB account's name, subscription ID, tenant ID, network configuration, and tags. Because the Config Store is itself implemented as a Cosmos DB database, it could be queried with the full expressive power of Cosmos DB's SQL engine — enabling attackers to enumerate every account in a region or filter directly by a target organization's subscription or tenant ID, turning a theoretical platform-wide key into a practical, targeted takeover capability against any named customer. Wiz verified this reach extended to Microsoft's own internal Cosmos DB-backed services, including databases supporting Microsoft Entra ID, Microsoft Teams, and Microsoft Copilot, observing access to thousands of Microsoft-internal databases within a single region/tenant during testing.

Wiz reported CosmosEscape to Microsoft on November 20, 2025; Microsoft acknowledged the same day and deployed a hotfix blocking the vulnerable Gremlin entry point within 48 hours (November 22, 2025), while beginning work on a long-term architectural fix. That fix — which eliminated the Cosmos Master Key entirely in favor of a hardened authentication architecture with new guardrails and enhanced monitoring — completed rollout across all Azure regions by July 2026. Microsoft states it found no evidence of unauthorized activity beyond Wiz's own authorized testing and that no customer data was accessed; no customer action is required. No CVE or MSRC case number has been publicly assigned. Wiz plans to present the full exploit chain at Black Hat USA 2026 on August 6, 2026 ('One Key to Rule Them All: Taking Over a Flagship Cloud Service'). CosmosEscape is the third Wiz-discovered Cosmos DB tenant-isolation-class flaw after ChaosDB (2021, Jupyter Notebook feature, cross-tenant admin access) and CosMiss (2022, also Jupyter Notebook-related), underscoring a recurring architectural risk pattern in Cosmos DB's shared-service design.

MITRE ATT&CK techniques by tactic:

Execution

T1059 Command and Scripting Interpreter

Privilege Escalation

T1068 Exploitation for Privilege Escalation; T1611 Escape to Host

Initial Access

T1190 Exploit Public-Facing Application

Lateral Movement

T1210 Exploitation of Remote Services

Collection

T1213 Data from Information Repositories; T1530 Data from Cloud Storage

Discovery

T1526 Cloud Service Discovery; T1580 Cloud Infrastructure Discovery; T1619 Cloud Storage Object Discovery

Credential Access

T1528 Steal Application Access Token; T1552 Unsecured Credentials

Impact

T1565 Data Manipulation

Resource Development

T1585 Establish Accounts

defense-impairment

T1599 Network Boundary Bridging

Remediation

Patches

  • Gremlin API entry-point hotfix, deployed 2025-11-22 (within 48 hours of the 2025-11-20 report).
  • Full architectural remediation (Cosmos Master Key elimination) rolled out across all Azure regions by July 2026.

Immediate actions

  • Microsoft-side: block the vulnerable Gremlin API entry point that permitted .NET reflection-based sandbox escape (deployed as a hotfix within 48 hours of disclosure).
  • Customers: no customer action required per Microsoft; however, Cosmos DB customers with heightened risk tolerance should regenerate primary/secondary keys as a precaution given the historical pattern of Cosmos DB tenant-isolation flaws (ChaosDB, CosMiss, CosmosEscape).
  • Audit Cosmos DB diagnostic logs for anomalous Gremlin queries, especially any referencing .NET reflection APIs, System.Reflection namespaces, or unexpected process/command execution artifacts.

Workarounds

  • None required from customers; Microsoft states the fix is fully server-side and transparent to customers.

Longer-term hardening

  • Microsoft completed an architectural fix eliminating the platform-wide 'Cosmos Master Key' entirely, replacing it with a hardened, properly-scoped authentication architecture.
  • Microsoft implemented new guardrails around the Gremlin query-to-.NET compilation path to prevent reflection-based sandbox escapes.
  • Microsoft enhanced monitoring and detection capabilities around the DB Gateway and Config Store.
  • Customers should apply defense-in-depth for managed database services: never assume DBaaS sandbox/query engines provide airtight isolation from the underlying multi-tenant control plane; treat 'network isolation' and 'private endpoint' features as complementary to, not a substitute for, provider-side isolation guarantees.

Affected and fixed versions

  • Microsoft — Azure Cosmos DB (Gremlin API)
    Vulnerable versions: Gremlin API / DB Gateway service, all Cosmos DB accounts prior to the 2025-11-22 hotfix
    Fixed in: Gremlin API entry point post-2025-11-22 hotfix; full architectural fix (Cosmos Master Key elimination) across all Azure regions by July 2026
  • Microsoft — Azure Cosmos DB (SQL, MongoDB, Cassandra APIs)
    Vulnerable versions: All accounts platform-wide, indirectly exposed via the cross-API Cosmos Master Key even though the sandbox escape entry vector was Gremlin-specific
    Fixed in: Post architectural fix, July 2026

Timeline

  • Wiz Research discloses ChaosDB, a prior Cosmos DB tenant-isolation vulnerability in the Jupyter Notebook feature granting cross-tenant admin access — establishing a pattern of Cosmos DB multi-tenant isolation flaws later echoed by CosmosEscape.
  • Microsoft notifies over 30% of Azure Cosmos DB customers of the ChaosDB exposure and advises regenerating primary keys.
  • Wiz Research reports the CosmosEscape vulnerability chain (Gremlin sandbox escape leading to Cosmos Master Key exposure) to Microsoft; Microsoft acknowledges the report the same day.
  • Microsoft deploys a hotfix blocking the vulnerable Gremlin API entry point within 48 hours of disclosure and begins developing a long-term architectural fix.
  • Microsoft completes rollout of the long-term architectural fix eliminating the platform-wide Cosmos Master Key across all Azure regions (source states 'July 2026' at month-level precision; exact day not specified).
  • Wiz Research publishes the public technical blog post 'CosmosEscape: Taking Over Every Database in Azure Cosmos DB', disclosing the full vulnerability chain.
  • SecurityWeek and other outlets report on the CosmosEscape disclosure and Microsoft's completed remediation.
  • Wiz Research is scheduled to present the complete CosmosEscape exploit chain at Black Hat USA 2026 in a talk titled 'One Key to Rule Them All: Taking Over a Flagship Cloud Service.'

Sources cited

Previous and next in vulnerability

AI-drafted from 13 cited sources; published ; last updated —.

Threadlinqs Intelligence — Real-Time Threat Detection Platform

// threat_feed
$ sort --newest
Showing all threats

Live intelligence console

Threat level

Latest Threats