{"id":2417,"date":"2017-03-16T11:52:26","date_gmt":"2017-03-16T11:52:26","guid":{"rendered":"https:\/\/emtunc.org\/blog\/?p=2417"},"modified":"2017-06-11T15:24:18","modified_gmt":"2017-06-11T14:24:18","slug":"bypassing-safe-links-exchange-online-advanced-threat-protection","status":"publish","type":"post","link":"https:\/\/emtunc.org\/blog\/03\/2017\/bypassing-safe-links-exchange-online-advanced-threat-protection\/","title":{"rendered":"Bypassing Safe Links in Exchange Online Advanced Threat Protection"},"content":{"rendered":"<p>In this article I will go through my findings and analysis on the\u00a0<strong><a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/mt148491(v=exchg.150).aspx\">Safe Links<\/a><\/strong> feature of Microsoft&#8217;s Office 365 Exchange Online Advanced Threat Protection.<\/p>\n<p><!--more--><\/p>\n<p>Essentially what Safe Links does is it rewrites all URLs in in-bound e-mails that pass through the Exchange Online Protection platform. So if you send an e-mail to an organization with Safe Links enabled then the e-mail will look like this (original):<\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false wrap-toggle:false show-plain-default:true lang:default decode:true\">Hello Bob,\r\nThis is the link I was talking to you about: https:\/\/example.com<\/pre>\n<p>The URL gets rewritten to look like this (passed through Safe Links):<\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false wrap:true wrap-toggle:false show-plain-default:true lang:default decode:true\">Hello Bob,\r\nThis is the link I was talking to you about: https:\/\/emea01.safelinks.protection.outlook.com\/?url=http%3A%2F%2Fexample.com\/[...]<\/pre>\n<h3>Bypass Method 1<\/h3>\n<p>It is not uncommon for organizations to add their own domains to the Safe Links whitelist policy. This is done for one of many reasons&#8230; either you trust your own domains or you don&#8217;t want to inconvenience staff when sending documents internally imagine sending a .pdf on your corporate site to 1,000&#8217;s of staff &#8211; a significant portion would click the link and be presented with this page:<\/p>\n<p><a href=\"https:\/\/emtunc.org\/blog\/wp-content\/uploads\/2017\/03\/2017-03-16-11_25_38-Office365.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2509\" src=\"https:\/\/emtunc.org\/blog\/wp-content\/uploads\/2017\/03\/2017-03-16-11_25_38-Office365.png\" alt=\"\" width=\"1132\" height=\"551\" srcset=\"https:\/\/emtunc.org\/blog\/wp-content\/uploads\/2017\/03\/2017-03-16-11_25_38-Office365.png 1132w, https:\/\/emtunc.org\/blog\/wp-content\/uploads\/2017\/03\/2017-03-16-11_25_38-Office365-300x146.png 300w, https:\/\/emtunc.org\/blog\/wp-content\/uploads\/2017\/03\/2017-03-16-11_25_38-Office365-768x374.png 768w, https:\/\/emtunc.org\/blog\/wp-content\/uploads\/2017\/03\/2017-03-16-11_25_38-Office365-1024x498.png 1024w\" sizes=\"auto, (max-width: 1132px) 100vw, 1132px\" \/><\/a><\/p>\n<p>This bypass exploits the whitelisted domains in the Safe Links policy by using URL obfuscation techniques.<\/p>\n<p>Imagine you have Example Ltd which owns the domain example.com. The administrators of example.com have added the example.com domain to the whitelist in their Safe Links policy such that e-mails containing the URL example.com don&#8217;t get re-written by EOP.<\/p>\n<p>Using a URL obfuscation technique like the below can trick EOP into thinking that the domain is whitelisted when in fact it isn&#8217;t:<\/p>\n<pre class=\"nums:false lang:default decode:true\">Hello Bob,\r\nThis is the link I was talking to you about: https:\/\/example.com@emtunc.org\/malware.exe<\/pre>\n<p>As you can see, simply obfuscating the URL by posting bogus credentials tricks Safe Links in to thinking that the domain is example.com instead of emtunc.org\/malware.exe.<\/p>\n<p>Another obfuscation technique is:<\/p>\n<pre class=\"nums:false wrap:true lang:default decode:true\">Hello Jane in finance,\r\nURGENT - please see outstanding invoice due to us: https:\/\/example.com.emtunc.org\/malware.exe<\/pre>\n<p>Here the\u00a0<em>advanced<\/em> threat protection isn&#8217;t checking the entire domain &#8211; instead it is tricked by a basic obfuscation technique of inserting the white-listed domain as a subdomain of the malicious domain.<\/p>\n<h3>Bypass Method 2<\/h3>\n<p>With this technique, an attacker could simply block or re-direct requests from the Exchange Online Protection infrastructure &#8211; yup, it&#8217;s as simple as that. It&#8217;s less of a vulnerability and more of a non-ideal configuration.<\/p>\n<p>Helpfully, Microsoft makes the EOP IP ranges <a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/dn163583(v=exchg.150).aspx\" target=\"_blank\" rel=\"noopener\">available online<\/a>\u00a0so all you need to do is block those ranges on your webserver with some .htaccess rules.<\/p>\n<p>Even if the IP ranges weren&#8217;t available online, the EOP requests contain absolutely no headers which makes it very easy to distinguish EOP traffic and genuine traffic.<\/p>\n<p>This is what genuine traffic looks like (notice the browser headers\u00a0are present):<\/p>\n<pre class=\"nums:false lang:default decode:true\">1.2.3.4 - - [23\/Feb\/2017:11:58:26 +0000] \"GET \/blog\/02\/2017\/ninite-appsheet-patching-just-got-easier\/ HTTP\/1.1\" 200 18347 \"android-app:\/\/com.google.android.gm\" \"Mozilla\/5.0 (Linux; Android 7.1.1; Nexus 5X Build\/N4F26O) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/56.0.2924.87 Mobile Safari\/537.36\"<\/pre>\n<p>This is what EOP requests look like (notice how no headers are sent so easy to distinguish from legitimate traffic):<\/p>\n<pre class=\"nums:false lang:default decode:true\">40.107.196.15 - - [13\/Jan\/2017:12:24:03 +0000] \"GET \/malware.exe HTTP\/1.1\" 404 406 \"-\" \"-\"<\/pre>\n<h3>Timeline<\/h3>\n<ul>\n<li><strong>15\/01\/2017<\/strong> &#8211; First reported<\/li>\n<li><strong>20\/01\/2017<\/strong> &#8211; I requested an update<\/li>\n<li><strong>01\/02\/2017<\/strong> &#8211; I requested an update<\/li>\n<li><strong>07\/01\/2017<\/strong> &#8211; MSRC claimed a\u00a0&#8216;bug&#8217; caused my replies to be missed. MSRC asked for some further clarifications which I addressed<\/li>\n<li><strong>15\/02\/2017<\/strong> &#8211; I requested an update<\/li>\n<li><strong>23\/02\/2017<\/strong> &#8211; I notified MSRC that I will be publishing this article on the 27th<\/li>\n<li><strong>24\/02\/2017<\/strong> &#8211; I was asked to delay the publishing of this post and notified that a new MSRC case was created<\/li>\n<li><strong>15\/03\/2017 &#8211;<\/strong> MSRC advised that the issue doesn&#8217;t <em>&#8220;meet the\u00a0security servicing bug bar&#8221;<\/em> and that they are closing the case<\/li>\n<li><strong>16\/03\/2017 &#8211;<\/strong> Published<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>In this article I will go through my findings and analysis on the\u00a0Safe Links feature of Microsoft&#8217;s Office 365 Exchange Online Advanced Threat Protection.<\/p>\n","protected":false},"author":32,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"categories":[1],"tags":[260,234,37],"class_list":["post-2417","post","type-post","status-publish","format-standard","hentry","category-tech","tag-atp","tag-exchange-online","tag-office-365"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1trTO-CZ","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/posts\/2417","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/users\/32"}],"replies":[{"embeddable":true,"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/comments?post=2417"}],"version-history":[{"count":12,"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/posts\/2417\/revisions"}],"predecessor-version":[{"id":2533,"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/posts\/2417\/revisions\/2533"}],"wp:attachment":[{"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/media?parent=2417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/categories?post=2417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/tags?post=2417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}