Two vulnerabilities makes an exploit XSS and csrf in bing
The Bing Images favourites feature accepted a request without a CSRF token, allowing an attacker to add a favourite containing a javascript: link. When the victim clicked that link, JavaScript executed, enabling account compromise.
Published on medium.com
{{media:0}}
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Bing Images was testing three new features called Stream, Favorites and Trending, all still in beta at the time of the research. The feature relevant here is the ability to search for an image and add it directly to your favourites by clicking the heart symbol shown after an image search. The saved items are then displayed in the Favorites tab of the page.

Bing Images
The researcher describes this as his 4th and 5th valid bug reports submitted to Microsoft, and the write-up covers an XSS and a CSRF vulnerability in Bing.
Setup
No special accounts, roles or tooling are described beyond a normal browser session against the beta Bing Images feature. The screenshots were taken on a 1080p screen. The only precondition is that the Favorites feature is available and that the user can add images to their favourites.
Finding it
The researcher started from the add-to-favourites flow: search for an image, click the heart symbol, and the image is added to your favourites.

Looking at the request that the heart symbol sends, two things stood out. The request is URL-encoded, and once decoded it contains no CSRF token and no X-Requested-With : XMLHttpRequest header. The absence of both means the endpoint is vulnerable to CSRF attacks. The second observation was that the webpage displays this saved data in the Favorites tab, which raised the question of whether JavaScript could be injected into it.

