Improper parsing of QR codes in address bar leads to XSS
A QR code generator website allowed users to create QR codes containing javascript: URIs. When a victim scanned such a QR code with Firefox, the browser executed the JavaScript in the context of the QR code generator's domain, allowing the attacker to steal cookies and data from that domain.
- Fixed in 3 months
- Paid in 4 months
- Disclosed after 3 months
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
Steps to reproduce:
1. Goto URL https://www.the-qrcode-generator.com/
2. Click on tab `free text`
3. Paste the following exploit to generate QR code
---------------------------------------------------------
javascript:fetch('https://www.google.com/').then(res=>res.text()).then(data=>alert(data));
---------------------------------------------------------
4. Open firefox and scan the QR code generated by the website
5. You will triage javascript code execution in reference to google.com
Video POC: https://drive.google.com/file/d/1G71vasB7MYSUClXDmsx5gV_dYFnLn1Mt/view
Actual results:
This results in stealing users current cookies and data on the current domain by just scanning the QR
Expected results:
javascript URI's should not be allowed, or some kind of warning message should be displayed.
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 QR code generator did not validate or sanitise the input before encoding it into a QR code, and Firefox executed the javascript: URI when scanned.
What the attacker needed
Victim uses Firefox; victim scans attacker's QR code
How it was found
- Go to the QR code generator website.
- Select the free text tab.
- Enter a javascript: URI as the text to encode.
- Generate the QR code.
- Scan the QR code using Firefox.
- Observe JavaScript execution in the context of the website's domain.
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 QR code is just a picture that stores text, often a web address. Some browsers, like Firefox, will run text that starts with 'javascript:' as code instead of treating it as a harmless link. The website let anyone make a QR code with such code, so scanning it ran the attacker's code on the website's own domain, giving access to the victim's session there.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.