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:
|
#152
|
||||
|
||||
That query will most likely not catch modification templates or plugins where they don't have the securitytoken nor will it catch if it is a javascript problem. You can try disabling your modifications and seeing if the error goes away.
|
#153
|
|||
|
|||
Hello,
I'm trying to implement an add-on (ZP Poll) that shows vb polls in a non-vb page (joomla). Everything works well until users try to vote , then they get the security token issue. This hack is not resident in vbulletin and the only line with a form is Code:
<form action=\"" . $directory . "/poll.php?do=pollvote&pollid=\"" . $pollid . "\" method=\"post\">" |
#154
|
||||
|
||||
You should ask the author of that modification for help adding the securitytoken.
|
#155
|
|||
|
|||
Hi Lynne,
I've been trying to get hold of the developer for days. I was hoping there is a generic way to add tokens to such non-vb pages. I'm attaching the script so you can advise on where I could add the token ? |
#156
|
||||
|
||||
I'm no CSRF expert at all. I was able to just add the line to all my custom mods and everything worked perfectly. You can try adding the securitytoken right after the form line you posted above and see if that works.
|
#157
|
|||
|
|||
i have problem with a theme header ( i think so ) quick search (java one) doesnt work with this theme:
where to add special lines to make it work? here is the script Code:
<!-- designed by hanafi@enthropia.com/napy8gen@yahoo.co.uk for forumtemplates.com --> <a name="top"></a> <table width="80%" border="0" align="center" cellpadding="0" cellspacing="0" class="wrapper" style="height:100%;"> <tr> <td class="headerwrap"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="headerwrap2"> <tr> <td><a href="$vboptions[forumhome].php$session[sessionurl_q]"> <img src="images/lily/lily_logo.gif" alt="$vboptions[bbtitle]" width="285" height="140" border="0" id="lily_logo" /></a></td> </tr> <tr> <td class="navwrap"> <!-- nav buttons bar --> <table id="navstyle" cellpadding="$stylevar[cellpadding]" cellspacing="0" border="0" width="100%" align="center" style="border-top-width:0px"> <tr align="center"> <if condition="$show['member']"> <td><a href="usercp.php$session[sessionurl_q]">$vbphrase[user_cp]</a></td> </if> <if condition="$show['registerbutton']"> <td><a href="register.php$session[sessionurl_q]" rel="nofollow">$vbphrase[register]</a></td> </if> $template_hook[navbar_buttons_left] <td><a href="faq.php$session[sessionurl_q]" accesskey="5">$vbphrase[faq]</a></td> <td><a href="memberlist.php$session[sessionurl_q]">$vbphrase[members_list]</a></td> <td><a href="calendar.php$session[sessionurl_q]">$vbphrase[calendar]</a></td> <if condition="$show['popups']"> <if condition="$show['searchbuttons']"> <if condition="$show['member']"> <td><a href="search.php?$session[sessionurl]do=getnew" accesskey="2">$vbphrase[new_posts_nav]</a></td> <else /> <td><a href="search.php?$session[sessionurl]do=getdaily" accesskey="2">$vbphrase[todays_posts]</a></td> </if> <td id="navbar_search" ><a href="search.php$session[sessionurl_q]" accesskey="4" rel="nofollow">$vbphrase[search]</a> <if condition="$show['quicksearch']"> <script type="text/javascript"> vbmenu_register("navbar_search"); </script></if></td> </if> <if condition="$show['member']"> <td id="usercptools" ><a href="$show[nojs_link]#usercptools">$vbphrase[quick_links]</a> <script type="text/javascript"> vbmenu_register("usercptools"); </script></td> </if> <else /> <if condition="$show['searchbuttons']"> <td><a href="search.php$session[sessionurl_q]" accesskey="4">$vbphrase[search]</a></td> <if condition="$show['member']"> <td><a href="search.php?$session[sessionurl]do=getnew" accesskey="2">$vbphrase[new_posts_nav]</a></td> <else /> <td><a href="search.php?$session[sessionurl]do=getdaily" accesskey="2">$vbphrase[todays_posts]</a></td> </if> </if> <td><a href="forumdisplay.php?$session[sessionurl]do=markread" rel="nofollow">$vbphrase[mark_forums_read]</a></td> <if condition="$show['member']"> <td><a href="#" onclick="window.open('misc.php?$session[sessionurl]do=buddylist&focus=1','buddylist','statusbar=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=250,height=300'); return false;">$vbphrase[open_buddy_list]</a></td> </if> </if> $template_hook[navbar_buttons_right] <if condition="$show['member']"> <td><a href="login.php?$session[sessionurl]do=logout&logouthash=$bbuserinfo[logouthash]" onclick="return log_out('$vbphrase[sure_you_want_to_log_out]')">$vbphrase[log_out]</a></td> </if> </tr> </table> <!-- / nav buttons bar --> </td> </tr> </table></td> <td class="headerR"> </td> </tr> </table></td> </tr> <tr> <td valign="top" class="cwrap"> <!-- /end long header part --> <!-- content table --> $spacer_open <br/> <div align="center">@vbbanners@</div> $_phpinclude_output |
#158
|
||||
|
||||
If you think it's a problem with a particular mod, go read the mod thread and see if anyone posted the fix in there. There was also a discussion in this thread about fixing javascript (not java, that is very different) problems. Did you read the thread at all?
|
#159
|
||||
|
||||
Hi Lynne, do you know how to make the Default var?
Thank you |
#160
|
||||
|
||||
I don't understand what you mean, sorry.
|
#161
|
||||
|
||||
Hi Lynne,
I mean how to make the AJAX call a script without click a button (or a link) when a user just loaded the page. For example: I have Installed AJAX Advanced Forum Statistic. I browse the index page, that Mod loads the Statistics using AJAX for the default. I hope you understand what I mean. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|