Closed Bug 1800890 (CVE-2023-23602) Opened 2 years ago Closed 1 year ago

connect-src CSP header does not apply to WebWorker initiated WebSocket connections

Categories

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

Firefox 107
defect

Tracking

()

VERIFIED FIXED
109 Branch
Tracking Status
firefox-esr102 109+ verified
firefox107 --- wontfix
firefox108 --- wontfix
firefox109 + verified

People

(Reporter: kzar, Assigned: tschuster)

References

(Blocks 1 open bug)

Details

(Keywords: sec-moderate, Whiteboard: [domsecurity-active] [post-critsmash-triage][adv-main109+][adv-esr102.7+])

Attachments

(4 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:107.0) Gecko/20100101 Firefox/107.0

Steps to reproduce:

  1. Navigate to https://testpages.kzar.co.uk/csp/?csp=connect-src+%27none%27

Actual results:

"WebSocket (third-party via WebWorker via inline script)" is listed as Loaded.

Expected results:

"WebSocket (third-party via WebWorker via inline script)" is listed as Failed. (Which happens with Chrome 107.0.5304.87)

Group: firefox-core-security → dom-core-security
Component: Untriaged → DOM: Security
Product: Firefox → Core
Flags: needinfo?(dveditz)

I've updated the test page again, so now it's also checking that a message is successfully echoed back from the WebSocket server too.

So I think there are probably two issues here in Firefox:

  1. The smaller/known issues is that Blob URLs generally don't inherit CSPs (bug 1626566). That means even if it worked, we would not be applying the CSP of the loading page in the Worker.
  2. We weren't correctly checking the CSP when creating a WebSocket in a Worker even when that Worker had a CSP (i.e. provided via the CSP header).
Assignee: nobody → tschuster
Attached file Bug 1800890 r?asuth!

Thanks for looking into this Tom.

  1. The smaller/known issues is that Blob URLs generally don't inherit CSPs...

It's maybe worth point out that my test page does also have a test for opening a WebSocket via a blob URI iframe, which seems to be successfully blocked by the CSP.

Seems like you are right. It also seems like we inherit the CSP from the creating page when using a blob URL for the Worker constructor. I am actually not sure anymore, which behavior is actually correct. As I expected we still seem to respect an explicit Content-Security-Policy header when the Worker is delivered via HTTP.

Flags: needinfo?(bugmail)

My understanding is:

  • A worker loaded via a Blob URL should inherit the CSP of the document that minted the Blob URL (which should pedantically be the parent of the dedicated worker itself but there may be some edge cases in there). Spec-wise:
  • A worker loaded via HTTP(S) should use the CSP served with the top-level script load of the worker. (The above links are relevant for this too.) As discussed in https://github.com/w3c/webappsec-csp/issues/336 we do think there is some divergence between what the tests say about this and what the correct thing is, but it's my understanding that we have some level of consensus that this is correct but spec changes may be needed.
    • (Note that the initial top-level fetch of the worker may be impacted by the CSP of the window creating the Worker instance, however, but I am not 100% on that at this moment, but we're talking about the websocket creation in the worker which is only constrained by what the worker CSP says.)
Flags: needinfo?(bugmail)

I've updated the test page again Tom. For the Blob iframe, I'm now taking care to put all the WebSocket opening code in the Blob URI itself (like we are doing for the WebWorker test). I'm still seeing the same results though!

Depends on D162827

Attachment #9304882 - Attachment description: WIP: Bug 1800890 → Bug 1800890 r?asuth!
Attachment #9305342 - Attachment description: WIP: Bug 1800890 - Test → Bug 1800890 - Test r?asuth
Whiteboard: [domsecurity-active]
Severity: -- → S3
Priority: -- → P3
Blocks: CSP
Group: dom-core-security → core-security-release
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 109 Branch

If we want to uplift this to ESR102 eventually, a rebased patch is going to be needed.

Whiteboard: [domsecurity-active] → [domsecurity-active] [reminder-test 2023-02-01]
Flags: qe-verify+
Whiteboard: [domsecurity-active] [reminder-test 2023-02-01] → [domsecurity-active] [reminder-test 2023-02-01][post-critsmash-triage]

Reproduced with Fx 107.0 on Ubuntu 22.
Verified fixed on Fx 109.0a1 (2022-12-06) on Windows 10, macOS 12 and Ubuntu 22.

Flags: qe-verify+

Please attach a rebased patch for ESR102 uplift and nominate for approval when you get a chance.

Flags: needinfo?(tschuster)
Flags: needinfo?(tschuster)

We're getting release tracking alerts for ESR. Andrew, can you review this in time? If not, we'll find another reviewer.

Flags: needinfo?(bugmail)

Comment on attachment 9309345 [details]
Bug 1800890 - ESR r?asuth!

ESR Uplift Approval Request

  • If this is not a sec:{high,crit} bug, please state case for ESR consideration: Uplift was requested
  • User impact if declined:
  • Fix Landed on Version: 109
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky):
Attachment #9309345 - Flags: approval-mozilla-esr102?

