1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-05 22:14:59 +02:00

[ticket/11310] Add hashes to action links to prevent CSRF attacks

PHPBB3-11310
This commit is contained in:
Joas Schilling 2013-03-12 17:10:32 +01:00
parent d6930df7a2
commit 5eef287646

View File

@ -68,13 +68,20 @@ class acp_styles
$action = $this->request->variable('action', ''); $action = $this->request->variable('action', '');
$post_actions = array('install', 'activate', 'deactivate', 'uninstall'); $post_actions = array('install', 'activate', 'deactivate', 'uninstall');
if ($action && in_array($action, $post_actions) && !check_link_hash($request->variable('hash', ''), $action))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
foreach ($post_actions as $key) foreach ($post_actions as $key)
{ {
if (isset($_POST[$key])) if ($this->request->is_set_post($key))
{ {
$action = $key; $action = $key;
} }
} }
if ($action != '') if ($action != '')
{ {
$this->s_hidden_fields['action'] = $action; $this->s_hidden_fields['action'] = $action;
@ -921,21 +928,23 @@ class acp_styles
'L_ACTION' => $this->user->lang['DETAILS'] 'L_ACTION' => $this->user->lang['DETAILS']
); );
// Activate // Activate/Deactive
$action_name = ($style['style_active'] ? 'de' : '') . 'activate';
$actions[] = array( $actions[] = array(
'U_ACTION' => $this->u_action . '&action=' . ($style['style_active'] ? 'de' : '') . 'activate&id=' . $style['style_id'], 'U_ACTION' => $this->u_action . '&action=' . $action_name . '&hash=' . generate_link_hash($action_name) . '&id=' . $style['style_id'],
'L_ACTION' => $this->user->lang['STYLE_' . ($style['style_active'] ? 'DE' : '') . 'ACTIVATE'] 'L_ACTION' => $this->user->lang['STYLE_' . ($style['style_active'] ? 'DE' : '') . 'ACTIVATE']
); );
/* // Export /* // Export
$actions[] = array( $actions[] = array(
'U_ACTION' => $this->u_action . '&action=export&id=' . $style['style_id'], 'U_ACTION' => $this->u_action . '&action=export&hash=' . generate_link_hash('export') . '&id=' . $style['style_id'],
'L_ACTION' => $this->user->lang['EXPORT'] 'L_ACTION' => $this->user->lang['EXPORT']
); */ ); */
// Uninstall // Uninstall
$actions[] = array( $actions[] = array(
'U_ACTION' => $this->u_action . '&action=uninstall&id=' . $style['style_id'], 'U_ACTION' => $this->u_action . '&action=uninstall&hash=' . generate_link_hash('uninstall') . '&id=' . $style['style_id'],
'L_ACTION' => $this->user->lang['STYLE_UNINSTALL'] 'L_ACTION' => $this->user->lang['STYLE_UNINSTALL']
); );
@ -957,7 +966,7 @@ class acp_styles
else else
{ {
$actions[] = array( $actions[] = array(
'U_ACTION' => $this->u_action . '&action=install&dir=' . urlencode($style['style_path']), 'U_ACTION' => $this->u_action . '&action=install&hash=' . generate_link_hash('install') . '&dir=' . urlencode($style['style_path']),
'L_ACTION' => $this->user->lang['INSTALL_STYLE'] 'L_ACTION' => $this->user->lang['INSTALL_STYLE']
); );
} }