Scan QR Code and Got Hacked (CVE-2021–43530 : UXSS on Firefox Android Version)
Firefox for Android's QR code scanner did not validate URLs, allowing an attacker to encode a javascript: URL that executes in the context of the scanned page. This could let an attacker steal sessions from any open web page.
Bug Bounty
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Mozilla Firefox for Android ships a QR code scanner so that users can open a web page without typing its address into the address bar. The researcher, hafiizh, found that this scanner did not validate the URL it received, which allowed a QR code carrying a javascript: URL to run script in the browser. The issue was tracked as CVE-2021-43530 and described as a Universal Cross-site Scripting (UXSS) flaw on the Android version of Firefox, reported against version 93.2.0.
A QR code is a two-dimensional matrix barcode invented in 1994 by the Japanese automotive company Denso Wave. In practice QR codes often hold a locator, identifier or tracker that points to a website or application, and they use four standardised encoding modes (numeric, alphanumeric, byte/binary and kanji) to store data efficiently.

Setup
The write-up describes no accounts, roles or tooling beyond the Firefox for Android application, version 93.2.0. The precondition is simply that the victim scans an attacker-supplied QR code with the browser's built-in scanner.
Finding it
The researcher starts from the difference between ordinary XSS and UXSS. Ordinary XSS needs a vulnerable page: the attacker gets access to the session on that page only, because the browser's security features keep other origins out of reach. UXSS instead abuses a client-side flaw in the browser or a browser extension to create the XSS condition itself. When such a flaw is exploited, the browser's functionality is changed and its security mechanisms may be bypassed or deactivated, so the attacker can reach any session belonging to pages that are open or cached at the moment of the attack, including sessions on safe, well-written sites. In short, UXSS needs no weak page to trigger.
The Firefox for Android QR scanner takes a URL from an untrusted source and hands it to the browser. The browser did not validate the URL address coming from the scan, which made it usable to steal sessions from the page being opened.
Exploitation
Step 1: Build a QR code with a javascript: URL
The attacker generates a QR code whose content is a URL with the javascript: scheme prefix instead of the usual http: or https:. The report does not include the exact payload string.
Step 2: Deliver the code to the victim
The QR code is given to the victim, who scans it with the Firefox for Android scanner.
Step 3: Script runs in the browser
Because the URL is not validated, the javascript: content is executed by the browser. The researcher demonstrates this in a proof-of-concept video.
Root cause
The report frames the root cause as the browser failing to validate the URL address from the QR scan. The report frames this as the browser failing to validate the URL address. Why the existing defences did not stop it is not discussed in the report.
Impact
By exploiting the flaw an attacker can steal sessions from the web page that is being opened. The attack requires the victim to scan an attacker-controlled QR code with the affected Firefox for Android version.
Fix
The report gives no detail on the code change. Its timeline records the report on 2021-10-20, the fix on 2021-10-25 and the award on 2021-10-26 (USD 2000).
Variants to test
- Other URL schemes in the scanner: try
data:,file:andblob:payloads in a QR code. A positive result is the browser rendering or executing the content instead of rejecting the scan. - Other entry points that accept URLs from untrusted sources, such as deep links, intents, clipboard paste or shared text. A positive result is a
javascript:ordata:URL being executed rather than navigated to. - Other mobile browsers with built-in QR scanners: feed the same
javascript:QR code. A positive result is script execution in the context of the scanned page.
What happened, in plain words
Mozilla Firefox for Android has a built-in QR code scanner. You point your phone's camera at a square barcode, and the browser opens the web page the code points to, so you never have to type an address. The researcher, hafiizh, found that this scanner did not check what kind of address the QR code contained. A QR code can hold a javascript: address instead of the usual http: or https: one, and Firefox would execute that JavaScript. The problem was tracked as CVE-2021-43530 and described as a Universal Cross-site Scripting (UXSS) flaw on the Android version of Firefox, reported against version 93.2.0. Mozilla paid a USD 2000 bounty, and the report was published on 19 October 2022.
This article walks through the same material, but from zero: what a QR code is, what XSS and UXSS mean, how the attack works, why it works and what damage it can do. No prior security knowledge is assumed.
I. QR Code
A QR code (short for quick response code) is a type of matrix barcode, also called a two-dimensional barcode. It was invented in 1994 by the Japanese automotive company Denso Wave. A barcode is a machine-readable optical label that can contain information about the item it is attached to. Think of the barcode on a cereal box: a scanner reads it and the till knows which product it is. A QR code is a two-dimensional barcode that a camera can read.
In practice, QR codes often contain data for a locator, identifier or tracker that points to a website or application. A restaurant menu QR code, for example, is just a web address written in a form a camera can read. QR codes use four standardised encoding modes (numeric, alphanumeric, byte/binary and kanji) to store data efficiently, and extensions may also be used.

