Closed Bug 1912587 Opened 1 year ago Closed 5 days ago

Calling Document.parseHTMLUnsafe() in a browser extension content script crashes the tab

Categories

(WebExtensions :: General, defect, P2)

Firefox 131
defect

Tracking

(firefox129 unaffected, firefox130 affected, firefox131 affected, firefox150 verified)

VERIFIED FIXED
150 Branch
Tracking Status
firefox129 --- unaffected
firefox130 --- affected
firefox131 --- affected
firefox150 --- verified

People

(Reporter: czerny.jakub, Assigned: robwu)

References

Details

(Whiteboard: [addons-jira])

Attachments

(3 files)

Attached file extention.zip

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:131.0) Gecko/20100101 Firefox/131.0

Steps to reproduce:

Use Document.parseHTMLUnsafe() in a content script of a Firefox browser extension.

Steps to reproduce:

  1. load the extension.zip browser extension attached as a temporary extension (about:debugging#/runtime/this-firefox)
  2. open any regular page, e.g. https://developer.mozilla.org
  3. select "Crush tab" from the context menu

Actual results:

"Gah. Your tab just crashed." crushed tab form is shown.

Console dump of the Browser Toolbox is attached.

Expected results:

The tab shouldn't crush

Attached file console-export.txt

Browser toolbox console dump

The Bugbug bot thinks this bug should belong to the 'WebExtensions::Untriaged' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Product: Firefox → WebExtensions

Hello,

I reproduced the issue on the latest Nightly (131.0a1/20240811212519) and Beta (130.0b3/20240809091641) under Windows 10 x64 and Ubuntu 22.04 LTS. The issue does NOT reproduce on the latest Release (129.0/20240801122119).

Since Release 129 does not seem to be affected by the issue, I performed a mozregression but did not find a regressor. All the tested builds (from 128 to 130) were bad.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee: nobody → amarchesini
Status: NEW → ASSIGNED

The severity field is not set for this bug.
:zombie, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(tomica)
Severity: -- → S4
Flags: needinfo?(tomica)
Priority: -- → P2
Whiteboard: [addons-jira]
Component: Untriaged → General

I'm linking the eslint no-unsanitized pugin PR to also have linting warnings on usage of the Document.parseHTMLUnsafe static method:

Attachment #9419080 - Attachment description: Bug 1912587 - Document.parseHTMLUnsafe() should use ContentPrincipal when called by an content-script, r?rpl → Bug 1912587 - Document.parseHTMLUnsafe() should use ContentPrincipal when called by a content script
Assignee: amarchesini → rob

Hi, there has recently been a spike in crashes related to this issue (see bug 1937488). The patch on this bug appears to be the correct solution; what all would need to be done in order to get it landed? I'm willing to take it over if needed.

Flags: needinfo?(rob)
See Also: → 1937488

I have updated the patch, it is ready for review. Thanks for flagging the other bug.

I'm going to mark this as a blocker to bug 1937488 instead of "See also" because I expect the fix here to resolve the crashes in bug 1937488.

Blocks: 1937488
Flags: needinfo?(rob)
See Also: 1937488
See Also: → 2020773
Attachment #9419080 - Attachment description: Bug 1912587 - Document.parseHTMLUnsafe() should use ContentPrincipal when called by a content script → Bug 1912587 - Document.parseHTMLUnsafe() should use source document's principal when called by a content script
Pushed by rob@robwu.nl: https://github.com/mozilla-firefox/firefox/commit/924fafc1962f https://hg.mozilla.org/integration/autoland/rev/956b68964441 Document.parseHTMLUnsafe() should use source document's principal when called by a content script r=rpl,smaug
Status: ASSIGNED → RESOLVED
Closed: 5 days ago
Resolution: --- → FIXED
Target Milestone: --- → 150 Branch

Verified as Fixed. Tested on the latest Nightly (150.0a1/20260305002319) under Windows 11 and Ubuntu 24.10.

Using the extension and STR from Comment 0, the tab no longer crashes.

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: