Skip to content
Access control Write-up Advanced

Twitterの非公開リストが見れた話

blog.ryotak.net

Published on blog.ryotak.net

TwitterはBug Bountyプログラム(脆弱性報奨金制度とも呼ばれる)を実施しており、脆弱性診断を行うことが認められています。 本記事は、そのプログラムを通して報告された脆弱性についてを解説したものであり、インターネット上のサービスに無差別に攻撃する事を推奨するものではありません。 また、Twitter上で脆弱性を発見した場合は無闇に� �開せず、TwitterのBug Bountyプログラムより報告してください。

RyotaK, on blog.ryotak.net

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 7 min read.

Context

Twitter runs a Bug Bounty programme through HackerOne, and the author used it to report a chain of issues affecting private lists. A Twitter list is a curated set of accounts; a list can be public or private, and a private list's membership is not meant to be visible to anyone other than its owner. The report describes how a private list's members could be read, and argues that the list ID needed to make that practical could be brute forced.

The chain has three parts: an access control flaw on a GraphQL endpoint, a missing rate limit on a REST endpoint, and a timing side channel exposed through a response header. The author's summary is that combining inappropriate access control, a lack of rate limiting and a timing attack allowed the contents of private Twitter lists to be viewed.

Setup

The GraphQL request shown goes to api.twitter.com with the web client origin https://twitter.com. The requests shown carry a normal logged-in web session: an OAuth2 session auth type, a CSRF token, a bearer token and cookies. The user agent, CSRF token, bearer token, cookie and OAuth header appear as [Redacted] in the published text.

The report does not describe any special tooling, accounts or versions beyond an authenticated session and the ability to send requests to the API and inspect response headers.

Finding it

Two observations drove the work. First, a GraphQL request for a list's members returned the members even when the list was private, so anyone who knew a private list's ID could read its contents. Second, while looking for a way to obtain such IDs, the author found that some Twitter API endpoints documented as rate limited were not rate limited in practice.

When the access control issue was reported on its own, Twitter's position was that obtaining the ID of a private list is difficult, and that without a way to get past that obstacle the issue was only a potential vulnerability. The author therefore set out to show that the attack was realistic, and continued investigating.

Exploitation

Step 1: read members of a private list through GraphQL

The following request to Twitter's GraphQL endpoint returns the member list of a list even when that list is private:

