Twitter Denial of Service bug or How i could prevent all followers from reading or accessing literally ANY tweets!
A malformed URL containing an invalid percent-encoding sequence caused Twitter's mobile site to throw an error when loaded, preventing the victim's followers from seeing any new tweets. An attacker could post such a URL to deny service to their followers.
Published on seekurity.com
It’s Seif Elsallamy here, I have been away for a while, I really miss doing the stuff i’m good at, Yes breaking things, here take a look at my old posts.
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
Twitter's mobile site, mobile.twitter.com, is a single-page style application: navigating between views inside the site does not reload the whole document, it fetches JavaScript resources over AJAX or XMLHttpRequest and swaps the content in place. The same URL opened from outside Twitter loads a full page; opened from inside Twitter it is loaded through that lighter path.
Twitter also rewrites links that users post. A link sent in a message or tweet is turned into a t.co short link, which redirects to the final destination. That rewriting serves tracking, content filtering and open-redirect protection, similar to Facebook's Linkshim. The researcher noticed one exception: links pointing at Twitter's own domains, twitter.com or mobile.twitter.com, are not rewritten into t.co links when sent from the mobile site.
The target of the research was the mobile site's message and conversation feature, and the goal was originally cross-site scripting, not denial of service.
Setup
The researcher logged in to Twitter and opened a conversation with himself, then sent and fuzzed various payloads in that conversation. No other accounts, tools or versions are described. The researcher tested by sending links into a conversation with himself on the mobile site.
Finding it
During the fuzzing, one payload contained the Unicode escape %u003e. Sending it caused an error after which no messages in the conversation could be seen any more. %u003e is a hexadecimal Unicode escape for >, and Twitter could not handle or load it.
The researcher then tried a URL containing %xx, for example:
https://mobile.twitter.com/%xx
%xx is not a valid hexadecimal value, and this produced the same error. The interpretation was that Twitter tries to resolve a value for %xx, fails, and raises an error every time that URL is called.
The theory behind the fuzzing was that a URL belonging to Twitter itself, containing variables, would be loaded from inside Twitter through the JavaScript path rather than as a fresh page, and that this different loading path might expose an XSS. As an illustration of the difference:
https://mobile.twitter.com/?'"><img/src=x/onerror=alert(1)>
Opened from outside Twitter this does not trigger XSS, but from inside Twitter it might, because the page is loaded in a different way. The XSS did not materialise; the malformed escape produced a denial of service instead.
Exploitation
Step 1: confirm the failing URL
Open the malformed URL directly:
https://mobile.twitter.com/%xx
The site attempts to resolve the invalid hexadecimal value, cannot, and returns an error. The same happens with the %u003e string that was first sent in the conversation.
Step 2: deliver the URL as a link in a message
Post the same URL in the form of a tweet or message. Because it belongs to mobile.twitter.com, Twitter does not wrap it in a t.co short link, so the raw URL reaches the recipient.
Step 3: observe the effect on the recipient
The researcher reports that the result prevented all his followers from loading any new tweets. The researcher describes the result as preventing literally all followers from loading any new tweets.
Step 4: reach users of the main site
The bug does not work on Twitter's main website, only on the mobile site version. To extend it, the researcher found a URL that switches the main site to the mobile-style interface:
https://twitter.com/i/onboarding/verify
At the time Twitter was testing a beta UI on the main site that users could switch to and from freely: click the profile picture, choose to try the new Twitter, and the interface changes to one that looks exactly like the mobile site UI. The researcher presents the beta interface as the way to reach the mobile-style UI on the main site.
Proof of concept
The recorded demonstration shows the behaviour in action.
Root cause
The mobile site loads internal URLs through JavaScript rather than as full page loads, and it tries to resolve percent-encoded values in those URLs. A value that is not valid hexadecimal, such as %xx, or the %u003e escape, cannot be resolved, and the resulting error breaks the in-site loading for the conversation. Because links to Twitter's own domains are exempt from t.co rewriting, the malformed URL is delivered unmodified and is loaded through the vulnerable path. The exact code involved is not shown in the report; the mechanism above is the behaviour the researcher observed.
Impact
An attacker who can send a message or tweet containing the crafted URL can stop followers from loading any new tweets on the mobile site. The effect is limited to the mobile site version and to the beta UI; the main website is not affected. The report does not describe persistence, scope beyond the followers who load the conversation, or any server-side effect.
Fix
Twitter fixed the bug after it was reported. The report does not describe the change that was made.
Variants to test
- Send other invalid percent escapes, such as
%zzor a truncated%usequence, as links to the target's own domain in a message. A positive result is the same loading error that hides subsequent content. - Test other internal URLs that are exempt from the link shortener, for example profile or notification paths, with a malformed escape appended. A positive result is the conversation or timeline failing to load new content.
- Try the same technique in other single-page applications that load internal links over AJAX and exempt their own domains from link rewriting. A positive result is an error state that persists for the viewer after the link is opened.
- Check alternate interfaces and beta UIs that reuse the mobile front end, as the onboarding switch did here. A positive result is the bug reproducing in the alternate interface when it does not in the default one.
What happened, in plain words
A security researcher was poking around Twitter's mobile website, looking for a way to make it run his own code (a bug class called cross-site scripting, or XSS). He did not find that. Instead he found something simpler and, in its own way, more annoying: a specially malformed web address that, when sent to someone as a link, stops their Twitter from loading any new tweets. He reported it to Twitter, and Twitter fixed it.
This article walks through the whole thing from zero. You only need to know how to use a browser. Every technical word is explained the first time it appears, and there is a glossary at the end.
Some background terms first
What a denial of service is
A denial of service (DoS) attack is about making a resource (a site, an application, a server) unavailable for the purpose it was designed for. Think of a shop that is open and working, and then someone blocks the doorway so no customer can get in. Nothing is stolen and nothing is broken; the shop simply cannot do its job. That is the shape of the bug here: the tweets are still on Twitter's servers, but the person looking at the page cannot get them to appear.
What a single-page application is
Older websites worked like a book: every time you clicked a link, the browser asked the server for a whole new page and drew it from scratch. Many modern sites, including Twitter's mobile site, work more like a phone app. The first page loads once, and after that, when you move between views, the site quietly fetches small pieces of data or JavaScript in the background and swaps the content in place. The technical names for those background requests are AJAX and XMLHttpRequest. You never see a full page reload.
This matters because the same web address can behave differently depending on how it is opened. Opened from outside Twitter, in a fresh browser tab, mobile.twitter.com gives you a full page. Opened from inside Twitter, by clicking a link in a conversation, it is loaded through that lighter background path. Two doors into the same room, and the room is furnished differently depending on which door you use.
What link shortening is, and Twitter's exception
When you post a link on Twitter, Twitter does not show your link as you typed it. It replaces it with a short link on its own t.co domain, and that short link redirects the reader to the real destination. This is normal for large platforms. It lets them count clicks, filter out unwanted content, and protect against open redirection (a trick where a trusted site's link is used to bounce a visitor to a malicious destination). Facebook does something similar with a system called Linkshim.
The researcher noticed one exception. When you send a link from Twitter's mobile site that points at Twitter's own domains, twitter.com or mobile.twitter.com, Twitter does not wrap it in a t.co link. The raw address goes through untouched. Keep that exception in mind, because it is what lets the malformed address reach the victim in its original form.
What the researcher was actually hunting
The target was the mobile site's conversation feature, which he tested by messaging himself. The original goal was XSS, a bug where a site is tricked into running code supplied by an attacker inside another user's browser. The denial of service was found by accident along the way.
Setting up
The researcher logged in to Twitter and opened a conversation with himself. That is a neat trick for testing: you are both the sender and the recipient, so you can watch exactly what the other side sees. Into that conversation he sent and fuzzed various payloads. Fuzzing means firing lots of odd, malformed and unexpected inputs at a feature to see which ones make it behave strangely.
No other accounts, tools or software versions are described. The only precondition for everything that follows is being able to send a message containing a link to someone, and that person reading the conversation on the mobile site, or on the beta interface described further down.
Finding it
While fuzzing, one of the payloads contained the Unicode escape %u003e. Sending it caused an error, and after that no messages in the conversation could be seen at all. That is a strange and interesting result: the conversation did not just show a broken message, it stopped showing anything.
What is %u003e? Web addresses cannot contain certain characters directly, so they are written in an encoded form. A percent sign followed by two hexadecimal digits (0 to 9, A to F) stands for one character. %u003e is a hexadecimal Unicode escape, and it means the greater-than sign >. Twitter could not handle or load it.
The researcher then tried a URL containing %xx, like this:
https://mobile.twitter.com/%xx
Line by line: https:// is the scheme, telling the browser to speak secure web traffic. mobile.twitter.com is the server being asked. /%xx is a path on that server containing a percent escape, and xx is not a valid hexadecimal value, because x is not one of the digits 0 to 9 or letters A to F. This produced the same error as before.
The interpretation was straightforward: Twitter tries to work out what value %xx stands for, cannot, and raises an error every time that address is called. It is like a form that insists on a date in a particular format and refuses to move on when you type something it cannot parse.
Why was he sending these things at all? The theory behind the fuzzing was that a URL belonging to Twitter itself, containing variables, would be loaded from inside Twitter through that background JavaScript path rather than as a fresh page, and that this different loading path might expose an XSS. As an illustration of the difference between the two doors:
https://mobile.twitter.com/?'"><img/src=x/onerror=alert(1)>
Line by line: everything up to the ? is the address of Twitter's mobile site. The ? starts the query string, the part of a URL that carries parameters. What follows is a classic XSS test payload: a quote to try to break out of an HTML attribute, then an img tag whose src is a nonsense value x, and an onerror handler that runs alert(1) if the image fails to load. alert(1) pops up a small dialog box; if you ever see it appear on a site you do not control, that site has an XSS problem. Opened from outside Twitter this does not trigger XSS, but from inside Twitter it might, because the page is loaded in a different way.
The XSS never materialised. The malformed escape produced a denial of service instead.
Exploitation
Step 1: confirm the failing URL
Open the malformed URL directly:
https://mobile.twitter.com/%xx
The site attempts to resolve the invalid hexadecimal value, cannot, and returns an error. The same happens with the %u003e string that was first sent in the conversation. This step is about confirming the behaviour in isolation, before involving anyone else: one address, one error, repeatable.
Step 2: deliver the URL as a link in a message
Post the same URL in the form of a tweet or message. Because it belongs to mobile.twitter.com, Twitter does not wrap it in a t.co short link, so the raw URL reaches the recipient. This is the step where the link-shortener exception matters: if Twitter had rewritten the address, the recipient would have followed a t.co link and the malformed part might never have been loaded the same way.
Step 3: observe the effect on the recipient
The researcher reports that the result prevented all his followers from loading any new tweets. The researcher describes the result as preventing literally all followers from loading any new tweets. Put in everyday terms: the shop door is blocked, and it stays blocked for as long as that conversation is the thing being loaded.
Step 4: reach users of the main site
The bug does not work on Twitter's main website, only on the mobile site version. To extend it, the researcher found a URL that switches the main site to the mobile-style interface:
https://twitter.com/i/onboarding/verify
Line by line: https://twitter.com is the main site, and /i/onboarding/verify is a path under the site's onboarding (new-user setup) area. At the time, Twitter was testing a beta UI on the main site that users could switch to and from freely: click the profile picture, choose to try the new Twitter, and the interface changes to one that looks exactly like the mobile site UI. The researcher presents the beta interface as the way to reach the mobile-style UI on the main site.
Proof of concept
The recorded demonstration shows the behaviour in action.
Why it worked
The mobile site loads internal URLs through JavaScript rather than as full page loads, and it tries to resolve percent-encoded values in those URLs. A value that is not valid hexadecimal, such as %xx, or the %u003e escape, cannot be resolved, and the resulting error breaks the in-site loading for the conversation. Because links to Twitter's own domains are exempt from t.co rewriting, the malformed URL is delivered unmodified and is loaded through the vulnerable path. The exact code involved is not shown in the report; the mechanism above is the behaviour the researcher observed.
Who was affected
An attacker who can send a message or tweet containing the crafted URL can stop followers from loading any new tweets on the mobile site. The effect is limited to the mobile site version and to the beta UI; the main website is not affected. The report does not describe persistence, scope beyond the followers who load the conversation, or any server-side effect.
The fix
Twitter fixed the bug after it was reported. The report does not describe the change that was made.
Other things worth trying
These are variations on the same idea, useful if you want to understand how a researcher generalises from one finding.
- Send other invalid percent escapes, such as
%zzor a truncated%usequence, as links to the target's own domain in a message. A positive result is the same loading error that hides subsequent content. - Test other internal URLs that are exempt from the link shortener, for example profile or notification paths, with a malformed escape appended. A positive result is the conversation or timeline failing to load new content.
- Try the same technique in other single-page applications that load internal links over AJAX and exempt their own domains from link rewriting. A positive result is an error state that persists for the viewer after the link is opened.
- Check alternate interfaces and beta UIs that reuse the mobile front end, as the onboarding switch did here. A positive result is the bug reproducing in the alternate interface when it does not in the default one.
Glossary
- AJAX: a way for a web page to fetch data from a server in the background, without reloading the whole page.
- Beta UI: an early, still-being-tested version of a website's interface that users can opt into.
- Bounty: a payment a company makes to a researcher who reports a security bug responsibly.
- Cross-site scripting (XSS): a bug where a site is tricked into running code supplied by an attacker inside another user's browser.
- Denial of service (DoS): making a resource unavailable for the purpose it was designed for.
- Fuzzing: sending lots of odd or malformed inputs to a feature to see which ones make it misbehave.
- Hexadecimal: a number system using digits 0 to 9 and letters A to F, often used to write character codes.
- Linkshim: Facebook's system for rewriting and checking links posted on its platform.
- Open redirection: a trick where a trusted site's link is used to bounce a visitor to a malicious destination.
- Payload: the specific input an attacker sends to try to trigger a bug.
- Percent encoding: writing characters in a URL as a percent sign followed by two hexadecimal digits.
- Query string: the part of a URL after the
?, carrying parameters. - Single-page application: a site that loads once and then swaps content in place instead of reloading whole pages.
- t.co: Twitter's own link-shortening domain.
- Unicode escape: a way of writing a character by its code number, here in the form
%ufollowed by four hexadecimal digits. - XMLHttpRequest: the browser feature used to make background requests to a server, the engine behind AJAX.