Bug 251936
| Summary: | A Headers object with "request-no-cors" guard will accept non-safelisted headers with empty values | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Andreu Botella <abotella> |
| Component: | WebCore Misc. | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | achristensen, annevk, karlcow, webkit-bug-importer, wilander, youennf |
| Priority: | P2 | Keywords: | BrowserCompat, InRadar |
| Version: | Other | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| See Also: | https://github.com/web-platform-tests/wpt/pull/38431 | ||
Andreu Botella
Per the fetch spec, if a Headers object has the "request-no-cors" guard, appending or setting a header will only succeed if the header is a no-CORS-safelisted request header (https://fetch.spec.whatwg.org/#no-cors-safelisted-request-header), which only includes the `Accept`, `Accept-Language`, `Content-Language` and `Content-Type` header names, and doesn't include all header values.
However, Webkit seems to accept any header as long as its value is the empty string.
A test for this is running the following code on the console:
const request = new Request("https://example.com", {mode: "no-cors"});
request.headers.append("X-Test", "fsdfsd");
request.headers.has("X-Test"); // false
request.headers.append("X-Test", "");
request.headers.has("X-Test"); // true
The last line prints false in Firefox and Chromium.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Andreu Botella
Pull request: https://github.com/WebKit/WebKit/pull/9825
Karl Dubost
https://searchfox.org/wubkat/rev/8657349b48cece83215d92556db34a0a6ed55040/Source/WebCore/platform/network/HTTPParsers.cpp#841-857
and
https://searchfox.org/wubkat/rev/8657349b48cece83215d92556db34a0a6ed55040/Source/WebCore/platform/network/HTTPParsers.cpp#841-857
Radar WebKit Bug Importer
<rdar://problem/105207779>
Karl Dubost
Second link should have been
https://searchfox.org/wubkat/rev/8657349b48cece83215d92556db34a0a6ed55040/Source/WebCore/Modules/fetch/FetchHeaders.cpp#157-178
EWS
Committed 260066@main (2fbadf6b9f23): <https://commits.webkit.org/260066@main>
Reviewed commits have been landed. Closing PR #9825 and removing active labels.