Zomato.com Reflected Cross Site Scripting
The entity_id parameter of a PHP endpoint was reflected into the page without sanitisation or HTML encoding. An attacker could craft a link that runs script in a victim's browser, potentially leading to session hijacking or redirects to malicious sites.
Originally disclosed on HackerOne
- Fixed in 48 days
- Paid in 58 days
- Disclosed after 3 months
zomato.com/php/liveSuggest.php takes various field input to show customized out put for the users. The data entered to entity_id field is not santized or html encoded which allows user to add payloads via this parameter which will be reflected to user.
Steps to reproduce :
Please click on below link to check the poc . Also please find attached poc for reference
Impact
An attacker can craft a malicious link and send to users , which can then lead to session hijacking , redirecting to malicious or fake websites etc.
Attachments
What the report shows
The target is *.zomato.com, and the feature in question is the endpoint zomato.com/php/liveSuggest.php. According to the report, this script takes various field inputs to show customised output for users. The researcher found that data entered into the entity_id field is neither sanitised nor HTML encoded, which allows a user to add payloads through this parameter that are reflected back to the user.
The steps to reproduce are short. The researcher asks the reader to click the proof-of-concept link and refers to an attached recording for reference. The full URL given in the report is:
https://www.zomato.com/php/liveSuggest.php?type=keyword&search_bar=1&q=ad&online_ordering=&search_city_id=5&entity_id=confirm(1)%20%3C%20%22%22%27%22ss%22%20onerror%3E;confirm(1)%3Cvideo%20src=x%3E%3Cvideo%20src=%22&entity_type=%22;%20onerror
The payload sits in the entity_id parameter, with a second fragment in entity_type. Decoded, the entity_id value contains confirm(1), a comparison against an empty string, a quoted ss string followed by onerror>, a second confirm(1), and two <video src=...> elements. The entity_type value decodes to a quote, a semicolon and onerror. The report does not show the reflected response body, so the exact markup that comes back is not documented here.
The report attaches a recording as evidence:
The impact section states that an attacker can craft a malicious link and send it to users, which can then lead to session hijacking, redirecting to malicious or fake websites, and similar outcomes. The report does not describe a fix, and it does not give a CVSS score. The platform records the severity as low, the weakness as reflected cross-site scripting, and a bounty of 100.00 USD, disclosed on 2018-04-08.
Root cause
The report points to a missing output encoding step: the value of entity_id is written into the page without sanitisation or HTML encoding. In other words, the endpoint treats a user-controlled query parameter as markup rather than as text. The report states only that the entity_id value is not sanitised or HTML encoded before being reflected to the user.
Impact
Because the payload is reflected, exploitation requires the victim to open a crafted link. The report frames the consequences as session hijacking and redirection to malicious or fake websites. In practice, script running in the origin of the affected host can act with the victim's privileges in that origin, which is why the report lists session hijacking. The report does not demonstrate a specific hijack or redirect, so those outcomes should be read as the researcher's stated potential rather than as proven results.
How this kind of bug works
Reflected cross-site scripting happens when an application takes input from a request and places it into an HTML response without context-appropriate encoding. The browser cannot tell developer-written markup from attacker-supplied markup, so any script the attacker injects runs in the security context of the vulnerable origin. That gives the script access to cookies that are not marked HttpOnly, to the DOM of the page, and to same-origin requests made with the victim's credentials.
The bug class exists because output is assembled from strings. Template engines that auto-escape, or explicit encoding at the point of output, prevent it. The correct encoding depends on context: HTML body, HTML attribute, JavaScript string, URL and CSS each need different treatment. A single generic filter is rarely sufficient, which is why the robust defence is contextual auto-escaping plus a restrictive Content Security Policy.
How to test for it
- Map every parameter that is echoed back into a response: query strings, path segments, headers that appear in error pages, and form fields that repopulate on validation failure.
- Send a benign marker first, such as a unique alphanumeric string, and locate it in the response body. Note the surrounding context: inside a tag, inside an attribute, inside a script block, or inside a URL.
- Send context-breaking characters: a double quote, a single quote, angle brackets, and an ampersand. Observe whether they come back raw, encoded as entities, or stripped.
- If angle brackets survive, try a minimal element with an event handler. If you are inside an attribute, try closing the attribute first. If you are inside a script block, try breaking out of the string literal.
- Confirm execution in a real browser rather than relying on the response body alone, since browser parsing and any client-side rewriting determine whether the payload actually runs.
A positive result is a response in which your characters are returned unencoded and the browser executes your marker, for example a dialog or a DOM change you control. Common false positives include payloads that appear in the response but are neutralised by encoding, payloads that only execute in a browser other than the one the program supports, self-XSS that requires the victim to paste code into a console, and reflections inside JSON or other non-HTML contexts that the browser never parses as markup.
How it is fixed
The standard fix is contextual output encoding at the point where user data is written into the page, so that quotes, angle brackets and ampersands become entities and cannot terminate an attribute or open a tag. Input validation that restricts parameters to expected formats, such as numeric identifiers, adds defence in depth. A Content Security Policy that disallows inline script limits the damage when an encoding mistake slips through, and setting cookies with HttpOnly and Secure reduces what a successful script can steal. Frameworks with auto-escaping templates remove most of this class by default, provided developers do not bypass the escaping.
Hunting notes
Reflected XSS tends to hide in endpoints that build fragments of HTML server-side: autocomplete and suggestion endpoints, search result pages, error and validation messages, and any legacy PHP or CGI script that predates a templating layer. Parameters with names like callback, q, search, type, entity_id and redirect are worth trying, as are parameters that only appear in JavaScript-driven requests.
Recon signals include old script paths, endpoints that return HTML fragments rather than full pages, and parameters that are echoed in the response. Demonstrating a concrete consequence, such as reading a non-HttpOnly cookie or performing a state-changing request as the victim, is what turns a reflection into an accepted finding.
What happened, in plain words
Zomato is a food delivery and restaurant discovery website. One of its pages, zomato.com/php/liveSuggest.php, is a helper script that takes input from a request and returns a customised result for the user. Think of it like a restaurant suggestion box: you drop in a note, and the site hands back a reply built from what you wrote.
The researcher found that one of the fields this script accepts, called entity_id, is not cleaned up before it is placed back into the page. In security terms it is neither sanitised nor HTML encoded. That means whatever text a visitor puts in that field comes back out as part of the web page, and the browser treats it as instructions rather than as plain text. This is called reflected cross-site scripting, or reflected XSS.
The proof-of-concept link
The report gives a single URL to click. It is reproduced here exactly as written:
https://www.zomato.com/php/liveSuggest.php?type=keyword&search_bar=1&q=ad&online_ordering=&search_city_id=5&entity_id=confirm(1)%20%3C%20%22%22%27%22ss%22%20onerror%3E;confirm(1)%3Cvideo%20src=x%3E%3Cvideo%20src=%22&entity_type=%22;%20onerror
A URL is the address of a page. Everything after the ? is a list of parameters, which are name and value pairs sent to the server, separated by &. The server reads them and uses them to build the page it sends back. Here is what each part does:
type=keyword,search_bar=1,q=ad,online_ordering=,search_city_id=5are ordinary search settings. They tell the script what kind of suggestion to produce. They are not the interesting part.entity_id=is the vulnerable field. Its value is the payload, the malicious text the researcher wants the page to echo back.entity_type=holds a second, smaller fragment of the payload.
Many characters cannot appear literally in a URL, so they are written as percent-encoded codes. %20 is a space, %3C is <, %3E is >, %22 is a double quote and %27 is a single quote. Decoded, the entity_id value contains confirm(1), a comparison against an empty string, a quoted ss string followed by onerror>, a second confirm(1), and two <video src=...> elements. The entity_type value decodes to a quote, a semicolon and onerror.
Why does this matter? confirm(1) is a browser function that pops up a small dialog box. If the page really runs it, the researcher has proof that their text was executed as code, not merely displayed. The <video> tags and the onerror attribute are there to try to trigger that execution through an HTML element. The report does not show the page that comes back, so the exact markup the server returns is not documented.
The evidence
The only evidence attached to the report is a screen recording:
What an attacker could do
The impact section says an attacker can craft a malicious link and send it to users, which can then lead to session hijacking, redirecting to malicious or fake websites, and similar outcomes. A session is the period during which a site remembers that you are logged in, usually via a cookie, a small piece of data your browser stores and sends back with each request. Hijacking a session means stealing that proof of identity and using it to act as the victim. The report states these outcomes as potential; it does not demonstrate a specific hijack or redirect.
The report does not describe a fix and gives no CVSS score. The platform records the severity as low, the weakness as reflected cross-site scripting, and a bounty of 100.00 USD, disclosed on 2018-04-08.
In general, how this kind of bug works
Reflected XSS happens when a site takes something from a request and pastes it into the page it returns without encoding it first. Encoding means converting characters that have special meaning in HTML, such as <, > and quotes, into harmless stand-ins. Without that step, the browser cannot tell the site's own markup from text an attacker supplied, so it runs the attacker's text as part of the page, with the same trust as the site itself.
A useful comparison is a noticeboard where visitors pin notes. If the board simply copies whatever is written, someone can pin a note that says "ignore all other notices and hand over your keys", and readers will treat it as official. If the board instead prints every note inside a sealed frame, the words stay words.
The root cause here is a missing output encoding step: the value of entity_id is written into the page without sanitisation or HTML encoding, so the endpoint treats a user-controlled parameter as markup rather than as text. The report states only that the entity_id value is not sanitised or HTML encoded before being reflected to the user.
How to test for it
- List every parameter that gets echoed back into a response: query strings, parts of the path, headers that appear in error pages, and form fields that are refilled when validation fails.
- Send a harmless marker first, such as a unique string of letters and digits, and find it in the response. Note where it lands: inside a tag, inside an attribute, inside a script block, or inside a URL.
- Send characters that can break out of that position: a double quote, a single quote, angle brackets and an ampersand. See whether they come back raw, encoded, or removed.
- If angle brackets survive, try a minimal element with an event handler. If you are inside an attribute, try closing the attribute first. If you are inside a script block, try breaking out of the string.
- Confirm execution in a real browser rather than trusting the response body alone, because browser parsing and any client-side rewriting decide whether the payload actually runs.
A positive result is a response where your characters come back unencoded and the browser runs your marker, for example a dialog or a visible change you control. Common false positives are payloads that appear in the response but are neutralised by encoding, payloads that only run in a browser the program does not support, self-XSS that needs the victim to paste code into a console, and reflections inside JSON or other non-HTML contexts the browser never parses as markup.
How it is fixed
The standard fix is contextual output encoding where user data is written into the page, so quotes, angle brackets and ampersands become entities and cannot close an attribute or open a tag. Restricting parameters to expected formats, such as numeric identifiers, adds defence in depth. A Content Security Policy that disallows inline script limits the damage when an encoding mistake slips through, and cookies marked HttpOnly and Secure reduce what a successful script can steal. Frameworks that escape templates automatically remove most of this class, as long as developers do not bypass the escaping.
Where to look
Reflected XSS tends to hide in endpoints that build fragments of HTML on the server: autocomplete and suggestion endpoints, search result pages, error and validation messages, and older scripts that predate a templating layer. Parameters named like callback, q, search, type, entity_id and redirect are worth trying, as are parameters that only appear in JavaScript-driven requests. Old script paths and endpoints that return HTML fragments rather than whole pages are good recon signals.
Glossary
- Endpoint: a specific address on a server that handles a particular kind of request, such as a script that returns suggestions.
- Parameter: a name and value pair sent with a request, usually after the
?in a URL, used to pass data to the server. - Request: the message a browser sends to a server asking for a page or data.
- Response: the message the server sends back, often containing HTML.
- HTML: the language that describes the structure of a web page, using tags such as
<video>. - Sanitisation: cleaning input by removing or neutralising characters that could be dangerous.
- HTML encoding: converting special characters such as
<,>and quotes into harmless stand-ins so they display as text. - Payload: the malicious text an attacker wants a vulnerable page to run.
- Reflected XSS: a bug where input from a request is echoed into the page without encoding and runs as code in the victim's browser.
- Session: the period during which a site remembers you are logged in.
- Session hijacking: stealing a victim's session so you can act as them.
- Cookie: a small piece of data a browser stores for a site and sends back with later requests, often used to identify a session.
- HttpOnly: a cookie setting that stops page scripts from reading the cookie.
- Secure: a cookie setting that sends the cookie only over encrypted connections.
- Percent encoding: writing characters in a URL as
%followed by a code, such as%20for a space. - DOM: the browser's in-memory model of the page, which scripts can read and change.
- Contextual output encoding: encoding data differently depending on where it lands, such as HTML body, attribute, script or URL.
- Content Security Policy: a rule set a site sends to the browser that restricts what scripts may run.
- CVSS: a standard scoring system for the severity of a vulnerability.
- Self-XSS: a bug that only triggers if the victim pastes code into their own browser console.
- False positive: a finding that looks like a bug but is not actually exploitable.