Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for information security professionals. It's 100% free, no registration required.

This is not my main anti-CSRF mechanism; I know that https requests don't have a referer header; I know users or firewalls can remove it or set to an arbitrary fixed value.

I intend this mechanism just as a possible added security layer preventing CSRF in case my main mechanism is bypassed for some reason.

My code will be something like this:

exit('Anti-CSRF mechanism!');

I think this has no support and usability problems. right?

share|improve this question

1 Answer 1

Although checking the HTTP referer header is a method of mitigating CSRF, this proposed PHP implementation is trivial to bypass and therefore does not improve security. If the CSRF exploit originates from an HTTPS site then the referer will be absent. The lack of a referer should be considered an attack. However, a much better anti-csrf method is using a synchronization token.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.