Skip to content
CSRF Disclosed report Beginner

Posting to Twitter CSRF on php/post_twitter_authenticate.php

A page on Zomato that posts to Twitter lacked a CSRF token check, so an attacker could make a logged-in victim post arbitrary content to their linked Twitter account. The author also notes that combined with a stored XSS this could be more serious.

kuromatae Follow

Originally disclosed on HackerOne

Bounty$50 Low View original
  • Disclosed after 37 days

Hi !

This time, i found a CSRF who can lead to arbitrary writing on twitter account of victim if they have added it to zomato :)

Coupled with a stored XSS, it could be very troublesome to you.

In the page, it seems there is no token check at all.

You can see in the video the CSRF working and here is the POC i used:

https://www.zomato.com/php/post_twitter_authenticate.php?type=posttweet&message=Hello Zomato Team :)

Cordially,

Kuromatae.

Attachments

Poc_CSRF.mp4 From the original on HackerOne

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

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 4 min read.

What the report shows

The target is Zomato, and the feature involved is the integration that lets a user connect a Twitter account to their Zomato profile. The researcher, kuromatae, reported a cross-site request forgery (CSRF) in the endpoint that handles the Twitter authentication callback, php/post_twitter_authenticate.php. The report states that the issue can lead to arbitrary writing on the Twitter account of a victim who has added Twitter to Zomato, and notes that combined with a stored XSS it could be very troublesome.

The researcher's central observation is that the page appears to perform no token check at all. The proof of concept is a single GET request:

HTTP
https://www.zomato.com/php/post_twitter_authenticate.php?type=posttweet&message=Hello Zomato Team :)

The URL carries type=posttweet and a message parameter in the query string. The report states the page appears to perform no token check at all, and includes a video of the CSRF working.

The report includes a video demonstrating the CSRF working:

Poc_CSRF.mp4 From the original on HackerOne

The report was disclosed on 19 August 2017, rated low severity, and paid a bounty of 50.00 USD. The report does not describe a fix.

Root cause

The likely root cause is that the state-changing endpoint authenticates the request only by the victim's ambient session (cookies sent automatically by the browser) and does not require a per-request, unguessable token tied to that session. Any cross-origin page can therefore cause the browser to issue the request, and the server cannot distinguish it from a legitimate action initiated by the user.

Impact

The report frames the impact as arbitrary writing on the Twitter account of a victim who has added Twitter to Zomato. The report frames the impact as arbitrary writing on the victim's Twitter account, and adds that chaining with a stored XSS would make it considerably worse. The severity assigned was low and the bounty was 50.00 USD.

How this kind of bug works

CSRF exploits the fact that browsers attach cookies to requests based on the destination origin, not on who initiated the request. If a sensitive action is authorised purely by a session cookie and the request can be expressed as a simple cross-origin request (a GET, or a form POST with ordinary content types), an attacker's page can trigger it. The server sees a valid session and performs the action.

The standard defences are:

  1. Synchroniser tokens: a random, per-session (or per-request) value embedded in forms and checked server-side.
  2. SameSite cookies, which stop the browser from sending the session cookie on cross-site requests.
  3. Origin and Referer validation for state-changing requests.
  4. Requiring a custom header or a non-simple content type, which forces a CORS preflight that the attacker cannot satisfy.
  5. Never performing state changes on GET; using POST (and ideally PUT/DELETE) for mutations.

How to test for it

  1. Map every state-changing action: profile changes, linking or unlinking accounts, posting content, changing email or password, deleting resources, inviting users.
  2. For each, capture the legitimate request and inspect whether it carries an anti-CSRF token, and whether the token is validated (remove it, change it, reuse an old one, and see whether the request still succeeds).
  3. Check whether the action is reachable via GET, and whether parameters such as the message body are taken from the query string.
  4. Build a cross-origin test page that issues the same request (an image tag or auto-submitting form) and load it in a browser where the victim is logged in. A positive result is the action completing without any user interaction beyond visiting the page.
  5. Verify the token is actually bound to the session: try a token from another account, and try requests with no cookies at all to confirm the action depends on the session.

Common false positives: endpoints that look state-changing but are idempotent reads; requests that fail because of SameSite cookies or Origin checks even though no token is present; actions that require a re-authentication step; and cases where the request only succeeds because the tester was already on the same origin. Confirm the effect from a genuinely different origin and with a fresh victim session.

How it is fixed

Add a per-session anti-CSRF token to every state-changing form and validate it server-side; set session cookies with SameSite=Lax or Strict; validate the Origin/Referer headers; move mutations off GET; and avoid accepting sensitive content such as message bodies from the query string, preferring POST bodies with a non-simple content type.

Hunting notes

CSRF tends to hide in older PHP endpoints, OAuth callback handlers, account-linking flows, and any action implemented as a GET with parameters in the URL. Recon signals include endpoints named after actions (post_*, update_*, delete_*, authenticate), parameters carrying content directly, and forms without hidden token fields. To get a report accepted, demonstrate the full cross-origin flow with a working PoC page or video, show the resulting state change on the victim's account, and state the preconditions (victim logged in, account linked). Chaining with another bug, as the researcher notes here, strengthens the impact case.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 6 min read.

What happened, in plain words

Zomato is a restaurant discovery and food ordering site. It lets you connect your Twitter account to your Zomato profile. The researcher, kuromatae, found a problem in the part of Zomato that handles that Twitter connection: a file called php/post_twitter_authenticate.php.

