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:
|
#72
|
||||
|
||||
I've managed to rectify most of these errors myself, however, if I click the "Go Advanced" button on the quick reply part of viewing a thread, it shows the error? As far as I can tell, I've amended it all...
Any help? Have I missed a file? |
#73
|
|||
|
|||
Ok I am having trouble with my skins.
Its the security token thing. Where do I add it and where in it? |
#74
|
|||
|
|||
Hi i have added the this <input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" /> after value="$session[sessionhash to all my templates and my members are getting this
Quote:
YAHOO.util.Connect.asyncRequest('POST', scriptpath + '?do=ajax', { success: this.handle_ajax_response, failure: this.handle_ajax_error, timeout: vB_Default_Timeout, scope: this }, SESSIONURL + 'securitytoken=' + SECURITYTOKEN + '&foo=' + foo); thanks |
#75
|
|||
|
|||
Only time I get one is when I am uploading a flv movie clip. I got the first one up and that was it. Static picture attachments and albums are ok as are text posting. I created an flv attachment and mimed it with content-type: video/flv. This is not using a hack or mod but an inhouse feature.
So what would you suggest to fix it? I do have the passivevid product installed but all was ok till I created the flv attachment. |
#76
|
||||
|
||||
Quote:
|
#77
|
|||
|
|||
I'm sorry, I'm still a bit lost.
I'm using the FORM HACK modification. Can someone tell me what I should be adding, and where? I don't know if I'm supposed to add the "define" tag or the "Input securitytoken" tag" or both. |
#78
|
||||
|
||||
Quote:
HTML Code:
<input type="hidden" name="poststarttime" value="$poststarttime" />
HTML Code:
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
|
#79
|
|||
|
|||
What if all the templates look fine, and include the code above, but it still happens?
On my site, it happens to users who haven't logged in for a while. They log in, see the forum briefly and then get the error while being redirected to profile.php?do=dst. |
#80
|
|||
|
|||
Am I correct in assuming that this is where the change would take place?
What must be done? Code:
if ( zahl < postids.length){ postid = postids[zahl]; unhide.open("POST", "showthread.php", true); unhide.onreadystatechange = ausgeben; unhide.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded"); unhide.send("do=whatever&p="+postid+"&all="+old); } else zahl = 0; } |
#81
|
|||
|
|||
Quote:
Genius! Thank you - worked perfectly!! |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|