HeaderDial › Guides

Which HTTP headers browsers won't let an extension change

Far fewer than the "forbidden header" lists suggest. Those lists limit page JavaScript, not extensions. In Chrome 159 and Firefox 158, HeaderDial's declarativeNetRequest rules set and removed Sec-Fetch-Site, Sec-Fetch-Mode, Sec-Fetch-Dest, Sec-Fetch-User, the Sec-CH-UA client hints, Origin, Referer, User-Agent and Accept-Encoding, and could set Cookie and even Host. What did not work: removing Host (both browsers), removing Connection (Chrome) or Priority (Firefox), and changing Content-Length or Transfer-Encoding, which broke the request. On responses, Firefox would not replace an existing Content-Type or Strict-Transport-Security value.

Page JavaScript versus an extension

The Fetch standard lists request headers a page's fetch() or XHR may not set: Host, Content-Length, Connection, Cookie, Origin, Referer, anything starting with Sec- or Proxy-, and more. We sent all of these from a page's fetch(). Both browsers dropped every one of them, so the server received the browser's own values. The exception was User-Agent: Firefox sent the page's value and Chrome did not. A custom header such as X-Custom went through in both.

Extensions are not bound by that list. Chrome documents the ModifyHeaderInfo rules it accepts, and MDN describes Firefox's implementation. Neither page lists the headers that are ignored after a rule has been accepted, which is why we measured it.

Request headers, measured

We checked this with HeaderDial 0.3.0 in Chrome 159.0.8154.6 and Firefox 158.0.1 in November 2026. For each header we added one rule (set to a recognisable value, or remove), loaded a page and sent a fetch() POST, and compared what a local HTTP/1.1 test server received with a run without rules. Edge uses Chrome's engine, but we did not test it separately.

HeaderSetRemove
Sec-Fetch-Site, Sec-Fetch-Mode, Sec-Fetch-Dest, Sec-Fetch-Userworks in bothworks in both
Sec-CH-UA, Sec-CH-UA-Mobile, Sec-CH-UA-Platformworks in both (Firefox does not send them by itself, but sends them when set)works in Chrome; nothing to remove in Firefox
Other Sec- names, such as Sec-Purposeworks in bothnot sent by default
Origin, Referer, User-Agent, Accept, Accept-Encoding, Accept-Language, Content-Type, Upgrade-Insecure-Requestsworks in bothworks in both
Cookieworks in bothour test profile had no cookies; see Cookie and Set-Cookie
Authorization, Proxy-Authorization, Cache-Control, Pragma, DNT, Date, Viaworks in bothnot sent by default
Priorityworks in bothFirefox still sent it; Chrome did not send it over HTTP/1.1 in the first place
Hostworks in both: the server received the new name, and the connection still went to the real addressno effect in either browser
Connectionworks in both (we tried close)no effect in Chrome; removed in Firefox
Keep-Alive, TE, Trailer, Upgrade, Expectsent as set in both; the requests still succeedednot sent by default
Content-Lengthbroke requests: in Chrome every request failed, even with the correct length; in Firefox requests failed unless the value matched the bodyno effect in Chrome; in Firefox the POST went out without it, the server read no body, and the request failed
Transfer-Encodingbroke the request in bothnot sent by default

None of these rules was rejected when it was added. The browser accepted the rule and then sent, ignored or broke the header as shown.

What the API accepts

Some rules are refused when the extension adds them. We called declarativeNetRequest.updateSessionRules directly to see where the two browsers differ:

RuleChrome 159Firefox 158
append to a request header such as X-Customrejected ("Only standard HTTP request headers that can specify multiple values for a single entry are supported")accepted
append to Accept-Language, or to any response headeracceptedaccepted
set with an empty valueacceptedrejected ("value is required for operations append/set")
Header name with a space in itrejectedaccepted
set Hostacceptedaccepted

HeaderDial turns append into set for request headers outside Chrome's list, with a message saying so, and refuses invalid names before the browser sees them. In Firefox, a set row with an empty value would make the browser reject the profile's whole rule. Since HeaderDial 0.3.1 that row alone is skipped, with a message under the editor, and the profile's other headers still apply (checked in Firefox 158.0.1). Fill in a value or switch the row to remove.

Response headers, measured

Here we set or removed each header on a response and read what a fetch() on the page saw, or followed the redirect:

HeaderChrome 159Firefox 158
Server, Date, a custom headerset and remove workset and remove work
X-Frame-Options, Content-Security-Policy, Cache-Control, Access-Control-Allow-Origin, Referrer-Policy, Content-Dispositionset works (we did not test remove here)set works
Content-Typeset and remove workset over an existing value: fetch() still reported the server's type, but navigations and scripts used the new one (see the Content-Type guide)
Strict-Transport-Securityset and remove workremove works; set over an existing value had no effect (see the HSTS guide)
X-Content-Type-Optionsset and remove work, including for script blockingthe page saw the change, but script blocking followed the server's value
Location on a 302the browser followed the rewritten targetthe browser followed the rewritten target
Content-Length set to a wrong valuethe page saw the new value; the body was still completeno visible change
Content-Encoding: gzip on an uncompressed bodyfetch() failedno visible change

Set-Cookie is never readable from page JavaScript, so it needs a different test; see Cookie and Set-Cookie.

Steps: test a header yourself

  1. Click the HeaderDial icon. If the site-access banner appears, choose Allow on all sites or Only <current host>.
  2. Click + Request header (or + Response header), type the header name and a value you will recognise in a log, such as hd-test. Or choose remove.
  3. Open Where it applies, click + Only on…, choose Domain and enter a host whose logs you can read. A broken Content-Length rule on all sites breaks every form post.
  4. If the browser refuses the rule, the reason appears in the problems list under the profile.
  5. Load a page and look at what the server logged, or at an endpoint that echoes request headers. The DevTools Network panel shows what the browser meant to send. A server log shows what actually arrived.

The curl equivalent

Outside a browser nothing is forbidden, which is the main reason a server must not trust any of these headers:

curl -H "Host: admin.internal" http://203.0.113.10/
curl -H "Sec-Fetch-Site: same-origin" -H "Origin: https://app.example.com" -X POST https://app.example.com/api/transfer

Pitfalls

Fetch metadata (Sec-Fetch-*) and Origin protect users from other websites. A cross-site attacker cannot change them in a victim's browser. The user can, with an extension or curl, so they are no defence against the user. Never treat them as authentication.

Add to ChromeFirefox: coming soon