The problem is a cross-site request forgery, usually shortened to CSRF. To understand it, think about how a website knows who you are. When you log in, the site gives your browser a small piece of data called a session cookie. Your browser stores it and sends it back automatically with every request to that site. That is convenient, but it also means any page on the internet can make your browser send a request to Zomato, and your browser will attach your Zomato cookie without asking you. The receiving server sees a valid session and believes the request came from you.

A CSRF attack abuses exactly that. The attacker builds a page that quietly triggers an action on the target site while you are logged in. You only have to visit the attacker's page; you do not click anything on Zomato.

The researcher's key observation is that the page appears to perform no token check at all. A token here means a random, secret value that a legitimate form includes and the server verifies, proving the request really came from the site's own pages and not from somewhere else. Without that check, the server has nothing to distinguish a real action from a forged one.

The proof of concept is a single request:

HTTP
https://www.zomato.com/php/post_twitter_authenticate.php?type=posttweet&message=Hello Zomato Team :)

Line by line:

  • https://www.zomato.com/php/post_twitter_authenticate.php is the address of the endpoint, the script that handles the Twitter authentication step.
  • ? starts the query string, the part of a URL that carries parameters.
  • type=posttweet is one of the parameters in the URL.
  • message=Hello Zomato Team :) is the message parameter in the URL.

The proof of concept is a single request, and the report includes a video showing the CSRF working.

The report says this can lead to arbitrary writing on the Twitter account of a victim who has added Twitter to Zomato. It also notes that combined with a stored XSS, it could be very troublesome. Stored XSS means malicious script that is saved on the site and later runs in other visitors' browsers; chained with this CSRF, the effect would be considerably worse.

The report includes a video showing the CSRF working:

Poc_CSRF.mp4 From the original on HackerOne

The report was disclosed on 19 August 2017, rated low severity, and paid a bounty of 50.00 USD. It does not describe a fix.

In general, how this kind of bug works

CSRF exploits the fact that browsers attach cookies based on where a request is going, not on who started it. If a sensitive action is authorised purely by a session cookie, and the request can be expressed as a simple cross-origin request (a GET, or a form POST with ordinary content types), an attacker's page can trigger it. The server sees a valid session and performs the action.

The standard defences are:

  1. Synchroniser tokens: a random, per-session (or per-request) value embedded in forms and checked server-side.
  2. SameSite cookies, which stop the browser from sending the session cookie on cross-site requests.
  3. Origin and Referer validation for state-changing requests.
  4. Requiring a custom header or a non-simple content type, which forces a CORS preflight that the attacker cannot satisfy.
  5. Never performing state changes on GET; using POST (and ideally PUT/DELETE) for mutations.

How to test for it

  1. Map every state-changing action: profile changes, linking or unlinking accounts, posting content, changing email or password, deleting resources, inviting users.
  2. For each, capture the legitimate request and inspect whether it carries an anti-CSRF token, and whether the token is validated (remove it, change it, reuse an old one, and see whether the request still succeeds).
  3. Check whether the action is reachable via GET, and whether parameters such as the message body are taken from the query string.
  4. Build a cross-origin test page that issues the same request (an image tag or auto-submitting form) and load it in a browser where the victim is logged in. A positive result is the action completing without any user interaction beyond visiting the page.
  5. Verify the token is actually bound to the session: try a token from another account, and try requests with no cookies at all to confirm the action depends on the session.

Common false positives: endpoints that look state-changing but are idempotent reads; requests that fail because of SameSite cookies or Origin checks even though no token is present; actions that require a re-authentication step; and cases where the request only succeeds because the tester was already on the same origin. Confirm the effect from a genuinely different origin and with a fresh victim session.

How it is fixed

Add a per-session anti-CSRF token to every state-changing form and validate it server-side; set session cookies with SameSite=Lax or Strict; validate the Origin/Referer headers; move mutations off GET; and avoid accepting sensitive content such as message bodies from the query string, preferring POST bodies with a non-simple content type.

Hunting notes

CSRF tends to hide in older PHP endpoints, OAuth callback handlers, account-linking flows, and any action implemented as a GET with parameters in the URL. Recon signals include endpoints named after actions (post_*, update_*, delete_*, authenticate), parameters carrying content directly, and forms without hidden token fields. To get a report accepted, demonstrate the full cross-origin flow with a working PoC page or video, show the resulting state change on the victim's account, and state the preconditions (victim logged in, account linked). Chaining with another bug, as the researcher notes here, strengthens the impact case.

Glossary

  • CSRF (cross-site request forgery): an attack where another website makes your browser send a request to a site you are logged in to, so the action runs as you.
  • Endpoint: a specific address on a server that performs a particular action.
  • Session cookie: a small value your browser stores after login and sends automatically with requests to that site, so the site recognises you.
  • Token (anti-CSRF token): a random secret value included in a legitimate request and checked by the server, proving the request came from the site's own pages.
  • GET request: the simplest kind of web request, normally used to fetch a page; its parameters sit in the URL.
  • Query string: the part of a URL after ?, carrying parameters such as type=posttweet.
  • Parameter: a named value passed to a script, like message=....
  • Stored XSS: malicious script that is saved on a website and later runs in the browsers of people who view it.
  • SameSite cookie: a cookie setting that stops the browser sending the cookie on requests started by other sites.
  • Origin: the combination of scheme, host and port that identifies where a request comes from or goes to.
  • CORS preflight: an automatic check the browser makes before certain cross-origin requests, which an attacker cannot satisfy.
  • OAuth callback handler: the part of a site that receives the result when you authorise a third-party account connection.
  • PoC (proof of concept): a minimal demonstration that a vulnerability really works.
  • Bounty: a payment a company gives a researcher for reporting a valid security issue.

More from Eternal

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.