Taking over Azure DevOps Accounts with 1 Click
When performing subdomain takeovers, you should be asking yourself, what is the impact, and how do I prove it? This was especially the case when taking over the subdomain <span class="code_single-line">project-cascade.visualstudio.com</span>.
At first glance, it didn’t seem like we could do much by taking this subdomain over as nothing super sensitive lived under <span class="code_single-line">*.visualstudio.com</span>. However, under deeper examination, we were able to exploit a trust boundary, leading to a 1 click account takeover of Azure DevOps accounts.
Technical Details
Through automation, we found the subdomain <span class="code_single-line">project-cascade.visualstudio.com</span>, which was vulnerable to an Azure Zone DNS takeover.
The NS records for <span class="code_single-line">project-cascade.visualstudio.com</span> were pointing to Azure DNS, however they were no longer registered on Azure DNS. This resulted in the lookups being refused, as shown below:
As the lookups were being refused, we were able to to register the subdomain under an Azure account that we owned. By doing so, we were able to create arbitrary DNS records for the subdomain <span class="code_single-line">project-cascade.visualstudio.com</span>:
Azure Console with <span class="code_single-line">project-cascade.visualstudio.com</span> registered as a DNS Zone
From this point on wards, we registered two records:
- TXT Record - <span class="code_single-line">txt.project-cascade.visualstudio.com</span> with the value of <span class="code_single-line">Azure DNS Zone Takeover POC</span> (proof of concept)
- A Record - <span class="code_single-line">arec.project-cascade.visualstudio.com</span> with the value of <span class="code_single-line">3.88.203.203</span> (our host)
So, what’s next?
Now that we had successfully taken the subdomain over, it was time to investigate the security impact.
We discovered that there were subdomains underneath <span class="code_single-line">visualstudio.com</span> that facilitated an authentication flow through <span class="code_single-line">login.microsoftonline.com</span>.
For example, when visiting <span class="code_single-line">app.vssps.visualstudio.com</span>, we were redirected to:
Which then redirected to:
The most important thing to note from the URLs above, is the following parameter and value for the endpoint <span class="code_single-line">https://app.vssps.visualstudio.com/_signin</span>:
<span class="code_single-line">reply_to=https%3A%2F%2Fapp.vsaex.visualstudio.com%2F</span>
Through some testing, we determined that this authentication flow had a loosely configured <span class="code_single-line">reply_to</span> address, allowing any domain under <span class="code_single-line">*.visualstudio.com</span> to recieve the authentication tokens.
In order to demonstrate this account takeover flow, we crafted the following URL:
In the URL above, note that we changed the value of the <span class="code_single-line">reply_to</span> parameter to contain the following: <span class="code_single-line">https%3A%2F%2Farec.project-cascade.visualstudio.com%2F</span> (our subdomain takeover).
This will prompt the user to login via the normal microsoft live.com auth flow, or if the user is already logged in, proceed with the signin and redirect request.
Visual Studio Authentication Flow via <span class="code_single-line">login.microsoftonline.com</span>
Once logged in, this resulted in the following request being made which ultimately resulted in a POST request to our controlled domain <span class="code_single-line">arec.project-cascade.visualstudio.com</span>.
Our controlled domain received the following request which contains authentication tokens for <span class="code_single-line">app.vsaex.visualstudio.com</span>
What can this token be used for?
We found that we could exchange the stolen authentication token for a Bearer token through <span class="code_single-line">app.vsaex.visualstudio.com</span>. This Bearer token could then be used to authenticate to <span class="code_single-line">vsaex.visualstudio.com</span>, <span class="code_single-line">dev.azure.com</span> and <span class="code_single-line">vssps.dev.azure.com</span>.
This request returns the following response with a valid bearer token that can be used elsewhere
e.g. on <span class="code_single-line">app.vsaex.visualstudio.com</span> this token can be used to pull the user’s email
The Bearer token could be used to access <span class="code_single-line">https://app.vsaex.visualstudio.com/me?mkt=en-US</span> which we found to disclose project names for the associated user on <span class="code_single-line">dev.azure.com</span>.
Access to <span class="code_single-line">app.vsaex.visualstudio.com/me</span> through the stolen token
Ultimately, this allowed us to use the token on <span class="code_single-line">dev.azure.com</span> to access resources:
Impact
A malicious attacker could perform a 1 click drive by attack on an unsuspecting user by directing them to a URL such as:
This would result in their <span class="code_single-line">app.vsaex.visualstudio.com</span> tokens being disclosed.
From this point, the the attacker would have full control over the user’s Azure DevOps account.
Additionally, the zone takeover of project-cascade.visualstudio.com could have beeen used to validate ownership over the <span class="code_single-line">project-cascade.visualstudio.com</span> domain, setup MX records to capture emails to <span class="code_single-line">*.project-cascade.visualstudio.com</span> and prove ownership to create SSL certificates. This may have resulted in various opportunities for fraud and impersonation of Microsoft services.
Remediation
This attack could be mitigated at two points:
- Not having the dangling dns zone <span class="code_single-line">project-cascade.visualstudio.com</span>
- Restricting the reply_to url for visualstudio tokens on <span class="code_single-line">app.vssps.visualstudio.com</span> to the realm for <span class="code_single-line">app.vsaex.visualstudio.com</span>
Timeline
- 20th May 2020 - Report filed
- 22nd May 2020 - Issue triaged
- 22nd May 2020 - $3000 Bounty Awarded
Thanks to the MSRC and Azure Devops team for the quick triage and remediation of the issue.
Assetnote
Assetnote can help you detect these issues through continuously monitoring your attack surface. For a deeper and comprehensive integration, our Azure Integration ensures your infrastructure’s state is synced with our engine to ensure that your security team is alerted when hosted zone takeovers become vulnerable.
More Like This
Ready to get started?
Get on a call with our team and learn how Assetnote can change the way you secure your attack surface. We'll set you up with a trial instance so you can see the impact for yourself.