Skip to content
CSRF Disclosed report Beginner

CSRF on cards API

The cards API endpoint enforced CSRF protection only on the exact path with a .json extension, so an attacker could bypass it by removing the extension. This allowed an attacker to make a victim vote on a poll without their knowledge.

File Descriptor Follow

Originally disclosed on HackerOne

  • Triaged in 3 days
  • Fixed in 5 days
  • Paid in 7 days
  • Disclosed after 18 months

Summary by the researcher

This report demonstrates a technique to bypass CSRF protection by removing the file extension.

In short, if posting to /api/entity.json doesn't work, try /api/entity.

The report

Hi, I would like to report an CSRF issue on the cards API endpoint (/i/cards/api/v1.json).

##Detail Currently the endpoint is responsible for poll cards (maybe more to come). When a user votes, a request will be sent to this endpoint to record the user's selected choice. By default there's a CSRF protection in place which looks for authenticity_token in the query part of the URI. However, such check only appears for the exact path (/i/cards/api/v1.json). Given that the server seems to relax path extension, attackers can circumvent the protection by using the path /i/cards/api/v1 (without .json) for the request.

This is how a normal request looks like:

HTTP
POST https://twitter.com/i/cards/api/v1.json?tweet_id=657629231309041664&card_name=poll2choice_text_only&forward=false&capi_uri=capi%3A%2F%2Fpassthrough%2F1 HTTP/1.1
Host: twitter.com
Cookie: foo=bar

{"twitter:string:card_uri":"card://657629230759415808","twitter:long:original_tweet_id":"657629231309041664","twitter:string:selected_choice":"2"}

without providing a valid CSRF token, it will return a HTTP 403 error. Now that we trim the extension part (v1.json to v1) and resend it:

HTTP
POST https://twitter.com/i/cards/api/v1?tweet_id=657629231309041664&card_name=poll2choice_text_only&forward=false&capi_uri=capi%3A%2F%2Fpassthrough%2F1 HTTP/1.1
Host: twitter.com
Cookie: foo=bar

{"twitter:string:card_uri":"card://657629230759415808","twitter:long:original_tweet_id":"657629231309041664","twitter:string:selected_choice":"2"}

it still lacks the CSRF token, but this time it returns HTTP 200 and the vote is successfully made. All in all, attackers can abuse it and make victims to vote without noticing.

#PoC Here's a handy tool to CSRF any poll. You may also just intercept the vote request to validate the issue.

  1. Go to http://innerht.ml/pocs/twitter-cards-csrf/
  2. Fill in the poll card's information you want to CSRF (e.g. for https://twitter.com/Bugcrowd/status/657629231309041664 the parameters are

tweet_id: 657629231309041664, card_uri: card://657629230759415808, selected_choice: 2) 3. Click the button to activate the attacke. Of course the whole process can be silent.

The original report as published on HackerOne, by filedescriptor. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

The CSRF protection was applied only to the exact path with the .json extension, while the server also accepted the same endpoint without the extension and did not enforce the check there.

Impact

An attacker could make a victim vote on a poll without their knowledge; the endpoint may later support more actions.

What the attacker needed

Victim is logged in; victim visits attacker's page

How it was found

  1. Send a POST request to the cards API endpoint with the .json extension and without a CSRF token; it returns HTTP 403.
  2. Remove the .json extension from the path and resend the same request without a CSRF token; it returns HTTP 200 and the vote is recorded.
  3. Use a proof-of-concept page to fill in poll details and trigger the attack, potentially silently.

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.

CSRF (Cross-Site Request Forgery) is when a malicious site tricks your browser into sending a request to another site where you're logged in, without you intending to. Here, the server checked for a security token only on one specific URL path, but the same action was also available on a slightly different path that skipped the check. So an attacker could make you vote on a poll just by visiting a page.

What is CSRF?

Another site makes a signed-in user's browser perform an action they did not intend.

More by File Descriptor

View all

20 more disclosed reports, best first.

More from X / xAI

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.