Closed Bug 1551886 (CVE-2021-38491) Opened 6 years ago Closed 4 years ago

Opaque documents aren't considered in the mixed content blocker

Categories

(Core :: DOM: Security, defect, P3)

65 Branch
defect

Tracking

()

VERIFIED FIXED
92 Branch
Tracking Status
firefox-esr78 --- wontfix
firefox-esr91 --- wontfix
firefox90 --- wontfix
firefox91 --- wontfix
firefox92 --- verified

People

(Reporter: jkt, Assigned: n.goeggi)

References

(Blocks 1 open bug)

Details

(Keywords: sec-moderate, Whiteboard: [domsecurity-backlog1][post-critsmash-triage][adv-main92+])

Attachments

(2 files)

I raised Bug 1519406 about the mixed content blocker getting a requestingLocation that is a NullPrincipal. This principal doesn't appear to be handled correctly.

However it also seems that the way we evaluate if we should block is based only on the parent context: https://searchfox.org/mozilla-central/rev/116bd975c30746ddefc3d20e6947d1871469354f/dom/security/nsMixedContentBlocker.cpp#733-751

So I was able to replicate the unblocked resources:

  1. Go to https://example.com
  2. Use inspector to inject <iframe src="data:text/html,<iframe src='http://localhost'></iframe>"></iframe> or <iframe src="data:text/html,<iframe src='http://example.com'></iframe>"></iframe>

In Firefox the inner frame loads and Chrome blocks this.

This sounds suspiciously like what Christoph was saying in https://bugzilla.mozilla.org/show_bug.cgi?id=1550414#c5 . Christoph, is this also fixed when we move CSP to Client?

Flags: needinfo?(ckerschb)

I doubt it quite a lot as the MCB doesn't use CSP (besides for the opt in case by CSP). The code is in the evaluation of those lines and not traversing docshells / behaving in a similar way.

Christoph you haven't changed anything other than CSP right?

