Welcome Guest, Not a member yet? Register   Sign In
MY_Form_Validation w/ spam and CSRF protection
#6

[eluser]WanWizard[/eluser]
@n0xie:

If you also make the form field name random, how do you figure out which of the elements in the POST contains your nonce? Do you simply check the existence of the generated name (and if it exists, check the nonce)?

One of the issues I had with a simple key=>value session variable for the nonce was that a user can, within a session, have several screens open, all with forms. So you need to be able to track multiple issued nonces at once. I also use the nonce protection to protect against double posting (p.e. back button usage) by storing used nonces separately, with an expiry timestamp. If a form is posted with an invalid nonce, but the nonce exists in the used-list, I can issue an appropriate error message.

My template library automatically inserts nonce's in forms, and I've extended the form validation library so the run() method checks and validates the nonce as well. This way every form is automatically protected, and the developer doesn't have to worry about dealing with CSRF protection.


Messages In This Thread
MY_Form_Validation w/ spam and CSRF protection - by El Forum - 06-07-2010, 10:50 AM
MY_Form_Validation w/ spam and CSRF protection - by El Forum - 06-07-2010, 02:28 PM
MY_Form_Validation w/ spam and CSRF protection - by El Forum - 06-07-2010, 04:16 PM
MY_Form_Validation w/ spam and CSRF protection - by El Forum - 06-08-2010, 03:17 AM
MY_Form_Validation w/ spam and CSRF protection - by El Forum - 06-08-2010, 04:00 AM
MY_Form_Validation w/ spam and CSRF protection - by El Forum - 06-08-2010, 04:52 AM
MY_Form_Validation w/ spam and CSRF protection - by El Forum - 06-08-2010, 05:27 AM
MY_Form_Validation w/ spam and CSRF protection - by El Forum - 06-08-2010, 06:55 AM
MY_Form_Validation w/ spam and CSRF protection - by El Forum - 07-09-2010, 04:49 PM
MY_Form_Validation w/ spam and CSRF protection - by El Forum - 07-10-2010, 12:31 AM
MY_Form_Validation w/ spam and CSRF protection - by El Forum - 07-10-2010, 01:46 AM
MY_Form_Validation w/ spam and CSRF protection - by El Forum - 07-10-2010, 02:48 AM
MY_Form_Validation w/ spam and CSRF protection - by El Forum - 07-10-2010, 11:34 AM
MY_Form_Validation w/ spam and CSRF protection - by El Forum - 07-11-2010, 10:53 AM
MY_Form_Validation w/ spam and CSRF protection - by El Forum - 07-12-2010, 03:50 AM
MY_Form_Validation w/ spam and CSRF protection - by El Forum - 07-12-2010, 10:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB