Weedpacket;11052947 wrote:That header is user-supplied data and as such it's just as trustworthy as any other user-supplied data. They may decline to send it at all.
What weedpacket means to suggest is that this value is (optionally) supplied by the user themselves as part of their page request -- it comes directly from the user! They could supply anything they want including nothing at all. In my opinion, checking it will provide little real security, but it may have the practical effect of introducing one more hurdle to bad guys who are screwing around.
dalecosp wrote:So HTTP_REFERER should contain the URL of your login form, and if it doesn't, you could tell the user to come back when they have a browser that is ready to play nice....
Dalecosp indirectly points out that a user's browser may not "play nice." I think most reputable browsers will take care to supply a correct HTTP_REFERRER value, but there's always a chance some clown will have some weird or ancient browser that fails to play nice.
As for the recommendations:
Risk:
• It may be possible to steal or manipulate customer session and cookies, which might be used to impersonate a legitimate user, allowing the hacker to view or alter user records, and to perform transactions as that user
Causes:
• Insufficient authentication method was used by the application
Fix:
Validate the value of the "Referer" header, and use a one-time-nonce for each submitted form
Difference:
Header manipulated from: https://dev.abc123.com/login.php to: http://bogus.referer.ibm.com
This does seem like a pragmatic recommendation. They suggest that you:
Prevent CSRF attacks by displaying a nonce or some one-time token in the form which is submitted with the form and can only be validated by your server -- this typically involves storing some value in session. The basic idea is that this token is generated by your site and can ONLY be validated by your site to prevent some a-hole spoofing your login page and tricking users into entering their login credentials.
Check the HTTP_REFERER supplied with the request because most legitimate users should be using a well-behaved, modern browser that will honestly report this HTTP_REFERER value. This should effectively limit the exposure of your users to sneaky hacks.