(In reply to Jonathan Kingston [:jkt] from comment #2)

Christoph you haven't changed anything other than CSP right?

The problems described within this bug are orthogonal to my changes to the CSP code. For this bug we somehow need to inspect the embedding context in case the subresource loaded was triggered by an opaque origin. In general we need a better abstract mechanism for things that need to be inherited into opaque contexts. It seems we are fighting the same problems over and over.

FWIW, another testcase would be using a srcdoc iframe which I am pretty sure also doesn't work correctly.

Flags: needinfo?(ckerschb)
Group: core-security → dom-core-security
Keywords: sec-low

Just chatted with Dan and we think this is actually a sec-moderate. In terms of how we could fix that, we should check if we can somehow propagate the isSecureContext flag. In other words, if a secure context creates an opage origin iframe (e.g. data: iframe) then we can make a decision within the MixedContentBlocker based on that.

Keywords: sec-lowsec-moderate
Priority: -- → P3
Whiteboard: [domsecurity-backlog1]

Probably some wpt-tests around opaque origins would be beneficial.

<iframe src="data:text/html,<script>console.log(window.isSecureContext)</script>"></iframe> I think we also agreed that this should console true when it currently doesn't. This would potentially make the mcb only have to check parent.isSecureContext rather than the propagated ancestor is secure solution.

Christoph, please review this sec bug and figure out next steps?

Flags: needinfo?(ckerschb)

Doing either Bug 1660452 or even better Bug 1715167 will fix that problem. We should really tackle Bug 1715167 soon - marking dependency to Bug 1715167 so we keep the reference.

Depends on: 1715167
Flags: needinfo?(ckerschb)
Assignee: nobody → ngogge
Status: NEW → ASSIGNED

Backed out for WPT unexpected passes in worker-classic-data.http-rp/opt-in/fetch.https.html

https://hg.mozilla.org/integration/autoland/rev/f9a0759c1872473f30fa0221be70585f4baaa2e6

It had landed as https://hg.mozilla.org/integration/autoland/rev/ec131014f7fda0a016a8b0ea085e9c4edaff9b8e

Push with failures: https://treeherder.mozilla.org/jobs?repo=autoland&group_state=expanded&resultStatus=testfailed%2Cbusted%2Cexception%2Cretry%2Cusercancel%2Crunnable&revision=ec131014f7fda0a016a8b0ea085e9c4edaff9b8e&selectedTaskRun=Iz3EuQ-cSHqb-iQYkr9qPA.0
Failure log: https://treeherder.mozilla.org/logviewer?job_id=345905358&repo=autoland

16:06:57 INFO - TEST-UNEXPECTED-PASS | /mixed-content/gen/worker-classic-data.http-rp/opt-in/fetch.https.html | Mixed-Content: Expects blocked for fetch to cross-http origin and keep-scheme redirection from https context. - expected FAIL
8244	16:06:57 INFO - TEST-UNEXPECTED-PASS | /mixed-content/gen/worker-classic-data.http-rp/opt-in/fetch.https.html | Mixed-Content: Expects blocked for fetch to cross-http origin and no-redirect redirection from https context. - expected FAIL
8247	16:06:57 INFO - TEST-UNEXPECTED-PASS | /mixed-content/gen/worker-classic-data.http-rp/opt-in/fetch.https.html | Mixed-Content: Expects blocked for fetch to cross-http origin and swap-scheme redirection from https context. - expected FAIL
8250	16:06:57 INFO - TEST-UNEXPECTED-PASS | /mixed-content/gen/worker-classic-data.http-rp/opt-in/fetch.https.html | Mixed-Content: Expects blocked for fetch to cross-https origin and swap-scheme redirection from https context. - expected FAIL
8253	16:06:57 INFO - TEST-UNEXPECTED-PASS | /mixed-content/gen/worker-classic-data.http-rp/opt-in/fetch.https.html | Mixed-Content: Expects blocked for fetch to same-http origin and keep-scheme redirection from https context. - expected FAIL
8256	16:06:57 INFO - TEST-UNEXPECTED-PASS | /mixed-content/gen/worker-classic-data.http-rp/opt-in/fetch.https.html | Mixed-Content: Expects blocked for fetch to same-http origin and no-redirect redirection from https context. - expected FAIL
8259	16:06:57 INFO - TEST-UNEXPECTED-PASS | /mixed-content/gen/worker-classic-data.http-rp/opt-in/fetch.https.html | Mixed-Content: Expects blocked for fetch to same-http origin and swap-scheme redirection from https context. - expected FAIL
8262	16:06:57 INFO - TEST-UNEXPECTED-PASS | /mixed-content/gen/worker-classic-data.http-rp/opt-in/fetch.https.html | Mixed-Content: Expects blocked for fetch to same-https origin and swap-scheme redirection from https context. - expected FAIL
8398	16:07:04 INFO - TEST-UNEXPECTED-PASS | /mixed-content/gen/worker-classic-data.http-rp/opt-in/xhr.https.html | Mixed-Content: Expects blocked for xhr to cross-http origin and keep-scheme redirection from https context. - expected FAIL
8401	16:07:04 INFO - TEST-UNEXPECTED-PASS | /mixed-content/gen/worker-classic-data.http-rp/opt-in/xhr.https.html | Mixed-Content: Expects blocked for xhr to cross-http origin and no-redirect redirection from https context. - expected FAIL
8404	16:07:04 INFO - TEST-UNEXPECTED-PASS | /mixed-content/gen/worker-classic-data.http-rp/opt-in/xhr.https.html | Mixed-Content: Expects blocked for xhr to cross-http origin and swap-scheme redirection from https context. - expected FAIL
8407	16:07:04 INFO - TEST-UNEXPECTED-PASS | /mixed-content/gen/worker-classic-data.http-rp/opt-in/xhr.https.html | Mixed-Content: Expects blocked for xhr to cross-https origin and swap-scheme redirection from https context. - expected FAIL
8410	16:07:04 INFO - TEST-UNEXPECTED-PASS | /mixed-content/gen/worker-classic-data.http-rp/opt-in/xhr.https.html | Mixed-Content: Expects blocked for xhr to same-http origin and keep-scheme redirection from https context. - expected FAIL
8413	16:07:04 INFO - TEST-UNEXPECTED-PASS | /mixed-content/gen/worker-classic-data.http-rp/opt-in/xhr.https.html | Mixed-Content: Expects blocked for xhr to same-http origin and no-redirect redirection from https context. - expected FAIL
8416	16:07:04 INFO - TEST-UNEXPECTED-PASS | /mixed-content/gen/worker-classic-data.http-rp/opt-in/xhr.https.html | Mixed-Content: Expects blocked for xhr to same-http origin and swap-scheme redirection from https context. - expected FAIL
8419	16:07:04 INFO - TEST-UNEXPECTED-PASS | /mixed-content/gen/worker-classic-data.http-rp/opt-in/xhr.https.html | Mixed-Content: Expects blocked for xhr to same-https origin and swap-scheme redirection from https context. - expected FAIL
Flags: needinfo?(ngogge)
Group: dom-core-security → core-security-release
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 92 Branch

Is this something we need to consider backporting to Beta/ESR78?

Flags: needinfo?(ckerschb)

(In reply to Ryan VanderMeulen [:RyanVM] from comment #14)

Is this something we need to consider backporting to Beta/ESR78?

The short answer is no, no need to do that.

The longer answer is:

  • Our implementation of the mixed content blocker has not been able to correctly detect this corner case almost since it's inception.
  • Additionally to uplifting this patch we would have to uplift all the Principal changes from Bug 1715167 which are (in my opinion) more likely to cause some other side effect when uplifted than the benefit of having this corner case fixed.

Thanks for checking though!

Flags: needinfo?(ngogge)
Flags: needinfo?(ckerschb)
Flags: qe-verify+
Whiteboard: [domsecurity-backlog1] → [domsecurity-backlog1][post-critsmash-triage]

Hello!
Tried to verify the issue but this is what I came across on Windows 10x64 and I don't know if this is expected:

  1. Using <iframe src="data:text/html,<iframe src='http://example.com'></iframe>"></iframe> -> the second iFrame is blocked on Chrome, Firefox 92.0b9 and is not blocked on affected Firefox 91.0a (20210707215219).
  2. Using <iframe src="data:text/html,<iframe src='http://localhost'></iframe>"></iframe> -> the second iFrame does not get blocked on Chrome, Firefox 92.0b9 and Firefox 91.0a (affected build) Is this expected? Thank you in advance!
Flags: needinfo?(ngogge)

Hi, thanks for verifying!

This is indeed expected. Requests made to localhost are always assumed to be delivered securely and are therefore exempt from mixed content blocking.

Flags: needinfo?(ngogge)
Whiteboard: [domsecurity-backlog1][post-critsmash-triage] → [domsecurity-backlog1][post-critsmash-triage][adv-main92+]

(In reply to Niklas from comment #17)

Hi, thanks for verifying!

This is indeed expected. Requests made to localhost are always assumed to be delivered securely and are therefore exempt from mixed content blocking.

Thank you! Closing this as verified based on the above.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
Attached file advisory.txt
Attachment #9239138 - Attachment is obsolete: true
Attachment #9239138 - Attachment is obsolete: false
Alias: CVE-2021-38491
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: