The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
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:
|
#162
|
||||
|
||||
Quote:
I'm not an ajax expert at all, so I can't really answer questions regarding ajax. |
#163
|
|||
|
|||
god i'm so confused
if I do a search in templates for that line, but it comes back with 100+ templates. Am I expected to go through every one and check for that securitytoken line? The only thing that's not working for me is my search |
#164
|
||||
|
||||
Then try just adding the line in the templates that look like they are search related. If it's a specific page that isn't working, you can find the list of templates on the page by going into debug mode and looking at the bottom of the page. Or, you can just do this - - vboptions > General Settings > Add Template Name in HTML Comments > set to Yes . Then go back to your page and view the source code and you will see the name of the template called around your part of the code.
|
#165
|
|||
|
|||
that line is in the templates related to the search portion. Are there any other suggestions?
|
#166
|
||||
|
||||
<font color="DarkGreen">it is Useful information Thank you</font>
|
#167
|
|||
|
|||
What do you do if only a few users have the issue and no one else?
|
#168
|
|||
|
|||
Guys,
Lynne directed me to this thread and after over a week of no one responding to my cries for help my problem is solved. THANK YOU LYNNE!!!!! Users were getting a Security Token message when they tried to use the search function and this thread helped rectify the issue within a short amount of time. As an FYI we are running VB 3.8+ over at our place. |
#169
|
|||
|
|||
hello, i have a problem with security token in IBPROarcade whem i go submit the score, it show in this page of forum. i have vb 4
foro/index.php?act=Arcade&do=newscore where template or i have to modify to fix that? Thank's |
#170
|
||||
|
||||
Questions/Problems regarding modifications need to be asked in the modification thread. That is where the support for modifications is - not out here in the main forums. Please note that if a modification is unsupported (or even if it says it is supported), you may be on your own if you chose to install it.
|
#171
|
|||
|
|||
I am creating an application form that posts info to my officer forums. It was very easy to make in SMF but I keep getting the security token error when doing it in VB4 gold.
<?php // ####################### SET PHP ENVIRONMENT ########################### error_reporting(E_ALL & ~E_NOTICE); // #################### DEFINE IMPORTANT CONSTANTS ####################### define('THIS_SCRIPT', 'epeen_application.php'); define('CSRF_PROTECTION', true); ..... blah blah // ###### YOUR CUSTOM CODE GOES HERE ##### $pagetitle = 'ePeen Application'; $application_form = '<div id="appForm"> <div id="innerGutsApp"> <form id="ePeenApp" class="appnitro" method="post" action="submit_app.php"> <div class="form_description"> <h2>ePeen Application</h2> <p>Flex Your ePeen Here!</p> </div> ... ... blah blah <li class="buttons"> <input type="hidden" name="s" value="$session[sessionhash]" /> <input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" /> <input type="hidden" name="form_id" value="111237" /> <input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" /> </li> </ul> </form> </div> </div>'; // ###### NOW YOUR TEMPLATE IS BEING RENDERED ###### $templater = vB_Template::create('ePeen_application'); $templater->register_page_templates(); $templater->register('navbar', $navbar); $templater->register('pagetitle', $pagetitle); $templater->register('application_form', $application_form); print_output($templater->render()); ?> I have what is required but I still get the security token error. Any idea how I can make this work? I have tried taking the form out of my php file and put it directly into the template with no change. I need to get this site done and this is one of my last road blocks. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|