$3k Bug Bounty - Twitter’s OAuth Mistakes
Twitter's OAuth authorisation screen for PIN-based apps incorrectly showed that the app did not have access to Direct Messages, when in fact it did. An attacker could use leaked official API keys to create a malicious app that tricked users into granting DM access.
Published on shkspr.mobi
Imagine the scenario. You're trying out some cool new Twitter app.
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 OAuth authorisation flow is the mechanism by which third-party applications obtain access to a user's account. When a user signs in to an app via OAuth, Twitter presents a consent screen listing the permissions the app is requesting. Users rely on that screen to decide whether to trust the app, so the accuracy of the displayed permissions is a security boundary in itself.
This write-up concerns a mismatch between what Twitter's OAuth screen told users and what an app could actually do. Specifically, the consent screen stated that certain apps did not have access to Direct Messages, while in practice they did. The report was published on the researcher's own blog, shkspr.mobi; the subject of the research was Twitter itself.
Setup
The scenario is a user trying out a new Twitter app. The app asks the user to sign in via OAuth as usual, and the user reviews the permissions shown on the consent screen. The key observation is that the screen indicates the app does not want to access Direct Messages.

The image shows the Twitter login screen with the information that the app cannot access Direct Messages highlighted.
No special accounts, tools or versions are described beyond this. The precondition for the issue is an app using the official Twitter API keys that were leaked many years ago, as discussed below.
Finding it
The researcher noticed that the permissions displayed on Twitter's OAuth screen did not match the access an app actually held. The consent screen said the app did not have access to Direct Messages, but the app did have that access.
The underlying reason is historical. Many years ago the official Twitter API keys were leaked. As a result, app authors who cannot get their app approved by Twitter are still able to access the Twitter API using those keys. For some reason, Twitter's OAuth screen says that these apps do not have access to Direct Messages, even though they do.
The consequence is that users could be tricked into allowing access to their Direct Messages. In the researcher's framing, the app promptly leaks to the world the user's private messages, inappropriate jokes and memes.
Exploitation
Step 1: Understand the callback restriction
Twitter has put restrictions in place in the name of good security. The most important is restricting callback addresses: after a successful login, apps will only return to a predefined URL. This means an attacker cannot take the official Twitter keys and send the user to their own app. The researcher describes this as a sensible security decision.
Step 2: Identify the PIN-based flow
Not every app has a URL, or supports callbacks, or is an actual app. Twitter has a secondary authorisation mechanism for such cases: the user logs in, Twitter provides a PIN, and the user types the PIN into the app.

The image shows the Twitter login screen displaying a security PIN.
Step 3: Observe the incorrect permissions
It appears that these official PIN apps do not display the correct OAuth information to the user.
The report does not include the specific requests, responses or payloads used to demonstrate the issue; the proof of concept was provided to Twitter through the bug bounty platform rather than reproduced in the write-up.
Root cause
The consent screen says these apps do not have access to Direct Messages, but they do, and the PIN apps do not display the correct OAuth information. The screen claims the app does not have access to Direct Messages when it does. The callback restriction, which is otherwise a sound defence, does not help here: the PIN flow exists precisely for apps without a callback URL, so the restriction does not prevent these apps from operating, and the misleading consent screen means the user cannot make an informed decision. The report does not state the underlying implementation detail that causes the mismatch.
Impact
Users could be tricked into allowing access to their Direct Messages while the consent screen said DMs were not in scope. Users could therefore be tricked into granting access to their private messages. The impact is limited to users who authorise such an app, and it depends on the app being able to use the leaked keys and, for the PIN flow, on the user completing the PIN-based authorisation. The report does not describe any further exploitation beyond reading the messages.
Fix
Twitter fixed the issue, and on 2018-12-07 the researcher clarified that it was still present on some API keys.
The researcher also asks whether Twitter will audit old apps and make sure the permissions are correctly displayed, and suggests that Twitter should ideally have a much more granular permissions model: allow apps to read DMs but not send them, write tweets but not delete them, and read tweets but not follow people.
Timeline
| Date | Event |
|---|---|
| 2018-11-06 | Submitted via HackerOne (report 434763) |
| 2018-11-06 | Provided clarification and PoC; issue accepted |
| 2018-11-15 | Proposed publication date of 30 November rejected due to US holidays |
| 2018-11-16 | Bug bounty of $2,940 offered; W2 form completed to state non-US taxpayer status |
| 2018-11-17 | Drank a fair amount of cider |
| 2018-11-21 | £2,287.05 deposited in the researcher's UK bank account; PayPal was also an option |
| 2018-12-06 | Twitter fixed the issue and published the bounty payout; researcher cleared to publish |
| 2018-12-07 | Researcher clarified that the issue was still present on some API keys |
| 2018-12-14 | Report published |
Variants to test
- A positive result is a token that can call an endpoint the screen said was out of scope.
- A positive result is the same mismatch appearing specifically in the PIN path.
- A positive result is a token granted read access that can also send or delete.
- A positive result is the issue persisting on keys not covered by the fix.

