Closed
Bug 1402363
(CVE-2017-7835)
Opened 7 years ago
Closed 7 years ago
when a redirect is blocked for mixed content blocking the original redirect response is returned instead
Categories
(Core :: DOM: Security, defect, P1)
Tracking
()
RESOLVED
FIXED
mozilla58
People
(Reporter: bkelly, Assigned: ckerschb)
References
(Blocks 1 open bug)
Details
(Keywords: sec-moderate, Whiteboard: [tor][domsecurity-active][adv-main57+][post-critsmash-triage])
Attachments
(2 files, 1 obsolete file)
1.96 KB,
patch
|
kmckinley
:
review+
mayhemer
:
review+
ritu
:
approval-mozilla-beta+
|
Details | Diff | Splinter Review |
5.15 KB,
patch
|
kmckinley
:
review+
ritu
:
approval-mozilla-beta+
|
Details | Diff | Splinter Review |
Jake Archibald at google noticed some weird behavior. See this demo:
https://firefox-redirect-bug.glitch.me/
Source code is at:
https://glitch.com/edit/#!/firefox-redirect-bug?path=public/script.js:1:0
In this case he is trying to fail a fetch() call by redirecting from an https:// origin to an http:// origin. This does produce the failure message:
Blocked loading mixed active content “http://example.com/”
But the fetch() succeeds and the 302 response is returned instead.
I instrumented FetchDriver a bit and its actually not seeing an AsyncOnChannelRedirect() call. Instead its just getting an OnStartRequest() with a channel with a successful mStatus.
Christoph, is this a problem with our AsyncOpen2() security checks? Or is it possible an http cache issue, Honza?
I'm marking this a secure bug since Jake told me that some sites include private information in redirects that should not be exposed to scripts.
Reporter | ||
Comment 1•7 years ago
|
||
Add NI for questions in comment 0.
Flags: needinfo?(honzab.moz)
Flags: needinfo?(ckerschb)
Reporter | ||
Comment 2•7 years ago
|
||
In the short term I can fix this by failing the fetch if we get OnStartRequest with a redirect status when redirect mode is not manual.
Reporter | ||
Comment 3•7 years ago
|
||
Anne, do you agree with Jake about this being a security issue? How critical is it? I'm not sure of the severity.
Flags: needinfo?(annevk)
Reporter | ||
Updated•7 years ago
|
status-firefox55:
--- → wontfix
status-firefox56:
--- → affected
status-firefox57:
--- → affected
status-firefox58:
--- → affected
status-firefox-esr52:
--- → affected
Reporter | ||
Comment 4•7 years ago
|
||
Andrew, this patch makes us fail any unexpected 30x responses from necko at the FetchDriver. In general we should not see these, but it seems they can happen when the redirect is failed for things like mixed content.
Reporter | ||
Comment 5•7 years ago
|
||
Comment on attachment 8911228 [details] [diff] [review]
P1 Fail unexpected redirect responses in FetchDriver. r=asuth
Review of attachment 8911228 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/fetch/FetchDriver.cpp
@@ +480,5 @@
> FetchDriver::OnStartRequest(nsIRequest* aRequest,
> nsISupports* aContext)
> {
> workers::AssertIsOnMainThread();
> + printf_stderr("### ### [%p] FetchDriver::%s\n", this, __func__);
I'll remove the printfs.
Reporter | ||
Comment 6•7 years ago
|
||
The problem with fixing this at the Fetch API layer, though, is that other necko consumers may have the same problem. It seems XHR probably needs to be fixed as well.
Reporter | ||
Comment 7•7 years ago
|
||
Comment on attachment 8911228 [details] [diff] [review]
P1 Fail unexpected redirect responses in FetchDriver. r=asuth
Lets wait and see if this can be fixed in necko before proceeding here.
Attachment #8911228 -
Flags: review?(bugmail)
Comment 8•7 years ago
|
||
Okay, so we expose the content of a redirect when it goes from HTTPS to HTTP? That is somewhat problematic given https://fetch.spec.whatwg.org/#atomic-http-redirect-handling. The site would first need to be XSS'd successfully though before an attacker could steal such a token and the site would need to redirect to an HTTP service which seems less likely and would already reveal the token to network attackers as well. Unless I'm missing something I don't think this is severe.
Flags: needinfo?(annevk)
Assignee | ||
Comment 9•7 years ago
|
||
(In reply to Ben Kelly [:bkelly] from comment #0)
> Christoph, is this a problem with our AsyncOpen2() security checks? Or is
> it possible an http cache issue, Honza?
At first, I was thinking it can't be a problem for AsyncOpen2(), since I was thinking we have tests for that. Now I looked at the code and compared CSP and MixedContentBlocker redirect handling. It seems for CSP, we explicitly Cancel() the old channel [1], while for MixedContent we don't do that [2]. Looking at the comments of AsyncOnChannelRedirect() [3] that shouldn't be a problem though, but also wanted to make sure. Nevertheless, the fetch should go through [2] and returning an error from within that function should prevent the channel from loading any data.
@Honza: Is the above a potential issue?
@ Kate (Tanvi is not accepting ni? requests): I thought we have tests for mixed content redirect handling, but I couldn't fine any in dom/security/test/mixedcontentblocker/. There are only wpt tests for redirect handling. If we don't have mixed content redirect tests, could you please file a bug for that? We definitely need those.
[1] https://dxr.mozilla.org/mozilla-central/source/dom/security/nsCSPService.cpp#336
[2] https://dxr.mozilla.org/mozilla-central/source/dom/security/nsMixedContentBlocker.cpp#397
[3] https://dxr.mozilla.org/mozilla-central/source/netwerk/base/nsIChannelEventSink.idl#66
Flags: needinfo?(ckerschb) → needinfo?(kmckinley)
Reporter | ||
Comment 10•7 years ago
|
||
I believe nsCORSListenerProxy also does an explicit cancel:
https://searchfox.org/mozilla-central/source/netwerk/protocol/http/nsCORSListenerProxy.cpp#741
I think the explicit cancel is probably what we want here as well.
Christoph, do you mind taking this bug however we decide we want it to go? I think it would be best to fix in the common code instead of in fetch, xhr, other consumers, etc.
![]() |
||
Comment 11•7 years ago
|
||
So, necko's nsHttpChannel explicitly provides the redirect 30X response to the consumer (mListener) when the redirect is vetoed. This is by design and won't change.
What you want is to explicitly cancel the source channel to not get 30X but a gecko loading error code in OnStartRequest/OnStopRequest instead. What nsCORSListenerProxy does is correct.
What's suggested in comment 9 - to call Cancel(NS_BINDING_ABORTED) or similar error on the source channel - seems correct to me.
Flags: needinfo?(honzab.moz)
Comment 12•7 years ago
|
||
It does seem problematic that each caller needs to account for this. Ideally that gets abstracted somehow so we don't get this leak if we ever introduce another way to load code.
Reporter | ||
Updated•7 years ago
|
Assignee: bkelly → ckerschb
Updated•7 years ago
|
Group: core-security → dom-core-security
![]() |
||
Comment 13•7 years ago
|
||
(In reply to Anne (:annevk) from comment #12)
> It does seem problematic that each caller needs to account for this. Ideally
> that gets abstracted somehow so we don't get this leak if we ever introduce
> another way to load code.
The source channel cancellation MUST be handled above necko. We want to provide the content of the 30X response by default.
Reporter | ||
Comment 14•7 years ago
|
||
I think there is some confusion. There are kind of 3 layers here:
1. nsIChannel implementations
2. Security proxies and listeners that enforce CORS, mixed content, CSP, etc.
3. End client code like fetch(), xhr, document loading, etc.
Right now its up to layer (3) to cancel on the blocked redirect for mixed content. For things like CORS and CSP we cancel at layer (2). We just need to cancel at layer (2) for mixed content as well.
I think Honza is saying we can't do the cancellation at layer (1).
![]() |
||
Comment 15•7 years ago
|
||
(In reply to Ben Kelly [:bkelly] from comment #14)
> I think there is some confusion. There are kind of 3 layers here:
>
> 1. nsIChannel implementations
> 2. Security proxies and listeners that enforce CORS, mixed content, CSP, etc.
> 3. End client code like fetch(), xhr, document loading, etc.
>
> Right now its up to layer (3) to cancel on the blocked redirect for mixed
> content. For things like CORS and CSP we cancel at layer (2). We just need
> to cancel at layer (2) for mixed content as well.
>
> I think Honza is saying we can't do the cancellation at layer (1).
Yes, exactly, thanks for clarifying this.
Comment 16•7 years ago
|
||
I'm sorry for causing confusing. I understood what Honza meant. I was just saying that it not being in 2 surprised me.
Comment 17•7 years ago
|
||
s/confusing/confusion/. :-(
Comment 18•7 years ago
|
||
In the tree, the only mixed-content blocker blocker tests that include tests for redirection are in browser/base/content/test/siteIdentity/browser_mcb_redirect.js, and they don't cover this case.
Created bug 1403406 for testing and adding the Cancel to MCB, but maybe it should be in this instead.
Flags: needinfo?(kmckinley)
Assignee | ||
Comment 19•7 years ago
|
||
(In reply to Kate McKinley [:kmckinley, :Kate] from comment #18)
> In the tree, the only mixed-content blocker blocker tests that include tests
> for redirection are in
> browser/base/content/test/siteIdentity/browser_mcb_redirect.js, and they
> don't cover this case.
>
> Created bug 1403406 for testing and adding the Cancel to MCB, but maybe it
> should be in this instead.
I'll fix the problem in this bug and will also add the required tests within this bug - thanks kate.
Assignee | ||
Updated•7 years ago
|
Priority: -- → P1
Whiteboard: [tor][domsecurity-active]
Reporter | ||
Updated•7 years ago
|
Attachment #8911228 -
Attachment is obsolete: true
Updated•7 years ago
|
Assignee | ||
Comment 21•7 years ago
|
||
Attachment #8913600 -
Flags: review?(kmckinley)
Attachment #8913600 -
Flags: review?(honzab.moz)
Assignee | ||
Comment 22•7 years ago
|
||
Attachment #8913602 -
Flags: review?(kmckinley)
![]() |
||
Comment 23•7 years ago
|
||
Comment on attachment 8913600 [details] [diff] [review]
bug_1402363_mcb_redirect.patch
Review of attachment 8913600 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/security/nsMixedContentBlocker.cpp
@@ +395,5 @@
> requestingPrincipal,
> &decision);
> + if (NS_FAILED(rv)) {
> + autoCallback.DontCallback();
> + aOldChannel->Cancel(NS_ERROR_DOM_BAD_URI);
Why exactly NS_ERROR_DOM_BAD_URI?
Attachment #8913600 -
Flags: review?(honzab.moz) → review+
Comment 24•7 years ago
|
||
Comment on attachment 8913600 [details] [diff] [review]
bug_1402363_mcb_redirect.patch
Review of attachment 8913600 [details] [diff] [review]:
-----------------------------------------------------------------
lgtm
Attachment #8913600 -
Flags: review?(kmckinley) → review+
Comment 25•7 years ago
|
||
Comment on attachment 8913602 [details] [diff] [review]
bug_1402363_mcb_redirect_test.patch
Review of attachment 8913602 [details] [diff] [review]:
-----------------------------------------------------------------
lgtm
Attachment #8913602 -
Flags: review?(kmckinley) → review+
Assignee | ||
Comment 26•7 years ago
|
||
(In reply to Honza Bambas (:mayhemer) from comment #23)
> Why exactly NS_ERROR_DOM_BAD_URI?
No particular reason. Mostly because we use NS_ERROR_DOM_BAD_URI when blocking redirects within nsCORSListenerProxy and nsCSPService.
Assignee | ||
Comment 27•7 years ago
|
||
Just chatted with freddyb, we both think it's sec-moderate.
Keywords: sec-moderate
Assignee | ||
Comment 28•7 years ago
|
||
I also verified that https://firefox-redirect-bug.glitch.me/ works correctly now and both requests fail.
Assignee | ||
Comment 29•7 years ago
|
||
Comment on attachment 8913600 [details] [diff] [review]
bug_1402363_mcb_redirect.patch
Approval Request Comment
Currently we don't block mixed content redirects. If an HTTPS page hits a 302 to HTTP, then mixed content blocker should block the load which we didn't do correctly.
[Feature/Bug causing the regression]:
Bug 418354 - Mixed content detection does not take redirection into account
[User impact if declined]:
End users might get a false impression, because the pages state seems to be secure but the underlying redirect from HTTPS to HTTP exposes the user to tampering and eavesdropping attacks.
[Is this code covered by automated tests?]:
Yes
[Has the fix been verified in Nightly?]:
not yet.
[Needs manual test from QE? If yes, steps to reproduce]:
Not really, but there is also the testpage from comment 0.
[List of other uplifts needed for the feature/fix]:
XXX
[Is the change risky?]:
Nope, not risky, we are just correctly cancelling the old channel on the network layer if redirect is blocked.
[Why is the change risky/not risky?]:
see previous
[String changes made/needed]:
no
Attachment #8913600 -
Flags: approval-mozilla-beta?
Assignee | ||
Comment 30•7 years ago
|
||
Comment on attachment 8913602 [details] [diff] [review]
bug_1402363_mcb_redirect_test.patch
Approval Request Comment
See previous comment.
Attachment #8913602 -
Flags: approval-mozilla-beta?
Assignee | ||
Comment 31•7 years ago
|
||
Maybe this bug is the reason we had to disable the mcb_redirect tests when landing Bug 418354, see:
https://bugzilla.mozilla.org/attachment.cgi?id=8507083&action=diff
I filed Bug 1404812 to investigate.
Comment on attachment 8913600 [details] [diff] [review]
bug_1402363_mcb_redirect.patch
Sec-mod, still early in beta cycle, Beta57+
Attachment #8913600 -
Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #8913602 -
Flags: approval-mozilla-beta? → approval-mozilla-beta+
Assignee | ||
Comment 33•7 years ago
|
||
Comment 34•7 years ago
|
||
uplift |
https://hg.mozilla.org/releases/mozilla-beta/rev/e28505bd7c04
https://hg.mozilla.org/releases/mozilla-beta/rev/37d18f6628dc
Flags: in-testsuite+
https://hg.mozilla.org/mozilla-central/rev/2773796df8a3
https://hg.mozilla.org/mozilla-central/rev/fcefba24074f
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
Updated•7 years ago
|
Group: dom-core-security → core-security-release
Comment 36•7 years ago
|
||
Is this something you think we should consider for ESR52 backport as well? Note that we typically only take sec-high/crit patches unless there's a good reason for doing so.
Flags: needinfo?(ckerschb)
Assignee | ||
Comment 37•7 years ago
|
||
(In reply to Ryan VanderMeulen [:RyanVM] from comment #36)
> Is this something you think we should consider for ESR52 backport as well?
> Note that we typically only take sec-high/crit patches unless there's a good
> reason for doing so.
Dan, what do you think? I would rather like to see that fixed in ESR52 as well, allowing mixed content redirects might be troublesome even though we only categorized this bug as sec-moderate.
Flags: needinfo?(ckerschb) → needinfo?(dveditz)
Updated•7 years ago
|
Updated•7 years ago
|
Whiteboard: [tor][domsecurity-active] → [tor][domsecurity-active][adv-main57+]
Updated•7 years ago
|
Alias: CVE-2017-7835
Updated•7 years ago
|
Flags: qe-verify-
Whiteboard: [tor][domsecurity-active][adv-main57+] → [tor][domsecurity-active][adv-main57+][post-critsmash-triage]
Updated•6 years ago
|
Group: core-security-release
You need to log in
before you can comment on or make changes to this bug.
Description
•