![]() |
|
Article Options |
Implementing CSRF Protection in modifications
by
![]() Rating:
![]() With the new version released today for vBulletin 3.6.10 and 3.7.0 RC4, a new protection against Cross Site Request Forgery (CSRF) has been introduced. This new protection might influence the coding in modifications. Scott MacVicar took the time to compile a short explanation on this new protection for the coders on vBulletin.org: Changes for CSRF protection with third party modifications Cross Site Request Forgery (CSRF) involves taking advantage of the stateless nature of HTTP, there are no ways to ensure the exact origin of a request, its also not possible to detect what was actually initiated by a user and what was forced by a third party script. A token was added to the latest version of each of the vBulletin products, with the release of 3.6.10 and 3.7.0 RC4 it is no longer possible to submit a POST request directly without passing in the known token. The addition of a security token for each POST request removes the ability for a remote page to force a user to submit an action. At the moment this protection will only apply to vBulletin files and third party files will need to opt into this protection and add the appropriate hidden field. This was done to preserve backwards compatibility. Adding Protection to your own files To opt your entire file into CSRF protection the following should be added to the top of the file under the define for THIS_SCRIPT.
With this change all POST requests to this file will check for the presence of the securitytoken field and compare it to the value for the user, if its wrong an error message will be shown and execution with halt. If this value is set to false then all CSRF protection is removed for the file, this is appropriate for something that intentionally accepts remote POST requests. You should always add this to your file, even if you don't think the script is ever going to receive POST requests. An absence of this defined constant within your files will result in the old style referrer checking being performed. Template Changes The following should be added to all of the forms which POST back to vBulletin or a vBulletin script. This will automatically be filled out with a 40 character hash that is unique to the user.
Again it is worthwhile adding this to your templates even if it is currently not using the CSRF protection. Exempting Certain Actions It may be appropriate to exempt a particular action from the CSRF protection, in this case you can add the following to the file.
The above example would exempt both example.php?do=action_one and example.php?do=action_two from the CSRF protection, if the CSRF_SKIP_LIST constant is defined with no value then it will exempt the default action. If the skip list needs to be changed at runtime is it available within the registry object, using the init_startup hook the following code would be used to exempt 'example.php?do=action_three'.
The following members like this post: Chris8
|
||||||||||||||||
Views: 103298
|
Comments |
#2
|
||||
|
||||
Also, you need to add the security token to AJAX requests using POST. This can be simply added using the variable "SECURITYTOKEN". An example is below.
__________________
Former vBulletin.org Staff Member View My Modifications 29 Releases and Counting... Latest Modification: dmActivityStream - vBookie Integration (4.x) Please do not PM me to ask for support - please use the relevant thread or forum. No members have liked this post.
|
#3
|
||||
|
||||
If you wanna search all template that you need to edit to add "<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />" you can use that query in your MySQL database:
--------------- Added 24 Apr 2008 at 18:00 --------------- calendarjump, FAQ, forumjump, WHOSONLINE don't need to be edited if you haven't modded it No members have liked this post.
Last edited by RedFoxy; 24 Apr 2008 at 18:00. Reason: Auto-Merged DoublePost |
#4
|
|||
|
|||
wow now THIS is a headache. i have security token errors all over my forum....
--------------- Added 24 Apr 2008 at 11:31 --------------- so WHAT does this mean? that we have to redo ALL of our mods and templates with this CSRF or whatever code??? No members have liked this post.
Last edited by GoTTi; 24 Apr 2008 at 19:55. Reason: Auto-Merged DoublePost |
#5
|
||||
|
||||
It means you need to add the one line of HTML above to your templates and submission forms that are causing the errors.
__________________
Wayne Luke Get started with your own social network. Purchase and download vBulletin today. No members have liked this post.
|
#6
|
|||
|
|||
wow now this is retarded....
No members have liked this post.
|
#7
|
|||
|
|||
Originally Posted by Wayne Luke
Can someone give an example on how to do that? I am not a coder and get lost with this easily...now for the trained eye it's no doubt a piece of cake. For instance I was using the Cyb PayPal Donate Mod and upgrading to 3.6.10 broke it with that security token update. I posted in that thread yesterday but I don't think the creator has been around.
![]()
No members have liked this post.
|
#8
|
|||
|
|||
OK...... wanna explain this for the SLOW?
which templates SPECIFICLY do we need to add WHAT SPECIFIC code? to make 3rd party mods (vb.com) to WORK correctly on our sites? I think a few 100 people are STUCK on what to do even tho it was explained from "coders", leaving "non-coders" and only editors of codes or mods such as myself BAFFLED as to what Exactly and how Exactly to do the such above instructions... No members have liked this post.
|
#9
|
||||
|
||||
Originally Posted by Aclikyano
You must add this to any form on your site. I haven't tried the query above, but it should work and you can add them.
![]()
__________________
Former vBulletin.org Staff Member Do not request support through any other means except the forums. Useful Post With Links on Learning How To Develop vBulletin Plugins Latest Modification: Stop Forum Spam Integration No members have liked this post.
|
#10
|
||||||||
|
||||||||
Originally Posted by RedFoxy
Does this MySQL query mean that it will insert the ![]()
after each instances of the following code
This will affect only templates that need the security token embedded right? No members have liked this post.
|
#11
|
|||
|
|||
=/ I dont get it, I have errors now too.. with RC 4
No members have liked this post.
|
#12
|
|||
|
|||
What are the "forms"? and where do we edit them?
No members have liked this post.
|
#13
|
|||
|
|||
everyone has errors ^^ by FORMS i think he means TEMPLATES. (style settings, etc)
No members have liked this post.
|
#14
|
||||
|
||||
Originally Posted by Aclikyano
Forms are not equal to templates but some templates have forms in them. ![]()
A form is anywhere your users can submit data. If you have modifications that submit data and cannot update their templates then you need to post for support in the modification thread. It isn't hard to find out where this needs to go. In your Admin CP under Styles & Template select Search In Templates... Search for: value="$session[sessionhash]" In every template this occurs in add this line directly after the line containing the above, if it doesn't exist already: <input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" /> Save the template.
__________________
Wayne Luke Get started with your own social network. Purchase and download vBulletin today. No members have liked this post.
Last edited by Wayne Luke; 25 Apr 2008 at 19:52. |
![]() |
![]() |
||||
Article | Author | Type | Replies | Last Post |
Show Thread Enhancements Stamps (CSRF protection added) | misr.cc | vBulletin 3.7 Add-ons | 98 | 14 Oct 2012 14:54 |
Add-On Releases vBTube 1.2.9 (CSRF protection added) | Playa82 | vBulletin 3.7 Add-ons | 434 | 22 Jan 2012 23:08 |
Mini Mods [ITECH] Inferno CSRF Auto Protection | Inferno Tech | vBulletin 3.6 Add-ons | 15 | 02 Nov 2010 04:01 |
«
Previous Article
|
Next Article
»
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Article Options | |
|
|
New To Site? | Need Help? |
All times are GMT. The time now is 20:54.