Skip to content

Commit

Permalink
Added CRSF security token checks in ACL plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
splitbrain committed Jan 17, 2010
1 parent 49eb6e3 commit d7554c0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
12 changes: 8 additions & 4 deletions lib/plugins/acl/admin.php
Expand Up @@ -31,7 +31,7 @@ function getInfo(){
return array(
'author' => 'Andreas Gohr',
'email' => 'andi@splitbrain.org',
'date' => '2009-08-07',
'date' => '2010-01-17',
'name' => 'ACL Manager',
'desc' => 'Manage Page Access Control Lists',
'url' => 'http://dokuwiki.org/plugin:acl',
Expand Down Expand Up @@ -67,6 +67,7 @@ function handle() {
// fresh 1:1 copy without replacements
$AUTH_ACL = file(DOKU_CONF.'acl.auth.php');


// namespace given?
if($_REQUEST['ns'] == '*'){
$this->ns = '*';
Expand All @@ -89,7 +90,8 @@ function handle() {
}

// handle modifications
if(isset($_REQUEST['cmd'])){
if(isset($_REQUEST['cmd']) && checkSecurityToken()){

// scope for modifications
if($this->ns){
if($this->ns == '*'){
Expand Down Expand Up @@ -310,6 +312,7 @@ function _html_detail(){
echo '<input type="hidden" name="id" value="'.hsc($ID).'" />'.NL;
echo '<input type="hidden" name="do" value="admin" />'.NL;
echo '<input type="hidden" name="page" value="acl" />'.NL;
echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'.NL;
echo '</div></form>'.NL;
}

Expand Down Expand Up @@ -480,11 +483,11 @@ function _html_list_acl($item){
$alt = '+';
}
$ret .= '<img src="'.$img.'" alt="'.$alt.'" />';
$ret .= '<a href="'.wl('',$this->_get_opts(array('ns'=>$item['id']))).'" class="idx_dir'.$cl.'">';
$ret .= '<a href="'.wl('',$this->_get_opts(array('ns'=>$item['id'],'sectok'=>getSecurityToken()))).'" class="idx_dir'.$cl.'">';
$ret .= $base;
$ret .= '</a>';
}else{
$ret .= '<a href="'.wl('',$this->_get_opts(array('id'=>$item['id'],'ns'=>''))).'" class="wikilink1'.$cl.'">';
$ret .= '<a href="'.wl('',$this->_get_opts(array('id'=>$item['id'],'ns'=>'','sectok'=>getSecurityToken()))).'" class="wikilink1'.$cl.'">';
$ret .= noNS($item['id']);
$ret .= '</a>';
}
Expand Down Expand Up @@ -562,6 +565,7 @@ function _html_table(){
echo '<input type="hidden" name="acl_w" value="'.hsc($this->who).'" />'.NL;
echo '<input type="hidden" name="do" value="admin" />'.NL;
echo '<input type="hidden" name="page" value="acl" />'.NL;
echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'.NL;
echo '<table class="inline">';
echo '<tr>';
echo '<th>'.$this->getLang('where').'</th>';
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/acl/ajax.php
Expand Up @@ -19,11 +19,11 @@
//close session
session_write_close();

if(!auth_isadmin()) die('forbidden');
if(!auth_isadmin()) die('for admins only');
if(!checkSecurityToken()) die('CRSF Attack');

$ID = getID();

if(!auth_isadmin) die('for admins only');
require_once(DOKU_INC.'inc/pluginutils.php');
require_once(DOKU_INC.'inc/html.php');
$acl = plugin_load('admin','acl');
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/acl/script.js
Expand Up @@ -48,7 +48,8 @@ acl = {
data[1] = ajax.encVar('id',frm.elements['id'].value);
data[2] = ajax.encVar('acl_t',frm.elements['acl_t'].value);
data[3] = ajax.encVar('acl_w',frm.elements['acl_w'].value);
data[4] = ajax.encVar('ajax','info');
data[4] = ajax.encVar('sectok',frm.elements['sectok'].value);
data[5] = ajax.encVar('ajax','info');

ajax.elementObj = $('acl__info');

Expand Down

0 comments on commit d7554c0

Please sign in to comment.