HTTP
GET /graphql/iUmNRKLdkKVH4WyBNw9x2A/ListMembers?variables=%7B%22listId%22%3A%22[ここにリストID]%22%2C%22count%22%3A20%2C%22withTweetResult%22%3Afalse%2C%22withUserResult%22%3Afalse%7D HTTP/1.1
Host: api.twitter.com
User-Agent: [Redacted]
Accept: */*
Accept-Language: ja,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
content-type: application/json
x-twitter-auth-type: OAuth2Session
x-twitter-client-language: ja
x-twitter-active-user: yes
x-csrf-token: [Redacted]
Origin: https://twitter.com
authorization: Bearer [Redacted]
Connection: close
Cookie: [Redacted]

The operation is ListMembers, reached through the path segment iUmNRKLdkKVH4WyBNw9x2A. The variables parameter is a URL-encoded JSON object with listId (the placeholder [ここにリストID] marks where the target list ID goes), count set to 20, and withTweetResult and withUserResult both set to false. The request is authenticated as an ordinary web session through the authorization, x-csrf-token and cookie headers. The important part is that the request returned the members of a list even when that list was private.

Step 2: find an endpoint without the documented rate limit

While searching for a way to obtain private list IDs, the author found that some endpoints documented as rate limited had no rate limit in reality. One of them was POST /1.1/lists/destroy.json, the endpoint for deleting a list. Attempting to delete someone else's private list simply returned a 404, but the absence of a rate limit meant the attempt could be repeated without restriction.

HTTP
POST /1.1/lists/destroy.json
Content-Type: application/x-www-form-urlencoded
Authorization: OAuth [Redacted]

list_id=[ここにリストID]

This call takes the target list ID as the form field list_id and authenticates with an OAuth header. Against a list the caller does not own, the response is a 404.

Step 3: turn response timing into an oracle

The author noticed that almost every response from the Twitter API carries an x-response-time header, and that this header accurately reports the time spent processing the request inside the API. Comparing two cases, an attempt to delete another user's private list and an attempt to delete a list that does not exist, produced a difference of around 20 in the x-response-time value.

Combined with the missing rate limit on POST /1.1/lists/destroy.json, that difference allows private list IDs to be brute forced within a realistic amount of time. The author reported this and it was triaged by Twitter's security team.

Step 4: why guessing IDs is feasible

The report explains the structure of Twitter IDs to justify the brute force. An ID is composed of a millisecond timestamp, a Worker ID, a data centre ID and a value used to avoid ID collisions. The collision-avoidance value starts at 0 and is incremented on each collision, and the data centre ID is basically 10. If the millisecond timestamp and the Worker ID can be estimated, the ID is effectively known.

Twitterチームの返信画像
Twitterチームの返信画像 From the original on blog.ryotak.net

The image shows the reply from the Twitter team during this exchange.

Root cause

The primary flaw is a missing authorisation check on the ListMembers GraphQL operation: the endpoint returned the members of a private list to a caller who was not its owner, so access control depended only on knowledge of the list ID. The ID was treated as the secret, and the report's argument is that this is not a sufficient control because IDs are predictable from a timestamp and Worker ID once those are estimated.

The second flaw is that POST /1.1/lists/destroy.json was documented as rate limited but was not, which removed the practical obstacle to repeated guessing. The third is the x-response-time header, which reports internal processing time accurately enough to distinguish an existing private list from a non-existent one, giving an oracle for the guess. Together they made the private list contents reachable.

Impact

An attacker with an authenticated session could read the membership of any private list whose ID they knew or could recover. With the timing oracle and the missing rate limit, IDs could be brute forced in realistic time, so the practical precondition of knowing the ID could be met. The report does not describe any other data being exposed, and the delete endpoint itself only returned 404 for lists the caller did not own.

Fix

Twitter fixed the vulnerability, with the timeline recording the fix on 2020/8/1.

Variants to test

  1. Persisted GraphQL operations on other objects. Send a ListMembers-style query for another object type (for example a private collection or a protected resource) with only its ID as the selector, and check whether the response differs between the owner's session and another authenticated session. A positive result is data returned to the non-owner.
  2. Documented rate limits that do not exist. Take endpoints whose documentation states a rate limit and send repeated requests, watching for throttling responses. A positive result is a long run of normal responses with no rate limit error.
  3. Timing headers as oracles. Look for headers that report server processing time, then compare requests for an existing private object against a non-existent one. A positive result is a consistent, measurable difference between the two cases.
  4. ID predictability. Where IDs embed timestamps and worker identifiers, estimate those components and check whether generated candidate IDs resolve to real objects. A positive result is a candidate ID that returns an object the tester does not own.

Timeline

Date Event
2020/5/29 Vulnerability reported
2020/5/30 Twitter: more information needed
2020/5/30 Additional information sent
2020/6/1 Twitter: more information needed
2020/6/2 Additional information sent
2020/6/2 Twitter: internal investigation
2020/6/6 Twitter: accepted as a vulnerability
2020/6/24 Twitter: bounty amount decided
2020/8/1 Twitter: vulnerability fixed
2020/8/4 Vulnerability disclosed

The author notes that during triage there were several moments when the report nearly was rejected, including a reply that being able to obtain the member list of a private list was "not a risk worth handling in the Bug Bounty programme". Persistently explaining why it mattered led to it being accepted. The lesson drawn is that even when a rejection looks certain, explaining clearly why something is a security problem can turn the decision around, and that later reports still saw the triage team try to reject on the grounds that there was no way to obtain the ID, even after the team had acknowledged in an earlier report that obtaining IDs is easy.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 15 min read.

What happened, in plain words

Twitter lets anyone create a list: a named collection of accounts that you follow as a group. A list can be public, meaning anyone can see who is on it, or private, meaning only the owner should be able to see its members. The author of this report found a way to read the members of a private list, and then found a way to make that attack practical. The whole thing was reported through Twitter's Bug Bounty programme, a scheme where companies pay people for finding and reporting security problems instead of exploiting them.

The report chains three separate weaknesses together. First, a GraphQL endpoint returned the members of a private list to an authenticated caller who supplied the list's ID. Second, an endpoint for deleting lists was supposed to be rate limited (that is, it should stop you after too many requests in a short time) but in practice was not, so it could be called over and over. Third, almost every response from the API included a header reporting how long the server took to process the request, and that timing differed slightly depending on whether a list existed or not. Put together, these let someone guess private list IDs and then read the lists.

Before going further, a few words on the building blocks, because the rest of the article uses them constantly.

  • An API (Application Programming Interface) is the set of addresses a service exposes so that programs, rather than people clicking in a browser, can ask it for data or ask it to do something. Think of it as the service's back counter: the website is the shop front, the API is where apps place their orders.
  • A request is one message sent to the API: a method (such as GET to read something or POST to change something), a path (which operation you want), and headers (extra information such as who you are).
  • A header is a small labelled line attached to a request or a response, carrying metadata. Content-Type says what format the body is in; Cookie carries your session; x-response-time (as seen later) reports timing.
  • A cookie is a small piece of data your browser stores for a site and sends back on every request, so the server can recognise your logged-in session. A token is similar in spirit: a string that proves who you are or what you are allowed to do. Both are secrets; if someone else gets yours, they can act as you.
  • GraphQL is a style of API where the client names the exact operation and fields it wants, instead of the server having a fixed set of URLs for every possible query. Twitter's web client uses it heavily.
  • Rate limiting is a cap on how many requests a client may make in a period. It exists to stop abuse and to keep the service usable for everyone.
  • A timing attack is when an attacker learns something not from what a response says, but from how long it takes. If one case is consistently a little slower than another, the difference itself leaks information.
  • Access control (or authorisation) is the check that decides whether the person asking is allowed to see or do the thing they are asking for. When that check is missing, the problem is often called an access control flaw or, more loosely, an insecure direct object reference: the server trusts that if you know an object's ID, you are allowed to use it.

The setup

The GraphQL request shown went to api.twitter.com and carried the origin https://twitter.com. The requests shown in the report carry an ordinary logged-in web session: an OAuth2 session auth type, a CSRF token, a bearer token and cookies. In the published text the user agent, the CSRF token, the bearer token, the cookie and the OAuth header appear as [Redacted].

A quick note on those session pieces, since they appear in the first request:

  • OAuth2 is a standard way for an app to prove it is acting on behalf of a user. x-twitter-auth-type: OAuth2Session tells the server this is a browser session logged in as a user.
  • A CSRF token (Cross-Site Request Forgery token) is a random value the site gives your browser and expects back on state-changing requests, so that another website cannot silently make requests on your behalf. It is a guard against a class of attack where a malicious page tricks your browser into sending a request you did not intend.
  • A bearer token is a credential sent in the authorization header. Whoever holds it can use the API as the account it belongs to, which is why it is redacted.

The report does not describe any special tooling, accounts or versions beyond an authenticated session and the ability to send requests to the API and inspect response headers.

Finding it

Two observations drove the work. First, a GraphQL request for a list's members returned the members even when the list was private, so anyone who knew a private list's ID could read its contents. Second, while looking for a way to obtain such IDs, the author found that some Twitter API endpoints documented as rate limited were not rate limited in practice.

When the access control issue was reported on its own, Twitter's position was that obtaining the ID of a private list is difficult, and that without a way to get past that obstacle the issue was only a potential vulnerability. In other words, the company argued that the door was unlocked but nobody could find the door. The author therefore set out to show that the attack was realistic, and continued investigating. That is the reason for everything that follows: not to find more bugs for their own sake, but to prove that the first bug was reachable in practice.

Exploitation

Step 1: read members of a private list through GraphQL

The following request to Twitter's GraphQL endpoint returns the member list of a list even when that list is private:

HTTP
GET /graphql/iUmNRKLdkKVH4WyBNw9x2A/ListMembers?variables=%7B%22listId%22%3A%22[ここにリストID]%22%2C%22count%22%3A20%2C%22withTweetResult%22%3Afalse%2C%22withUserResult%22%3Afalse%7D HTTP/1.1
Host: api.twitter.com
User-Agent: [Redacted]
Accept: */*
Accept-Language: ja,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
content-type: application/json
x-twitter-auth-type: OAuth2Session
x-twitter-client-language: ja
x-twitter-active-user: yes
x-csrf-token: [Redacted]
Origin: https://twitter.com
authorization: Bearer [Redacted]
Connection: close
Cookie: [Redacted]

