HeaderDial › Guides

How to change or remove the Origin header to test CORS and CSRF checks

To test how your server treats a foreign or missing Origin, add a request header named Origin in HeaderDial, set it to a value such as https://evil.example (or choose remove), and limit it to the host you are testing. In Chrome 159 and Firefox 158 the server received the changed value on fetch(), XHR, CORS preflights and form posts. The browser's own CORS check is not affected: it still compares the response with the page's real origin. So this tests your server's logic, not the browser's.

When browsers send Origin

Origin holds only scheme, host and port, such as https://app.example.com. Browsers send it on cross-origin fetch() and XHR calls (every CORS request), and on requests other than GET and HEAD, including form posts. A same-origin fetch() with GET carries none, and neither does an ordinary link or an image loaded without the crossorigin attribute. Pages with an opaque origin, such as sandboxed iframes, send the literal value null.

Servers use it in two ways. CORS code decides which Access-Control-Allow-Origin to answer with. CSRF defences compare it with the site's own origin before accepting a state-changing request; Django and Rails, among others, can do this in addition to tokens.

What we measured

We tested in November 2026 with HeaderDial 0.2.0, Chrome 159 and Firefox 158. A page on http://127.0.0.1:port made requests to itself and to http://localhost:port, a different site. A local server logged the headers it received. Both browsers behaved identically. Edge uses Chrome's engine, but we did not test it separately.

RequestNo ruleOrigin set to https://evil.exampleOrigin removed
Same-origin fetch() GETnoneevil.examplenone
Same-origin fetch() POSTreal originevil.examplenone
Cross-origin fetch() GET and POST, XHR POSTreal originevil.examplenone
CORS preflight (OPTIONS)real originevil.examplenone
HTML form POST, same- and cross-originreal originevil.examplenone

The Sec-Fetch-Site header kept its true value (same-origin or cross-site) in every case.

Then we varied the server's Access-Control-Allow-Origin response, to see whether the page could read the answer:

Server answered withNo ruleOrigin set to evil.example
*readablereadable
The request's Origin, reflectedreadableblocked
The page's real originreadablereadable
https://evil.exampleblockedblocked

The browser checks the response against the origin the page really has. A server that reflects the request's Origin echoed https://evil.example, which did not match, so the call failed. A server that answered with the real origin passed, even though it had seen the forged one. With Origin removed, the reflecting server answered null and the call was blocked too.

What to test with it

Steps

  1. Click the HeaderDial icon. In the site-access banner, choose Allow on all sites. If you allow single hosts instead, allow both the page's host and the API host.
  2. Click + Request header, type Origin (it is in the suggestions) and enter the origin to send, without a path: https://evil.example. Or set the operation to remove. Browsers don't allow appending to Origin, so append becomes set.
  3. Open Where it applies, click + Only on…, choose Domain and enter the host that receives the requests.
  4. For CSRF tests, tick POST (and PUT, PATCH, DELETE if you use them) under Methods (none ticked = all), so page loads and reads keep working. Preflights are separate OPTIONS requests, so they are changed only when OPTIONS is ticked or no method is.
  5. Repeat the action and check the status code and response headers in the DevTools Network panel, and the request in your server log.

The curl equivalent

# CSRF check: expect 403
curl -i -X POST -H "Origin: https://evil.example" -d "amount=1" https://app.example.com/transfer

# CORS allow-list: which Access-Control-Allow-Origin comes back?
curl -si -H "Origin: https://evil.example" https://api.example.com/data | grep -i '^access-control'

curl does no CORS checking, so it shows exactly what the server answers. That is also the point of this whole exercise: any client outside a browser can send any Origin.

Pitfalls

CORS protects users from other websites; it does not protect your server. Never treat a matching Origin as authentication. Changing it in the browser only shows what a script or curl can already do.

Add to ChromeFirefox: coming soon