Small security patch: Make sure that the envelope sender address doesn't
authorpallo <pallo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 19 Sep 2000 08:22:44 +0000 (08:22 +0000)
committerpallo <pallo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 19 Sep 2000 08:22:44 +0000 (08:22 +0000)
contain any spaces or other chars that could be used in an expolit.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@746 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/smtp.php

index f8c3fdbbe845a4cacfbc3415e70afa78fa4804bb..ef8684da7d408ad68ac24a13cc6c90658b3b87b2 100644 (file)
    function sendSendmail($t, $c, $b, $subject, $body, $more_headers) {
       global $sendmail_path, $username, $domain;
 
+      // Build envelope sender address. Make sure it doesn't contain 
+      // spaces or other "weird" chars that would allow a user to
+      // exploit the shell/pipe it is used in.
+      $envelopefrom = "$username@$domain";
+      $envelopefrom = ereg_replace("[[:blank:]]","", $envelopefrom);
+      $envelopefrom = ereg_replace("[[:space:]]","", $envelopefrom);
+      $envelopefrom = ereg_replace("[[:cntrl:]]","", $envelopefrom);
+
       // open pipe to sendmail
-      $fp = popen (escapeshellcmd("$sendmail_path -t -f$username@$domain"), "w");
+      $fp = popen (escapeshellcmd("$sendmail_path -t -f$envelopefrom"), "w");
       
       $headerlength = write822Header ($fp, $t, $c, $b, $subject, $more_headers);
       $bodylength = writeBody($fp, $body);