Implementing CSRF Protection in modifications
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. PHP Code:
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. Code:
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" /> 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. PHP Code:
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'. PHP Code:
|
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.
Code:
YAHOO.util.Connect.asyncRequest('POST', scriptpath + '?do=ajax', { |
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:
Quote:
--------------- Added [DATE]1209056453[/DATE] at [TIME]1209056453[/TIME] --------------- calendarjump, FAQ, forumjump, WHOSONLINE don't need to be edited if you haven't modded it |
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??? |
Quote:
|
wow now this is retarded....
|
Quote:
|
<font face="Tahoma">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...</font> |
Quote:
|
Quote:
Code:
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" /> Code:
<input type="hidden" name="s" value="$session[sessionhash]" /> |
=/ I dont get it, I have errors now too.. with RC 4
|
Quote:
|
everyone has errors ^^ by FORMS i think he means TEMPLATES. (style settings, etc)
|
Quote:
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. |
Thank you Wayne. :up:
|
Quote:
|
Quote:
2- Thanks Plugin Doesn't work again and it doesn't work on this mod . :( i have a question to vBulletin Core Dev Team : Sorry , Did you thinking before release a version perfectly ? :confused: because about the 98% percent of the forums i think use the many mods and with your advices no thing gonna change! because no body can modify the all form ! |
Have you even read the first reply to the thread regarding AJAX requests?
|
Quote:
Quote:
|
thanks
|
Quote:
|
I did the find/replace fix and now on several pages I have an extra /> hanging around. Various mods are still not working. Any help is appreciated.
|
Quote:
lt was not too hard:) ... infact it is easy .. the other way is : Quote:
|
Quote:
|
Could some one PLEASE tell me how to close this vulnerability in vB 3.0.xx?
I would certainly appreciate it. |
Quote:
Both come back with the same error: An error occurred while attempting to execute your query. The following information was returned. error number: 1146 error desc: Table 'iwfu2_main.template' doesn't exist |
Quote:
|
Quote:
Im trying to get one of my important mods to work, but not having much luck. Ive tried all the other advice, and the only thing I can think it could be is the Ajax. This is the part of the mod: Quote:
Quote:
I would ask in the mod thread, however this has been unsupported a long time ago! |
Quote:
Quote:
|
The bad part is that not all forms have value="$session[sessionhash]" in them in some of the hacks out there. I basically look for <form and then add the line anywhere underneath that where there is a <input type="hidden" line.
|
Quote:
Thats why I think its now an ajax issue. Ive tried to figure it out but to no avail. The odd thing is, it works fine in 3.6.10, but not in 3.7 RC4 --------------- Added [DATE]1209242134[/DATE] at [TIME]1209242134[/TIME] --------------- problem solved! I had a search around and tried the fix that was being used for a shoutbox. I changed all 3 instances of "securitytoken=" to "&securitytoken=" in vbulletin_global.js and it did the trick! |
I can't save my vbulletin settings without this error.
What do I change to fix this? In a template? I also can not import any hacks without an error. Where do I fix this? In a template? --------------- Added [DATE]1209251058[/DATE] at [TIME]1209251058[/TIME] --------------- Quote:
I am getting the error when I try to edit a template and save it so this will not work. |
Quote:
|
I cannot do anything, including editing templates, turning the board on or loading templates without the security error.
|
You may want to run the upgrade script again so it makes the necessary changes or run the query listed back on the first page.
|
I added this line to all my custom templates and followed the instructions as listed.
No errors No problems with any mods casino is still working:) thank you:up: cmedic |
Quote:
define('DISABLE_HOOKS', true); |
Quote:
I've already added the 3 &'s before "securitytoken" in my clienscript/vbulletin_global.js I have also updated ALL my templates per the security token instructions given and still im having problems with every mod that uses java and ajax I am running 3.7 RC4 |
Quote:
Quote:
Quote:
|
Quote:
|
All times are GMT. The time now is 02:33 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|