-
Notifications
You must be signed in to change notification settings - Fork 75
Description
The fetch API allows callers to set headers on the given request via the headers property on the RequestInit object. However, this explicitly forbids certain headers from being set; these are called forbidden header names. These headers are instead set by the browser, and often have security considerations.
One such header is the Origin header, which indicates the origin initiating the request. This allows servers to restrict which data they allow in a cross-origin context. By design, the browser does not allow websites to modify this header, since that would allow websites to imitate a same-site request even if they were cross-site.
However, extensions, by design, can modify the Origin header by listening for the request in the declarativeNetRequest or webRequest APIs and modifying the header there. Additionally, requests made from an extension origin to an origin to which the extension has access are already treated as same-site requests (and do not have the origin header set by the browser). This is not a security risk, as we limit this to extensions to which the extension has host permission (and could thus run scripts directly upon).
We would like to investigate allowing extensions to set these headers directly in the fetch API (from a suitably-trusted caller), rather than needing to separately monitor and modify the request via declarativeNetRequest or webRequest. This results in simpler, cleaner code for extensions and a significantly more performant operation.
To support this, we would like to work with the editors of other specifications to investigate the feasibility of modifying the web specification for the fetch API to indicate websites may not set forbidden header names, but that doing this may be allowed by the user agent for certain contexts, such as extensions. This follows discussions we have had about ensuring new behavior we add is covered by specifications and that we are not introducing new behavior which is undocumented and cannot benefit other clients that may have similar requirements.