Implement additional CORS restrictions
Categories
(Core :: DOM: Networking, enhancement, P1)
Tracking
()
Tracking | Status | |
---|---|---|
firefox65 | --- | fixed |
People
(Reporter: annevk, Assigned: jkt)
References
(Blocks 1 open bug)
Details
(Keywords: dev-doc-complete, Whiteboard: [necko-triaged])
Attachments
(1 file)
Updated•6 years ago
|
Reporter | ||
Comment 1•6 years ago
|
||
Comment 2•6 years ago
|
||
Comment 3•6 years ago
|
||
Assignee | ||
Comment 4•6 years ago
|
||
Assignee | ||
Comment 5•6 years ago
|
||
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Comment 6•6 years ago
|
||
Comment 8•6 years ago
|
||
bugherder |
Updated•6 years ago
|
Comment 10•6 years ago
|
||
Assignee | ||
Comment 11•6 years ago
|
||
Comment 12•6 years ago
|
||
The main MDN CORS article is this one: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
Certain HTTP header reference pages like "Accept-Language" mention "CORS-safelisted request-header: yes"
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language
Which then links to a page
https://developer.mozilla.org/en-US/docs/Glossary/Simple_header
I'm not sure I understand the new restrictions introduced here, but can you have a look and see if we should mention this on any of these pages?
If not, then I'm happy to just have it on the Fx 65 rel notes and we can set this bug to "dev-doc-complete".
Updated•6 years ago
|
Assignee | ||
Comment 13•6 years ago
|
||
It's a little complex I guess and I dunno if it's worthy of MDN, however it is at least inconsistent.
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS mentions
Content-Type
(but note the additional requirements below)- The only allowed values for the
Content-Type
header are:application/x-www-form-urlencoded
multipart/form-data
text/plain
This is somewhat true but ignores that there can be a boundary in the Content-Type
like text/plain; charset=US-ASCII
which is somewhat explained in the parsing of the essence: https://mimesniff.spec.whatwg.org/#mime-type-miscellaneous the essence is used to check the allowed values in that list on MDN.
The changes here are to narrow what the values of a CORS-safelisted request-header
are permissable under CORS. This link is already in MDN and perhaps it's worthwhile just mentioning there are caveats to the values?
So for example the change reduced the values permissible as a safelisted header:
Accept-Language
andContent-Language
can only be values with0-9
,A-Z
,a-z
, space or*,=.;=
Content-Type
andAccept
can't contain https://fetch.spec.whatwg.org/#cors-unsafe-request-header-byte which is:"():<>?@[\]{}
, Delete, Tab and control characters: 0x00 to 0x19
For values not considered safelisted then we use a preflight request to check that the server can handle these values. The change is mostly to prevent websites attacking webservers (local or remote) that don't do correct security checking; they are leaking data or adding more functionality than they should be doing to a third party.
Comment 14•6 years ago
|
||
Thanks so much for your answer, :jkt! This sheds some light.
I'm cc'ing Mike aka sideshowbarker who is one of the main contributors to our CORS docs and knows a lot more about this than me. Mike, would you be willing to help out with updates here?
I think we could mention the reduced values permissible as a safelisted header on these pages:
https://developer.mozilla.org/en-US/docs/Glossary/Simple_header
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Language
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type
Comment 15•6 years ago
|
||
(In reply to Florian Scholz [:fscholz] (MDN) from comment #14)
I'm cc'ing Mike aka sideshowbarker who is one of the main contributors to our CORS docs and knows a lot more about this than me. Mike, would you be willing to help out with updates here?
Yeah, I’d be happy to put some time into this
Comment 16•5 years ago
|
||
This came up again here: https://bugzilla.mozilla.org/show_bug.cgi?id=1309358#c30
As part of that, I've now updated these pages:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers
https://developer.mozilla.org/en-US/docs/Glossary/CORS-safelisted_request_header (especially the additional restriction section)
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Language
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type
Marking as dev-doc-complete but let me know if there is more left to do. Would also appreciate a review if you have a minute, :sideshowbarker.
Thanks!
Description
•