IDOR to delete images from other stores
The photo deletion endpoint accepted a photo identifier without verifying that the photo belonged to the restaurant specified in the request. An attacker could delete images from other stores by supplying a photo ID obtained from a public restaurant page.
- Triaged in under an hour
- Fixed in 42 hours
- Paid in 2 days
- Disclosed after 2 days
Summary by the researcher
When I was testing the restaurant manager specific endpoints on Zomato I discovered that pictures added were being deleted with a get request like so:
GET /php/client_manage_handler?res_id=REDACTED&photo_ids%5B%5D=r_YxNDUOTE4MTYzO&removable=1&case=remove-active-photo HTTP/1.1
Host: www.zomato.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://www.zomato.com/
X-Requested-With: XMLHttpRequest
Cookie: REDACTED
Connection: close
photo_ids seemed like a potential IDOR and I found it was possible to find the ID by visiting a restaurants front page. Since I didn't want to delete a photo in production I decided to contact someone who I knew also had access to a manager account to test my intuition. As I had no way of seeing if his private picture was deleted I waited for his response and then submitted my report with the following POC:
@Zomato team promptly verified and fixed the issue and it was a pleasure to work with them for the first time.
The report
Summary: The parameter photo_ids in below request is vulnerable to IDOR
/php/client_manage_handler?██████████&case=remove-active-photo
Description: Since there is no check for res_id or ownership I was able to delete Gerben's image by just using the photo_id from his store. This is a problem because it is a get request and I can try a bunch of ID's to randomly delete photos that don't belong to me or try to find a way to leak this ID from store page to do targeted deletes.
I believe if you try to delete multiple photos there will be more ids in the request so that would allow to expand the attack by trying a lot of ids at once.
Platform(s) Affected: [website]
Steps To Reproduce:
- Get 2 stores.
- With store 1 navigate to https://www.zomato.com/clients/manage_photos.php
- Start to delete a photo and capture the request that looks like :
GET /php/client_manage_handler?███&case=remove-active-photo HTTP/1.1
Host: www.zomato.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://www.zomato.com/
X-Requested-With: XMLHttpRequest
Cookie: _ga=GA1.2.2082511252.1535917423; _gid=GA1.2.1587734047.1535917423; PHPSESSID=4821c7caf69f3253db3be3d4c42a15b7b04d223a; fbcity=283; zl=en; fbtrack=a09417c27b7e98b4b3f2ad8357ef3903; __utmx=141625785.FQnzc5UZQdSMS6ggKyLrqQ$0:NaN; __utmxx=141625785.FQnzc5UZQdSMS6ggKyLrqQ$0:1535944804:8035200; dpr=2; cto_lwid=82057293-9985-419b-a25b-4d8b6d89951b; G_ENABLED_IDPS=google; zhli=1; squeeze=cd186e1f53eee0d94e51ef00c9d4eb25; orange=2769113; al=1; session_id=null
Connection: close
X-Forwarded-For: 127.0.0.1
4 . Save the photo_ids parameter
5 . Go to your second restaurant account and capture the same request with a different res_id and cookies
6 . Replace the photo_ids with the id from step 4 and send request.
7 . Observe the photo is deleted.
Impact
By using targeted or blind attacks it is possible to delete photos that don't belong to a restaurant because of this IDOR. My leading theory is that currently you are checking that the logged in user has permissions on the res_id in the request but not verifying that the res_id owns that photograph. There should be an additional check to ensure that the photo_id belongs to that restaurant before deleting it.
Regards, Eray
Context
Zomato is a restaurant discovery and food ordering site. Restaurants that are listed on it get a manager area where they can maintain their store profile, including the photos shown on the store's public page. One of the actions in that area is removing a photo from the store's gallery. The report concerns the endpoint that performs that removal, /php/client_manage_handler, reached from the photo management page at https://www.zomato.com/clients/manage_photos.php.
The researcher's summary describes the removal as happening through a GET request carrying the restaurant identifier and one or more photo identifiers, with a case=remove-active-photo marker telling the handler which action to take.
Setup
Two restaurant manager accounts are needed, each with access to a different store, so that a photo belonging to one store can be targeted from a session authenticated to the other. The researcher also had a contact who held a manager account, and used that account to test the idea against a real store rather than deleting a photo from production himself.
No special tooling is described beyond a browser with developer tools or an intercepting proxy capable of capturing and replaying requests. The captured requests show Firefox 61 on Windows, and the replay is done by editing the captured request and sending it again.
Finding it
While testing the restaurant manager specific endpoints, the researcher noticed that photos were being deleted with a GET request. The request looked like this:
GET /php/client_manage_handler?res_id=REDACTED&photo_ids%5B%5D=r_YxNDUOTE4MTYzO&removable=1&case=remove-active-photo HTTP/1.1
Host: www.zomato.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://www.zomato.com/
X-Requested-With: XMLHttpRequest
Cookie: REDACTED
Connection: close
The parameters are res_id (the restaurant), photo_ids[] (the photo or photos to act on, sent as an array), removable=1 and case=remove-active-photo. The photo_ids parameter looked like a potential IDOR to the researcher, because it is a direct reference to an object supplied by the client. He also found that the photo ID could be obtained by visiting a restaurant's front page, which means the identifier is not secret.
Because he did not want to delete a photo in production, he asked someone he knew who also had access to a manager account to test the intuition. He had no way of seeing whether that person's private picture had been deleted, so he waited for the response before submitting the report.
Exploitation
Step 1: obtain two stores
Two stores are required: one whose session is used to send the request, and one whose photo is the target. One store supplies the authenticated session and the other supplies the photo_ids value.
Step 2: open the photo management page
With store 1, navigate to:
https://www.zomato.com/clients/manage_photos.php
This is the manager page from which photos are managed and deleted.
Step 3: capture the delete request
Start to delete a photo and capture the request, which looks like:
GET /php/client_manage_handler?███&case=remove-active-photo HTTP/1.1
Host: www.zomato.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://www.zomato.com/
X-Requested-With: XMLHttpRequest
Cookie: _ga=GA1.2.2082511252.1535917423; _gid=GA1.2.1587734047.1535917423; PHPSESSID=[redacted]; fbcity=283; zl=en; fbtrack=[redacted]; __utmx=141625785.FQnzc5UZQdSMS6ggKyLrqQ$0:NaN; __utmxx=141625785.FQnzc5UZQdSMS6ggKyLrqQ$0:1535944804:8035200; dpr=2; cto_lwid=82057293-9985-419b-a25b-4d8b6d89951b; G_ENABLED_IDPS=google; zhli=1; squeeze=[redacted]; orange=2769113; al=1; session_id=null
Connection: close
X-Forwarded-For: [redacted]
The query string is masked in the report, but it is the same shape as the earlier request: res_id, photo_ids[], removable=1 and case=remove-active-photo. The session cookie identifies the logged-in manager of store 1.
Step 4: save the photo_ids parameter
Record the photo_ids value from the captured request. This is the identifier of a photo belonging to store 1.
Step 5: capture the same request from the second account
Go to the second restaurant account and capture the same request, this time with a different res_id and different cookies. This gives a request whose session and res_id belong to store 2.
Step 6: swap in the other photo's ID
Replace the photo_ids value in the store 2 request with the ID saved in step 4, and send the request. The request now carries store 2's session and res_id but store 1's photo identifier.
Step 7: observe the result
The photo is deleted. The handler acts on the photo named in photo_ids without confirming that the photo belongs to the restaurant in res_id.
Root cause
The researcher's leading theory is that the application checks that the logged-in user has permission on the res_id in the request, but does not verify that the res_id owns the photograph named in photo_ids. The ownership check stops at the restaurant boundary and never reaches the photo object, so any authenticated manager can name any photo ID. The report does not show the server-side code, so this is stated as a theory rather than a confirmed reading of the implementation.
Two properties of the request make the gap easier to exploit. The action is performed with GET, so it can be triggered by simply loading a URL, and the photo identifier is exposed on the restaurant's public front page, so it can be collected without any privileged access.
Impact
An authenticated restaurant manager can delete photos belonging to other restaurants. The researcher describes two modes: targeted deletes, using a photo ID harvested from a store page, and blind attacks, trying a range of IDs to delete photos at random. Because the request is a GET, it can be issued repeatedly and cheaply.
The report also notes that deleting multiple photos would put more IDs in the request, which would let an attacker try many IDs at once and widen the attack. The impact is limited to photo deletion: the report does not describe reading, modifying or taking over anything else.
Fix
The report recommends an additional check to ensure that the photo_id belongs to the restaurant before deleting it.
Variants to test
- Swap the object identifier in any manager-side action that takes an ID alongside a store or account ID, such as photo, menu, description or hours handlers. A positive result is that the action succeeds against an object belonging to a different store.
- Harvest identifiers from public store pages and feed them into authenticated requests from a second account. A positive result is that a public identifier is accepted for a write action on another store.
- Send several IDs in the array parameter at once, as the researcher suggests. A positive result is that multiple foreign objects are affected in a single request.
- Try the same request without the session cookie, or with a session for an unrelated account. A positive result is that the action still succeeds, which would show the ownership check is missing entirely rather than only incomplete.
- Check whether the action is reachable as a GET that a victim's browser could be made to issue. A positive result is that a cross-site request performs the deletion without any additional token.
Hunting notes
This kind of bug tends to hide in manager and dashboard endpoints where a request carries both a container identifier (a store, account or organisation) and a child object identifier (a photo, document or record). The container ID is usually checked against the session, which makes the endpoint look protected, while the child ID is trusted as supplied. Endpoints that perform state changes over GET are worth flagging during recon, because they are easy to replay and easy to trigger.
A useful signal is any identifier that appears both in an authenticated management request and on a public page. If the same value can be read without logging in, it can be collected at scale and used for targeted or blind attacks.
The researcher avoided deleting a photo in production himself: he asked a contact with a manager account to test the idea, and waited for the response before reporting.
What happened, in plain words
Zomato is a website where you can look up restaurants and order food. Every restaurant listed there has a public page showing its details and a gallery of photos. The restaurant owner or manager can log in to a private area and change that page, including adding and removing photos.
This report is about one button in that private area: the one that deletes a photo. The researcher found that the website did not properly check who was allowed to delete which photo. A manager logged in to their own restaurant could send the delete request with a photo identifier belonging to a completely different restaurant, and the website would delete that other restaurant's photo anyway.
This kind of mistake has a name: IDOR, short for Insecure Direct Object Reference. The idea is simple. When a website lets you act on something, it often names that thing with an identifier, a short code such as a number or a random-looking string. If the website trusts whatever identifier you send without checking that the thing belongs to you, you can swap in someone else's identifier and act on their stuff. A comparison: imagine a cloakroom where you hand in a ticket with a number and get a coat back. If the attendant never checks that the number on your ticket matches the coat you are claiming, you can read out any number and walk away with a stranger's coat. The ticket number is the "direct object reference", and the missing check is the "insecure" part.
A few everyday terms used throughout, explained once here:
- Endpoint: a specific address on a website that does one job. Think of a large office building: the street address gets you into the building, but each department has its own door. An endpoint is one of those doors, such as the one that handles photo deletion.
- Request: the message your browser sends to a website when you click something or load a page. It says what you want and carries your credentials.
- GET request: a request whose entire content is in the address (the URL). Loading a page is a GET. Because everything is in the address, a GET can be triggered just by visiting a link, which matters later.
- Cookie: a small piece of data your browser stores for a website and sends back with every request. The most important one here is the session cookie, which is how the website recognises that you are logged in. It works like a wristband at an event: show it at the door and you are let in without proving who you are again.
- Parameter: a named value attached to a request, such as
res_id=123. Parameters are how you tell an endpoint which restaurant or which photo you mean. - API: a way for one piece of software to talk to another, usually by sending requests to endpoints and getting data back. The photo deletion endpoint is effectively a small API used by the manager page.
Context
Zomato gives each listed restaurant a manager area. There, the restaurant can maintain its store profile, including the photos shown on its public page. One action in that area is removing a photo from the gallery.
The report concerns the endpoint that performs the removal, /php/client_manage_handler, which is reached from the photo management page at https://www.zomato.com/clients/manage_photos.php.
The researcher's summary describes the removal as happening through a GET request that carries the restaurant identifier and one or more photo identifiers, plus a marker case=remove-active-photo that tells the handler which action to take. In other words, the request says "for this restaurant, remove these photos".
Setup
To test the idea you need two restaurant manager accounts, each with access to a different store. That way a photo belonging to one store can be targeted from a session that is logged in to the other. The researcher also had a contact who held a manager account, and he used that account to test the idea against a real store rather than deleting a photo from production himself.
No special tooling is described beyond a browser with developer tools, or an intercepting proxy. A proxy here means a program that sits between your browser and the website, letting you pause a request, look at it, change it and send it on. The captured requests show Firefox 61 on Windows, and the replay is done by editing the captured request and sending it again.
Finding it
While testing the restaurant manager specific endpoints, the researcher noticed that photos were being deleted with a GET request. The request looked like this:
GET /php/client_manage_handler?res_id=REDACTED&photo_ids%5B%5D=r_YxNDUOTE4MTYzO&removable=1&case=remove-active-photo HTTP/1.1
Host: www.zomato.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://www.zomato.com/
X-Requested-With: XMLHttpRequest
Cookie: REDACTED
Connection: close
Line by line, in plain words:
- The first line is the request itself.
GETis the method, meaning the whole request is in the address./php/client_manage_handleris the endpoint, the door that does the work. Everything after the?is the set of parameters. res_id=REDACTEDnames the restaurant. The value is hidden here, but it is the store the request is acting on.photo_ids%5B%5D=r_YxNDUOTE4MTYzOnames the photo. The%5B%5Dis the encoded form of[], so the real parameter name isphoto_ids[]. The square brackets mean the value is a list, so the endpoint can accept several photo identifiers at once.r_YxNDUOTE4MTYzOis one photo's identifier.removable=1andcase=remove-active-photoare extra flags telling the handler which action to take.Host: www.zomato.comsays which website the request is for.User-Agentsays which browser sent it. Here it is Firefox 61 on Windows.Accept,Accept-LanguageandAccept-Encodingtell the server what kinds of response the browser can handle and in which language, and that it can compress the reply.Referersays which page the request came from.X-Requested-With: XMLHttpRequestis a hint that the request was made by the page's own JavaScript rather than by typing the address in the bar.Cookie: REDACTEDis the session cookie, the wristband that proves the sender is logged in. It is hidden here.Connection: closeasks the server to close the connection after replying.
The parameters are res_id (the restaurant), photo_ids[] (the photo or photos to act on, sent as a list), removable=1 and case=remove-active-photo. The photo_ids parameter looked like a potential IDOR to the researcher, because it is a direct reference to an object supplied by the client. He also found that the photo ID could be obtained by visiting a restaurant's front page, which means the identifier is not secret. Anyone can read it without logging in.
Because he did not want to delete a photo in production, he asked someone he knew who also had access to a manager account to test the intuition. He had no way of seeing whether that person's private picture had been deleted, so he waited for the response before submitting the report.
Exploitation
Step 1: obtain two stores
Two stores are required: one whose session is used to send the request, and one whose photo is the target. One store supplies the logged-in session and the other supplies the photo_ids value. The reason for two is that the test is about crossing a boundary: you want to prove that a session for store A can act on a photo of store B.
Step 2: open the photo management page
With store 1, navigate to:
https://www.zomato.com/clients/manage_photos.php
This is the manager page from which photos are managed and deleted. Opening it in the browser is how you reach the normal, intended flow, so you can watch what the page sends when you use it.
Step 3: capture the delete request
Start to delete a photo and capture the request, which looks like:
GET /php/client_manage_handler?███&case=remove-active-photo HTTP/1.1
Host: www.zomato.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://www.zomato.com/
X-Requested-With: XMLHttpRequest
Cookie: _ga=GA1.2.2082511252.1535917423; _gid=GA1.2.1587734047.1535917423; PHPSESSID=[redacted]; fbcity=283; zl=en; fbtrack=[redacted]; __utmx=141625785.FQnzc5UZQdSMS6ggKyLrqQ$0:NaN; __utmxx=141625785.FQnzc5UZQdSMS6ggKyLrqQ$0:1535944804:8035200; dpr=2; cto_lwid=82057293-9985-419b-a25b-4d8b6d89951b; G_ENABLED_IDPS=google; zhli=1; squeeze=[redacted]; orange=2769113; al=1; session_id=null
Connection: close
X-Forwarded-For: [redacted]
Again line by line:
- The first line is the same endpoint,
/php/client_manage_handler, with the samecase=remove-active-photomarker. The query string is masked in the report, but it is the same shape as the earlier request:res_id,photo_ids[],removable=1andcase=remove-active-photo. Host,User-Agent,Accept,Accept-Language,Accept-Encoding,RefererandX-Requested-Withdo the same jobs as before.- The
Cookieline is longer this time. It contains several cookies set by the site, including analytics cookies such as_gaand_gid, and the important one,PHPSESSID, which is the session cookie that identifies the logged-in manager of store 1. The value is hidden here. Connection: closeagain asks the server to close the connection after replying.X-Forwarded-For: [redacted]is a header that normally records the client's address as seen by a proxy. Here it carries a local address, which is what the captured request shows.
Capturing the request is the key move. Once you can see the exact message the page sends, you can copy it and change one value at a time.
Step 4: save the photo_ids parameter
Record the photo_ids value from the captured request. This is the identifier of a photo belonging to store 1. You keep it because it is the value you will later plant into the other store's request.
Step 5: capture the same request from the second account
Go to the second restaurant account and capture the same request, this time with a different res_id and different cookies. This gives a request whose session and res_id belong to store 2. The cookies differ because a different account is logged in; the res_id differs because a different restaurant is being managed.
Step 6: swap in the other photo's ID
Replace the photo_ids value in the store 2 request with the ID saved in step 4, and send the request. The request now carries store 2's session and res_id but store 1's photo identifier. If the server checks only that you are allowed to manage store 2, and never checks that the photo belongs to store 2, the deletion will go through.
Step 7: observe the result
The photo is deleted. The handler acts on the photo named in photo_ids without confirming that the photo belongs to the restaurant in res_id.
Root cause
The researcher's leading theory is that the application checks that the logged-in user has permission on the res_id in the request, but does not verify that the res_id owns the photograph named in photo_ids. The ownership check stops at the restaurant boundary and never reaches the photo object, so any logged-in manager can name any photo ID. The report does not show the server-side code, so this is stated as a theory rather than a confirmed reading of the implementation.
Two properties of the request make the gap easier to exploit. The action is performed with GET, so it can be triggered by simply loading a URL. And the photo identifier is exposed on the restaurant's public front page, so it can be collected without any privileged access.
Impact
A logged-in restaurant manager can delete photos belonging to other restaurants. The researcher describes two modes: targeted deletes, using a photo ID harvested from a store page, and blind attacks, trying a range of IDs to delete photos at random. Because the request is a GET, it can be issued repeatedly and cheaply.
The report also notes that deleting multiple photos would put more IDs in the request, which would let an attacker try many IDs at once and widen the attack. The impact is limited to photo deletion: the report does not describe reading, modifying or taking over anything else.
Fix
The report recommends an additional check to ensure that the photo_id belongs to the restaurant before deleting it.
Variants to test
- Swap the object identifier in any manager-side action that takes an ID alongside a store or account ID, such as photo, menu, description or hours handlers. A positive result is that the action succeeds against an object belonging to a different store.
- Harvest identifiers from public store pages and feed them into logged-in requests from a second account. A positive result is that a public identifier is accepted for a write action on another store.
- Send several IDs in the list parameter at once, as the researcher suggests. A positive result is that multiple foreign objects are affected in a single request.
- Try the same request without the session cookie, or with a session for an unrelated account. A positive result is that the action still succeeds, which would show the ownership check is missing entirely rather than only incomplete.
- Check whether the action is reachable as a GET that a victim's browser could be made to issue. A positive result is that a cross-site request performs the deletion without any additional token.
Hunting notes
This kind of bug tends to hide in manager and dashboard endpoints where a request carries both a container identifier (a store, account or organisation) and a child object identifier (a photo, document or record). The container ID is usually checked against the session, which makes the endpoint look protected, while the child ID is trusted as supplied. Endpoints that perform state changes over GET are worth flagging during recon, because they are easy to replay and easy to trigger.
A useful signal is any identifier that appears both in a logged-in management request and on a public page. If the same value can be read without logging in, it can be collected at scale and used for targeted or blind attacks.
The researcher avoided deleting a photo in production himself: he asked a contact with a manager account to test the idea, and waited for the response before reporting.
Glossary
- API: a way for software to talk to other software by sending requests to endpoints and receiving data back.
- Blind attack: trying many identifiers without knowing in advance which one belongs to a real target, and seeing what happens.
- Cookie: a small piece of data a website stores in your browser and receives back with each request.
- Cross-site request: a request to one website that is triggered from another website, often without the user realising.
- Endpoint: a specific address on a website that performs one particular job.
- GET request: a request whose content is entirely in the URL, so it can be triggered just by loading a link.
- Handler: the piece of server software that receives a request at an endpoint and carries out the action.
- Header: a named line in a request or response carrying extra information, such as the browser type or cookies.
- IDOR (Insecure Direct Object Reference): a flaw where a website accepts an identifier supplied by the user and acts on the object it names without checking that the object belongs to that user.
- Identifier (ID): a short code, such as a number or random string, that names a specific object such as a restaurant or a photo.
- Intercepting proxy: a tool that sits between browser and website so requests can be paused, inspected, edited and resent.
- Parameter: a named value attached to a request, such as
res_id=123, telling the endpoint what to act on. - Production: the live website with real users and real data, as opposed to a test environment.
- Recon: the exploratory phase of testing where you look around a site to find endpoints and behaviours worth examining.
- Request: the message a browser sends to a website asking it to do something or return something.
- Root cause: the underlying reason a flaw exists, as opposed to its visible symptom.
- Session cookie: the cookie that proves you are logged in, sent with each request so the site recognises you.
- State change: an action that alters stored data, such as deleting a photo, as opposed to merely reading it.
- User-Agent: a header saying which browser and operating system sent the request.
- Write action: an action that changes data on the server, such as deleting or editing something.