Sending Valid Phishing E-mails From Microsoft.com Domain by Using Office 365
This post covers a weird and simple vulnerability that I found in Microsoft Office 365 service. To be honest, I can't say I fully understand the logic behind of this vulnerability. Anyway, it's fixed now.
In september, I was testing spam filters of various e-mail services such as Gmail, Outlook 365 and Yandex. I used my university e-mail address which uses Office 365 Web Service and personal e-mail addresses from Gmail and Yandex. I installed sees tool on an Amazon server to send phishing e-mails. The test wasn't so successful. A sample setting for targeting my Yandex e-mail:
It landed on spam folder. Tried with Gmail and Outlook 365, still no luck. Maybe this tool was not so efficient maybe I was doing a mistake, I wasn't sure.
Suddenly, a weird thing happened. I saw an e-mail on my Yandex inbox which has "Verify Test 2" on it's subject field and has a green valid sign.
At first few seconds, I was thinking that I accidently sent another test e-mail to my Yandex e-mail and it worked. But then I realized I was using "Verify Test 1" subject for Yandex, and "Verify Test 2" for Outlook. There should be something else.
After few minutes of inspection, I remembered that I set up an e-mail forwarding rule for my Outlook 365 e-mail to Yandex. So, Outlook forwarded this e-mail to Yandex. But why that valid sign appeared now?
I checked it in Yandex's website it says: (By the way this feature is not supported anymore.)
"With a DKIM signature, the email recipient can verify that the message really came from the supposed sender."
It was a simple DKIM(DomainKeys Identified Mail) validator. So basically if an e-mail signed by a valid certificate regarding to the domain name of the sender, we see that cool icon. So, sender domain is microsoft.com, it should have been signed by Microsoft's certificate??
In order to understand whats going on, I checked the headers of these spam and valid e-mails. The header below is belongs to the e-mail which is marked as spam by Yandex:
It's received by Amazon server, there is no valid signature, no surprise it was landed on spam folder. Let's check the header of valid e-mail:
To be honest, I didn't fully understand whats going on since I'm no expert on e-mail authentication topic. E-mail received by outlook.com domain and has a DKIM signature info in it. Let's check that (I removed bh and b fields):
a= the signing algorithm
c= the canonicalization algorithm
d= signing domain
h=the list of signed header fields
bh= body hash
b= digital signature of the contents
So my e-mail address is [email protected] but the signing domain is bilgiedu.onmicrosoft.com. I'm not sure if it's like that on all Outlook 365 clients, probably it is.
But in the e-mail, sender is [email protected]. This part was a confusion for me. Is onmicrosoft.com's signature is same with microsoft.com? If so that's an issue on Microsoft's side. Or, it's not like that and Yandex has an issue on identifying valid DKIM signatures. Or, I totally don't know shit about this DKIM stuff.
Update (20 November 2016): Reddit user ptmb wrote a good explanation about whats going on:
"To further develop on /u/indrora 's explanation of DKIM, the problem here, and why it was related to DKIM, was that when Outlook was redirecting the messages it was signing them with it's own DKIM key instead of keeping whatever signature was originally in the email (or lack of it).
That means that instead of having an email with a proof of identity from the original sender, you received an email with a proof of identity from the "redirector".
And because Outlook was blindly signing these messages it was redirecting, if the message had a fake from field saying [email protected], then after Outlook blindly redirected it, it'd have a genuine DKIM signature from microsoft by coincidence, even though the original email wasn't from Microsoft at all."
I decided to do some additional tests. I changed my forwarding address to my Gmail address and sent another spam e-mail with microsoft.com domain to my Outlook address. It landed on spam folder in Outlook and inbox in Gmail.
I changed forwarding address to Yandex again. This time I changed the spam e-mail's domain with an other domain name than microsoft.com. It landed on spam box in both Outlook and Yandex. Also there was no "green valid sign" on it (obviously)
Even if I didn't fully understand whats going on, I could send valid e-mails from microsoft.com to anyone.
Anyway, I decided to notify both Yandex and Microsoft. I said to Yandex you may have a problem with that "green valid sign", it may cause a security illusion for users. Also I sent a vulnerability report to Microsoft.
I couldn't hear back from Yandex but later on Microsoft security team said they reproduced the vulnerability. After some time, vulnerability is fixed. The weird thing is, Yandex disabled that "green sign" feature after some time (I don't know exact date). I'm not sure if it's related with this anomaly. Anyway, you can find remediation timeline below.
Timeline:
-September 3, 2016: Issue reported to Microsoft
-September 3, 2016: Microsoft forwarded the report to analysts
-September 29, 2016: Microsoft said they reproduced the issue
-October 27, 2016: Microsoft said the vulnerability is fixed
-November 2016: Microsoft gives credit to me: https://technet.microsoft.com/en-us/security/cc308575