Javascript Scheme Hrefs in Child Frames Execute in Parent Origin on Download
A page containing a javascript: link, when embedded in a cross-origin iframe, could have that link's script run in the parent page's origin if the user long-pressed the link and chose download. An attacker could therefore run script in the embedding site's context, though it required a deliberate user action.
Originally disclosed on Mozilla
- Fixed in 20 months
- Paid in 20 months
- Disclosed after 20 months
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
Steps to reproduce:
Embed a page similar to the following in an iframe with differing origins.
<!DOCTYPE html>
<html>
<body>
<a href="javascript:alert(document.body.innerHTML)">Javascript URI</a>
</body>
</html>
If this link is long pressed and you press download it will execute the script in the context of the parent page and origin.
Actual results:
Javascript will run in the context of the parent origin / page.
Expected results:
Should either do nothing or run in the context of the child iframe.
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 download handling of a javascript: URL in a child frame did not re-check the frame's origin and executed the script in the parent's context.
Impact
Script could run in the embedding page's origin, but only after the user long-pressed the link and chose download, and the report shows only an alert as proof.
What the attacker needed
Attacker page embedded cross-origin in a frame; victim long-presses the link; victim chooses download
How it was found
- Embed a page with a javascript: link in an iframe from a different origin.
- Long-press the link and choose download.
- The script runs in the parent page's origin.
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 javascript: link is a link whose address is a small script instead of a web page. Normally a page inside a frame is kept separate from the page around it, so script from one should not run as the other. Here, choosing 'download' on such a link made the script run as the outer page, which breaks that separation.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.