A possibility of Account Takeover in Medium
Medium's Twitter login relied on the Twitter username to identify the account, so an attacker could change their own Twitter username to match a victim's old username and log into the victim's Medium account. The attacker could take over any Medium account linked to Twitter if the victim had changed their Twitter username.
Published on medium.com
There are times when you discover something that is very common and ordinary which just blows your mind and you start thinking, “How come I didn’t knew this before!?”. I recently had that kind of a moment when I came to know that Twitter allows users to change their username.
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
Medium is a publishing platform where readers and writers sign in with an email address or through a third-party identity provider. One of those providers is Twitter, and Medium lets an existing account be linked to a Twitter profile from the account settings. After linking, the "Sign In with Twitter" option is meant to authenticate the owner of that Twitter profile and take them back into the same Medium account.
The report looks at what that link is actually keyed on. The claim is that the Twitter login on Medium depended on the Twitter username, and because Twitter lets a user change their username at any time, the link could be made to point at a different person.
Setup
Two Twitter accounts are needed: the victim's, already linked to a Medium account, and the attacker's. The scenario assumes the victim's Twitter username changes at some point after linking, as happens when someone renames their handle. No special tools are described; the whole flow is carried out through the Medium settings page and the Twitter sign-in dialog in a browser.
Finding it
The starting observation is almost trivial: Twitter allows users to change their username. That raised the question of whether any site's Twitter integration trusts the username as an identifier. The researcher calls the idea crazy but worth trying, and on Medium it turned out to be correct: the login from Twitter depended on the Twitter username rather than on something immutable tied to the Twitter account.
Exploitation
Step 1: link a Medium account to Twitter
Log in to Medium, open Settings and connect the account to Twitter. The screenshots show the account before linking, the Twitter authorisation dialog, and the state after linking.

Medium account before connecting to Twitter

Twitter profile being connected to Medium

After connecting Medium to Twitter
Step 2: the victim renames their Twitter handle
Suppose the Twitter user later changes their username to something else. The attacker renames their own Twitter account to notsoshant.

Attacker's profile
Step 3: sign in with the attacker's Twitter account
Go to Medium and choose the Sign In with Twitter option. Logging in with the attacker's Twitter profile results in Medium logging the attacker into the victim's Medium account.

