Add security tokens to change password plugin
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 18 Dec 2009 06:46:16 +0000 (06:46 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 18 Dec 2009 06:46:16 +0000 (06:46 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13878 7612ce4b-ef26-0410-bec9-ea0150e637f0

plugins/change_password/functions.php
plugins/change_password/options.php

index f4de30cd806ba27dd08578a96f99b0304ff48579..1e511274c4f710fce3621f395350c55c6ef150bd 100644 (file)
@@ -105,7 +105,7 @@ function cpw_do_change()
 
     /* make sure we write the session data before we redirect */
     session_write_close();
-    header('Location: '.SM_PATH. 'src/options.php?optmode=submit&optpage=change_password&plugin_change_password=1');
+    header('Location: '.SM_PATH. 'src/options.php?optmode=submit&optpage=change_password&plugin_change_password=1&smtoken=' . sm_generate_security_token());
     exit;
 }
 
index 2d504666db9630aed3b8f937a8e2aeb33533e084..05941d043f78f761a2dd5ad1a1fee7c10396c78b 100644 (file)
@@ -53,6 +53,11 @@ if (file_exists(SM_PATH . 'plugins/change_password/backend/'.$cpw_backend.'.php'
 
 /* the form was submitted, go for it */
 if(sqgetGlobalVar('cpw_go', $cpw_go, SQ_POST)) {
+
+    // security check
+    sqgetGlobalVar('smtoken', $submitted_token, SQ_POST, '');
+    sm_validate_security_token($submitted_token, 3600, TRUE);
+
     /* perform basic checks */
     $Messages = cpw_check_input();
 
@@ -83,6 +88,7 @@ if (isset($Messages) && count($Messages) > 0) {
 
 ?><tr><td>
     <?php echo addForm($_SERVER['PHP_SELF'], 'post'); ?>
+    <input type="hidden" name="smtoken" value="<?php echo sm_generate_security_token() ?>" />
     <table>
       <tr>
         <th align="right"><?php echo _("Current Password:")?></th>