From e1d9b4824c1e5750dfbf51dc1c8b2d54cf0895c3 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Wed, 27 Mar 2013 11:51:15 -0400 Subject: [PATCH] Whitelist configuration options (user preferences) that can be changed using save-pref command --- program/steps/utils/save_pref.inc | 29 ++++++++++++++++++++++------- 1 files changed, 22 insertions(+), 7 deletions(-) diff --git a/program/steps/utils/save_pref.inc b/program/steps/utils/save_pref.inc index 25f12df..3c3cfa0 100644 --- a/program/steps/utils/save_pref.inc +++ b/program/steps/utils/save_pref.inc @@ -4,9 +4,12 @@ +-----------------------------------------------------------------------+ | program/steps/utils/save_pref.inc | | | - | This file is part of the RoundCube Webmail client | - | Copyright (C) 2005-2010, RoundCube Dev. - Switzerland | - | Licensed under the GNU GPL | + | This file is part of the Roundcube Webmail client | + | Copyright (C) 2005-2013, The Roundcube Dev Team | + | | + | Licensed under the GNU General Public License version 3 or | + | any later version with exceptions for skins & plugins. | + | See the README file for a full license statement. | | | | PURPOSE: | | Save preferences setting in database | @@ -14,13 +17,26 @@ +-----------------------------------------------------------------------+ | Author: Aleksander Machniak <alec@alec.pl> | +-----------------------------------------------------------------------+ - - $Id: html2text.inc 3780 2010-06-23 09:55:08Z alec $ - */ $name = get_input_value('_name', RCUBE_INPUT_POST); $value = get_input_value('_value', RCUBE_INPUT_POST); +$whitelist = array( + 'preview_pane', + 'list_cols', + 'collapsed_folders', + 'collapsed_abooks', +); + +if (!in_array($name, array_merge($whitelist, $RCMAIL->plugins->allowed_prefs))) { + raise_error(array('code' => 500, 'type' => 'php', + 'file' => __FILE__, 'line' => __LINE__, + 'message' => sprintf("Hack attempt detected (user: %s)", $_SESSION['username'])), + true, false); + + $OUTPUT->reset(); + $OUTPUT->send(); +} // save preference value $RCMAIL->user->save_prefs(array($name => $value)); @@ -41,5 +57,4 @@ $OUTPUT->reset(); $OUTPUT->send(); - -- Gitblit v1.9.1