Closed
Bug 1200869
Opened 9 years ago
Closed 9 years ago
CORS preflight cache poisoning with a CORS header being mistaken with another CORS header
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla43
People
(Reporter: ehsan.akhgari, Assigned: ehsan.akhgari)
References
Details
(Keywords: csectype-sop, sec-high, Whiteboard: [post-critsmash-triage][adv-main41+][adv-esr38.3+])
Attachments
(1 file)
3.01 KB,
patch
|
sicking
:
review+
abillings
:
approval-mozilla-aurora+
abillings
:
approval-mozilla-beta+
lizzard
:
approval-mozilla-esr38+
abillings
:
sec-approval+
|
Details | Diff | Splinter Review |
There is a bug in nsCORSPreflightListener::AddResultToCache() in that we call GetResponseHeader() without emptying out the out value passed to it, which causes us to mistake the value of a header that we have checked before with the next header if the response doesn't include the next header. This hits us in three cases:
* If the preflight response includes Access-Control-Max-Age, but not Access-Control-Allow-Methods, when we check for Access-Control-Allow-Methods, we mistakenly use the value of the Access-Control-Max-Age header. Even though Access-Control-Max-Age can only be a string parseable as a number, surprisingly nothing actually fails an attempt to XHR with a method equal to such a string!
* If the preflight response includes Access-Control-Allow-Methods but not Access-Control-Allow-Headers, we use the value of the Access-Control-Allow-Methods instead of the Access-Control-Allow-Headers.
* If the preflight response includes Access-Control-Max-Age but not Access-Control-Allow-Headers nor Access-Control-Allow-Methods, when we check for Access-Control-Allow-Headers, we mistakenly use the value of the Access-Control-Max-Age header.
I think the third bug is not possible to trigger from script since there is no way to force a preflight without using a non-simple method or header, and the CORS preflight will fail in that case without either an Access-Control-Allow-Headers or an Access-Control-Allow-Methods header.
Going back in the history, I think we have had this bug since forever. It definitely predates bug 644476, similar to bug 1200856. I didn't look back further.
Assignee | ||
Comment 1•9 years ago
|
||
Attachment #8655726 -
Flags: review?(jonas)
Assignee | ||
Updated•9 years ago
|
Keywords: csectype-sop,
sec-high
Updated•9 years ago
|
Group: core-security → dom-core-security
Assignee | ||
Comment 2•9 years ago
|
||
Comment on attachment 8655726 [details] [diff] [review]
Empty the header value for code hygiene
Review of attachment 8655726 [details] [diff] [review]:
-----------------------------------------------------------------
Arguably that's a pretty bad API on the nsIHttpChannel. Ideally I'd like to see this fixed there since I'd imagine this bites more callsites. But up to you and the necko peers.
r=me on this patch either way.
Attachment #8655726 -
Flags: review?(jonas) → review+
Assignee | ||
Comment 4•9 years ago
|
||
I agree, this is a terrible API. Filed bug 1201229 for fixing that.
Assignee | ||
Comment 5•9 years ago
|
||
Comment on attachment 8655726 [details] [diff] [review]
Empty the header value for code hygiene
[Security approval request comment]
How easily could an exploit be constructed based on the patch? This requires knowledge of the semantics of GetResponseHeader, so I don't think a reader can immediately figure out what this patch does (I'm assuming that we don't check in the test at the same time.)
Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem? I think the commit message is sneaky enough, and I don't think we should land the tests before this fix gets shipped to the release channel.
Which older supported branches are affected by this flaw? All branches.
If not all supported branches, which bug introduced the flaw?
Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be? The backports are trivial and very low risk.
How likely is this patch to cause regressions; how much testing does it need? I've tested it locally and on try and the problem is also quite well understood. I'm not too much worried about regressions from this.
Attachment #8655726 -
Flags: sec-approval?
Attachment #8655726 -
Flags: approval‑mozilla‑b2g37_v2_2r?
Attachment #8655726 -
Flags: approval-mozilla-release?
Attachment #8655726 -
Flags: approval-mozilla-esr38?
Attachment #8655726 -
Flags: approval-mozilla-esr31?
Attachment #8655726 -
Flags: approval-mozilla-beta?
Attachment #8655726 -
Flags: approval-mozilla-b2g37?
Attachment #8655726 -
Flags: approval-mozilla-aurora?
Comment 6•9 years ago
|
||
sec-approval+ for trunk. We should take this on Aurora, Beta, and ESR38 as well. ESR31 is at EOL so we don''t need it there.
status-firefox40:
--- → wontfix
status-firefox41:
--- → affected
status-firefox42:
--- → affected
status-firefox43:
--- → affected
status-firefox-esr31:
--- → wontfix
status-firefox-esr38:
--- → affected
tracking-firefox41:
--- → +
tracking-firefox42:
--- → +
tracking-firefox43:
--- → +
tracking-firefox-esr38:
--- → 41+
Comment 7•9 years ago
|
||
Comment on attachment 8655726 [details] [diff] [review]
Empty the header value for code hygiene
Also, this should land without tests until it is released publicly.
Attachment #8655726 -
Flags: sec-approval?
Attachment #8655726 -
Flags: sec-approval+
Attachment #8655726 -
Flags: approval-mozilla-release?
Attachment #8655726 -
Flags: approval-mozilla-esr31?
Attachment #8655726 -
Flags: approval-mozilla-beta?
Attachment #8655726 -
Flags: approval-mozilla-beta+
Attachment #8655726 -
Flags: approval-mozilla-aurora?
Attachment #8655726 -
Flags: approval-mozilla-aurora+
Assignee | ||
Updated•9 years ago
|
Flags: in-testsuite?
Liz, here is another esr38 nom.
Flags: needinfo?(lhenry)
Comment 9•9 years ago
|
||
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla43
Comment 10•9 years ago
|
||
Comment on attachment 8655726 [details] [diff] [review]
Empty the header value for code hygiene
Approved for ESR38
Flags: needinfo?(lhenry)
Attachment #8655726 -
Flags: approval-mozilla-esr38? → approval-mozilla-esr38+
Comment 11•9 years ago
|
||
status-b2g-v2.0:
--- → wontfix
status-b2g-v2.0M:
--- → wontfix
status-b2g-v2.1:
--- → wontfix
status-b2g-v2.1S:
--- → affected
status-b2g-v2.2:
--- → affected
status-b2g-v2.2r:
--- → affected
status-b2g-master:
--- → fixed
Comment 13•9 years ago
|
||
Updated•9 years ago
|
Whiteboard: [post-critsmash-triage]
Comment 14•9 years ago
|
||
Comment on attachment 8655726 [details] [diff] [review]
Empty the header value for code hygiene
https://hg.mozilla.org/releases/mozilla-b2g37_v2_2/rev/d3cb4f28c735
https://hg.mozilla.org/releases/mozilla-b2g37_v2_2r/rev/d3cb4f28c735
https://hg.mozilla.org/releases/mozilla-b2g34_v2_1s/rev/b2a5888625db
Attachment #8655726 -
Flags: approval‑mozilla‑b2g37_v2_2r?
Attachment #8655726 -
Flags: approval-mozilla-b2g37?
Updated•9 years ago
|
Updated•9 years ago
|
Group: dom-core-security → core-security-release
Updated•9 years ago
|
Whiteboard: [post-critsmash-triage] → [post-critsmash-triage][adv-main41+][adv-esr38.3+]
Assignee | ||
Comment 15•9 years ago
|
||
Now that the fixes have been shipped, can I check in the tests (and those of bug 1200856)? Given that I have seen a number of vulnerabilities in CORS preflights lately, I think this area of the code really benefits from having more test coverage.
Assignee | ||
Comment 16•9 years ago
|
||
(In reply to Ehsan Akhgari (don't ask for review please) from comment #15)
> Now that the fixes have been shipped, can I check in the tests (and those of
> bug 1200856)? Given that I have seen a number of vulnerabilities in CORS
> preflights lately, I think this area of the code really benefits from having
> more test coverage.
Flags: needinfo?(abillings)
Comment 17•9 years ago
|
||
Ah yes. Please check in the tests!
Flags: needinfo?(abillings) → needinfo?(ehsan)
Assignee | ||
Updated•9 years ago
|
Flags: needinfo?(ehsan)
Assignee | ||
Comment 18•9 years ago
|
||
Flags: in-testsuite? → in-testsuite+
Updated•9 years ago
|
Group: core-security-release
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•