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.
| Request | No rule | Origin set to https://evil.example | Origin removed |
|---|---|---|---|
Same-origin fetch() GET | none | evil.example | none |
Same-origin fetch() POST | real origin | evil.example | none |
Cross-origin fetch() GET and POST, XHR POST | real origin | evil.example | none |
CORS preflight (OPTIONS) | real origin | evil.example | none |
| HTML form POST, same- and cross-origin | real origin | evil.example | none |
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 with | No rule | Origin set to evil.example |
|---|---|---|
* | readable | readable |
The request's Origin, reflected | readable | blocked |
| The page's real origin | readable | readable |
https://evil.example | blocked | blocked |
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
- CSRF origin checks. Submit a form or
POSTwith a foreign Origin. A protected endpoint should refuse it, typically with403. Then remove Origin and see what happens: does the server fall back toRefereror a token, or let it through? - CORS allow-lists. Send an origin that should not be allowed and look at the response headers. If the server answers
Access-Control-Allow-Origin: https://evil.example, it reflects any origin. Combined withAccess-Control-Allow-Credentials: true, that lets any site read logged-in responses. - Origin-based routing. Multi-tenant back ends sometimes pick a tenant or configuration from Origin. You can try each one from a single page.
Steps
- 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.
- 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. - Open Where it applies, click + Only on…, choose Domain and enter the host that receives the requests.
- 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.
- 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
- You may break your own page. If the server allows origins by reflecting them, the page's calls start failing while the rule is on, as in the table above. Limit the rule to the endpoints under test.
- Other headers still tell the truth.
Sec-Fetch-Siteis unchanged andRefererstill names the real page. A server that checks them is not fooled by an Origin rule alone; see changing the Referer header. An extension can changeSec-Fetch-Sitetoo, though: see which headers browsers won't let you change. - Caches. If a CDN caches responses whose
Access-Control-Allow-Origindepends on Origin, it needsVary: Origin. Otherwise one origin's answer can be served to another. - Switch it off afterwards. Give the row an expiry such as 15 min, or press Alt+Shift+D to pause every profile.
Add to ChromeFirefox: coming soon