Attacker's Twitter profile highlighted in victim's profile
The report does not include the HTTP requests or responses behind these steps; the evidence is the sequence of screens above.
Root cause
The Twitter sign-in on Medium was resolving the local account from the Twitter username. A username is user-controlled and mutable, so it is not a stable identifier for an external identity. Because the link was keyed on the username, changing the Twitter username moved the association with it.
Likely the stored link was matched on the handle rather than on an immutable Twitter account identifier, so the check that should have tied the login to the original Twitter account had nothing stable to compare against. The report frames the underlying lesson as OAuth being easy to implement incorrectly.
Impact
An attacker can take over a Medium account that is linked to Twitter, provided the victim has changed their Twitter username. The attacker then signs in through Twitter and lands in the victim's Medium account. The report does not describe any further actions taken with the hijacked account.
Medium closed the report without a reward or credit, stating:
"Report does not meet the criteria outlined in the Bug Bounty program (https://medium.com/policy/mediums-bug-bounty-disclosure-program-34b1c80764c2), and therefore is not eligible for a reward."
The researcher's reading is that it fell under the excluded category of "Bugs that require unlikely user interaction or phishing".
Fix
Medium patched the issue. The report gives the dates but not the change itself: disclosed on 13 September 2018 and patched on 25 September 2018. A fix for this class of bug would be to key the external identity on an immutable provider-side identifier rather than on the username.
Variants to test
- Any "Sign in with" or "Connect account" flow where the provider lets users rename themselves. Link an account, rename the provider handle, register the old handle on a second provider account, and sign in. A positive result is being logged into the first local account.
- Providers that expose both a numeric or opaque ID and a display handle. Check whether the callback stores the handle only; a positive result is that changing the handle on the provider side still resolves to the same local account, or that a new handle resolves to the old one.
- Account unlinking and re-linking. Unlink a provider account, rename the handle, and link again from a different provider account. A positive result is the old local account being reachable through the new handle.
- Email-based recovery that trusts a provider-supplied address. If the provider allows changing the address, try claiming a released address and using it for login or password reset. A positive result is access to the original account.
Timeline
- 13 September 2018: vulnerability disclosed to Medium.
- 25 September 2018: vulnerability patched by Medium. No reward or credit given.
What happened, in plain words
Medium is a website where people publish and read articles. To use it you need an account, and you can create that account with an email address or by letting another service vouch for who you are. One of those other services is Twitter. If you already have a Medium account, you can go into your settings and connect it to your Twitter profile, so that later you can press "Sign In with Twitter" instead of typing a password.
The report describes a flaw in that connection. The connection between your Medium account and your Twitter account was, according to the researcher, remembered by Medium using your Twitter username, the short handle that starts with an @ and appears on your profile. Twitter lets anyone change their username whenever they like. So if you change yours, the link Medium stored under the old name can be reached by whoever signs in with that username.
The researcher found this by noticing something very ordinary, that Twitter usernames can be changed, and asking whether any website's Twitter login trusted the username as an identity. On Medium, it did. Medium fixed the problem but decided the report did not qualify for a reward.
Before going further, a few words that come up constantly below.
- An account on a website is your personal space there, protected by something only you know or hold.
- Logging in (or signing in) is proving to the website that you are the owner of that account.
- A third-party identity provider is a company that vouches for you to another website, the way a friend might confirm your identity at a door. Twitter is acting as that friend here.
- OAuth is the standard set of rules that websites use to do this vouching. You have seen it as the "Sign in with Google" or "Sign in with Twitter" buttons. You never give the website your Twitter password; Twitter tells the website that you are who you say you are.
- A username or handle is the public name you choose on a service, like the name on a badge. It is chosen by you and can usually be changed.
- An identifier is something a computer uses to tell two things apart. A good identifier never changes and is never chosen by the user, like a passport number. A username is a bad identifier because the user controls it and can change it.
- Account takeover is the name for this whole class of problem: someone else ends up inside your account.
The setup you need to picture
To follow the story you only need to imagine two people, each with a Twitter account, and one of them with a Medium account.
The first person is the victim. They have a Twitter account and a Medium account, and at some point they connected the two. The second person is the attacker, who has their own Twitter account and their own Medium account, or can make one.
The scenario assumes the victim changes their Twitter username at some point after connecting the two accounts. That is completely normal behaviour: people rename their handles all the time. Nothing else is needed. No special software, no hacking tools, no command line. The whole thing happens in a browser, on Medium's settings page and in Twitter's sign-in window.
How the researcher got there
The starting point is almost too simple to call a discovery. Twitter lets users change their username. That is a feature everyone knows about and nobody thinks twice about.
The researcher's question was: what if some website's Twitter integration uses the username to decide who you are? In other words, when a site asks Twitter "who is this person?", does it accept the name on the badge as proof, or does it check something that cannot be swapped?
The researcher calls the idea crazy but worth trying. On Medium it turned out to be right. The Twitter login on Medium depended on the Twitter username rather than on something permanent that belongs to the Twitter account and cannot be changed.
Step by step: how the attack works
Step 1: connect a Medium account to Twitter
The first step is the ordinary, intended use of the feature. Log in to Medium, open Settings, and connect the account to Twitter. Medium sends you to Twitter, Twitter asks whether you want to allow Medium to see your account, and you say yes. From then on, Medium remembers that this Medium account belongs to that Twitter account.
The screenshots show the three moments of this flow: the Medium account before anything is connected, the Twitter window asking for permission, and the state afterwards, when the link exists.

Medium account before connecting to Twitter

Twitter profile being connected to Medium

After connecting Medium to Twitter
Why this step matters: without a link there is nothing to abuse. The vulnerability lives in how that link is stored and looked up later.
Step 2: the victim renames their Twitter handle
Now suppose the Twitter user later changes their username to something else. On Twitter this is a normal settings change. The important consequence is that the username Medium stored no longer matches the victim's current handle.
The attacker renames their own Twitter account to notsoshant.

Attacker's profile
Why this step matters: the attacker is not breaking into anything here. They are using a public feature of Twitter to take a name that the victim has voluntarily released. The attack depends on Medium trusting a username that can change.
Step 3: sign in with the attacker's Twitter account
Go to Medium and choose the Sign In with Twitter option. The attacker logs in with their own Twitter profile.
Medium then logs the attacker into the victim's Medium account.

Attacker's Twitter profile highlighted in victim's profile
Why this step matters: this is where the flaw becomes visible. The attacker proved ownership of a Twitter account, but Medium treated that as proof of ownership of a different Medium account, because the name matched what it had stored.
The report does not include the HTTP requests or responses behind these steps. The evidence is the sequence of screens above, not captured network traffic.
Why it worked
The Twitter sign-in on Medium was working out which local account to open by looking at the Twitter username. A username is chosen by the user and can be changed at any time, so it is not a stable identifier for an external identity. Because the link was keyed on the username, changing the Twitter username moved the association with it.
A useful comparison is a cloakroom. If the attendant writes your name on the ticket instead of giving you a numbered tag, then anyone who later uses the same name can collect your coat. The number on a tag is unique and never reused; a name is neither.
Most likely the stored link was matched on the handle rather than on a permanent Twitter account identifier, so the check that should have tied the login to the original Twitter account had nothing stable to compare against. The report frames the underlying lesson as OAuth being easy to implement incorrectly.
What an attacker could do with it
An attacker can take over a Medium account that is linked to Twitter, as long as the victim has changed their Twitter username. The attacker then signs in through Twitter and lands in the victim's Medium account.
The report does not describe any further actions taken with the hijacked account.
What Medium said
Medium closed the report without a reward or credit, stating:
"Report does not meet the criteria outlined in the Bug Bounty program (https://medium.com/policy/mediums-bug-bounty-disclosure-program-34b1c80764c2), and therefore is not eligible for a reward."
The researcher's reading is that it fell under the excluded category of "Bugs that require unlikely user interaction or phishing".
The fix
Medium patched the issue. The report gives the dates but not the change itself: disclosed on 13 September 2018 and patched on 25 September 2018.
A fix for this class of bug would be to key the external identity on a permanent identifier supplied by the provider rather than on the username. In plain terms: store the passport number, not the name on the badge.
Other places to look for the same mistake
These are variations on the same idea, useful if you want to check other websites for the same flaw.
- Any "Sign in with" or "Connect account" flow where the provider lets users rename themselves. Link an account, rename the provider handle, register the old handle on a second provider account, and sign in. A positive result is being logged into the first local account.
- Providers that expose both a numeric or opaque ID and a display handle. Check whether the callback stores the handle only. A positive result is that changing the handle on the provider side still resolves to the same local account, or that a new handle resolves to the old one.
- Account unlinking and re-linking. Unlink a provider account, rename the handle, and link again from a different provider account. A positive result is the old local account being reachable through the new handle.
- Email-based recovery that trusts a provider-supplied address. If the provider allows changing the address, try claiming a released address and using it for login or password reset. A positive result is access to the original account.
Timeline
- 13 September 2018: vulnerability disclosed to Medium.
- 25 September 2018: vulnerability patched by Medium. No reward or credit given.
Glossary
- Account: your personal space on a website, protected by credentials that prove you own it.
- Account takeover: a situation where someone other than the owner gains access to an account.
- Attacker: the person trying to gain access to someone else's account.
- Browser: the program you use to visit websites, such as Chrome, Firefox or Safari.
- Callback: the step in an OAuth flow where the identity provider sends you back to the website with information about who you are.
- Credentials: the things that prove your identity, such as a password or a linked account.
- Handle: another word for username, the public name you choose on a service.
- HTTP request: the message a browser sends to a server asking for something, such as a page or an action.
- HTTP response: the message a server sends back to the browser.
- Identifier: a value used to tell two things apart, ideally one that never changes and is not chosen by the user.
- Identity provider: a service that vouches for who you are to another website, such as Twitter or Google.
- Link (verb): to connect one account to another so that one can be used to sign in to the other.
- OAuth: the standard set of rules websites use to let one service vouch for your identity to another, behind buttons like "Sign in with Twitter".
- Phishing: tricking someone into giving up their credentials or taking an action that helps an attacker.
- Provider: short for identity provider.
- Root cause: the underlying reason a vulnerability exists, as opposed to its visible symptom.
- Sign in: proving to a website that you own an account, also called logging in.
- Third party: a company or service other than the website you are using.
- Username: the public name you choose on a service, which can usually be changed.
- Victim: the person whose account is being attacked.
- Vulnerability: a weakness in a website or system that an attacker can use to do something harmful.
- Vulnerability disclosure: the process of reporting a vulnerability to the company that owns the system.
- Bug bounty program: a scheme where a company offers rewards to people who report vulnerabilities in its systems.