Twitter ID exposure via error-based side-channel attack
A user's Twitter ID could be confirmed by loading a developer API endpoint as a script and observing whether it loaded or errored, because the endpoint returned a 403 for IDs other than the logged-in user's. An attacker who knew a victim's Twitter ID could therefore identify the victim when they visited a malicious website.
- Triaged in 9 days
- Fixed in 27 days
- Paid in 10 days
- Disclosed after 2 months
Twitter ID Confirmator
Summary
Recently I discovered a privacy-related vulnerability in Twitter. An attacker exploiting this vulnerability can identify a user when they visit a malicious website.
Description
Threat model: The attacker knows the victim’s Twitter ID/username and aims at identifying them when visiting one of the controlled websites such as a blog or a news website. Another goal that the attacker could wish to achieve is to identify a user out of a group of potential target users.
Vulnerability I found out that a user-related content is being loaded when visiting the developer tools and that is https://developer.twitter.com/api/users/USER_ID/client-applications.json. If the USER_ID is different from the ID of a currently logged in user the error 403 will be returned with the following JSON output
{"error":{"message":"You are not logged in as a user that has access to this developer.twitter.com resource.","sent":"2019-03-06T01:20:56+00:00","transactionId":"00d08f800009d7be"}}.
Otherwise, a list of created apps will be displayed (the list will be empty if the user didn't create any app) and no error will be thrown.
It is possible to detect whether the file returned an error or not by a simple onload/onerror event handlers. The example code is shown in #Steps-to-reproduce
Steps to reproduce
- Visit any website
- Execute the following javascript code while replacing
Your IDwith an ID you want to test for
var id = 'Your ID'
var script = document.createElement('script');
script.src = `https://developer.twitter.com/api/users/${id}/client-applications.json`;
script.onload = () => console.log('ID match');
script.onerror = e => console.log('ID mismatch');
document.head.appendChild(script);
These steps have been implemented in the Proof of Concept: https://terjanq.github.io/Bug-Bounty/Twitter/confirming-username/poc.html
PoC in action: https://youtu.be/_S_ImYPvvhc
Impact
An attacker can expose the identity of Twitter users when they visit a prepared for that purpose website.
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
Root cause
Likely the developer API endpoint returned a distinguishable error (403) for IDs other than the logged-in user's, allowing a cross-origin script load to act as an oracle for the user's identity.
Impact
An attacker could expose the identity of Twitter users when they visit a prepared website.
What the attacker needed
Victim is logged in to Twitter; victim visits attacker-controlled site; attacker knows victim's Twitter ID
How it was found
- Visit any website.
- Run JavaScript that creates a script element pointing to the developer API endpoint with the ID to test.
- Attach onload and onerror handlers to log whether the ID matched or not.
- Append the script to the document head to trigger the request.
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 log into a website, your browser can load resources from other sites. This report found that a Twitter developer page would load successfully only if the ID in the URL matched the logged-in user, and would fail otherwise. By loading that page as a script, a malicious site could tell whether you were the person it was looking for.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.