Closed Bug 1782211 (CVE-2022-40959) Opened 2 years ago Closed 2 years ago

Uninitialized FeaturePolicy in transient about:blank

Categories

(Core :: DOM: Core & HTML, defect, P2)

defect

Tracking

()

VERIFIED FIXED
106 Branch
Tracking Status
firefox-esr91 --- wontfix
firefox-esr102 105+ verified
firefox104 --- wontfix
firefox105 + verified
firefox106 + verified

People

(Reporter: arminius, Assigned: edgar)

References

Details

(Keywords: csectype-spoof, sec-high, Whiteboard: [adv-main105+][adv-esr102.3+])

Attachments

(3 files)

A transient placeholder about:blank document never initializes its FeaturePolicy. This can be used to bypass feature restrictions with the same attack scenarios and impact as bug 1771685.

The bug occurs because a transient about:blank doesn't call Document::StartDocumentLoad() where the policy would usually be set up. The FP also isn't among the security properties that are explicitly initialized in nsDocShell::CreateAboutBlankContentViewer().

Proof of concept

This iframe contains two blank sub frames, one of which is stopped immediately with window.stop(), so it never starts loading to replace the initial transient about:blank. Thus, the document holds an unrestricted FeaturePolicy and can hijack the top-level context's fullscreen permission, whereas the other frame has loaded regularly and is denied fullscreen as expected.
(I'm using srcdoc only to keep the PoC self-contained - the cross-origin examples from bug 1771685 apply here as well.)

<iframe allow="fullscreen 'none'" srcdoc="
  <button onclick='regular.document.firstChild.requestFullscreen()'>fullscreen regular</button>
  <button onclick='transient.document.firstChild.requestFullscreen()'>fullscreen transient</button>
  <iframe name='regular'></iframe>
  <iframe name='transient'></iframe>
  <script>transient.stop()</script>
"></iframe>

Also, sorry for reporting this right after the patch for bug 1771685 has already landed. When I filed that one I hadn't been aware there's another FeaturePolicy initialization bug.

Flags: sec-bounty?
Attached file poc.html
See Also: → CVE-2022-38473
Group: core-security → dom-core-security
Component: DOM: Security → DOM: Core & HTML
Severity: -- → S2
Flags: needinfo?(echen)
Priority: -- → P2
Assignee: nobody → echen
Flags: needinfo?(echen)

Comment on attachment 9289120 [details]
Bug 1782211 - Init feature policy;

Security Approval Request

  • How easily could an exploit be constructed based on the patch?: Patch makes it fairly obvious that it's related to about:blank and feature policy.
  • Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?: Yes
  • Which older supported branches are affected by this flaw?: All
  • If not all supported branches, which bug introduced the flaw?: None
  • Do you have backports for the affected branches?: Yes
  • If not, how different, hard to create, and risky will they be?: Should just apply
  • How likely is this patch to cause regressions; how much testing does it need?: Should be safe, it makes sure we initial the feature policy properly for about:blank.
  • Is Android affected?: Yes
Attachment #9289120 - Flags: sec-approval?

Comment on attachment 9289120 [details]
Bug 1782211 - Init feature policy;

Approved to land and uplift

Attachment #9289120 - Flags: sec-approval? → sec-approval+
Group: dom-core-security → core-security-release
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 106 Branch

Please nominate this for Beta & ESR102 approval when you get a chance.

Comment on attachment 9289120 [details]
Bug 1782211 - Init feature policy;

ESR Uplift Approval Request

  • If this is not a sec:{high,crit} bug, please state case for ESR consideration: This is a sec-high bug.
  • User impact if declined: An untrusted cross-origin <iframe> might bypass feature restrictions and hijack the top-level context's permission.
  • Fix Landed on Version: 106
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Should be safe, it makes sure we initial the feature policy properly for about:blank.

Beta/Release Uplift Approval Request

  • User impact if declined: An untrusted cross-origin <iframe> might bypass feature restrictions and hijack the top-level context's permission.
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: Follow the steps in https://bugzilla.mozilla.org/show_bug.cgi?id=1782211#c0
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Should be safe, it makes sure we initial the feature policy properly for about:blank.
  • String changes made/needed: None
  • Is Android affected?: Yes
Flags: needinfo?(echen)
Attachment #9289120 - Flags: approval-mozilla-esr102?
Attachment #9289120 - Flags: approval-mozilla-beta?
Flags: qe-verify+
QA Whiteboard: [qa-triaged]

Comment on attachment 9289120 [details]
Bug 1782211 - Init feature policy;

Approved for 105.0b4 and 102.3esr.

Attachment #9289120 - Flags: approval-mozilla-esr102?
Attachment #9289120 - Flags: approval-mozilla-esr102+
Attachment #9289120 - Flags: approval-mozilla-beta?
Attachment #9289120 - Flags: approval-mozilla-beta+

Managed to reproduce the issue on Firefox 104.0RC using the information from Comment 0.
The issue is no longer reproducible on Firefox 105.0b4, or on Firefox 106.0a1 latest build.
Tests were performed under Windows 10x64, Ubuntu 22.04 and under macOS 10.14.
I will also verify the issue on 102.3ESR build as soon as the build is available.

Flags: sec-bounty? → sec-bounty+

The issue is no longer reproducible also on Firefox 102.3.0esr(treeherder build).
Based on this and comment 11, I'm marking the issue as Verified Fixed.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
Whiteboard: [adv-main105+][adv-esr102.3+]
Attached file advisory.txt
Alias: CVE-2022-40959
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: