Closed Bug 2094645 Opened 12 days ago Closed 4 days ago

When the `upgrade-insecure-requests` CSP is in a seperate standalone rule with others existing, too, requests are not upgraded

Categories

(Core :: DOM: Security, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
163 Branch
Tracking Status
firefox-esr115 --- affected
firefox-esr153 162+ fixed
firefox161 + fixed
firefox162 + fixed
firefox163 + fixed

People

(Reporter: skyschub, Assigned: tschuster)

References

(Blocks 1 open bug)

Details

(Keywords: webcompat:platform-bug)

User Story

user-impact-score:60

Attachments

(1 file, 4 external files)

(see comment 1)

Blocks: 2087136
User Story: (updated)

Actually, my original report is wrong. We do upgrade requests before checking CSP, but only if upgrade-insecure-requests is in the same CSP. So a request with a header of

Content-Security-Policy: upgrade-insecure-requests; script-src 'unsafe-inline' https:

works in Firefox, but two CSP headers:

Content-Security-Policy: upgrade-insecure-requests
Content-Security-Policy: script-src 'unsafe-inline' https:

does not work in Firefox, but works fine in Chrome. The attached test-case shows this. This feels like something we can fix!

Blocks: 2097577
Summary: Consider doing the HTTPS-upgrade before checking CSP → When the `upgrade-insecure-requests` CSP is in a seperate standalone rule with others existing, too, requests are not upgraded

Also, while being wrong, I was still wrong - the second page linked to this report is not affected by the same issue, I'll figure that one out in a new bug, the salesforce-issue is more relevant.

No longer blocks: 2087136

Very interesting, I will have look ASAP.

The problem in our code is that permitsScheme will allow loading http: schemes as long as aUpgradeInsecure is true and the "enforced"/allowed scheme is https:. However we only set the parameter aUpgradeInsecure based on the existence of the upgrade-insecure-requests directive inside the current Content-Security-Policy. This matches with what you found.

From a specification perspective we are totally wrong here. We never really implemented the CSP 3.0 6.7.2.8. Does url match expression in origin with redirect count? algorithm. That algorithm doesn't even consider upgrade-insecure-requests, instead it maches an URLs that have already been upgraded, because Step 7. of main fetch (the policy enforcement) runs after Step 6. (the upgrading).

I think this also means we have potentially similar issues if the upgrading happens due to a mechanism that isn't CSP's upgrade-insecure-requests.

I am going to upload a patch that fixes this specific issue only.

Assignee: nobody → tschuster
Status: NEW → ASSIGNED
Pushed by tschuster@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/cb404a4c5f7f https://hg.mozilla.org/integration/autoland/rev/d8ae56d57374 CSP: Also consider upgrade-insecure-requests directives in other policies when deciding to allow http: URLs. r=freddyb,simonf
Status: ASSIGNED → RESOLVED
Closed: 4 days ago
Resolution: --- → FIXED
Target Milestone: --- → 163 Branch
Attachment #9691201 - Flags: approval-mozilla-beta?

firefox-beta Uplift Approval Request

  • User impact if declined/Reason for urgency: The login page for Salesforce is broken.
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing: - Load https://bugzilla.mozilla.org/attachment.cgi?id=9690470
  • Make sure there is a green box instead of a red box
  • Risk associated with taking this patch: low
  • Explanation of risk level: This is a fairly obvious change that just re-uses existing helper methods.
  • String changes made/needed?: no
  • Is Android affected?: yes

firefox-esr153 Uplift Approval Request

  • User impact if declined/Reason for urgency: The login page for Salesforce is broken.
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing: - Load https://bugzilla.mozilla.org/attachment.cgi?id=9690470
  • Make sure there is a green box instead of a red box
  • Risk associated with taking this patch: low
  • Explanation of risk level: This is a fairly obvious change that just re-uses existing helper methods.
  • String changes made/needed?: no
  • Is Android affected?: yes
Attachment #9691202 - Flags: approval-mozilla-esr153?

firefox-release Uplift Approval Request

  • User impact if declined/Reason for urgency: The login page for Salesforce is broken.
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing: - Load https://bugzilla.mozilla.org/attachment.cgi?id=9690470
  • Make sure there is a green box instead of a red box
  • Risk associated with taking this patch: low
  • Explanation of risk level: This is a fairly obvious change that just re-uses existing helper methods.
  • String changes made/needed?: no
  • Is Android affected?: yes
Attachment #9691203 - Flags: approval-mozilla-release?
Attachment #9691201 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9691202 - Flags: approval-mozilla-esr153? → approval-mozilla-esr153+
Attachment #9691203 - Flags: approval-mozilla-release? → approval-mozilla-release+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: