views:

141

answers:

1

Will this idea work? It seems pretty stupid, because my app is simply checking that the browser sent two copies of the same information (ie the session key).

Also, remembering to make this check sounds very tedious. Do web frameworks such as Rails and CakePHP have things that make it easier to write XSRF-proof web apps?

+2  A: 

Assuming that the session key is not leaked (which could happen if your PHP is poorly configured and uses session.use_trans_sid) and you are not vulnerable to session fixation attacks, yes, this is secure. This is because a request forger cannot read your cookies, and thus does not know what the correct value is.

You may be interested in CSRF Magic, which claims to allow you to protect your application by including a single file.

Edward Z. Yang
Thanks, Ambush Commander! If my session key is leaked, won't I have much bigger problems? I thought the point of XSRF was that an attacker uses it because he can't gain access to stuff like that.
allyourcode
Is what I've suggested a common technique?
allyourcode