How I found DOM-Based XSS on Microsoft MSRC and How they fixed it

渗透技巧 1年前 (2023) admin
374 0 0

Microsoft MSRC ฺBlog site: Dom-based XSS Vulnerability

Table of Contents

Introduction

In this blog post, I am excited to share my experience of discovering a DOM-Based XSS vulnerability on the Microsoft Security Response Center (MSRC) website, and how the Microsoft Security Team quickly and efficiently resolved the issue by fixing the vulnerability.

Background of DOM-Based XSS

DOM-based XSS vulnerabilities usually arise when JavaScript takes data from an attacker-controllable source, such as the URL, and passes it to a sink that supports dynamic code execution, such as eval() or innerHTML (in this case). This enables attackers to execute malicious JavaScript, which typically allows them to hijack other users’ accounts.

For more information, please refer to:

Finding and Analyzing the Vulnerable Code

On February 12th, 2023, I read on the MSRC blog that they had released a new MSRC Blog Site, which started on February 9th, 2023.

How I found DOM-Based XSS on Microsoft MSRC and How they fixed it

The aforementioned blog post announced that the MSRC Blog Site had been refreshed with a new look and improved site performance, search functionality, categories, and tags. That indicates new development functions have been added to the site.

Here is a step-by-step guide that outlines how I found and analyzed the vulnerable code and determined the root cause of the issue.

I started by using the search function and looking at the website’s HTML source code. I discovered that the search.js file was being loaded and the search query was being added to the URL as a query parameter.

How I found DOM-Based XSS on Microsoft MSRC and How they fixed it

Then, I started analyzing the search.js file to find the root cause of the vulnerability.

How I found DOM-Based XSS on Microsoft MSRC and How they fixed it

How I found DOM-Based XSS on Microsoft MSRC and How they fixed it

How I found DOM-Based XSS on Microsoft MSRC and How they fixed it

How I found DOM-Based XSS on Microsoft MSRC and How they fixed it

Conclusion

As shown in the previous steps, the code retrieves user input from the param function and directly set it as the innerHTML of a DOM element without proper input sanitation, allowing potential attackers to inject and execute malicious scripts in the victim’s browser.

For example

How I found DOM-Based XSS on Microsoft MSRC and How they fixed it

Reporting the Vulnerability to Microsoft

To report the vulnerability, I followed the steps outlined on the Microsoft Security Response Center website

I provided them with a detailed report outlining the vulnerability and a proof of concept (PoC) that demonstrated the attack. You can find more information about how to report a vulnerability to Microsoft on my blog

Summary of Vulnerability

The vulnerability was found in the Microsoft MSRC Blog, specifically in the search functionality at https://msrc.microsoft.com/blog/search/. The vulnerability was caused by the unsanitized user input received from the “query” parameter, which is used to set the innerHTML of a DOM element in the search results. This made it for an attacker to inject malicious scripts and execute them in the victim’s browser, leading to a Dom-based XSS attack.

Vulnerable product: Microsoft MSRC Blog version: 1.1.02231.103–9e425f97

Vulnerable URLhttps://msrc.microsoft.com/blog/search/

Vulnerable JavaScript: https://msrc.microsoft.com/blog/js/search.js

Vulnerable Function: param

Vulnerable Parameterquery

Testing Payload<img/src/onerror=alert(1)>

Example PoC URLhttps://msrc.microsoft.com/blog/search/?query=<img/src/onerror=alert(1)>

Proof of Concept (PoC)

I record a below VDO PoC to demonstrate the existence of a DOM-Based XSS vulnerability on the MSRC Blog Site.

Microsoft MSRC Blog: How I Discovered a Dom-based XSS Vulnerability — YouTube

How MSRC Team Fixing the Vulnerability

After discovering the vulnerability, I reported it to the MSRC team. They acknowledged the report and began investigating and fixing the issue.

The MSRC team implemented getSearchParamClean to replace the vulnerable param function.

How I found DOM-Based XSS on Microsoft MSRC and How they fixed it

The new function uses a Dompurify library to properly sanitize user input before using it to set the innerHTML of a DOM element. This would prevent any potential XSS attacks by removing any malicious scripts from user input before it is displayed on the page.

How I found DOM-Based XSS on Microsoft MSRC and How they fixed it

Verify fixed vulnerability

How I found DOM-Based XSS on Microsoft MSRC and How they fixed it

Attempting to inject the XSS payload into the search query parameter should result in the payload being sanitized and not executed.

How I found DOM-Based XSS on Microsoft MSRC and How they fixed it

 

Disclosure Timelines

Here are the timelines for the vulnerability disclosure:

I appreciate your feedback and would love to hear your thoughts on my blog. If you have any comments or suggestions, please feel free to reach out to me on:

 

版权声明:admin 发表于 2023年2月25日 上午9:50。
转载请注明:How I found DOM-Based XSS on Microsoft MSRC and How they fixed it | CTF导航

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...