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:
define('CSRF_PROTECTION', true);
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.
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'.
PHP Code:
if (THIS_SCRIPT == 'example') { $vbulletin->csrf_skip_list[] = 'action_three'; }
i have a question to vBulletin Core Dev Team : Sorry , Did you thinking before release a version perfectly ? 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 !
I have 17 products installed comprised of 88 plugins and quite a few new templates. I had a problem with one product after upgrading to vBulletin 3.7.0 RC4 on my site. That was Princeton's Quick Reply in PMs. Adding the security token to the form took about 20 seconds and the site was fully operational again.
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 it, if it doesn't exist already:
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
Save the template.
Thank you !:up: I do all the changes and now have no problem ..
lt was not too hard ... infact it is easy .. the other way is :
Quote:
Originally Posted by RedFoxy
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:
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.
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:
I used it to fix all mod that i've installed in my vBulletin board
--------------- Added [DATE]1209056453[/DATE] at [TIME]1209056453[/TIME] ---------------
calendarjump, FAQ, forumjump, WHOSONLINE don't need to be edited if you haven't modded it
I have tried this query under Maintenance - Run SQL query, and also on my PHPMyAdmin database query
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
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.
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:
<script type="text/javascript">
var qstring = '';
function check_pager(qstring)
{
vbPage = new vB_AJAX_Handler(true);
vbPage.onreadystatechange(ShowPager);
I have tried this query under Maintenance - Run SQL query, and also on my PHPMyAdmin database query
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
That is because you most likely have a table prefix inside of it. Try following this post instead:
Quote:
Originally Posted by Wayne Luke
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]" />
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.