The final image, of blood being drawn from the researcher's arm, appears in the blog's "What links here" section, in a 2019 year-in-review post that links back to this article.
What happened, in plain words
Twitter lets other apps connect to your account. When you connect one, Twitter shows you a screen listing what the app is allowed to do. You read that list and decide whether to trust the app. That screen is the whole basis of your decision, so if it lies to you, you can be tricked into handing over more than you meant to.
That is what this report is about. Twitter's permission screen told users that certain apps could not read their Direct Messages (DMs, Twitter's private messages). In reality those apps could read them. A user could therefore authorise an app believing their private messages were off limits, and the app could then read those messages.
The researcher, Terence Eden, found the mismatch, reported it to Twitter through the HackerOne bug bounty platform, and was paid $2,940. The report was published on his own blog, shkspr.mobi, on 2018-12-14.
A few words before we start, because the rest of the article leans on them:
- OAuth is a way for one website or app to get limited access to your account on another, without you handing over your password. Think of a hotel key card: the front desk (Twitter) gives the app a card that opens only certain doors, and you are shown a list of which doors before the card is made.
- An API is the set of doors a program can knock on to ask a service for data or actions. It is the machine-facing side of a website: where you click buttons, a program sends requests.
- API keys are the passwords that programs use to identify themselves to an API. If a key leaks, anyone holding it can pretend to be that program.
- A consent screen is the page that lists the permissions an app is asking for, so you can approve or refuse.
- A callback URL is the address an app tells Twitter to send you back to after you log in. It is how the app receives the result of your login.
The setup
Imagine you are trying out a cool new Twitter app. It asks you to sign in via OAuth, as usual. You look through the permissions, and you are relieved: it does not want to access your Direct Messages.

The image shows the Twitter login screen, with the line saying the app cannot access your Direct Messages highlighted.
So you authorise it, and in the researcher's scenario the app then promptly leaks to the world all your private messages, inappropriate jokes and memes.
Why does the screen say one thing and the app do another? The report gives a historical reason. Many years ago, the official Twitter API keys were leaked. Those keys are the credentials that identify an app to Twitter's API. Because they leaked, app authors who cannot get their app approved by Twitter can still use the Twitter API with those keys.
For some reason, Twitter's OAuth screen says that these apps do not have access to Direct Messages. But they do. The result is that users could be tricked into allowing access to their DMs: the screen understates what the app can do, and the app does the rest.
The restriction that should have helped
Twitter has put some restrictions in place in the name of good security. The most important one is the restriction on callback addresses. After a successful login, an app will only return to a predefined URL. In plain terms: the app has to register in advance where Twitter will send you back, and Twitter will not send you anywhere else.
That is a sensible decision, and it blocks an obvious attack. If someone takes the leaked official keys, they cannot simply point the login at their own app, because the return address is fixed in advance and does not belong to them.
But not every app has a URL. Not every app supports callbacks. Not every app is even an actual app. Twitter has a second way of authorising for those cases: you log in, Twitter shows you a PIN, and you type that PIN into your app.