Comment on attachment 9309345 [details]
Bug 1800890 - ESR r?asuth!

Approved for 102.7esr, thanks for rebasing.

Flags: needinfo?(bugmail)
Attachment #9309345 - Flags: approval-mozilla-esr102? → approval-mozilla-esr102+

Verified fixed on Fx 102.7esr on Windows 10, macOS 13 and Ubuntu 22.

Status: RESOLVED → VERIFIED
Whiteboard: [domsecurity-active] [reminder-test 2023-02-01][post-critsmash-triage] → [domsecurity-active] [reminder-test 2023-02-01][post-critsmash-triage][adv-main109+][adv-esr102.7+]

Shouldn’t this report be eligible for a bug bounty?

The reporter seems to not have used our Bug bounty form, so we never had the sec-bounty? flag set, which is what we use for internal triage. We often times get people report bugs without any wish to be credited or rewarded, so there's no process to go through bugs without the flag.

Either way, we can easily change that: Dave do you want us to take a look whether this qualifies for a bug bounty?

The final decision is at the discretion of the bug bounty committee. Our docs and FAQ have more info https://www.mozilla.org/en-US/security/client-bug-bounty/

Flags: needinfo?(kzar)

The reporter seems to not have used our Bug bounty form...

Sorry, I didn't realise I was supposed to do that. Is the process to file the issue first, then fill out the form after the issue is accepted?

Dave do you want us to take a look whether this qualifies for a bug bounty?

Yes please, that would be great!

Flags: needinfo?(kzar)

(In reply to Dave Vandyke from comment #23)

The reporter seems to not have used our Bug bounty form...
Sorry, I didn't realise I was supposed to do that. Is the process to file the issue first, then fill out the form after the issue is accepted?

This is just the typical "file a new bug" form with "hidden security bug" and "please consider me for a bounty" preset. I just set the last flag directly. Not a problem.

Dave do you want us to take a look whether this qualifies for a bug bounty?

Yes please, that would be great!

The bug bounty team is going to look at this in one of the next meetings. It may take a couple of weeks until you hear more.

Flags: sec-bounty?
Alias: CVE-2023-23602
Flags: sec-bounty?
Flags: sec-bounty+
Flags: needinfo?(dveditz)

2 months ago, Tom Schuster (MoCo) placed a reminder on the bug using the whiteboard tag [reminder-test 2023-02-01] .

tschuster, please refer to the original comment to better understand the reason for the reminder.

Flags: needinfo?(tschuster)
Whiteboard: [domsecurity-active] [reminder-test 2023-02-01][post-critsmash-triage][adv-main109+][adv-esr102.7+] → [domsecurity-active] [post-critsmash-triage][adv-main109+][adv-esr102.7+]

It seems like we might not automatically sync WPT added in a secure bug?

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: