Changeset 1556

Show
Ignore:
Timestamp:
03/17/08 19:47:09 (2 months ago)
Author:
Neal
Message:

Added CSRF protection to the mark as read links.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/punbb-1.3-dev/upload/header.php

    r1533 r1556  
    176176        $visit_links = array( 
    177177                '<li id="vs-searchnew"><a href="'.pun_link($pun_url['search_new']).'" title="'.$lang_common['New posts info'].'">'.$lang_common['New posts'].'</a></li>', 
    178                 '<li id="vs-markread"><a href="'.pun_link($pun_url['mark_read']).'">'.$lang_common['Mark all as read'].'</a></li>' 
     178                '<li id="vs-markread"><a href="'.pun_link($pun_url['mark_read'], generate_form_token('markread'.$pun_user['id'])).'">'.$lang_common['Mark all as read'].'</a></li>' 
    179179        ); 
    180180 
  • branches/punbb-1.3-dev/upload/include/rewrite_rules.php

    r1492 r1556  
    5454        '/^users\/(.*)\/([0-9-]+)\/?([a-z_]+)[\/_-]([a-zA-Z]+)[\/_-]p(age)?[\/_-]?([0-9]+)(\.html?|\/)?$/i'                                             =>      'userlist.php?username=$1&show_group=$2&sort_by=$3&sort_dir=$4&p=$6', 
    5555        '/^(email|report|subscribe|unsubscribe)[\/_-]?([0-9]+)(\.html?|\/)?$/i'                                                                                                 =>      'misc.php?$1=$2', 
    56         '/^(mark|rules)[\/_-]?(read)?(\.html?|\/)?$/i'                                                                                                                                                 =>      'misc.php?action=$1$2', 
    57         '/^mark[\/_-](forum)[\/_-]?([0-9]+)[\/_-](read)(\.html?|\/)?$/i'                                                                                                               =>      'misc.php?action=markforumread&fid=$2', 
     56        '/^(mark|rules)[\/_-]?(read)?[\/_-]?([a-z0-9])?(\.html?|\/)?$/i'                                                                                                               =>      'misc.php?action=$1$2&csrf_token=$3', 
     57        '/^mark[\/_-](forum)[\/_-]?([0-9]+)[\/_-](read)[\/_-]([a-z0-9]+)(\.html?|\/)?$/i'                                                                              =>      'misc.php?action=markforumread&fid=$2&csrf_token=$4', 
    5858        '/^help[\/_-]([a-z]+)(\.html?|\/)?$/i'                                                                                                                                                                  =>      'help.php?section=$1', 
    5959        '/^moderate[\/_-]?([0-9]+)(\.html?|\/)?$/i'                                                                                                                                                             =>      'moderate.php?fid=$1', 
  • branches/punbb-1.3-dev/upload/include/url/Default.php

    r1431 r1556  
    4646        'login'                                                 =>      'login.php', 
    4747        'logout'                                                =>      'login.php?action=out&amp;id=$1&amp;csrf_token=$2', 
    48         'mark_read'                                             =>      'misc.php?action=markread', 
    49         'mark_forum_read'                               =>      'misc.php?action=markforumread&amp;fid=$1', 
     48        'mark_read'                                             =>      'misc.php?action=markread&amp;csrf_token=$1', 
     49        'mark_forum_read'                               =>      'misc.php?action=markforumread&amp;fid=$1&amp;csrf_token=$2', 
    5050        'new_topic'                                             =>      'post.php?fid=$1', 
    5151        'new_reply'                                             =>      'post.php?tid=$1', 
  • branches/punbb-1.3-dev/upload/include/url/File_based.php

    r1544 r1556  
    4848        'login'                                                 =>      'login.html', 
    4949        'logout'                                                =>      'logout$1-$2.html', 
    50         'mark_read'                                             =>      'mark-read.html', 
    51         'mark_forum_read'                               =>      'mark-forum$1-read.html', 
     50        'mark_read'                                             =>      'mark-read-$1.html', 
     51        'mark_forum_read'                               =>      'mark-forum$1-read-$2.html', 
    5252        'new_topic'                                             =>      'new-topic$1.html', 
    5353        'new_reply'                                             =>      'new-reply$1.html', 
  • branches/punbb-1.3-dev/upload/include/url/File_based_(fancy).php

    r1549 r1556  
    4848        'login'                                                 =>      'login.html', 
    4949        'logout'                                                =>      'logout$1-$2.html', 
    50         'mark_read'                                             =>      'mark-read.html', 
    51         'mark_forum_read'                               =>      'mark-forum$1-read.html', 
     50        'mark_read'                                             =>      'mark-read-$1.html', 
     51        'mark_forum_read'                               =>      'mark-forum$1-read-$2.html', 
    5252        'new_topic'                                             =>      'new-topic$1.html', 
    5353        'new_reply'                                             =>      'new-reply$1.html', 
  • branches/punbb-1.3-dev/upload/include/url/Folder_based.php

    r1492 r1556  
    4646        'login'                                                 =>      'login/', 
    4747        'logout'                                                =>      'logout/$1/$2/', 
    48         'mark_read'                                             =>      'mark/read/', 
    49         'mark_forum_read'                               =>      'mark/forum/$1/read/', 
     48        'mark_read'                                             =>      'mark/read/$1/', 
     49        'mark_forum_read'                               =>      'mark/forum/$1/read/$2/', 
    5050        'new_topic'                                             =>      'new/topic/$1/', 
    5151        'new_reply'                                             =>      'new/reply/$1/', 
  • branches/punbb-1.3-dev/upload/include/url/Folder_based_(fancy).php

    r1546 r1556  
    4646        'login'                                                 =>      'login/', 
    4747        'logout'                                                =>      'logout/$1/$2/', 
    48         'mark_read'                                             =>      'mark/read/', 
    49         'mark_forum_read'                               =>      'mark/forum/$1/read/', 
     48        'mark_read'                                             =>      'mark/read/$1/', 
     49        'mark_forum_read'                               =>      'mark/forum/$1/read/$2/', 
    5050        'new_topic'                                             =>      'new/topic/$1/', 
    5151        'new_reply'                                             =>      'new/reply/$1/', 
  • branches/punbb-1.3-dev/upload/misc.php

    r1534 r1556  
    8585                message($lang_common['No permission']); 
    8686 
     87        // We validate the CSRF token. If it's set in POST and we're at this point, the token is valid. 
     88        // If it's in GET, we need to make sure it's valid. 
     89        if (!isset($_POST['csrf_token']) && (!isset($_GET['csrf_token']) || $_GET['csrf_token'] !== generate_form_token('markread'.$pun_user['id']))) 
     90                csrf_confirm_form(); 
     91 
    8792        ($hook = get_hook('mi_markread_selected')) ? eval($hook) : null; 
    8893 
     
    108113        if ($pun_user['is_guest']) 
    109114                message($lang_common['No permission']); 
     115 
     116        // We validate the CSRF token. If it's set in POST and we're at this point, the token is valid. 
     117        // If it's in GET, we need to make sure it's valid. 
     118        if (!isset($_POST['csrf_token']) && (!isset($_GET['csrf_token']) || $_GET['csrf_token'] !== generate_form_token('markforumread'.$pun_user['id']))) 
     119                csrf_confirm_form(); 
    110120 
    111121        ($hook = get_hook('mi_markforumread_selected')) ? eval($hook) : null; 
  • branches/punbb-1.3-dev/upload/search.php

    r1551 r1556  
    782782                        $pun_page['crumbs'][] = $lang_common['New posts']; 
    783783                        $pun_page['main_info'] = (($pun_page['num_pages'] == 1) ? sprintf($lang_common['Page info'], $lang_search['Topics with new'], $num_hits) : '<span>'.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' </span>'.sprintf($lang_common['Paged info'], $lang_search['Topics with new'], $pun_page['start_from'] + 1, $pun_page['finish_at'], $num_hits)); 
    784                         $pun_page['main_foot_options'][] = '<a class="user-option" href="'.pun_link($pun_url['mark_read']).'">'.$lang_common['Mark all as read'].'</a>'; 
     784                        $pun_page['main_foot_options'][] = '<a class="user-option" href="'.pun_link($pun_url['mark_read'], generate_form_token('markread'.$pun_user['id'])).'">'.$lang_common['Mark all as read'].'</a>'; 
    785785                        break; 
    786786 
  • branches/punbb-1.3-dev/upload/viewforum.php

    r1554 r1556  
    158158if (!$pun_user['is_guest'] && $db->num_rows($result)) 
    159159{ 
    160         $pun_page['main_foot_options'][] = '<a class="user-option" href="'.pun_link($pun_url['mark_forum_read'], $id).'"><span>'.$lang_forum['Mark forum read'].'</span></a>'; 
     160        $pun_page['main_foot_options'][] = '<a class="user-option" href="'.pun_link($pun_url['mark_forum_read'], array($id, generate_form_token('markforumread'.$pun_user['id']))).'"><span>'.$lang_forum['Mark forum read'].'</span></a>'; 
    161161 
    162162        if ($pun_page['is_admmod'])