Bug 272740 - NUL bytes in header values allowed for fetch-API
Summary: NUL bytes in header values allowed for fetch-API
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 17
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: BrowserCompat, InRadar
Depends on:
Blocks:
 
Reported: 2024-04-16 03:57 PDT by jannis.rautenstrauch
Modified: 2024-05-05 07:31 PDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jannis.rautenstrauch 2024-04-16 03:57:17 PDT
Fetching a resource that contains a NUL byte in a header value using the fetch API does not result in an error in WebKit and even things such as HSTS work on such responses.
Firefox and Chromium throw a network error for such cases.

Example response: `strict-transport-security: max-age=20; in\u0000cludeSubDomains`
Example URL: http://sub.headers.websec.saarland/_hp/tests/upgrade-hsts.sub.html?resp_type=parsing&browser_id=1&label=HSTS&first_id=32575&last_id=32575&scheme=http&t_resp_id=32575&t_element_relation=direct_direct&t_resp_origin=https://sub.headers.websec.saarland

Seems to only be happening for `fetch`, img responses with \x00 in a header value seem to be blocked: https://bugs.webkit.org/show_bug.cgi?id=272739
Comment 1 Radar WebKit Bug Importer 2024-04-23 03:59:59 PDT
<rdar://problem/126913166>
Comment 2 youenn fablet 2024-04-29 05:46:00 PDT
This seems to be restricted to no-cors case, where we do a sanitization in networking process, while we should check for nul headers in the response before.
Comment 3 youenn fablet 2024-04-29 06:41:42 PDT
Pull request: https://github.com/WebKit/WebKit/pull/27869
Comment 4 youenn fablet 2024-04-30 01:34:58 PDT
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/45980
Comment 5 EWS 2024-05-05 07:31:53 PDT
Committed 278389@main (85f98322e6a6): <https://commits.webkit.org/278389@main>

Reviewed commits have been landed. Closing PR #27869 and removing active labels.