O Request, Where Art Thou From?
There may be a reason why you don’t want to use tokens for CSRF protection, such as having a stateless setup or not wanting to use a lot of resources. Perhaps the application doesn’t have strict security requirements. For any of these situations, you can just use the standard information the browser includes in a typical request.
Modern browsers send Referer and Origin headers with requests when navigating through links or submitting forms on a web page. They give the application information about which page the request originated from and can be used for both tracking and CSRF protection. You can look at the headers to determine if the form did originate on your site.
Attackers can spoof headers if they’re ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access