The image shows the Twitter login screen displaying a security PIN.
It appears that these official PIN apps do not display the correct OAuth information to the user. In other words, the same mismatch shows up in the PIN route: the screen tells you less than the app can actually do.
Why this matters
The consent screen says these apps do not have access to Direct Messages, but they do, and the PIN apps do not display the correct OAuth information. The screen claims the app cannot reach Direct Messages when it can.
The callback restriction, sound as it is, does not save you here. The PIN flow exists precisely for apps that have no callback URL, so the restriction does not stop those apps from working at all. And because the consent screen is misleading, you cannot make an informed decision about what you are approving.
Users could be tricked into allowing access to their Direct Messages while the screen said DMs were out of scope. The impact is limited to people who authorise such an app, and it depends on the app being able to use the leaked keys and, in the PIN flow, on the user completing the PIN authorisation. The report does not describe any further exploitation beyond reading the messages.
The fix
Twitter fixed the issue. On 2018-12-06 the company published the bounty payout and told the researcher he was clear to publish. On 2018-12-07 he clarified that the issue was still present on some API keys. The report does not describe the technical change Twitter made.
The researcher also asks whether Twitter will audit old apps and make sure the permissions are correctly displayed. He suggests that Twitter should ideally have a much more granular permissions model: allow apps to read DMs but not send them, write tweets but not delete them, and read tweets but not follow people. The everyday comparison is a key card that opens the front door but not the safe, rather than one card that opens the whole building.
Timeline
| Date | Event |
|---|---|
| 2018-11-06 | Submitted via HackerOne (report 434763) |
| 2018-11-06 | Provided clarification and proof of concept; issue accepted |
| 2018-11-15 | Proposed publication date of 30 November rejected due to US holidays |
| 2018-11-16 | Bug bounty of $2,940 offered; W2 form completed to state non-US taxpayer status |
| 2018-11-17 | Drank a fair amount of cider |
| 2018-11-21 | £2,287.05 deposited in the researcher's UK bank account; PayPal was also an option |
| 2018-12-06 | Twitter fixed the issue and published the bounty payout; researcher cleared to publish |
| 2018-12-07 | Researcher clarified that the issue was still present on some API keys |
| 2018-12-14 | Report published |
What to test if you want to look for this yourself
Each one is a comparison: what the screen promises versus what the app can actually do.
A token is the short-lived pass the app receives after you approve it; it is what the app shows Twitter on every later request. A positive result is a token that can call something the screen said was out of scope. A positive result is the same mismatch appearing specifically in the PIN path. A positive result is a token granted read access that can also send or delete. A positive result is the issue persisting on keys the fix did not cover.

The final image, of blood being drawn from the researcher's arm, appears in the blog's "What links here" section, in a 2019 year-in-review post that links back to this article.
Glossary
- API: the machine-facing side of a service, the set of requests a program can send to read data or perform actions.
- API keys: credentials that identify a program to an API, like a password for software.
- Callback URL: the address an app registers in advance so that Twitter sends the user back there after login.
- Consent screen: the page listing the permissions an app requests, shown to the user before they approve.
- Direct Messages (DMs): Twitter's private messages between users.
- HackerOne: the bug bounty platform through which the issue was submitted.
- OAuth: a standard that lets an app get limited access to your account on another service without your password, with the permissions shown to you first.
- PIN flow: Twitter's alternative authorisation for apps without a callback URL, where the user logs in, receives a PIN, and types it into the app.
- Proof of concept (PoC): a demonstration that the issue is real, usually the smallest set of steps that reproduces it.
- Scope: the set of permissions a token carries, such as reading DMs or writing tweets.
- Token: the pass an app receives after you approve it, presented on later requests in place of your password.
- W2 form: a US tax form; the researcher completed it to state he is not a US taxpayer.