
Executive Summary
The recent discovery of a critical vulnerability in Azure Cosmos DB, dubbed CosmosEscape, has raised significant concerns within the cybersecurity community. This flaw allowed potential attackers to gain unauthorized access to databases by exposing primary keys, thereby enabling full read and write capabilities across the service. The implications of this vulnerability are profound, given the widespread use of Cosmos DB in various Microsoft services.
What Happened
Cybersecurity firm Wiz reported a severe vulnerability in Azure Cosmos DB that could have led to a complete compromise of all databases hosted on the service. The vulnerability, referred to as CosmosEscape, enabled attackers to obtain a platform-wide key, which could be used to retrieve the primary keys of any Cosmos DB account. This access would allow attackers to list all databases associated with specific organization identifiers, such as subscription and tenant IDs.
Wiz's analysis revealed that the vulnerability could be exploited through the Gremlin API, a widely used graph query language. The flaw stemmed from the Gremlin engine's failure to adequately restrict access, particularly concerning .NET reflection, which was leveraged to execute arbitrary code.
Technical Root Cause
The core issue with the CosmosEscape vulnerability lies in the Gremlin API's design. While the engine was intended to enforce restrictions on operations, it did not account for .NET reflection, which allowed Wiz to bypass the sandbox protections. This bypass enabled code execution on the DB Gateway, a service responsible for executing customer queries.
Wiz discovered that the gateway utilized a signing key that could retrieve primary keys across all tenants and regions. This signing key, termed the Cosmos Master Key, provided access to a configuration store that contained sensitive information about every Cosmos DB account, including names, subscription IDs, and tenant IDs.
Exposure and Affected Environments
The implications of the CosmosEscape vulnerability are extensive. Not only could it affect publicly accessible databases, but it also posed risks to private and network-isolated Cosmos DB accounts, including those used by Microsoft itself. The ability to enumerate all accounts in a region and filter by tenant ID meant that attackers could precisely target specific organizations.
Wiz reported the vulnerability to Microsoft in November 2025, and within two days, Microsoft deployed a hotfix to mitigate the immediate threat. A comprehensive architectural fix was rolled out across all regions by July 2026. Fortunately, Microsoft conducted thorough access log reviews and found no evidence of unauthorized access or data breaches.
Patch and Mitigation Playbook
Organizations utilizing Azure Cosmos DB should take immediate action to ensure their systems are protected against potential exploitation of the CosmosEscape vulnerability. Here are recommended steps:
- Upgrade Systems: Ensure that all Azure Cosmos DB instances are updated to the latest versions that include the security patches.
- Review Access Logs: Conduct a thorough review of access logs to identify any unusual activity that may indicate attempted exploitation.
- Implement Network Segmentation: Limit access to Cosmos DB instances by implementing network segmentation and restricting access to only necessary users and applications.
- Enhance Monitoring: Utilize advanced monitoring tools to detect any unauthorized access attempts or anomalies in database activity.
- Educate Staff: Provide training for staff on recognizing phishing attempts and other social engineering tactics that could lead to credential theft.
Security Program Lessons Learned
The CosmosEscape incident highlights several critical lessons for organizations regarding their cybersecurity posture:
- Proactive Vulnerability Management: Regularly assess and patch vulnerabilities within your systems to mitigate risks before they can be exploited.
- Sandbox Limitations: Understand the limitations of sandbox environments and ensure that security measures are robust enough to prevent bypass attempts.
- Collaboration with Vendors: Maintain open lines of communication with service providers to quickly address vulnerabilities and implement fixes.
- Incident Response Planning: Develop and regularly update incident response plans to ensure preparedness for potential security breaches.
“The CosmosEscape vulnerability serves as a stark reminder of the importance of robust security practices in cloud environments.” - Cybersecurity Analyst
Sources
- Critical Flaw Led to Azure Cosmos DB Pwnage
- Critical Code Execution Vulnerability Patched in TeamCity
- JetBrains warns of critical TeamCity remote code execution flaw
A critical vulnerability in Azure Cosmos DB, named CosmosEscape, exposed primary keys, allowing unauthorized access to databases. This article explores the implications, technical details, and recommended actions for organizations.
databases hosted on the service. The vulnerability, referred to as CosmosEscape , enabled attackers to obtain a platform-wide key, which could be used to retrieve the primary keys of any Cosmos DB account. This access would allow attackers to list all databases associated with specific organization identifiers, such as subscription and tenant IDs. Wiz's analysis revealed that the vulnerability could be exploited through the Gremlin API, a widely used graph query language. The flaw stemmed from the Gremlin engine's failure to adequately restrict access, particularly concerning .NET reflection, which was
This report consolidates available public details and highlights where evidence is still limited, helping teams prioritize immediate defensive action while additional technical indicators are collected.
Operational Security Context
leveraged to execute arbitrary code. Technical Root Cause The core issue with the CosmosEscape vulnerability lies in the Gremlin API's design. While the engine was intended to enforce restrictions on operations, it did not account for .NET reflection, which allowed Wiz to bypass the sandbox protections. This bypass enabled code execution on the DB Gateway, a service responsible for executing customer queries. Wiz discovered that the gateway utilized a signing key that could retrieve primary keys across all tenants and regions. This signing key, termed the Cosmos Master Key ,
provided access to a configuration store that contained sensitive information about every Cosmos DB account, including names, subscription IDs, and tenant IDs. Exposure and Affected Environments The implications of the CosmosEscape vulnerability are extensive. Not only could it affect publicly accessible databases, but it also posed risks to private and network-isolated Cosmos DB accounts, including those used by Microsoft itself. The ability to enumerate all accounts in a region and filter by tenant ID meant that attackers could precisely target specific organizations. Wiz reported the vulnerability to Microsoft in November
Based on observed patterns in recent campaigns, the likely attacker objective is to establish durable access, exploit trust relationships, and later pivot toward higher-value systems. Where specific attribution or tooling data is absent, these details are not publicly disclosed and should be treated as unknown.
SOC Detection and Triage Workflow
2025, and within two days, Microsoft deployed a hotfix to mitigate the immediate threat. A comprehensive architectural fix was rolled out across all regions by July 2026. Fortunately, Microsoft conducted thorough access log reviews and found no evidence of unauthorized access or data breaches. Patch and Mitigation Playbook Organizations utilizing Azure Cosmos DB should take immediate action to ensure their systems are protected against potential exploitation of the CosmosEscape vulnerability. Here are recommended steps: Upgrade Systems: Ensure that all Azure Cosmos DB instances are updated to the latest versions that
Security engineering teams should validate exploitability across environments, map exposure by asset criticality, and confirm whether available telemetry can detect pre-compromise reconnaissance, exploitation attempts, and post-exploitation behavior.
Engineering Remediation Checklist
a stark reminder of the importance of robust security practices in cloud environments.” - Cybersecurity Analyst Sources Critical Flaw Led to Azure Cosmos DB Pwnage Critical Code Execution Vulnerability Patched in TeamCity JetBrains warns of critical TeamCity remote code execution flaw Named CosmosEscape, the vulnerability exposed the primary key for Cosmos DB accounts, granting full read and write access. The post Critical Flaw Led to Azure Cosmos DB Pwnage appeared first on SecurityWeek . databases on the service, filtering them by specific organization identifiers, such as subscription and tenant IDs.
Organizations with internet-facing systems, third-party integrations, or delayed patch cycles generally carry elevated risk. Internal segmentation gaps can increase blast radius if an attacker obtains initial foothold credentials.
Detection and Monitoring Priorities
- Correlate authentication anomalies with unusual process execution and outbound traffic spikes.
- Alert on privilege escalation events, lateral movement indicators, and unauthorized persistence changes.
- Prioritize monitoring of externally exposed services and high-value identity providers.
- Track integrity changes in scripts, scheduled tasks, startup items, and critical configuration files.
- Hunt for command-and-control beaconing patterns and suspicious use of remote administration tools.
Detection coverage should be validated through tabletop simulation or controlled testing to ensure response teams receive actionable, high-confidence alerts quickly.
Mitigation Checklist
- Patch affected services and validate version levels across all environments.
- Restrict exposed management and service ports to trusted networks only.
- Enable detailed logging and alerting for suspicious process or network activity.
- Harden endpoint controls and isolate high-risk systems until remediation completes.
- Conduct post-remediation validation and document residual risk.
Mitigations should be sequenced by risk: immediately reduce exposed attack surface, then remove persistence opportunities, and finally harden architecture to prevent recurrence.
Incident Response and Recovery Planning
- Establish a clear incident commander and communication cadence across security, IT, and leadership.
- Capture and preserve relevant logs and forensic artifacts before major containment changes.
- Contain compromised accounts and hosts, then execute structured eradication with validation checkpoints.
- Document lessons learned and implement control improvements with owner accountability and timelines.
Recovery should include business continuity planning, legal or regulatory assessment where required, and transparent stakeholder updates based on verified facts.
Validation and Follow-through
“Chained together, these capabilities could have enabled precision targeting at platform scale: from identifying a specific organization’s databases to compromising them, all from publicly accessible endpoints,” Wiz says. According to the cybersecurity firm, because Microsoft uses Cosmos DB to store data across Entra ID, Teams, and Copilot, the vulnerability potentially exposed the tech giant’s databases to unauthorized access. The issue could have been exploited through the Gremlin API, a popular graph query language that This report consolidates available public details and highlights where evidence is still limited, helping teams prioritize
immediate defensive action while additional technical indicators are collected. relies on a custom Gremlin engine, compiling queries into .NET code that was executed in a sandbox. Advertisement. Scroll to continue reading. Pwning the sandbox While the engine enforced restrictions to prevent access beyond Gremlin operations, it did not account for .NET reflection, which Wiz used to build arbitrary code execution primitives. “By bypassing the Gremlin sandbox, we’ve gained code execution on the DB Gateway, a service that executes customer queries on their behalf, running on multi-tenant Service Fabric clusters,” Wiz
Security leaders should align technical remediation with stakeholder communication, incident readiness, and continuous monitoring to reduce repeat exposure.