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:
|
#82
|
|||
|
|||
Quote:
Quote:
|
#83
|
|||
|
|||
Quote:
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; SESSIONURL + 'securitytoken=' + SECURITYTOKEN; } else if (hmax < laenge){ hmax = laenge; SESSIONURL + 'securitytoken=' + SECURITYTOKEN; 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() + SESSIONURL + 'securitytoken=' + SECURITYTOKEN; } else if (window.ActiveXObject) { unhide = new ActiveXObject("Microsoft.XMLHTTP") + SESSIONURL + 'securitytoken=' + SECURITYTOKEN; } 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) + SESSIONURL + 'securitytoken=' + SECURITYTOKEN; } 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) + SESSIONURL + 'securitytoken=' + SECURITYTOKEN; </script> </if> <div id="hide_fieldset"><fieldset> <legend><span class="highlight">$vbphrase[sid_hide_post_hide]</span></legend> $hide_img </fieldset></div> Salud2 |
#84
|
|||
|
|||
This is really a mess! I'm not a professional coder.Plz Some One make a step by step instruction to do this to avoid security token missing error,as it'd help lot of people.
Thanks |
#85
|
|||
|
|||
I have seen this one before but don't know exactly what triggers it BUT for what its worth,
Find in your footer template the following, Code:
<if condition="$show['dst_correction']"> <!-- auto DST correction code --> <form action="profile.php?do=dst" method="post" name="dstform"> <input type="hidden" name="s" value="$session[sessionhash]" /> <input type="hidden" name="do" value="dst" /> </form> Code:
<if condition="$show['dst_correction']"> <!-- auto DST correction code --> <form action="profile.php?do=dst" method="post" name="dstform"> <input type="hidden" name="s" value="$session[sessionhash]" /> <input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" /> <input type="hidden" name="do" value="dst" /> </form> |
#86
|
|||
|
|||
its ok for you all to say do this if people know the code and i dont know
surely as jelsoft screwed up with this they should issue a fix,i installed my 3.7 as a clean 1st time full install and i still get this error |
#87
|
|||
|
|||
Quote:
But posted in the early posts is the exact steps you should take to search your templates and find the ones that need the line of code added to it. |
#88
|
|||
|
|||
Do yourself a favor..if your having problems and the hacks you have installed are something you can live without then uninstall them., revert your templates, upgrade, and you will be stress-free. Have you tried contacting the author of the hack? he probably has moved onto other things which is why you are here. If that's the case, the hack is obviously unsupported now and it's just a matter of time anyways before it breaks under another update and you will have to go through this all over again.
|
#89
|
|||
|
|||
Quote:
therefore it would be impossible for it to be anything other than vbulletin itself causing the problem it is 100% vbulletin 3.7.0 at fault there was at the time it started NO other software hack or mods installed |
#90
|
|||
|
|||
I can't comment accurately on your situation, but I had serious reservations myself in upgrading from 3.6.9 to 3.7.0. I have a custom hack coded for my forum that I was almost positive was going to fail with this CSRF thing. I did the following and it was the smoothest upgrade I've ever had. Not even my custom hack cracked:
Backup database, backup my /images folder, shut down forum, do upgrade. Upload my custom /images and overwrite the new, then perform upgrade. After, go back and revert everything the upgrade reported as needing to be reverted. Sounds to me like some of the upgrade files were munged during the transfer. I'd re-upload the upgrade files and make sure all appropriate ascii files are transferred as ascii and all binary as binary. Something that simple can easily be overlooked. Also, make sure your config.php is correctly configured. Something is missing..you just have to. Seeing as it was a brand new install, I'd say the problem is either with a corrupt file upload or misconfigured config.php. Something isn't seeing something the way it's supposed to. Many people have installed the 3.7.0 software as an upgrade (which is a helluva lot trickier than a virgin install) and are running with no problem. |
#91
|
|||
|
|||
ok here is the thing .... i almost check all my templates for security tokken code.... and fix all of them ....
but still only super mod getting security tokken error when ever they try to reply to the post... whether in new reply or quick reply .... can some1 tell me which templates i have fix.... |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|