A feature in the Twitter API (application programming interface) can be abused by attackers to launch credible social engineering attacks that would give them a high chance of hijacking user accounts, a mobile application developer revealed Wednesday at the Hack in the Box security conference in Amsterdam.
The issue has to do with how Twitter uses the OAuth standard to authorize third-party apps, including desktop or mobile Twitter clients, to interact with user accounts through its API, Nicolas Seriot, a mobile applications developer and project manager at Swissquote Bank in Switzerland, said Thursday.
Twitter allows apps to specify a custom callback URL where users will be redirected after granting those apps access to their accounts through an authorization page on Twitter’s site.
Seriot found a way to craft special links that, when clicked by users, will open Twitter app authorization pages for popular clients like TweetDeck. However, those requests would specify the attacker’s server as callback URLs, forcing users’ browsers to send their Twitter access tokens to the attacker.
The access token allows actions to be performed with the associated account through the Twitter API without the need of a password. An attacker could use such tokens to post new tweets on behalf of the compromised users, read their private messages, modify the location displayed in their tweets, and more.
The presentation essentially covered the security implications of allowing custom callbacks and described a method of using this feature to masquerade as legitimate and trusted Twitter clients in order to steal user access tokens and hijack accounts, Seriot said.
An attacker could send an email with such a crafted link to the social media manager of an important company or news organization suggesting, for example, that it’s a link to follow someone on Twitter.
When clicking on the link, the target would see an SSL-protected Twitter page asking him to authorize TweetDeck, Twitter for iOS, or some other popular Twitter client, to access his account. If the target is already using the impersonated client, he might believe that the previously granted authorization has expired and they need to re-authorize the app.
Clicking the “authorize” button would force the user’s browser to send the access token to the attacker’s server, which would then redirect the user back to the Twitter website. The user wouldn’t see any sign of something bad happening, Seriot said.
In order to perform such an attack and craft the special links in the first place, the attacker would need to know the Twitter API tokens for the applications he wishes to impersonate. These are generally hardcoded in the applications themselves and can be extracted in several ways, Seriot said.
The developer built an open-source OAuth library for Mac OS X that can be used to interact with the Twitter API and generate authorization links with rogue callback URLs. However, the library, which is called STTwitter, was built for legitimate purposes and is intended to add Twitter support to Adium, a popular multi-protocol chat client for Mac OS X.
According to Seriot, Twitter could prevent such attacks by disabling the callback functionality from its OAuth implementation. However, he doesn’t believe that the company will do this, because it’s technically a legitimate feature that’s used by some clients.
Twitter did not immediately respond to a request for comment sent Thursday.