Exploitation
Step 1: Decode the add-to-favourites request
The request sent when clicking the heart symbol is URL-encoded. Once decoded it looks like this:
{“WriteNewCollection”:true,”query”:”lucianazogbi”,”mid”:”[redacted]”,”description”:”lucianazogbi”,”MediaUrl”:”https://beautifulgeniuses.files.wordpress.com/2015/01/lucianazogbi.jpg”,”SourceUrl”:”http://beautifulgeniuses.com/2015/01/14/lucianazogbi/”,”ThWidth”:300,”ThHeight”:300,”MediaWidth”:640,”MediaHeight”:640,”MD5″:”[redacted]″,”MediaFormat”:””,”ThumbnailId”:“OIP.[redacted]″,”CollectionType”:0,”ContentId”:”XGql0naP”}
The body carries the search query, the image identifiers, the media and source URLs, thumbnail and media dimensions, an MD5 value, a thumbnail ID, a collection type and a content ID. There is no anti-CSRF token in the body and no X-Requested-With : XMLHttpRequest header on the request, so a cross-site request can be forged without either being present.
Step 2: Confirm the CSRF condition
Because the request lacks a CSRF token and the X-Requested-With : XMLHttpRequest header, the researcher concluded it is vulnerable to CSRF attacks. The saved data is then rendered in the Favorites tab.

Step 3: Attempt injection into the saved fields
Since the Favorites tab displays the saved data, the next step was to try injecting JavaScript into it. The researcher tried all the fields, and none of them worked.

Step 4: Find the injectable link
When he had almost given up, he found that a link is vulnerable to XSS: it accepts javascript:code links in the <a> href tag. Clicking such a link executes the code, which the researcher demonstrates with the familiar popup.

Root cause
The add-to-favourites endpoint accepts a state-changing request without a CSRF token and without requiring the X-Requested-With : XMLHttpRequest header, so a cross-site request can perform the action on behalf of a logged-in user. Separately, the Favorites tab renders a stored link into an <a> href without preventing the javascript: scheme, so a link saved through the same flow executes script when clicked. The field-level injection attempts failed, but the link rendering accepted a javascript: link.
Impact
By sending the user to a single malicious site it is possible to compromise his account. The CSRF lets an attacker add content to the victim's favourites without their consent, and a saved javascript: link executes script when clicked in the Favorites tab.
Fix
The researcher reported the issue to Microsoft and it is now fixed. Because the feature was still in beta-testing, it took more than 5 months to fix in order to make it more secure. The report does not describe the specific code changes.
Variants to test
- Look for state-changing JSON endpoints that accept a body without a CSRF token and without an
X-Requested-With : XMLHttpRequestheader. A positive result is a request that succeeds cross-site with the victim's session. - For features that save user-supplied URLs and later render them as links, try
javascript:payloads in the URL field. A positive result is script execution when the link is clicked in the saved view. - When field-level injection fails, check every place the saved data is rendered, including link hrefs, rather than only the text fields. A positive result is any context where the value is interpreted as a URL scheme rather than displayed as text.
- Combine a CSRF that stores attacker-controlled content with a stored XSS in the rendering of that content. A positive result is a single malicious page that both saves the payload and leads the victim to execute it.
What happened, in plain words
Bing Images, the image search part of Microsoft's Bing search engine, was testing three new features called Stream, Favorites and Trending. All three were still in beta, meaning they were released to some users for testing before being finished. The researcher who wrote this report found two security problems in the Favorites feature and showed that, used together, they let an attacker take over a victim's Bing account. He reported them to Microsoft, they were fixed, and his name went into the March 2016 Hall Of Fame, a public list of people who have reported security bugs.
This was his 4th and 5th valid bug report to Microsoft. The two problems are an XSS (cross-site scripting) and a CSRF (cross-site request forgery). Both terms are explained below where they first matter, and again in the glossary at the end.

The screenshot above is the author's profile picture next to the article title.
The feature being tested
The Favorites feature works like this: you search for an image, and next to the results there is a heart symbol. Click the heart and the image is added to your favourites. Everything you saved is then shown in a tab called Favorites on the same page.

The screenshot shows the Bing Images page with the new beta features.
To understand the rest of the article you need three everyday ideas:
- A request is the message your browser sends to a website's server when you do something, for example when you click a button. Think of it as an order slip you hand to a waiter: it says what you want and who you are.
- A cookie is a small piece of data the website stores in your browser after you log in, and your browser sends it back with every request. It is how the site recognises you, like a wristband at an event that proves you already paid to get in.
- A token (here, a CSRF token) is a secret value the website puts inside forms and requests so it can tell that the request really came from its own pages and not from somewhere else. It is like a stamped receipt that only the shop's own till can print.
Looking at how it is implemented
The researcher was curious about how the heart button was built, so he looked at the request it sends. These are built into every browser and let you watch the requests a page sends. He searched for an image and clicked the heart.

The screenshot shows the search results with the heart symbol used to add an image to favourites.
When you click the heart, the image is added to your favourites, and the request that does it looks like this:

The screenshot shows the request that adds the image to favourites.
Two things stood out when he read that request:
- The data in the request is URL-encoded. URL encoding is a way of writing characters that are not allowed in a web address, such as spaces or special symbols, using a percent sign and codes. It is like spelling out a word letter by letter over the phone because the other side cannot hear it properly. To read the request properly you have to decode it back.
- Once decoded, the request contains no CSRF token and no
X-Requested-With : XMLHttpRequestheader. A header is an extra line of information attached to a request, separate from its main content, like the label on a parcel.X-Requested-With : XMLHttpRequestis a header that browsers add when a page fetches data in the background with JavaScript; its presence tells the server the request came from the site's own code.
Why does the missing token matter? Because a website cannot tell a request made by its own page from a request made by a different website that your browser is also visiting. If there is no token and no special header to check, another site can quietly send the same request using your logged-in cookie. That is CSRF: someone else's page makes your browser perform an action on a site where you are logged in, without you intending it. The everyday comparison is a signed blank cheque: if the bank never checks who filled it in, anyone who gets hold of one can write an amount.
The second observation was that the page displays the saved data in the Favorites tab. That raised an obvious question: if the page shows back what was saved, can JavaScript be slipped into that data so it runs in the browser? JavaScript is the programming language that web pages use to be interactive; if an attacker can get their own JavaScript to run on a site you trust, that is XSS, cross-site scripting. The everyday comparison is a noticeboard where anyone can pin a note: if the board does not check the notes, someone can pin one that says "hand your keys to the person at the door".
Step 1: Decode the add-to-favourites request
The request sent when clicking the heart symbol is URL-encoded. Once decoded it looks like this:
{“WriteNewCollection”:true,”query”:”lucianazogbi”,”mid”:”[redacted]”,”description”:”lucianazogbi”,”MediaUrl”:”https://beautifulgeniuses.files.wordpress.com/2015/01/lucianazogbi.jpg”,”SourceUrl”:”http://beautifulgeniuses.com/2015/01/14/lucianazogbi/”,”ThWidth”:300,”ThHeight”:300,”MediaWidth”:640,”MediaHeight”:640,”MD5″:”[redacted]″,”MediaFormat”:””,”ThumbnailId”:“OIP.[redacted]″,”CollectionType”:0,”ContentId”:”XGql0naP”}
This is a JSON object: a way of writing data as a list of names and values, like a form where each box has a label. Going through it field by field:
WriteNewCollectionis set totrue, which tells the server to create a new collection (a set of favourites).queryis the search term the user typed, herelucianazogbi.midis a long identifier for the image.descriptionrepeats the search term.MediaUrlis the address of the image file itself.SourceUrlis the address of the page the image came from.ThWidthandThHeightare the width and height of the thumbnail, the small preview version of the image, both 300 here.MediaWidthandMediaHeightare the dimensions of the full image, both 640 here.MD5is a fingerprint of the file, a short string computed from its contents so the server can recognise the same file again.MediaFormatis empty in this example.ThumbnailIdis an identifier for the thumbnail.CollectionTypeis set to0.ContentIdis another identifier for the saved item.
What matters for security is what is not in the body: there is no anti-CSRF token. And on the request as a whole there is no X-Requested-With : XMLHttpRequest header. So a request coming from a different website can be forged without either of those being present. The server has nothing to check that would reveal the request did not come from Bing's own page.
Step 2: Confirm the CSRF condition
Because the request lacks a CSRF token and the X-Requested-With : XMLHttpRequest header, the researcher concluded it is vulnerable to CSRF attacks. In practice that means: an attacker builds a page that, when you visit it while logged in to Bing, makes your browser send this same add-to-favourites request. Your cookie goes along automatically, the server sees a logged-in user, and the image lands in your favourites even though you never clicked anything on Bing.
The saved data is then rendered in the Favorites tab.

The screenshot shows the saved item appearing in the Favorites tab.
Step 3: Attempt injection into the saved fields
Since the Favorites tab displays the saved data, the next step was to try injecting JavaScript into it. The idea: if the page takes a value you supplied and puts it into the page without cleaning it, the browser may treat it as code rather than as text. The researcher tried all the fields, one by one, and none of them worked. That is a useful result in itself: the other fields did not accept the injected JavaScript.

The screenshot shows the saved item in the Favorites tab, including the link that turned out to be the weak point.
Step 4: Find the injectable link
When he had almost given up, he found that a link is vulnerable to XSS: it accepts javascript:code links in the <a> href tag.
Two terms there. An <a> tag is the HTML element that makes a clickable link on a web page, and href is its attribute, the part that says where the link goes. Normally href holds an address like https://example.com. But browsers also understand a scheme called javascript:, where what follows the colon is run as code when the link is clicked. So if a site saves a link you give it and later puts it back into an href without checking the scheme, a saved javascript: link becomes a way to run your code in the victim's browser, on the site's own page.
Clicking such a link executes the code, which the researcher demonstrates with the familiar popup. A popup is the simplest proof that JavaScript ran: it is harmless in itself, but it shows the code executed in the context of the site.

The screenshot shows the popup appearing after the injected link was clicked.
Why the two bugs together matter
Each bug alone is limited. The CSRF lets an attacker add content to your favourites without your consent, but adding an image is not very damaging. Put them together and the chain closes:
- The attacker sends you to a single malicious page.
- That page uses the CSRF to save an item in your favourites. You do not notice, because you never clicked anything on Bing.
- Later you open your Favorites tab and click the saved link, and the script runs.
By sending the user to a single malicious site it is possible to compromise his account. The researcher notes that if he had stopped after the CSRF, he would not have found the XSS: combining the two is what made a working exploit.
The fix
The researcher reported the issue to Microsoft and it is now fixed. Because the feature was still in beta-testing, it took more than 5 months to fix in order to make it more secure. The report does not describe the specific code changes.
What to take away
If you want to look for similar problems yourself, these are the habits the report demonstrates:
- Watch the requests a feature sends. Browser developer tools show them, and reading them is often enough to spot a missing token or header.
- For any request that changes something on your account, ask whether it carries a CSRF token or another check that proves it came from the site's own page. A request that succeeds from another site with your session is the bug.
- For features that save something you supply and show it back later, try to get code into it. If plain text fields are cleaned, look at every other place the value appears, especially link addresses, rather than only the text boxes.
- Think in chains. A low-impact bug that stores attacker-controlled content plus a bug that runs that content can add up to account compromise.
Glossary
- Beta: a version of a feature released to some users for testing before it is finished.
- Browser developer tools: built-in tools in a browser that let you inspect a page and the requests it sends.
- Cookie: a small piece of data a site stores in your browser after you log in and that your browser sends back with each request, so the site recognises you.
- CSRF (cross-site request forgery): another website makes your browser send a request to a site where you are logged in, so an action happens without your intent.
- CSRF token: a secret value placed in requests so the server can verify the request came from its own pages.
- Escaping: turning special characters into harmless text so they are displayed rather than interpreted as code.
- Header: an extra line of information attached to a request or response, separate from its main content.
- href: the attribute of an
<a>link that says where the link points. - HTML: the language web pages are written in, made of tags such as
<a>for links. - JavaScript: the programming language that makes web pages interactive and that runs in your browser.
- JSON: a way of writing data as a list of names and values.
javascript:scheme: a link prefix that makes the browser run what follows as code when the link is clicked.- MD5: a fingerprint computed from a file's contents, used to recognise the same file again.
- Popup: a small window a script can open, often used to prove that JavaScript ran.
- Request: the message your browser sends to a server when you do something on a page.
- Thumbnail: a small preview version of an image.
- Token: a secret value used to prove a request is genuine; see CSRF token.
- URL encoding: writing characters that are not allowed in a web address using percent codes, so they can be sent safely.
- XSS (cross-site scripting): getting an attacker's JavaScript to run inside a site you trust, usually because the site displays user-supplied data without cleaning it.
X-Requested-With : XMLHttpRequest: a header browsers add when a page fetches data in the background with JavaScript, which a server can check to tell such requests apart.