The image above is a QR code, the kind of square pattern a phone camera reads.
Why does this matter for security? Because a QR code is just a container for text. Whatever text is inside it, the phone will act on. If the text is a normal web address, the browser opens a page. If the text is something else, the question becomes: does the app check before acting? That question is the heart of this bug.
II. Universal Cross-site Scripting (UXSS) Vulnerability
Before UXSS, you need to know what ordinary XSS is.
Cross-site scripting (XSS) is a class of attack against websites and web applications that are vulnerable because of insufficient client-side or server-side code development. In plain words: a website takes something a user supplied (a comment, a search term, a profile name) and puts it into a page without cleaning it up, so an attacker can slip code into the page. When another user views that page, the attacker's code runs in their browser, inside that website.
The susceptible web page is the fundamental condition for these attacks, and their effect always circles around the user session on the vulnerable web page itself. A session is the browser's logged-in state with a site: after you log in, the site gives your browser a small piece of data (often a cookie) so it recognises you on the next request. If a user visits an XSS-vulnerable website while using a web-based CRM application, the attacker will only have access to the compromised session and will not be able to access the CRM's session. This behaviour is caused by security features built into browsers. Browsers keep websites apart on purpose, so code running on one site cannot read data from another.
UXSS keeps the basic XSS characteristics: exploit a vulnerability, execute malicious code. Nevertheless, there is a significant difference. Unlike traditional XSS attacks, UXSS is a sort of attack that uses client-side vulnerabilities in browsers or browser extensions to produce an XSS situation and execute malicious code. When such flaws are discovered and exploited, the browser's functionality is changed, and its security mechanisms may be circumvented or deactivated.
As a result, the attacker may get access to any session belonging to web pages presently opened (or cached) by the browser at the moment the attack is launched, rather than simply a compromised session on a vulnerable web page. Simply said, UXSS does not require a weak web page to activate and may breach web sessions belonging to safe, well-written websites, creating a vulnerability where none exists.
An everyday comparison: ordinary XSS is like finding one door in one house that does not lock. UXSS is like finding a flaw in the master key system itself, so every house on the street becomes reachable even though every one of them locked its door properly.
III. UXSS On Mozilla Firefox (Android Version) Version 93.2.0
In the Firefox browser application (Android version) there is a QR code scan feature to open web pages without typing the URL location in the address bar. This makes it easier for users to open web pages. But in addition to making it easier for users to open web pages, there is a UXSS vulnerability where the web browser (Firefox) does not validate the URL address. It can be used by attackers to steal sessions from the web page that is being opened.
Validation here means checking the input before acting on it. A web address normally starts with a scheme, the part before the colon: http: or https: for web pages. The scheme tells the browser what kind of thing the address is and how to handle it. Some schemes are not web pages at all. The javascript: scheme means "run the text that follows as code". That is a legitimate browser feature used by websites, but it is dangerous when the text comes from an untrusted source, because it means the browser will execute whatever the source says.
Attackers exploit this vulnerability by generating a QR code with the URL address prefix javascript: (normally using http: or https:). After the QR code is formed, the QR code is given to the victim to be scanned and the JavaScript is executed.
So the attack has three steps:
- Build the QR code. The attacker creates a QR code whose content is a URL with the
javascript:scheme prefix instead of the usualhttp:orhttps:. The report does not include the exact payload string. - Deliver it. The QR code is given to the victim, who scans it with the Firefox for Android scanner. The QR code is given to the victim, who scans it with the Firefox for Android scanner.
- The script runs. Because the URL is not validated, the
javascript:content is executed by the browser.
Why does the attacker need the victim to scan? Because the code runs in the victim's browser, with the victim's logged-in sessions. The attacker cannot run it remotely; the victim has to bring the code into their own browser.
The researcher demonstrates the whole thing in a proof-of-concept video.
The video is the proof of concept for CVE-2021-43530, showing the UXSS on Firefox for Android.
Root cause
The report frames the root cause as the browser failing to validate the URL address from the QR scan. The report frames this as the browser failing to validate the URL address. Why the existing defences did not stop it is not discussed in the report.
In everyday terms: the scanner is a door that takes whatever is written on the envelope and hands it straight to the browser, without asking whether the envelope contains a web address or an instruction to run code.
Impact
By exploiting the flaw an attacker can steal sessions from the web page that is being opened, and, as a UXSS issue, potentially reach sessions of other pages open or cached in the browser at the time of the attack. The attack requires the victim to scan an attacker-controlled QR code with the affected Firefox for Android version.
What does "steal a session" mean in practice? If the attacker's code runs in the browser with access to the victim's sessions, it can act as the victim on sites where the victim is logged in.
Fix
The report gives no detail on the code change. Its timeline records the report on 2021-10-20, the fix on 2021-10-25 and the award on 2021-10-26 (USD 2000).
Variants to test
Once you understand the pattern, you can look for the same mistake elsewhere. The idea is always the same: an app takes a URL from an untrusted source and acts on it without checking the scheme.
- Other URL schemes in the scanner. Try
data:,file:andblob:payloads in a QR code. A positive result is the browser rendering or executing the content instead of rejecting the scan.data:URLs carry content inline,file:URLs point at files on the device, andblob:URLs point at in-memory data; if any of them is executed rather than refused, the same class of bug is present. - Other entry points that accept URLs from untrusted sources, such as deep links, intents, clipboard paste or shared text. A deep link is a link that opens a specific screen inside an app rather than a web page; an intent is Android's message that asks an app to do something. A positive result is a
javascript:ordata:URL being executed rather than navigated to. - Other mobile browsers with built-in QR scanners. Feed the same
javascript:QR code. A positive result is script execution in the context of the scanned page.
Glossary
- Barcode: a machine-readable optical label that can contain information about the item it is attached to.
- Blob URL: a URL that points at data held in the browser's memory rather than at a file or a website.
- Bounty: a reward a company pays a researcher for reporting a security bug.
- Browser extension: an add-on that adds features to a browser and runs with some of the browser's privileges.
- Cache: a store of previously fetched pages or data that the browser keeps so it can reuse them.
- Client-side: happening in the user's browser or app rather than on the website's server.
- Cookie: a small piece of data a website stores in your browser, often used to recognise your logged-in session.
- Cross-site scripting (XSS): an attack that slips code into a vulnerable web page so it runs in another user's browser.
- CVE: a public identifier for a known security vulnerability, here CVE-2021-43530.
- Data URL: a URL that carries its content inline, inside the address itself.
- Deep link: a link that opens a specific screen inside an app rather than a web page.
- Denso Wave: the Japanese automotive company that invented the QR code in 1994.
- File URL: a URL that points at a file on the device.
- Intent: Android's message that asks an app to perform an action.
- JavaScript: the programming language that runs in web browsers.
- Matrix barcode: a two-dimensional barcode, such as a QR code, that stores data in a grid rather than in lines.
- Proof of concept (PoC): a demonstration that a vulnerability can actually be exploited.
- QR code: a two-dimensional matrix barcode that a camera can read, often holding a web address.
- Scheme: the part of a URL before the colon, such as
http:,https:orjavascript:, which tells the browser how to handle the address. - Server-side: happening on the website's server rather than in the user's browser.
- Session: the logged-in state between a browser and a website, usually kept alive by a cookie or token.
- Universal Cross-site Scripting (UXSS): an attack that abuses a flaw in the browser or an extension itself, so code can reach sessions of any open or cached page, not just a vulnerable one.
- URL: a web address.
- Validation: checking input before acting on it, for example confirming a URL starts with
http:orhttps:. - Version 93.2.0: the Firefox for Android version named in the report as affected.