Wednesday, June 14, 2017

A Look at CVE-2017-8514 --- SharePoint's `Follow` Feature XSS

TL;DR: All your SharePoint installations are belong to us. The XSS (worth $2500) affecting both on-premises and online version looks like ...

http|https://<Any SharePoint URL Goes Here>?FollowSite=0&SiteName='-confirm(document.domain)-'

SharePoint needs no more marketing given it is one of the most popular enterprise content management systems. According to Redmond Magazine: "SharePoint and OneDrive are used by more than 75,000 customers, with more than 160 million users.". I am not a SharePoint MVP but as far as I can see, it comes in two flavors i.e., SharePoint on-premises and SharePoint online. Organizations prefer to use the on-premises model given it is in general only accessible over the intranet or internal network.  

One common use-case that I have seen or experienced in the organization is: There are many teams working in an organization for a day-to-day job e.g., HR, Marketing, Application, Legal and/or Security team etc. In SharePoint, one can have a dedicated site or page for a respective team where they can share relevant stuff (e.g., documents, news etc.) among team members and at the same time sharing outside the team is also possible. SharePoint provides fine-grained permission levels and role-based access control. 

SharePoint is all about sharing. In this line of direction, SharePoint provides a feature called "Follow" a site in order to get updates on site's activity in your newsfeed. One way to follow a site is to click on the "Follow" feature available at the top right of the page. It looks like ...

Follow a Site Feature in SharePoint

At this time, SharePoint sends a POST request to the following end-point: (bbmsft is the tenant name in my case and this will be different in your case). I played around with that POST request but was unable to find something interesting. I observed that this is not the only way to follow a site. You can also share your site(s) with others by using the Share feature available at the top right corner. Once you send out Share invitation, on the receiving end email looks like ...

The "Follow" feature as a part of email's content is now available in the form of a GET request. The URL at that time looks like:

The URL has two GET parameters i.e., FollowSite=1 and SiteName=<AnySiteNameGoesHere>. The FollowSite GET parameter holds a Boolean value of 0 or 1. 0 for not following and 1 for following. It is a sort of flag. The GET parameter SiteName is of our interest. It is reflected back as a part of script context like the following (watch out for the keyword ReflectionHere). In real life, this would be the name of site you want to follow.

<script type="text/javascript">
SP.SOD.executeFunc('followingcommon.js', 'FollowSiteFromEmail', function() { FollowSiteFromEmail('ReflectionHere'); });

As you can see in the above code, the developers're using single quote around ReflectionHere and I found that potentially dangerous characters like ', <> and / etc were not encoded. In order to keep it simple, the XSS payload like '-confirm(document.domain)-' should do the job for you. Further, I noticed that the above inline JavaScript code snippet only appears or  becomes a part of DOM if GET parameters (FollowSite and SiteName) are present in the URL. The screen-shot is given below.

A quick PoC of this XSS on one of the test-bed I had ...

Situation In the Wild:

The XSS looks simple because it only needs a SharePoint URL and simply add two GET parameters with one hold the XSS payload like:

http[s]://<SHAREPOINT URL>?FollowSite=0&SiteName='-confirm(document.domain)-'

Google dorking (inurl:SitePages/Home.aspx?) for SharePoint Home Page shows 19,000+ results. The SharePoint site's home page has a general format like http(s)://<Any SharePoint URL>/SitePages/Home.aspx. Some notable and vulnerable examples I was able to identify quickly from Google Dorks are given below. If you have a SharePoint site and you can see "Follow" feature on the page, than there is a great chance that you are vulnerable. Please keep in mind that following examples (Govt. sites, agencies, universities and colleges) does not include on-premises SharePoint installations.


Timeline and Bounty:

Reported to Microsoft on 20th February 2017
Triaged and Case # Assigned email from 20th February 2017 and Case # was 37482
Case Reproduction Email Confirmation from 28th February 2017
Bounty Qualifying Email from on 9th March 2017.
10th March 2017, email from regarding the bounty amount which was $2500.

On 9th June 2017, I received an email regarding fix and patch will be released as a part of June 2017 updates. Here is the link to CVE-2017-8514: Microsoft has also released a fix for a stored XSS I found in SharePoint Project Web App. CVE-2017-8551 is related to that. I will try to do a write-up on that later.    

I think, it's time to go and patch your SharePoint.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.