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:
|
#62
|
|||
|
|||
Can anyone help me with this problem,
Details of the reported exploit are as follows; Multiple CSRF Vulnerabilities ============================= Example ------------------ if ($_REQUEST['do'] == 'deletereply'){ ------------------ Because the "delete" command can be executed via a GET request (ie. URL in a signature), if a user with permission clicks a link that is specifically crafted, it can delete something. CSRF. This is in my HelpCenter modification. I thought I had covered all CSRF issues but its seems I may have missed something but I dont know how to correct as ive covered everything from this thread. Thanks, Paul. |
#63
|
||||
|
||||
Quote:
|
#64
|
|||
|
|||
I'm trying to add the security token to a mod that is giving me an error message. The mod is very important and I'm not getting any answers from the author.
The mod uses AJAX, which is what is not working. When someone uses quickreply and posts their reply it's supposed to automatically reveal the hidden content. Instead it gives the security token issue. Here are the templates. Must there be a change to the xml file also? Code:
<!--hide-addon--> <if condition="$vboptions[disable_ajax] != 2"> <script type="text/javascript"><!-- var hpostid = 0; var hmax = 0; function findposts(obj,call){ ruf = call; var laenge = obj.innerHTML.length; if (hmax == '0'){ hmax = laenge; } else if (hmax < laenge){ hmax = laenge; Rufen(ruf); } } var hide_aktiv = null; var unhide = null; var zahl = 0; var old; var postid function Rufen(posting){ if (window.XMLHttpRequest) { unhide = new XMLHttpRequest(); } else if (window.ActiveXObject) { unhide = new ActiveXObject("Microsoft.XMLHTTP"); } old = posting var postids = posting.split(","); 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; } function ausgeben() { if (unhide.readyState == 4) { if (unhide.responseText != 'sid_hide_still_active'){ document.getElementById("post_message_"+postid).innerHTML = unhide.responseText; zahl++; Rufen(old); } else { zahl++; Rufen(old); } } else setTimeout('ausgeben()', 200); } //--> </script> </if> Code:
<if condition="$vboptions[disable_ajax] != 2 AND $vboptions[sid_hide_ajax_on] == 1"> <script type="text/javascript"> if (hide_aktiv) window.clearInterval(hide_aktiv); var hide_aktiv = window.setInterval("findposts(fetch_object('posts'),'$hide_call')", 3000); </script> </if> <div id="hide_fieldset"><fieldset> <legend><span class="highlight">$vbphrase[sid_hide_post_hide]</span></legend> $hide_img </fieldset></div> I am not asking for the solution, but guidance. |
#65
|
|||
|
|||
Quote:
I agree completely with the companion, I use this modification and tb I have these problems, it is a product very used in the forum and I cannot allow me the luxury of removing it, ask them please that they should help us in this topic, graces(thanks) Pd: since always I ask for excuses for my English one, for which I use one I translate of Spanish to groins, sie |
#66
|
|||
|
|||
Yes BIG Thank You to every one who got this needed info to us. This fixed all my mods that went down after the move to vB 3.7.0 Gold.........................
Now the mods I have been running for over 2.5 years are all back online... |
#67
|
|||
|
|||
Quote:
What did this look like before the edit? What are you editing? Is it a template, a plug-in? |
#68
|
|||
|
|||
Hi guys, I don't really understand this, what I want to do is make it so this does not show anymore.
Please help me take that off. Thanks. |
#69
|
|||
|
|||
wow ! This is a precious thread !
thank you |
#70
|
|||
|
|||
Greetings all,
Well, you guys are my last hope. I had a mod written for me last year, my forum members love it and at the moment it's running but when I upgrade I don't expect it to survive..so I'm trying to get a handle on this so that I can do it myself. The coder has long since disappeared so help is appreciated. The beginning of this thread says that: "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." I have this line at the beginning of my mods .php file: define('THIS_SCRIPT', 'dataawards_awards'); Do I add this: define('CSRF_PROTECTION', true); Directly below that line? will that solve the entire security token issue or do I need to hunt for form/posts? Talking about form/posts...is this one?: $awarddisplay.= '<form action="' . htmlentities($_SERVER['PHP_SELF']) . '?addawards=' . $_REQUEST['addawards'] . '&type=' . $type . '" method="POST">'; If I understand this correctly I need to find all form/posts (since you are posting and not requesting, thus the need for the security token): <input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" /> Thanks, I hope I can work through this on my own, but if anyone wants to make some money, I'd rather pay to have it done..PM if interested. |
#71
|
|||
|
|||
Quote:
I do what you said and my problem is solved now... thanks again |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|