Skip to content
XSS Disclosed report Beginner

XSS in instacart.com/store/partner_recipe

karel_origin Follow

Originally disclosed on HackerOne

Bounty$100 Medium View original
  • Fixed in 3 days
  • Paid in 3 days
  • Disclosed after 4 months

Summary by the researcher

The recipe_url parameter would reflect anything inside an href attribute, you only had to inject javascript:alert(1) and had to click on the link to execute the payload.

I was able to bypass this later by using javascript:alert(1)//https://example.com, Thanks to instacart for the quick fix and bounty. :)

The report

Please open the following url

https://www.instacart.com/store/partner_recipe?recipe_url=javascript:alert(1)&partner_name=&ingredients%5B%5D=apples&ingredients%5B%5D=butter&ingredients%5B%5D=Splenda+Brown+Sugar+Blend&ingredients%5B%5D=cinnamon&ingredients%5B%5D=nutmeg&title=Barb%27s+Fried+Apples+-Diabetic-Low+Fat&description=&image_url=%2Fassets%2Fimg%2Fno-recipe-image.jpg

and click on the "Barb's Fried Apples -Diabetic-Low Fat" image to trigger the payload.

The affected parameter is recipe_url

The original report as published on HackerOne, by karel_origin. 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 Instacart's partner recipe page at instacart.com/store/partner_recipe, a feature that renders a recipe supplied through URL parameters, including a title, a list of ingredients and an image. The researcher found that the recipe_url parameter was reflected into an href attribute without adequate restriction, so a javascript: URL placed there would run when the rendered link was clicked.

The reproduction is a single GET request to the partner recipe endpoint with the payload in recipe_url:

HTTP
https://www.instacart.com/store/partner_recipe?recipe_url=javascript:alert(1)&partner_name=&ingredients%5B%5D=apples&ingredients%5B%5D=butter&ingredients%5B%5D=Splenda+Brown+Sugar+Blend&ingredients%5B%5D=cinnamon&ingredients%5B%5D=nutmeg&title=Barb%27s+Fried+Apples+-Diabetic-Low+Fat&description=&image_url=%2Fassets%2Fimg%2Fno-recipe-image.jpg

After loading that URL, the researcher clicked the "Barb's Fried Apples -Diabetic-Low Fat" image, which is the link built from recipe_url, and the payload executed. The affected parameter is recipe_url.

The researcher notes that the page reflected anything placed inside the href attribute, so the only requirement was to inject javascript:alert(1) and get a click on the link. A later attempt used a variant that appends a URL after the payload:

Text
javascript:alert(1)//https://example.com

The report does not describe the filter or explain why this variant worked. The report does not describe the filter or explain the bypass in more detail.

The researcher thanks Instacart for the quick fix. The report is rated medium severity, with a bounty of 100.00 USD and disclosure on 2017-05-11.

Root cause

The parameter was reflected into an href attribute, so a javascript: value became an executable link. Escaping for HTML context prevents breaking out of the attribute, but it does not stop a value such as javascript:alert(1) from being a valid, executable URL.

Impact

The report demonstrates script execution in the origin of the partner recipe page after a user clicks the crafted link. The report demonstrates script execution in the page's origin after a user clicks the crafted link.

How this kind of bug works

URL-bearing attributes are a common sink. When an application takes a parameter and places it into href, src, action or similar attributes, the browser interprets the value as a URL, not as text. HTML-encoding the value stops attribute breakout but leaves the scheme intact, so javascript:, data: and, in some contexts, vbscript: values still execute when the link is followed or the resource is loaded.

The bug class is therefore about scheme and destination control, not about character escaping. The fix has to constrain what kind of URL is allowed, not just how it is encoded.

How to test for it

  1. Map every parameter that ends up in a link, image source, form action or redirect. Recipe, share, invite, avatar, return-URL and partner-integration features are typical.
  2. Send a benign marker first, such as a unique string, and confirm where it lands in the response. Check whether it sits inside an attribute and whether it is HTML-encoded.
  3. Replace the marker with a javascript: payload and load the page. A positive result is a link whose target begins with javascript: and which executes when clicked. For src sinks, execution may happen on load without a click.
  4. If the simple payload is blocked, test variants that keep a URL-like shape, for example appending a comment and a real URL, using different casing, or adding whitespace or control characters before the scheme. Only test payloads you understand and only on programs that permit it.
  5. Confirm execution in a real browser rather than relying on the response body alone.

Common false positives: the value is reflected but HTML-encoded and the scheme is rejected server-side; the link is rendered but the application rewrites the destination to a fixed host; the payload only appears in a context where the browser does not treat it as a URL; or a content security policy blocks inline script, in which case the finding may still be valid but the impact is reduced.

How it is fixed

  • Validate the scheme server-side and allow only http and https for user-supplied links.
  • Where possible, do not accept arbitrary URLs at all: map identifiers to known destinations on the server.
  • HTML-encode the value for the attribute context as defence in depth, understanding that this alone does not stop javascript: URLs.
  • Apply a content security policy that restricts script sources, as a secondary control.

Hunting notes

These bugs cluster in features that build links from request data: partner and affiliate pages, recipe and product imports, share buttons, OAuth and login return URLs, password reset links, and anything that renders a user-supplied image or avatar. Recon signals include parameters named url, link, redirect, return, next, image_url or recipe_url, and pages that echo request parameters into anchors.

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. 5 min read.

What happened, in plain words

Instacart is a grocery delivery site. Its partner recipe page at instacart.com/store/partner_recipe builds a recipe card from information supplied in the web address itself: a title, a list of ingredients and an image. A researcher found that one of those pieces of information, the recipe_url parameter, was placed straight into a link on the page without checking what kind of link it was. That let him make the link run JavaScript code when a visitor clicked it.

A quick word on the pieces involved. A URL is a web address. The part after the ? is the query string, a list of name=value pairs that the page reads to decide what to show. A parameter is one of those pairs. A GET request is simply your browser asking a server for a page by visiting an address. JavaScript is the programming language browsers run; alert(1) is the classic harmless test that pops up a box saying "1". A link in HTML is an <a> tag with an href attribute holding the destination address. Normally that address starts with https://, but browsers also accept a javascript: address, which means "run this code instead of going anywhere". That is the trick at the heart of this report.

The report

The researcher opened a single address in the browser. Everything the page needed was in the query string:

HTTP
https://www.instacart.com/store/partner_recipe?recipe_url=javascript:alert(1)&partner_name=&ingredients%5B%5D=apples&ingredients%5B%5D=butter&ingredients%5B%5D=Splenda+Brown+Sugar+Blend&ingredients%5B%5D=cinnamon&ingredients%5B%5D=nutmeg&title=Barb%27s+Fried+Apples+-Diabetic-Low+Fat&description=&image_url=%2Fassets%2Fimg%2Fno-recipe-image.jpg

Line by line, the parts that matter:

  • recipe_url=javascript:alert(1) is the payload. Instead of a normal web address, the value is a javascript: address that runs alert(1).
  • ingredients%5B%5D=apples and the following ingredients entries fill the ingredient list. %5B%5D is the encoded form of [], so the parameter name is really ingredients[], a list.
  • title=Barb%27s+Fried+Apples+-Diabetic-Low+Fat sets the recipe title. %27 is an encoded apostrophe and + stands for a space.
  • image_url=%2Fassets%2Fimg%2Fno-recipe-image.jpg is the picture to show; %2F is an encoded slash.
  • partner_name= and description= are present but empty.

After loading that address, the researcher clicked the "Barb's Fried Apples -Diabetic-Low Fat" image. That image is wrapped in the link built from recipe_url, so clicking it followed the javascript: address and the code ran. The affected parameter is recipe_url.

Why does this matter? The page took text from the visitor and trusted it as a link destination. Anyone could craft such an address and send it to someone; the victim only has to open it and click the recipe image. The code then runs in the page's origin, as if it came from Instacart itself.

The researcher later used a variant of the payload. He appended a real-looking address after the payload:

Text
javascript:alert(1)//https://example.com

In JavaScript, // starts a comment, so everything after it is ignored when the code runs. The report does not describe the filter or explain the bypass further.

The researcher thanks Instacart for the quick fix. The report is rated medium severity, with a bounty of 100.00 USD and disclosure on 2017-05-11.

In general, how this kind of bug works

This is cross-site scripting, or XSS: getting your own code to run in someone else's browser on a site you do not control. A sink is the place in the page where untrusted input ends up. Attributes that hold addresses, such as href (links), src (images and scripts) and action (forms), are common sinks. When a value lands in href, the browser reads it as an address, not as plain text.

Here is the key point. Making text safe for HTML, called HTML encoding (turning < into &lt; and so on), stops an attacker from breaking out of the attribute. It does not stop javascript:alert(1), because that is a perfectly valid address as far as the browser is concerned. The fix therefore has to control which kinds of address are allowed, not just how characters are written.

To look for this yourself:

  1. Find parameters that end up in links, image sources, form actions or redirects. Recipe, share, invite, avatar, return-URL and partner pages are typical.
  2. Send a harmless unique marker first and see where it appears in the page. Is it inside an attribute? Is it encoded?
  3. Replace the marker with a javascript: payload and load the page. A link whose destination starts with javascript: and runs code when clicked is a hit. For image sources, code may run on load without any click.
  4. If the simple payload is blocked, try variants that keep a URL-like shape, such as the comment trick above. Only test on programs that allow it.
  5. Confirm in a real browser, not just by reading the page source.

Watch for false positives: the value may be reflected but encoded and the scheme rejected by the server; the site may rewrite the destination to a fixed host; or a content security policy (a browser rule limiting where scripts may come from) may block the code, which lowers the impact.

The fix is to check the scheme on the server and allow only http and https for user-supplied links. Better still, do not accept arbitrary addresses: store an identifier and map it to a known destination. HTML encoding and a content security policy are useful extra layers, but neither replaces the scheme check.

Glossary

  • URL: a web address, such as https://example.com/page.
  • Query string: the name=value pairs after the ? in a URL.
  • Parameter: one name=value pair in a query string.
  • GET request: a browser asking a server for a page by visiting an address.
  • JavaScript: the programming language browsers run.
  • alert(1): a JavaScript command that shows a pop-up box, used as a harmless test.
  • HTML: the markup language that describes a web page.
  • Attribute: a setting inside an HTML tag, such as href on a link.
  • href: the attribute holding a link's destination address.
  • src: the attribute holding the address of an image or script to load.
  • javascript: URL: an address that tells the browser to run code instead of navigating.
  • Payload: the crafted input that triggers the bug.
  • Cross-site scripting (XSS): running your own code in another user's browser on a site you do not control.
  • Sink: the place in a page where untrusted input ends up.
  • HTML encoding: rewriting characters such as < so they display as text rather than markup.
  • Filter: a check that tries to block dangerous input.
  • Bypass: getting past a filter.
  • Comment (//): in JavaScript, text after // is ignored when the code runs.
  • Content security policy: a browser rule limiting which scripts a page may run.
  • Session: the logged-in state a site keeps for you between requests.
  • Severity: a rating of how serious a bug is.
  • Bounty: money paid to a researcher for a valid report.

More by karel_origin

View all

4 more disclosed reports, best first.

More from Instacart

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.