Welcome to Egypt Forums Mark forums read | Egypt Main Page
Egypt Forums
Arabic Movies



Articles Thread, Implementing CSRF Protection in modifications in vBulletin; <div> Implementing CSRF Protection in modifications With the new version released today for vBulletin 3.6.10 and 3.7.0 RC4, a new ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=3353


Reply
LinkBack Thread Tools Display Modes
Implementing CSRF Protection in modifications
 
 
The God Father
Developer's Avatar

Reply With Quote
 
Join Date: Jul 2008
Location: NDC
Posts: 5,425
10-09-2008, 06:32 PM
 
<div> 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.

<div style="margin: 5px 10px;"> <div class="smallfont" style="margin-bottom: 2px;">PHP Code:
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.

<div style="margin: 5px 10px;"> <div class="smallfont" style="margin-bottom: 2px;">Code:
PHP Code:
     <input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
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.

<div style="margin: 5px 10px;"> <div class="smallfont" style="margin-bottom: 2px;">PHP Code:
PHP Code:
           define('CSRF_SKIP_LIST', 'action_one,action_two');
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:
PHP Code:
           if (THIS_SCRIPT == 'example')
{
        
$vbulletin->csrf_skip_list[] = 'action_three';
}
</span></span>
__________________
I Love Walking In The Rain Cuz Nobody Know I'm Crying !!
 
 
 
Reply

Articles Thread, Implementing CSRF Protection in modifications in vBulletin; <div> Implementing CSRF Protection in modifications With the new version released today for vBulletin 3.6.10 and 3.7.0 RC4, a new ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=3353


Bookmarks

Tags
csrf, implementing, modifications, protection


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Implementing CSRF Protection in modifications Developer Articles 4 08-04-2009 09:27 PM
vBulletin 3.7 Template Modifications Report Post Agreement Developer Mods for 3.7.x 2 07-03-2009 03:50 PM
Stamps (CSRF protection added) Developer Mods for 3.7.x 0 01-11-2008 11:24 PM
AK-Protection 3: Free Download Developer Software and Programs 0 21-09-2008 03:10 AM
Implementing Click-To-Seek For The FLVPlayback Component SABRAWY Flash Media Server 0 17-09-2008 08:29 AM