Line by line, in plain words:

  1. The first line is the request line. GET means "read something". The path starts with /graphql/ and then contains a long identifier, iUmNRKLdkKVH4WyBNw9x2A, followed by /ListMembers. That identifier is part of the path, followed by /ListMembers, the operation being run. ListMembers is the operation being run: give me the members of a list.
  2. After the ? comes the query string, variables=.... The value is a JSON object that has been URL-encoded, meaning special characters are written as %XX codes so they can travel safely in a URL. Decoded, it is {"listId":"[ここにリストID]","count":20,"withTweetResult":false,"withUserResult":false}. listId is where the target list ID goes; the placeholder [ここにリストID] marks that spot. count is 20, so up to 20 members are returned. withTweetResult and withUserResult are both false, meaning the response should not include extra tweet or user details, just the membership.
  3. Host: api.twitter.com says which server the request is for.
  4. User-Agent identifies the client software. It is redacted here.
  5. Accept: */* says the client will accept any response format. Accept-Language says which languages the client prefers. Accept-Encoding: gzip, deflate says the client can handle compressed responses.
  6. content-type: application/json declares the body format as JSON. This is a GET with no body, but the header is still sent.
  7. x-twitter-auth-type: OAuth2Session says this is a logged-in browser session. x-twitter-client-language: ja says the client language is Japanese. x-twitter-active-user: yes marks the user as active.
  8. x-csrf-token is the anti-forgery token described earlier, redacted here.
  9. Origin: https://twitter.com says the request originates from the Twitter website.
  10. authorization: Bearer [Redacted] carries the bearer token, redacted.
  11. Connection: close asks the server to close the connection after the response.
  12. Cookie: [Redacted] carries the session cookies, redacted.

The important part is not any single header but what the server did with the request: it returned the members even when the list was private. Supplying the ID was enough. That is the access control flaw. The author reported it, and Twitter replied that finding a private list's ID is difficult, so the issue was only potential. The next two steps exist to answer that objection.

Step 2: find an endpoint without the documented rate limit

While searching for a way to obtain private list IDs, the author found that some endpoints documented as rate limited had no rate limit in reality. One of them was POST /1.1/lists/destroy.json, the endpoint for deleting a list. Attempting to delete someone else's private list simply returned a 404, but the absence of a rate limit meant the attempt could be repeated without restriction.

HTTP
POST /1.1/lists/destroy.json
Content-Type: application/x-www-form-urlencoded
Authorization: OAuth [Redacted]

list_id=[ここにリストID]

Line by line:

  1. POST /1.1/lists/destroy.json is the request line. POST means "change something", and the path names the operation: destroy a list. The .json suffix says the response should be JSON.
  2. Content-Type: application/x-www-form-urlencoded says the body is in the same format a web form uses: name=value pairs.
  3. Authorization: OAuth [Redacted] carries the OAuth credential, redacted.
  4. After the blank line comes the body: list_id=[ここにリストID]. This is the form field naming the list to delete, with the placeholder where the ID goes.

This call takes the target list ID as the form field list_id and authenticates with an OAuth header. Against a list the caller does not own, the response is a 404. A 404 is the standard "not found" response. The point of this step is not deletion: it is that the endpoint can be called repeatedly with no throttling, which is exactly what a guessing attack needs. If the server had enforced the documented rate limit, an attacker would be slowed to a crawl; without it, they can fire requests as fast as the connection allows.

Step 3: turn response timing into an oracle

The author noticed that almost every response from the Twitter API carries an x-response-time header, and that this header accurately reports the time spent processing the request inside the API. Comparing two cases, an attempt to delete another user's private list and an attempt to delete a list that does not exist, produced a difference of around 20 in the x-response-time value.

An oracle in security means any signal that answers a yes/no question for the attacker. Here the question is "does a list with this ID exist?". The status code answers 404 in both cases, so it is useless as an oracle. The timing header, however, differs between the two cases. Around 20 units of difference is small, but it is consistent, and consistency is what makes an oracle usable. Combined with the missing rate limit on POST /1.1/lists/destroy.json, that difference allows private list IDs to be brute forced within a realistic amount of time. Brute forcing means trying candidate values one after another until one works. The author reported this and it was triaged by Twitter's security team. Triage is the first stage of a bug bounty: the company's team reviews the report, asks for more detail if needed, and decides whether it is a real vulnerability.

Step 4: why guessing IDs is feasible

The report explains the structure of Twitter IDs to justify the brute force. An ID is composed of a millisecond timestamp, a Worker ID, a data centre ID and a value used to avoid ID collisions. The collision-avoidance value starts at 0 and is incremented on each collision, and the data centre ID is basically 10. If the millisecond timestamp and the Worker ID can be estimated, the ID is effectively known.

Why does that matter? Because a long random number is unguessable, but a number built out of predictable parts is not. The timestamp narrows the search to the moment the list was created; the Worker ID identifies which machine issued the ID; the data centre ID is basically 10; and the collision counter starts at 0 and increments on each collision. So instead of searching an enormous space, an attacker searches a much smaller one. The timing oracle from step 3 then tells them when a candidate is right.

Twitterチームの返信画像
Twitterチームの返信画像 From the original on blog.ryotak.net

The image shows the reply from the Twitter team during this exchange.

Root cause

The primary flaw is a missing authorisation check on the ListMembers GraphQL operation: the endpoint returned the members of a private list to a caller who was not its owner, so access control depended only on knowledge of the list ID. The ID was treated as the secret, and the report's argument is that this is not a sufficient control because IDs are predictable from a timestamp and Worker ID once those are estimated. Treating an identifier as if it were a password is a common mistake: identifiers are often shown in URLs, logs and screenshots, and as this report shows, they can sometimes be computed.

The second flaw is that POST /1.1/lists/destroy.json was documented as rate limited but was not, which removed the practical obstacle to repeated guessing. The third is the x-response-time header, which reports internal processing time accurately enough to distinguish an existing private list from a non-existent one, giving an oracle for the guess. Together they made the private list contents reachable. That is the essence of a vulnerability chain: individually minor issues combine into a serious one.

Impact

An attacker with an authenticated session could read the membership of any private list whose ID they knew or could recover. With the timing oracle and the missing rate limit, IDs could be brute forced in realistic time, so the practical precondition of knowing the ID could be met. The report does not describe any other data being exposed, and the delete endpoint itself only returned 404 for lists the caller did not own.

Fix

Twitter fixed the vulnerability, with the timeline recording the fix on 2020/8/1.

Variants to test

If you want to look for similar problems in your own testing, these are the patterns to try. Only test systems you are authorised to test.

  1. Persisted GraphQL operations on other objects. Send a ListMembers-style query for another object type (for example a private collection or a protected resource) with only its ID as the selector, and check whether the response differs between the owner's session and another authenticated session. A positive result is data returned to the non-owner.
  2. Documented rate limits that do not exist. Take endpoints whose documentation states a rate limit and send repeated requests, watching for throttling responses. A positive result is a long run of normal responses with no rate limit error.
  3. Timing headers as oracles. Look for headers that report server processing time, then compare requests for an existing private object against a non-existent one. A positive result is a consistent, measurable difference between the two cases.
  4. ID predictability. Where IDs embed timestamps and worker identifiers, estimate those components and check whether generated candidate IDs resolve to real objects. A positive result is a candidate ID that returns an object the tester does not own.

Timeline

Date Event
2020/5/29 Vulnerability reported
2020/5/30 Twitter: more information needed
2020/5/30 Additional information sent
2020/6/1 Twitter: more information needed
2020/6/2 Additional information sent
2020/6/2 Twitter: internal investigation
2020/6/6 Twitter: accepted as a vulnerability
2020/6/24 Twitter: bounty amount decided
2020/8/1 Twitter: vulnerability fixed
2020/8/4 Vulnerability disclosed

The author notes that during triage there were several moments when the report nearly was rejected, including a reply that being able to obtain the member list of a private list was "not a risk worth handling in the Bug Bounty programme". Persistently explaining why it mattered led to it being accepted. The lesson drawn is that even when a rejection looks certain, explaining clearly why something is a security problem can turn the decision around, and that later reports still saw the triage team try to reject on the grounds that there was no way to obtain the ID, even after the team had acknowledged in an earlier report that obtaining IDs is easy.

Glossary

  • API: the set of addresses a service exposes so that programs can request data or actions, as opposed to a website meant for people to click.
  • Access control (authorisation): the check that decides whether the person asking is allowed to see or do the thing they are asking for.
  • Bearer token: a credential sent in the authorization header; whoever holds it can act as the account it belongs to.
  • Brute force: trying candidate values one after another until one works.
  • Bug Bounty programme: a scheme where a company pays people for finding and reporting security problems instead of exploiting them.
  • Cookie: a small piece of data a browser stores for a site and sends back on every request, so the server can recognise a logged-in session.
  • CSRF token: a random value the site gives your browser and expects back on state-changing requests, so another website cannot silently make requests on your behalf.
  • GraphQL: a style of API where the client names the exact operation and fields it wants, rather than the server having a fixed URL for every query.
  • Header: a small labelled line attached to a request or response carrying metadata, such as content type, cookies or timing.
  • ID: an identifier for an object, such as a list. It is not a password, even though some systems treat it as one.
  • OAuth2: a standard way for an app to prove it is acting on behalf of a user.
  • Oracle: any signal that answers a yes/no question for an attacker, such as whether an object exists.
  • Persisted query hash: a short fingerprint of a GraphQL query that the client sends instead of the full query text, which the server looks up.
  • Rate limiting: a cap on how many requests a client may make in a period, used to stop abuse and keep the service usable.
  • Request: one message sent to an API, with a method, a path, headers and sometimes a body.
  • REST: a style of API built around fixed URLs and standard methods such as GET and POST.
  • Timing attack: learning something not from what a response says but from how long it takes.
  • Triage: the first stage of a bug bounty, where the company's team reviews a report and decides whether it is a real vulnerability.
  • URL-encoded: a way of writing special characters as %XX codes so they can travel safely in a URL.
  • Vulnerability chain: several individually minor issues that combine into a serious one.
  • Worker ID: in this report, a small number identifying which machine issued an ID, one of the predictable parts of a Twitter ID.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.