[www.zomato.com] Privilege Escalation - /php/restaurant_menus_handler.php
An admin-only endpoint for managing restaurant menus lacked proper access controls, allowing any logged-in user to call it. An attacker could therefore edit or remove menus from any restaurant on the platform.
Originally disclosed on HackerOne
- Triaged in 3 months
- Fixed in 3 months
- Paid in 3 months
- Disclosed after 3 months
#Introduction
In the following ██████████ the endpoint /php/restaurant_menus_handler.php was found. This endpoint is meant solely to be accessible for admins, however due to insufficient protections normal users can access this endpoint too. This results in any Zomato user being able to edit and remove menu's from any restaurant. The following actions have been found in the JS file but there might be more: menu_collected, toggle-res-menu-type, clear_menu_tool, change-menu-type.
#POC Toggle-res-menu-type will be used in the POC since it switches between text and image menu's which makes it very easy to see the change happen on the page of the restaurant. When switching to text the images of the menu will disapear (and reappear when enabled).
Go to https://www.zomato.com/████ and view the images under the menu section. After that submit the following JS code in the developers console. After this reload the page and the menu images should be gone. Do it once more and the images should reappear again.
$.ajax({url:"/php/restaurant_menus_handler.php",type:"POST",data:{action:"toggle-res-menu-type",res_id:██████}
Impact
Any user can delete and edit any menu of any restaurant. The reason is that an admin endpoint has insufficient access protection.
Context
Zomato is a restaurant discovery and food delivery site. Each restaurant page carries a menu section, which can be presented either as text or as images. The menu content is managed through a backend handler at /php/restaurant_menus_handler.php, which the report describes as an endpoint intended to be reachable only by administrators. The handler accepts a set of actions, and the report names four of them found in the associated JavaScript file: menu_collected, toggle-res-menu-type, clear_menu_tool and change-menu-type. The researcher notes that this list may not be exhaustive.
Setup
No special account, role or tooling is described. No special account, role or tooling is described; the point of the finding is that ordinary users can reach an admin-only endpoint. The proof of concept is run from the browser's developer console while viewing a restaurant page, using jQuery's $.ajax to send the request.
Finding it
While reviewing the site, the researcher identified /php/restaurant_menus_handler.php as an endpoint that is meant solely to be accessible for admins. The protection around it was insufficient, so normal users could access it too. The consequence is that any Zomato user can edit and remove menus from any restaurant.
The actions available on the handler were taken from the JavaScript file. Of those, toggle-res-menu-type was chosen for the proof of concept because it switches a menu between text and image presentation, which makes the effect very easy to observe on the restaurant page: switching to text makes the menu images disappear, and switching back makes them reappear.
Exploitation
Step 1: Observe the baseline
Go to the target restaurant page, https://www.zomato.com/████, and view the images under the menu section. This establishes what the page looks like before the request is sent.
Step 2: Send the toggle request from the console
With the restaurant page open, submit the following JavaScript in the developer console:
$.ajax({url:"/php/restaurant_menus_handler.php",type:"POST",data:{action:"toggle-res-menu-type",res_id:██████}
The request is a POST to /php/restaurant_menus_handler.php. The action parameter selects toggle-res-menu-type, and res_id identifies the restaurant whose menu is being changed.
Step 3: Reload and confirm
Reload the page. The menu images should now be gone. Repeat the same request once more and reload: the images should reappear. The toggle behaviour is what makes the change unambiguous, since the same request flips the menu between the two presentations.
Root cause
The report attributes the issue to insufficient access protection on an admin endpoint: /php/restaurant_menus_handler.php is intended to be admin-only, but normal users can reach it. The report attributes the issue to insufficient access protection on an admin endpoint. The report does not describe the specific check that was missing or how authorisation was implemented, so the exact mechanism is not stated.
Impact
Any user can delete and edit any menu of any restaurant. The stated reason is that an admin endpoint has insufficient access protection. The report does not enumerate further consequences beyond editing and removing menus, and it does not describe any restriction on which restaurants are affected.
Fix
Variants to test
The report lists four actions on the handler and demonstrates only one. The others are worth trying wherever a similar handler is found:
Hunting notes
The researcher used toggle-res-menu-type because it switches between text and image menus, making the change easy to see on the restaurant page. That visible, reversible change on a live page is what made the missing authorisation easy to demonstrate.
What happened, in plain words
Zomato is a website where you look up restaurants and order food. Every restaurant has a page, and on that page there is a menu section. The menu can be shown in two ways: as text, or as pictures of the menu. Someone at Zomato has to be able to change that menu, so there is a small program on the server that does the changing for them.
That program lives at a web address ending in /php/restaurant_menus_handler.php. The report says this address was meant to be usable only by administrators, the staff members who are allowed to manage restaurant content. The problem: the server did not actually check properly who was calling it. An ordinary logged-in user could call it too. Because the endpoint's protections were insufficient, any user could change or delete the menu of any restaurant on the site.
This kind of bug is called privilege escalation: you have the rights of a normal user, but you manage to do something that only a more powerful user (here, an admin) should be able to do. A simple comparison: a hotel gives guests a key card that opens their own room. Privilege escalation is when that same guest card also opens the staff-only storage room, because the lock on that door checks that the card is a valid card but never checks that it belongs to staff.
Context
A few words first, because the rest of the article uses them.
- Endpoint: a specific web address on a server that does a job when something contacts it. Think of it as a service counter with its own address: you walk up to that counter and ask for something.
- Handler: the program behind an endpoint. The name
restaurant_menus_handler.phpliterally says it handles restaurant menus. The.phpending tells you it is written in PHP, a programming language commonly used for websites. - API: a way for one piece of software to ask another piece of software to do something, without a human clicking buttons. When your browser sends a request to an endpoint and gets an answer back, that is an API call.
- JavaScript: the language that runs inside your browser and makes web pages interactive. A website can ship a JavaScript file, and anyone can open that file and read it.
- Action: a name that tells the handler which job to do. One endpoint can offer several jobs, and the caller picks one by sending its name.
The menu content on Zomato is managed through the handler at /php/restaurant_menus_handler.php. The report describes this endpoint as intended to be reachable only by administrators. The handler accepts a set of actions, and the report names four of them, found in the JavaScript file that belongs to the site: menu_collected, toggle-res-menu-type, clear_menu_tool and change-menu-type. The researcher notes that this list may not be complete, so there could be more actions than these four.
Setup
Nothing special is needed to reproduce this: no special account, no special role, no extra tools. The point of the finding is that ordinary users can reach an admin-only endpoint.
The proof of concept is run from the browser's developer console. That is a panel built into every browser (usually opened with F12, or with the browser's menu) where you can type commands and have them run on the page you are currently viewing. It is normally used by developers to inspect and debug pages, but anyone can open it.
The commands use $.ajax, a function provided by a JavaScript library called jQuery. $.ajax is a convenient way to send a request to a server from inside the browser.
Finding it
While reviewing the site, the researcher identified /php/restaurant_menus_handler.php as an endpoint that is meant solely to be accessible for admins. The protection around it was insufficient, so normal users could access it too. The result is that any Zomato user can edit and remove menus from any restaurant.
The names of the actions available on the handler were taken from the JavaScript file. Reading a site's JavaScript is a normal part of this kind of review: the file has to tell the browser which endpoint to call and which action name to send, so those names are visible to anyone who opens the file.
Of the actions found, toggle-res-menu-type was chosen for the proof of concept. The reason is practical: it switches a menu between text and image presentation, which makes the effect very easy to see on the restaurant page. Switching to text makes the menu images disappear, and switching back makes them reappear. A change you can see with your own eyes, and reverse, is the clearest possible evidence.
Exploitation
Step 1: Observe the baseline
Go to the target restaurant page, https://www.zomato.com/████, and look at the images under the menu section. This is the baseline: what the page looks like before anything is sent. You record it so that afterwards you can tell exactly what changed.
Step 2: Send the toggle request from the console
With the restaurant page open, submit the following JavaScript in the developer console:
$.ajax({url:"/php/restaurant_menus_handler.php",type:"POST",data:{action:"toggle-res-menu-type",res_id:██████}
Line by line, in plain words:
$.ajax(starts a request to a server. The$is jQuery's shorthand, andajaxis the function that sends requests without reloading the page.url:"/php/restaurant_menus_handler.php"says where the request goes. The address starts with/, which means "on the same site I am currently on", so the request goes to Zomato's own server.type:"POST"says which kind of request this is. A POST request is the kind used to send data and ask the server to change something, as opposed to simply fetching a page to read.data:{action:"toggle-res-menu-type",res_id:██████}is the information sent along with the request.actionpicks the job: here, toggle the menu type.res_ididentifies the restaurant whose menu is being changed, so the server knows which restaurant to act on.- The request is a POST to
/php/restaurant_menus_handler.php, with theactionparameter set totoggle-res-menu-typeandres_ididentifying the restaurant.
Step 3: Reload and confirm
Reload the page. The menu images should now be gone. Repeat the same request once more and reload: the images should reappear. The toggle behaviour is what makes the change unambiguous, because the same request flips the menu between the two presentations. You are not guessing whether something happened: the pictures are either there or not.
Root cause
The report attributes the issue to insufficient access protection on an admin endpoint. /php/restaurant_menus_handler.php is intended to be admin-only, but normal users can reach it.
In security terms, this is a missing authorisation check. Authentication is proving who you are (logging in). Authorisation is deciding what you are allowed to do once you are known. The report does not describe the specific check that was missing or how authorisation was implemented, so the exact mechanism is not stated.
Impact
Any user can delete and edit any menu of any restaurant. The stated reason is that an admin endpoint has insufficient access protection. The report does not list further consequences beyond editing and removing menus, and it does not describe any restriction on which restaurants are affected.
Fix
Variants to test
The report lists four actions on the handler and demonstrates only one. The others are worth trying wherever a similar handler is found:
Hunting notes
Same origin means the same scheme, host and port, for example all pages under www.zomato.com.
The researcher used toggle-res-menu-type because it switches between text and image menus, making the change easy to see on the restaurant page. That visible, reversible change on a live page is what made the missing authorisation easy to demonstrate.
Glossary
- Action: a name sent to an endpoint that tells it which job to perform.
- Admin: a user with extra rights, here the staff member allowed to manage restaurant menus.
- API: a way for software to ask other software to do something, here the browser asking the server to change a menu.
- Authentication: proving who you are, for example by logging in.
- Authorisation: deciding what a known user is allowed to do.
- Baseline: the state of a page before you change anything, recorded so you can compare afterwards.
- Developer console: a panel in the browser where you can type and run JavaScript on the current page.
- Endpoint: a specific web address on a server that performs a job when contacted.
- Handler: the program behind an endpoint that carries out the requested work.
- JavaScript: the programming language that runs in the browser and makes pages interactive.
- jQuery: a JavaScript library that provides shortcuts such as
$.ajaxfor sending requests. - POST: a type of request used to send data and ask the server to change something.
- Privilege escalation: doing something that should require higher rights than the ones you have.
- Recon: the exploration phase where you look at a site and its files to find things worth testing.
- Same origin: the same scheme, host and port, so the browser treats the pages as one site and shares the session with them.
- Session: the login state the browser keeps and sends with requests so the server knows who you are.