diff options
author | Aleksander Machniak <alec@alec.pl> | 2013-10-17 10:17:32 +0200 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2013-10-17 10:21:29 +0200 |
commit | eb433aa33cec00b42eba3153fc905ebef9c6fd0b (patch) | |
tree | fee7c490d7cf1086e87d25436aa6341e39dd17de | |
parent | 7b1e818fdd217789620e189b289cb4efab1d743a (diff) |
Fix vulnerability in handling _session argument of utils/save-prefs (#1489382)
Conflicts:
CHANGELOG
program/lib/Roundcube/rcube_plugin_api.php
program/steps/utils/save_pref.inc
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | program/include/rcube_plugin_api.php | 7 | ||||
-rw-r--r-- | program/steps/utils/save_pref.inc | 19 |
3 files changed, 20 insertions, 8 deletions
@@ -1,6 +1,8 @@ CHANGELOG Roundcube Webmail =========================== +- Fix vulnerability in handling _session argument of utils/save-prefs (#1489382) + RELEASE 0.8.6 ------------- - Fix security issue in save-pref command diff --git a/program/include/rcube_plugin_api.php b/program/include/rcube_plugin_api.php index 61bab3ce9..a1e634a4f 100644 --- a/program/include/rcube_plugin_api.php +++ b/program/include/rcube_plugin_api.php @@ -30,13 +30,14 @@ class rcube_plugin_api { static private $instance; - + public $dir; public $url = 'plugins/'; public $output; public $config; - public $allowed_prefs = array(); - + public $allowed_prefs = array(); + public $allowed_session_prefs = array(); + public $handlers = array(); private $plugins = array(); private $tasks = array(); diff --git a/program/steps/utils/save_pref.inc b/program/steps/utils/save_pref.inc index 3c3cfa0ff..44cc47cef 100644 --- a/program/steps/utils/save_pref.inc +++ b/program/steps/utils/save_pref.inc @@ -19,16 +19,26 @@ +-----------------------------------------------------------------------+ */ -$name = get_input_value('_name', RCUBE_INPUT_POST); -$value = get_input_value('_value', RCUBE_INPUT_POST); +$name = get_input_value('_name', RCUBE_INPUT_POST); +$value = get_input_value('_value', RCUBE_INPUT_POST); +$sessname = get_input_value('_session', RCUBE_INPUT_POST); + +// Whitelisted preferences and session variables, others +// can be added by plugins $whitelist = array( 'preview_pane', 'list_cols', 'collapsed_folders', 'collapsed_abooks', ); +$whitelist_sess = array( + 'list_attrib/columns', +); -if (!in_array($name, array_merge($whitelist, $RCMAIL->plugins->allowed_prefs))) { +$whitelist = array_merge($whitelist, $RCMAIL->plugins->allowed_prefs); +$whitelist_sess = array_merge($whitelist_sess, $RCMAIL->plugins->allowed_session_prefs); + +if (!in_array($name, $whitelist) || ($sessname && !in_array($sessname, $whitelist_sess))) { raise_error(array('code' => 500, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => sprintf("Hack attempt detected (user: %s)", $_SESSION['username'])), @@ -42,7 +52,7 @@ if (!in_array($name, array_merge($whitelist, $RCMAIL->plugins->allowed_prefs))) $RCMAIL->user->save_prefs(array($name => $value)); // update also session if requested -if ($sessname = get_input_value('_session', RCUBE_INPUT_POST)) { +if ($sessname) { // Support multidimensional arrays... $vars = explode('/', $sessname); @@ -57,4 +67,3 @@ if ($sessname = get_input_value('_session', RCUBE_INPUT_POST)) { $OUTPUT->reset(); $OUTPUT->send(); - |