by stopcyring · 13y ago · 0 comments
https://owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF...
You cannot both a) forge the Referer header and b) trick the victim's browser into submitting a request - at the same time.
It's true that the REFERER header isn't always included in requests, BUT when it is included, you can consider the request cookies you receive plus the REFERER header accurate when taken together, barring a browser vulnerability. If there is no browser vulnerability, the attacker doesn't get to mess with the REFERER header on the victim's browser.
Note: It is NOT safe to trust an empty REFERER header.
Never. Trust. User. Input.
I'm not saying referrer checking is useless, but once again, you never trust user input. Ever. If you follow that rule you're decreasing attack vectors to essentially social engineering, brute force, and complex technological exploits using buffer overflows and the like (which I guess is still kind of a side effect of trusting user input).
"Although it is trivial to spoof the referer header on your own browser, it is impossible to do so in a CSRF attack."
(https://owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF...)