Source code taken from cacert-20140419.tar.bz2
authorMichael Tänzer <neo@nhng.de>
Mon, 21 Apr 2014 18:07:00 +0000 (20:07 +0200)
committerMichael Tänzer <neo@nhng.de>
Mon, 21 Apr 2014 18:07:00 +0000 (20:07 +0200)
includes/account.php
includes/general.php
locale/Makefile
pages/account/57.php
pages/index/1.php
scripts/cron/warning.php
scripts/gpgfillmissingemail.php
scripts/scanforexponents.php
scripts/send_heartbleed.php [new file with mode: 0644]
www/api/ccsr.php
www/gpg.php

index 7c3748d..7e9ee2a 100644 (file)
@@ -395,7 +395,8 @@ function buildSubjectFromSession() {
                        fputs($fp, $emails);
                        fclose($fp);
                        $challenge=$_SESSION['spkac_hash'];
-                       $res=`openssl spkac -verify -in $CSRname`;
+                       $CSRname_esc = escapeshellarg($CSRname);
+                       $res=`openssl spkac -verify -in $CSRname_esc`;
                        if(!strstr($res,"Challenge String: ".$challenge))
                        {
                                $id = $oldid;
@@ -457,7 +458,9 @@ function buildSubjectFromSession() {
                                $csrsubject .= "/emailAddress = ".$user['uniqueID'];
 
                        $tmpname = tempnam("/tmp", "id4csr");
-                       $do = `/usr/bin/openssl req -in $tmpfname -out $tmpname`; // -subj "$csr"`;
+                       $tmpfname_esc = escapeshellarg($tmpfname);
+                       $tmpname_esc = escapeshellarg($tmpname);
+                       $do = `/usr/bin/openssl req -in $tmpfname_esc -out $tmpname_esc`; // -subj "$csr"`;
                        @unlink($tmpfname);
                        $csr = "";
                        $fp = fopen($tmpname, "r");
@@ -733,9 +736,9 @@ function buildSubjectFromSession() {
                $fp = fopen($_SESSION['_config']['tmpfname'], "w");
                fputs($fp, $CSR);
                fclose($fp);
-               $CSR = $_SESSION['_config']['tmpfname'];
-               $_SESSION['_config']['subject'] = trim(`/usr/bin/openssl req -text -noout -in "$CSR"|tr -d "\\0"|grep "Subject:"`);
-               $bits = explode(",", trim(`/usr/bin/openssl req -text -noout -in "$CSR"|tr -d "\\0"|grep -A1 'X509v3 Subject Alternative Name:'|grep DNS:`));
+               $CSR = escapeshellarg($_SESSION['_config']['tmpfname']);
+               $_SESSION['_config']['subject'] = trim(`/usr/bin/openssl req -text -noout -in $CSR |tr -d "\\0"|grep "Subject:"`);
+               $bits = explode(",", trim(`/usr/bin/openssl req -text -noout -in $CSR |tr -d "\\0"|grep -A1 'X509v3 Subject Alternative Name:'|grep DNS:`));
                foreach($bits as $val)
                {
                        $_SESSION['_config']['subject'] .= "/subjectAltName=".trim($val);
@@ -886,22 +889,23 @@ function buildSubjectFromSession() {
 
                                mysql_query("update `domaincerts` set `renewed`='1' where `id`='$id'");
                                $query = "insert into `domaincerts` set
-                                               `domid`='".$row['domid']."',
+                                               `domid`='".intval($row['domid'])."',
                                                `CN`='".mysql_real_escape_string($row['CN'])."',
                                                `subject`='".mysql_real_escape_string($row['subject'])."',".
                                                //`csr_name`='".$row['csr_name']."', // RACE CONDITION
-                                               "`created`='".$row['created']."',
+                                               "`created`='".mysql_real_escape_string($row['created'])."',
                                                `modified`=NOW(),
-                                               `rootcert`='".$row['rootcert']."',
-                                               `type`='".$row['type']."',
-                                               `pkhash`='".$row['pkhash']."',
-                                               `description`='".$row['description']."'";
+                                               `rootcert`='".intval($row['rootcert'])."',
+                                               `type`='".intval($row['type'])."',
+                                               `pkhash`='".mysql_real_escape_string($row['pkhash'])."',
+                                               `description`='".mysql_real_escape_string($row['description'])."'";
                                mysql_query($query);
                                $newid = mysql_insert_id();
                                $newfile=generatecertpath("csr","server",$newid);
                                copy($row['csr_name'], $newfile);
-                               $_SESSION['_config']['subject'] = trim(`/usr/bin/openssl req -text -noout -in "$newfile"|tr -d "\\0"|grep "Subject:"`);
-                               $bits = explode(",", trim(`/usr/bin/openssl req -text -noout -in "$newfile"|tr -d "\\0"|grep -A1 'X509v3 Subject Alternative Name:'|grep DNS:`));
+                               $newfile_esc = escapeshellarg($newfile);
+                               $_SESSION['_config']['subject'] = trim(`/usr/bin/openssl req -text -noout -in $newfile_esc |tr -d "\\0"|grep "Subject:"`);
+                               $bits = explode(",", trim(`/usr/bin/openssl req -text -noout -in $newfile_esc |tr -d "\\0"|grep -A1 'X509v3 Subject Alternative Name:'|grep DNS:`));
                                foreach($bits as $val)
                                {
                                        $_SESSION['_config']['subject'] .= "/subjectAltName=".trim($val);
@@ -930,7 +934,8 @@ function buildSubjectFromSession() {
                                        printf(_("Your certificate request has failed to be processed correctly, see %sthe WIKI page%s for reasons and solutions."), "<a href='http://wiki.cacert.org/wiki/FAQ/CertificateRenewal'>", "</a>");
                                } else {
                                        $drow = mysql_fetch_assoc($res);
-                                       $cert = `/usr/bin/openssl x509 -in $drow[crt_name]`;
+                                       $crt_name = escapeshellarg($drow['crt_name']);
+                                       $cert = `/usr/bin/openssl x509 -in $crt_name`;
                                        echo "<pre>\n$cert\n</pre>\n";
                                }
                        }
@@ -972,8 +977,12 @@ function buildSubjectFromSession() {
                                        continue;
                                }
                                mysql_query("update `domaincerts` set `revoked`='1970-01-01 10:00:01' where `id`='$id'");
-                               printf(_("Certificate for '%s' has been revoked.")."<br>\n", $row['CN']);
+                               printf(_("Certificate for '%s' with the serial no '%s' has been revoked.").'<br/>', htmlspecialchars($row['CN']), htmlspecialchars($row['serial']));
                        }
+
+                       // TRANSLATORS: Please don't translate "Certificate Revocation List (CRL)", it's a technical term
+                       echo '<br/>'._('All listed certificates will be added to the Certificate Revocation List (CRL) soon.').'<br/>';
+
                }
                else
                {
@@ -1059,17 +1068,17 @@ function buildSubjectFromSession() {
 
                                mysql_query("update `emailcerts` set `renewed`='1' where `id`='$id'");
                                $query = "insert into emailcerts set
-                                               `memid`='".$row['memid']."',
+                                               `memid`='".intval($row['memid'])."',
                                                `CN`='".mysql_real_escape_string($row['CN'])."',
                                                `subject`='".mysql_real_escape_string($row['subject'])."',
-                                               `keytype`='".$row['keytype']."',
-                                               `csr_name`='".$row['csr_name']."',
-                                               `created`='".$row['created']."',
+                                               `keytype`='".mysql_real_escape_string($row['keytype'])."',
+                                               `csr_name`='".mysql_real_escape_string($row['csr_name'])."',
+                                               `created`='".mysql_real_escape_string($row['created'])."',
                                                `modified`=NOW(),
-                                               `disablelogin`='".$row['disablelogin']."',
-                                               `codesign`='".$row['codesign']."',
-                                               `rootcert`='".$row['rootcert']."',
-                                               `description`='".$row['description']."'";
+                                               `disablelogin`='".intval($row['disablelogin'])."',
+                                               `codesign`='".intval($row['codesign'])."',
+                                               `rootcert`='".intval($row['rootcert'])."',
+                                               `description`='".mysql_real_escape_string($row['description'])."'";
                                mysql_query($query);
                                $newid = mysql_insert_id();
                                $newfile=generatecertpath("csr","client",$newid);
@@ -1128,8 +1137,11 @@ function buildSubjectFromSession() {
                                        continue;
                                }
                                mysql_query("update `emailcerts` set `revoked`='1970-01-01 10:00:01' where `id`='$id'");
-                               printf(_("Certificate for '%s' has been revoked.")."<br>\n", $row['CN']);
+                               printf(_("Certificate for '%s' with the serial no '%s' has been revoked.").'<br/>', htmlspecialchars($row['CN']), htmlspecialchars($row['serial']));
                        }
+
+                       // TRANSLATORS: Please don't translate "Certificate Revocation List (CRL)", it's a technical term
+                       echo '<br/>'._('All listed certificates will be added to the Certificate Revocation List (CRL) soon.').'<br/>';
                }
                else
                {
@@ -1545,7 +1557,8 @@ function buildSubjectFromSession() {
                        fputs($fp, $emails);
                        fclose($fp);
                        $challenge=$_SESSION['spkac_hash'];
-                       $res=`openssl spkac -verify -in $CSRname`;
+                       $CSRname_esc = escapeshellarg($CSRname);
+                       $res=`openssl spkac -verify -in $CSRname_esc`;
                        if(!strstr($res,"Challenge String: ".$challenge))
                        {
                                $id = $oldid;
@@ -1597,7 +1610,9 @@ function buildSubjectFromSession() {
                                $csrsubject .= "/countryName=".$org['C'];
 
                        $tmpname = tempnam("/tmp", "id17csr");
-                       $do = `/usr/bin/openssl req -in $tmpfname -out $tmpname`;
+                       $tmpfname_esc = escapeshellarg($tmpfname);
+                       $tmpname_esc = escapeshellarg($tmpname);
+                       $do = `/usr/bin/openssl req -in $tmpfname_esc -out $tmpname_esc`;
                        @unlink($tmpfname);
                        $csr = "";
                        $fp = fopen($tmpname, "r");
@@ -1692,17 +1707,17 @@ function buildSubjectFromSession() {
                                        continue;
                                }
                                $query = "insert into `orgemailcerts` set
-                                               `orgid`='".$row['orgid']."',
-                                               `CN`='".$row['CN']."',
-                                               `ou`='".$row['ou']."',
-                                               `subject`='".$row['subject']."',
-                                               `keytype`='".$row['keytype']."',
-                                               `csr_name`='".$row['csr_name']."',
-                                               `created`='".$row['created']."',
+                                               `orgid`='".intval($row['orgid'])."',
+                                               `CN`='".mysql_real_escape_string($row['CN'])."',
+                                               `ou`='".mysql_real_escape_string($row['ou'])."',
+                                               `subject`='".mysql_real_escape_string($row['subject'])."',
+                                               `keytype`='".mysql_real_escape_string($row['keytype'])."',
+                                               `csr_name`='".mysql_real_escape_string($row['csr_name'])."',
+                                               `created`='".mysql_real_escape_string($row['created'])."',
                                                `modified`=NOW(),
-                                               `codesign`='".$row['codesign']."',
-                                               `rootcert`='".$row['rootcert']."',
-                                               `description`='".$row['description']."'";
+                                               `codesign`='".intval($row['codesign'])."',
+                                               `rootcert`='".intval($row['rootcert'])."',
+                                               `description`='".mysql_real_escape_string($row['description'])."'";
                                mysql_query($query);
                                $newid = mysql_insert_id();
                                $newfile=generatecertpath("csr","orgclient",$newid);
@@ -1755,8 +1770,11 @@ function buildSubjectFromSession() {
                                        continue;
                                }
                                mysql_query("update `orgemailcerts` set `revoked`='1970-01-01 10:00:01' where `id`='$id'");
-                               printf(_("Certificate for '%s' has been revoked.")."<br>\n", $row['CN']);
+                               printf(_("Certificate for '%s' with the serial no '%s' has been revoked.").'<br/>', htmlspecialchars($row['CN']), htmlspecialchars($row['serial']));
                        }
+
+                       // TRANSLATORS: Please don't translate "Certificate Revocation List (CRL)", it's a technical term
+                       echo '<br/>'._('All listed certificates will be added to the Certificate Revocation List (CRL) soon.').'<br/>';
                }
                else
                {
@@ -1850,9 +1868,9 @@ function buildSubjectFromSession() {
                $fp = fopen($_SESSION['_config']['tmpfname'], "w");
                fputs($fp, $CSR);
                fclose($fp);
-               $CSR = $_SESSION['_config']['tmpfname'];
-               $_SESSION['_config']['subject'] = trim(`/usr/bin/openssl req -text -noout -in "$CSR"|tr -d "\\0"|grep "Subject:"`);
-               $bits = explode(",", trim(`/usr/bin/openssl req -text -noout -in "$CSR"|tr -d "\\0"|grep -A1 'X509v3 Subject Alternative Name:'|grep DNS:`));
+               $CSR = escapeshellarg($_SESSION['_config']['tmpfname']);
+               $_SESSION['_config']['subject'] = trim(`/usr/bin/openssl req -text -noout -in $CSR |tr -d "\\0"|grep "Subject:"`);
+               $bits = explode(",", trim(`/usr/bin/openssl req -text -noout -in $CSR |tr -d "\\0"|grep -A1 'X509v3 Subject Alternative Name:'|grep DNS:`));
                foreach($bits as $val)
                {
                        $_SESSION['_config']['subject'] .= "/subjectAltName=".trim($val);
@@ -2043,15 +2061,15 @@ function buildSubjectFromSession() {
                                        continue;
                                }
                                $query = "insert into `orgdomaincerts` set
-                                               `orgid`='".$row['orgid']."',
-                                               `CN`='".$row['CN']."',
-                                               `csr_name`='".$row['csr_name']."',
-                                               `created`='".$row['created']."',
+                                               `orgid`='".intval($row['orgid'])."',
+                                               `CN`='".mysql_real_escape_string($row['CN'])."',
+                                               `csr_name`='".mysql_real_escape_string($row['csr_name'])."',
+                                               `created`='".mysql_real_escape_string($row['created'])."',
                                                `modified`=NOW(),
-                                               `subject`='".$row['subject']."',
-                                               `type`='".$row['type']."',
-                                               `rootcert`='".$row['rootcert']."',
-                                               `description`='".$row['description']."'";
+                                               `subject`='".mysql_real_escape_string($row['subject'])."',
+                                               `type`='".intval($row['type'])."',
+                                               `rootcert`='".intval($row['rootcert'])."',
+                                               `description`='".mysql_real_escape_string($row['description'])."'";
                                mysql_query($query);
                                $newid = mysql_insert_id();
                                //echo "NewID: $newid<br/>\n";
@@ -2070,7 +2088,8 @@ function buildSubjectFromSession() {
                                        printf(_("Your certificate request has failed to be processed correctly, see %sthe WIKI page%s for reasons and solutions.")." newid: $newid", "<a href='http://wiki.cacert.org/wiki/FAQ/CertificateRenewal'>", "</a>");
                                } else {
                                        $drow = mysql_fetch_assoc($res);
-                                       $cert = `/usr/bin/openssl x509 -in $drow[crt_name]`;
+                                       $crtname = escapeshellarg($drow['crt_name']);
+                                       $cert = `/usr/bin/openssl x509 -in $crtname`;
                                        echo "<pre>\n$cert\n</pre>\n";
                                }
                        }
@@ -2111,8 +2130,11 @@ function buildSubjectFromSession() {
                                        continue;
                                }
                                mysql_query("update `orgdomaincerts` set `revoked`='1970-01-01 10:00:01' where `id`='$id'");
-                               printf(_("Certificate for '%s' has been revoked.")."<br>\n", $row['CN']);
+                               printf(_("Certificate for '%s' with the serial no '%s' has been revoked.").'<br/>', htmlspecialchars($row['CN']), htmlspecialchars($row['serial']));
                        }
+
+                       // TRANSLATORS: Please don't translate "Certificate Revocation List (CRL)", it's a technical term
+                       echo '<br/>'._('All listed certificates will be added to the Certificate Revocation List (CRL) soon.').'<br/>';
                }
                else
                {
index d89c0e6..f36ccdf 100644 (file)
                //echo "Points due to name matches: $points<br/>";
 
                $shellpwd = escapeshellarg($pwd);
-               $do = `grep $shellpwd /usr/share/dict/american-english`;
+               $do = `grep -F -- $shellpwd /usr/share/dict/american-english`;
                if($do)
                        $points--;
 
                return(0);
        }
 
-       function hex2bin($data)
+       function gpg_hex2bin($data)
        {
                while(strstr($data, "\\x"))
                {
index 4215a4f..a2b856b 100644 (file)
@@ -144,7 +144,7 @@ GETTEXT_FILE_PATTERN := \
 ../pages/*/*.php \
 ../scripts/*.php \
 ../www/*.php \
-../www/*/*.php \
+../www/[a-z]*/*.php \
 # ../tverify/*.php \
 # ../tverify/*/*.php \
 
index 76eee27..0356eeb 100644 (file)
 */ ?>
 <?
   include_once($_SESSION['_config']['filepath'].'/includes/notary.inc.php');
-  
+
   if ($_SESSION['profile']['admin'] != 1 || !array_key_exists('userid',$_REQUEST) || intval($_REQUEST['userid']) < 1) {
 
   echo _('You do not have access to this page');
 
-  } else {  
+  } else {
     $user_id = intval($_REQUEST['userid']);
     $query = "select * from `users` where `id`='$user_id' and `users`.`deleted`=0";
     $res = mysql_query($query);
@@ -38,7 +38,7 @@
   </tr>
 </table>
 
-  
+
 <br>
 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
   <tr>
@@ -57,8 +57,8 @@
 ?>
   <tr>
     <td class="DataTD"><?=_('First active CCA')?></td>
-    <td class="DataTD"><?=$data['date']?></td>
-    <td class="DataTD"><?=$data['method']?></td>
+    <td class="DataTD"><?=isset($data['date'])?$data['date']:''?></td>
+    <td class="DataTD"><?=isset($data['method'])?$data['method']:''?></td>
     <td class="DataTD"><?=$type?></td>
   </tr>
 <?
@@ -71,8 +71,8 @@
 ?>
   <tr>
     <td class="DataTD"><?=_('First passive CCA')?></td>
-    <td class="DataTD"><?=$data['date']?></td>
-    <td class="DataTD"><?=$data['method']?></td>
+    <td class="DataTD"><?=isset($data['date'])?$data['date']:''?></td>
+    <td class="DataTD"><?=isset($data['method'])?$data['method']:''?></td>
     <td class="DataTD"><?=$type?></td>
   </tr>
 <?
 ?>
   <tr>
     <td class="DataTD"><?=_('Last CCA')?></td>
-    <td class="DataTD"><?=$data['date']?></td>
-    <td class="DataTD"><?=$data['method']?></td>
+    <td class="DataTD"><?=isset($data['date'])?$data['date']:''?></td>
+    <td class="DataTD"><?=isset($data['method'])?$data['method']:''?></td>
     <td class="DataTD"><?=$type?></td>
   </tr>
 </table>
 <br>
 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
-  <tr> 
+  <tr>
 <?
       if ($_SESSION['profile']['admin'] == 1 && array_key_exists('userid',$_REQUEST) && intval($_REQUEST['userid']) > 0) {
 ?>
     <tr><td colspan="3" class="DataTD"><a href="account.php?id=43&amp;userid=<?=$user_id ?>">back</a></td></tr>
-<?    } 
+<?    }
 ?>  </table>
 <?
   }
index 4f0ca83..3315d69 100644 (file)
@@ -35,7 +35,7 @@
 
   <tr>
     <td class="DataTD" width="125"><?=_("First Name")?>: </td>
-    <td class="DataTD" width="125"><input type="text" name="fname" value="<?=array_key_exists('fname',$_REQUEST)?sanitizeHTML($_REQUEST['fname']):""?>" autocomplete="off"></td>
+    <td class="DataTD" width="125"><input type="text" name="fname" size="30" value="<?=array_key_exists('fname',$_REQUEST)?sanitizeHTML($_REQUEST['fname']):""?>" autocomplete="off"></td>
     <td rowspan="4" class="DataTD" width="125"><? printf(_("Help on Names %sin the wiki%s"),'<a href="//wiki.cacert.org/FAQ/HowToEnterNamesInJoinForm" target="_blank">','</a>')?></td>
   </tr>
 
     <td class="DataTD" valign="top"><?=_("Middle Name(s)")?><br>
       (<?=_("optional")?>)
     </td>
-    <td class="DataTD"><input type="text" name="mname" value="<?=array_key_exists('mname',$_REQUEST)?sanitizeHTML($_REQUEST['mname']):""?>" autocomplete="off"></td>
+    <td class="DataTD"><input type="text" name="mname" size="30" value="<?=array_key_exists('mname',$_REQUEST)?sanitizeHTML($_REQUEST['mname']):""?>" autocomplete="off"></td>
   </tr>
 
   <tr>
     <td class="DataTD"><?=_("Last Name")?>: </td>
-    <td class="DataTD"><input type="text" name="lname" value="<?=array_key_exists('lname',$_REQUEST)?sanitizeHTML($_REQUEST['lname']):""?>" autocomplete="off"></td>
+    <td class="DataTD"><input type="text" name="lname" size="30" value="<?=array_key_exists('lname',$_REQUEST)?sanitizeHTML($_REQUEST['lname']):""?>" autocomplete="off"></td>
   </tr>
 
   <tr>
     <td class="DataTD"><?=_("Suffix")?><br>
       (<?=_("optional")?>)</td>
-    <td class="DataTD"><input type="text" name="suffix" value="<?=array_key_exists('suffix',$_REQUEST)?sanitizeHTML($_REQUEST['suffix']):""?>" autocomplete="off"><br><?=sprintf(_("Please only write Name Suffixes into this field."))?></td>
+    <td class="DataTD"><input type="text" name="suffix" size="30" value="<?=array_key_exists('suffix',$_REQUEST)?sanitizeHTML($_REQUEST['suffix']):""?>" autocomplete="off"><br><?=sprintf(_("Please only write Name Suffixes into this field."))?></td>
   </tr>
 
   <tr>
 
   <tr>
     <td class="DataTD"><?=_("Email Address")?>: </td>
-    <td class="DataTD"><input type="text" name="email" value="<?=array_key_exists('email',$_REQUEST)?sanitizeHTML($_REQUEST['email']):""?>" autocomplete="off"></td>
+    <td class="DataTD"><input type="text" name="email" size="30" value="<?=array_key_exists('email',$_REQUEST)?sanitizeHTML($_REQUEST['email']):""?>" autocomplete="off"></td>
     <td class="DataTD"><?=_("I own or am authorised to control this email address")?></td>
   </tr>
 
   <tr>
     <td class="DataTD"><?=_("Pass Phrase")?><font color="red">*</font>: </td>
-    <td class="DataTD"><input type="password" name="pword1" autocomplete="off"></td>
+    <td class="DataTD"><input type="password" name="pword1" size="30" autocomplete="off"></td>
     <td class="DataTD" rowspan="2">&nbsp;</td>
   </tr>
   <tr>
     <td class="DataTD"><?=_("Pass Phrase Again")?><font color="red">*</font>: </td>
-    <td class="DataTD"><input type="password" name="pword2" autocomplete="off"></td>
+    <td class="DataTD"><input type="password" name="pword2" size="30" autocomplete="off"></td>
   </tr>
 
   <tr>
   </tr>
 
   <tr>
-    <td class="DataTD">1)&nbsp;<input type="text" name="Q1" size="15" value="<?=array_key_exists('Q1',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['Q1']):""?>"></td>
-    <td class="DataTD"><input type="text" name="A1" value="<?=array_key_exists('A1',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['A1']):""?>" autocomplete="off"></td>
-    <td class="DataTD" rowspan="5">&nbsp;</td>
+    <td class="DataTD">&nbsp;</td>
+    <td class="DataTD"><?=_("Question")?></td>
+    <td class="DataTD"><?=_("Answer")?></td>
+  </tr>
+
+  <tr>
+    <td class="DataTD">1)</td>
+    <td class="DataTD"><input type="text" name="Q1" size="30" value="<?=array_key_exists('Q1',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['Q1']):""?>"></td>
+    <td class="DataTD"><input type="text" name="A1" size="30" value="<?=array_key_exists('A1',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['A1']):""?>" autocomplete="off"></td>
   </tr>
 
   <tr>
-    <td class="DataTD">2)&nbsp;<input type="text" name="Q2" size="15" value="<?=array_key_exists('Q2',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['Q2']):""?>"></td>
-    <td class="DataTD"><input type="text" name="A2" value="<?=array_key_exists('A2',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['A2']):""?>" autocomplete="off"></td>
+    <td class="DataTD">2)</td>
+    <td class="DataTD"><input type="text" name="Q2" size="30" value="<?=array_key_exists('Q2',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['Q2']):""?>"></td>
+    <td class="DataTD"><input type="text" name="A2" size="30" value="<?=array_key_exists('A2',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['A2']):""?>" autocomplete="off"></td>
   </tr>
 
   <tr>
-    <td class="DataTD">3)&nbsp;<input type="text" name="Q3" size="15" value="<?=array_key_exists('Q3',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['Q3']):""?>"></td>
-    <td class="DataTD"><input type="text" name="A3" value="<?=array_key_exists('A3',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['A3']):""?>" autocomplete="off"></td>
+    <td class="DataTD">3)</td>
+    <td class="DataTD"><input type="text" name="Q3" size="30" value="<?=array_key_exists('Q3',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['Q3']):""?>"></td>
+    <td class="DataTD"><input type="text" name="A3" size="30"value="<?=array_key_exists('A3',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['A3']):""?>" autocomplete="off"></td>
   </tr>
 
   <tr>
-    <td class="DataTD">4)&nbsp;<input type="text" name="Q4" size="15" value="<?=array_key_exists('Q4',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['Q4']):""?>"></td>
-    <td class="DataTD"><input type="text" name="A4" value="<?=array_key_exists('A4',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['A4']):""?>" autcomplete="off"></td>
+    <td class="DataTD">4)</td>
+    <td class="DataTD"><input type="text" name="Q4" size="30"" value="<?=array_key_exists('Q4',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['Q4']):""?>"></td>
+    <td class="DataTD"><input type="text" name="A4" size="30" value="<?=array_key_exists('A4',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['A4']):""?>" autcomplete="off"></td>
   </tr>
 
   <tr>
-  <td class="DataTD">5)&nbsp;<input type="text" name="Q5" size="15" value="<?=array_key_exists('Q5',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['Q5']):""?>"></td>
-    <td class="DataTD"><input type="text" name="A5" value="<?=array_key_exists('A5',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['A5']):""?>" autocomplete="off"></td>
+  <td class="DataTD">5)</td>
+    <td class="DataTD"><input type="text" name="Q5" size="30" value="<?=array_key_exists('Q5',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['Q5']):""?>"></td>
+    <td class="DataTD"><input type="text" name="A5" size="30" value="<?=array_key_exists('A5',$_SESSION['signup'])?sanitizeHTML($_SESSION['signup']['A5']):""?>" autocomplete="off"></td>
   </tr>
 
   <tr>
index 0c97ba2..8f607cd 100755 (executable)
@@ -38,7 +38,8 @@
                        {
                                $row['crt_name'] = str_replace("../", "www/", $row['crt_name']);
                                $row['crt_name'] = "/home/cacert/".$row['crt_name'];
-                               $subject = `openssl x509 -in '$row[crt_name]' -text -noout|grep Subject:`;
+                               $crt_name = escapeshellarg($row['crt_name']);
+                               $subject = `openssl x509 -in $crt_name -text -noout|grep Subject:`;
                                $bits = explode("/", $subject);
                                foreach($bits as $val)
                                {
index f328876..39f9d8f 100644 (file)
@@ -18,7 +18,7 @@
        require_once("../includes/mysql.php"); //general.php");
        //include "../includes/general.php";
 
-function hex2bin($data)
+function gpg_hex2bin($data)
        {
                while(strstr($data, "\\x"))
                {
@@ -69,7 +69,7 @@ echo "Found:\n";
                                if (preg_match("/<([\w.-]*\@[\w.-]*)>/", $bits[9],$match)) 
                                {
                                   //echo "Found: ".$match[1];
-                                   $mail = trim(hex2bin($match[1]));
+                                   $mail = trim(gpg_hex2bin($match[1]));
 
 
                                echo "EMail: *$mail**\n";
index 7136723..388fe1e 100755 (executable)
                if(!is_file($file))
                        continue;
 
+               $file_esc = escapeshellarg($file);
                if(substr($file, -3) == "der")
-                       $do = trim(`openssl x509 -inform der -in $file -text -noout 2>&1 |grep 'Exponent'`);
+                       $do = trim(`openssl x509 -inform der -in $file_esc -text -noout 2>&1 |grep 'Exponent'`);
                else
-                       $do = trim(`openssl x509 -in $file -text -noout 2>&1 |grep 'Exponent'`);
+                       $do = trim(`openssl x509 -in $file_esc -text -noout 2>&1 |grep 'Exponent'`);
 
                if($do == "")
                        continue;
diff --git a/scripts/send_heartbleed.php b/scripts/send_heartbleed.php
new file mode 100644 (file)
index 0000000..6bf0f5f
--- /dev/null
@@ -0,0 +1,248 @@
+#!/usr/bin/php -q
+<?php
+/*
+    LibreSSL - CAcert web application
+    Copyright (C) 2004-2009  CAcert Inc.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; version 2 of the License.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+include_once("../includes/mysql.php");
+
+// read texts
+
+$lines_EN = <<<EOF
+
+there are news [1] about a bug in OpenSSL that may allow an attacker to leak arbitrary information from any process using OpenSSL. [2]
+
+We contacted you, because you have subscribed to get general announcements, or you have had a server certificate since the bug was introduced into the OpenSSL releases and are especially likely to be affected by it.
+
+CAcert is not responsible for this issue. But we want to inform members about it, who are especially likely to be vulnerable or otherwise affected.
+
+
+Good news:
+==========
+Certificates issued by CAcert are not broken and our central systems did not leak your keys.
+
+
+Bad news:
+=========
+Even then you may be affected.
+
+Although your keys were not leaked by CAcert your keys on your own systems might have been compromised if you were or are running a vulnerable version of OpenSSL.
+
+
+To elaborate on this:
+=====================
+The central systems of CAcert and our root certificates are not affected by this issue. Regrettably some of our infrastructure systems were affected by the bug. We are working to fix them and already completed work for the most critical ones. If you logged into those systems, within the last two years, (see list in the blog post) you might be affected!
+
+But unfortunately given the nature of this bug we have to assume that the certificates of our members may be affected, if they were used in an environment with a publicly accessible OpenSSL connection (e.g. Apache web server, mail server, Jabber server, ...). The bug has been open in OpenSSL for two years - from December 2011 and was introduced in stable releases starting with OpenSSL 1.0.1.
+
+When an attacker can reach a vulnerable service he can abuse the TLS heartbeat extension to retrieve arbitrary chunks of memory by exploiting a missing bounds check. This can lead to disclosure of your private keys, resident session keys and other key material as well as  all volatile memory contents of the server process like passwords, transmitted user data (e.g. web content) as well as other potentially confidential information.
+
+Exploiting this bug does not leave any noticeable traces, thus for any system which is (or has been) running a vulnerable version of OpenSSL you must assume  that at least your used server keys are compromised and therefore must be replaced by newly generated ones. Simply renewing existing certificates is not sufficient! - Please generate NEW keys with at least 2048 bit RSA or stronger!
+
+As mentioned above this bug can be used to leak passwords and thus you should consider changing your login credentials to potentially compromised systems as well as any other system where those credentials might have been used as soon as possible.
+
+An (incomplete) list of commonly used software which include or link to OpenSSL can be found at [5].
+
+
+What to do?
+===========
+- Ensure that you upgrade your system to a fixed OpenSSL version (1.0.1g or above).
+- Only then create new keys for your certificates.
+- Revoke all certificates, which may be affected.
+- Check what services you have used that may have been affected within the last two years.
+- Wait until you think that those environments got fixed.
+- Then (and only then) change your credentials for those services. If you do it too early, i.e. before the sites got fixed, your data may be leaked, again. So be careful when you do this.
+
+
+CAcert's response to the bug:
+=============================
+- We updated most of the affected infrastructure systems and created new certificates for them. The remaining will follow, soon.
+- We used this opportunity to upgrade to 4096 bit RSA keys signed with SHA-512. The new fingerprints can be found in the list in the blog post. ;-)
+- With this email we contact all members, who had active server certificates within the last two years.
+- We will keep you updated, in the blog.
+
+A list of affected and fixed infrastructure systems and new information can be found at:
+
+https://blog.cacert.org/2014/04/openssl-heartbleed-bug/
+
+
+Links:
+[1] http://heartbleed.com/
+[2] https://www.openssl.org/news/secadv_20140407.txt
+[3] https://security-tracker.debian.org/tracker/CVE-2014-0160
+[4] http://www.golem.de/news/sicherheitsluecke-keys-auslesen-mit-openssl-1404-105685.html
+[5] https://www.openssl.org/related/apps.html
+EOF;
+
+$lines_EN = wordwrap($lines_EN, 75, "\n");
+$lines_EN = mb_convert_encoding($lines_EN, "HTML-ENTITIES", "UTF-8");
+
+
+$lines_DE = <<<EOF
+---
+German Translation / Deutsche Übersetzung:
+
+
+Liebes CAcert-Mitglied,
+
+es wurde ein Bug in OpenSSL gefunden [4], der es einem Angreifer erlaubt beliebige Informationen jedes Prozesses zu erlangen, der OpenSSL nutzt. [2]
+
+Wir schicken diese Mail an alle Mitglieder, die entweder die "Allgemeinen Ankündigungen" abonniert haben, oder von dem Bug besonders betroffen sein können, da sie Server-Zertifikate in der Zeit besessen haben, seitdem der Bug in die Releases von OpenSSL integriert wurde.
+
+Diese Gefahr geht nicht von CAcert aus, wir möchten aber gefährdete Mitglieder entsprechend informieren.
+
+
+Die gute Nachricht:
+===================
+Die von CAcert ausgestellten Zertifikate sind nicht kaputt und unsere zentralen Systeme waren auch nicht angreifbar und haben auch keine Schlüssel verraten.
+
+
+Die schlechte Nachricht:
+========================
+Dennoch kann jeder betroffen sein!
+
+Auch wenn keine Schlüssel durch CAcert preisgegeben wurden, können sie dennoch später kompromittiert worden sein, wenn auf Ihren Systemen eine angreifbaren Version von OpenSSL lief und die Schlüssel dort verwendet wurden.
+
+
+Um ins Detail zu gehen:
+=======================
+Die zentralen Systeme und die Stammzertifikate von CAcert sind von diesem Problem nicht betroffen. Leider sind einige unserer Infrastruktur-Systeme durch den Fehler betroffen. Wir arbeiten daran diese zu beheben und haben dies auch schon für die meisten erledigt. Jeder, der sich auf diese Systeme in den letzten zwei Jahren eingeloggt hat kann betroffen sein!
+
+Aufgrund der Art des Fehlers, müssen wir leider davon ausgehen, dass die Zertifikate unserer Mitglieder betroffen sind, wenn sie sich in eine Umgebung eingeloggt haben, die über öffentliche OpenSSL-Verbindungen zugänglich war (z.B. Apache Webserver, Mail-Server, Jabber-Server, ...). Dieser Fehler war zwei Jahre lang in OpenSSL - seit Dezember 2011 - und kam beginnend mit Version 1.0.1 in die stabilen Versionen.
+
+Angreifer, die einen verwundbaren Service erreichen können, können die TLS-Erweiterung "heartbeat" ausnutzen, um beliebige Speicherbereiche zu auslesen, indem sie eine fehlende Bereichsprüfung ausnutzen. Das kann zur Offenlegung von privaten Schlüsseln, im Speicher abgelegten Sitzungsschlüsseln, sonstige Schlüssel genauso wie jeglicher weiterer Speicherinhalt des Server-Prozesses wie Passwörter oder übermittelte Benutzerdaten (z.B. Webinhalte) oder anderer vertrauliche Informationen führen.
+
+Die Ausnutzung dieses Fehlers hinterlässt keine merklichen Spuren. Daher muss für jedes System, auf dem eine angreifbare Version von OpenSSL läuft (oder lief), angenommen werden, dass zumindest die verwendeten Server-Zertifikate kompromittiert sind und deswegen durch NEU generierte ersetzt werden müssen. Einfach die alten Zertifikate zu erneuern, reicht nicht aus! - Bitte NEUE Schlüssel mit 2048 Bit RSA oder stärker generieren!
+
+Wie oben erwähnt kann dieser Fehler ausgenutzt werden, um Passwörter zu entwenden. Daher sollte jeder überlegen, alle Zugangsdaten zu möglicherweise betroffenen Systemen und allen Systemen bei denen diese sonst noch verwendet worden sein könnten, so bald wie möglich auszutauschen.
+
+Eine (unvollständige) Liste an weit verbreiteter Software die OpenSSL verwendet kann z.B. unter folgendem Link gefunden werden. [5]
+
+
+Was ist zu tun?
+===============
+- Als erstes müssen die eigenen Systeme auf eine fehlerbereinigte Version von OpenSSL aktualisiert werden (Version 1.0.1g oder neuer).
+- Danach neue Schlüssel für die Zertifikate erstellen. Jetzt ist es sicher das zu tun.
+- Alle möglicherweise betroffenen Zertifikate widerrufen.
+- Überprüfen, welche fremden Dienste in den letzten zwei Jahren besucht worden sind.
+- Warten, bis dort wahrscheinlich der Fehler behoben wurde.
+- Dann (und erst dann) die Login-Daten für diese Dienste erneuern. Vorsicht: Wenn das zu früh getan wird, also wenn der Dienst noch nicht bereinigt wurde, können die Daten wieder abgegriffen werden.
+
+
+CAcerts Maßnahmen als Antwort auf den Bug:
+==========================================
+- Wir haben so gut wie alle Infrastruktur-Systeme auf den neuesten OpenSSL-Stand gebracht und für diese neue Zertifikate zu generiert, die restlichen folgen so schnell wie möglich.
+- Wir haben die Gelegenheit genutzt, um dabei auf 4096 Bit RSA-Schlüssel, die mit SHA-512 signiert sind, aufzurüsten.
+- Mit dieser E-Mail kontaktieren wir alle Mitglieder, die in den letzten zwei Jahren aktive Server-Zertifikate hatten.
+- Wir werden neue Informationen im Blog veröffentlichen.
+
+Eine Liste der betroffenen und reparierten Infrastruktur-Systeme befindet sich unter:
+
+https://blog.cacert.org/2014/04/openssl-heartbleed-bug/
+
+Links:
+[1] http://heartbleed.com/
+[2] https://www.openssl.org/news/secadv_20140407.txt
+[3] https://security-tracker.debian.org/tracker/CVE-2014-0160
+[4] http://www.golem.de/news/sicherheitsluecke-keys-auslesen-mit-openssl-1404-105685.html
+[5] https://www.openssl.org/related/apps.html
+EOF;
+
+$lines_DE = wordwrap($lines_DE, 75, "\n");
+$lines_DE = mb_convert_encoding($lines_DE, "HTML-ENTITIES", "UTF-8");
+
+
+// read last used id
+$lastid = 0;
+if (file_exists("send_heartbleed_lastid.txt"))
+{
+       $fp = fopen("send_heartbleed_lastid.txt", "r");
+       $lastid = trim(fgets($fp, 4096));
+       fclose($fp);
+}
+
+echo "ID now: $lastid\n";
+
+
+$count = 0;
+
+$query = "
+       (
+               select u.`id`, u.`fname`, u.`lname`, u.`email`, u.`language`
+               from `users` as u, `alerts` as a
+               where u.`deleted` = 0 and u.`id` > '$lastid'
+                       and a.`memid` = u.`id`
+                       and a.`general` = 1
+       )
+       union distinct
+       (
+               select u.`id`, u.`fname`, u.`lname`, u.`email`, u.`language`
+               from `users` as u, `domains` as d, `domaincerts` as dc
+               where u.`deleted` = 0 and u.`id` > '$lastid'
+                       and dc.`domid` = d.`id` and d.`memid` = u.`id`
+                       and dc.`expire` >= '2011-12-01'
+       )
+       union distinct
+       (
+               select u.`id`, u.`fname`, u.`lname`, u.`email`, u.`language`
+               from `users` as u, `domains` as d, `domlink` as dl, `domaincerts` as dc
+               where u.`deleted` = 0 and u.`id` > '$lastid'
+                       and dc.`id` = dl.`certid` and dl.`domid` = d.`id` and d.`memid` = u.`id`
+                       and dc.`expire` >= '2011-12-01'
+       )
+       union distinct
+       (
+               select u.`id`, u.`fname`, u.`lname`, u.`email`, u.`language`
+               from `users` as u, `org` as o, `orgdomaincerts` as dc
+               where u.`deleted` = 0 and u.`id` > '$lastid'
+                       and dc.`orgid` = o.`orgid` and o.`memid` = u.`id`
+                       and dc.`expire` >= '2011-12-01'
+       )
+       union distinct
+       (
+               select u.`id`, u.`fname`, u.`lname`, u.`email`, u.`language`
+               from `users` as u, `org` as o, `orgdomains` as d, `orgdomlink` as dl, `orgdomaincerts` as dc
+               where u.`deleted` = 0 and u.`id` > '$lastid'
+                       and dc.`id` = dl.`orgcertid` and dl.`orgdomid` = d.`id`
+                               and d.`orgid` = o.`orgid` and o.`memid` = u.`id`
+                       and dc.`expire` >= '2011-12-01'
+       )
+       order by `id`";
+
+$res = mysql_query($query);
+
+while($row = mysql_fetch_assoc($res))
+{
+       $mailtxt = "Dear ${row["fname"]} ${row["lname"]},\n".$lines_EN."\n\n";
+       switch ($row["language"])
+       {
+               case "de_DE":
+               case "de":
+                       $mailtxt .= $lines_DE;
+                       break;
+       }
+
+       sendmail($row['email'], "[CAcert.org] Information about Heartbleed bug in OpenSSL 1.0.1 up to 1.0.1f", $mailtxt, "support@cacert.org", "", "", "CAcert", "returns@cacert.org", "");
+
+       $fp = fopen("send_heartbleed_lastid.txt", "w");
+       fputs($fp, $row["id"]."\n");
+       fclose($fp);
+
+       $count++;
+       echo "Sent ${count}th mail. User ID: ${row["id"]}\n";
+
+       sleep (1);
+}
index 7efdf8d..403882f 100644 (file)
@@ -73,7 +73,9 @@ require_once '../../includes/lib/check_weak_key.php';
        $fp = fopen($incsr, "w");
        fputs($fp, $CSR);
        fclose($fp);
-       $do = `/usr/bin/openssl req -in $incsr -out $checkedcsr`;
+       $incsr_esc = escapeshellarg($incsr);
+       $checkedcsr_esc = escapeshellarg($checkedcsr);
+       $do = `/usr/bin/openssl req -in $incsr_esc -out $checkedcsr_esc`;
        @unlink($incsr);
        if(filesize($checkedcsr) <= 0)
                die("404,Invalid or missing CSR");
index 829bbcf..263c1d3 100644 (file)
@@ -187,18 +187,18 @@ function verifyEmail($email)
                        // Name (Comment) <Email>
                        if(preg_match("/^([^\(\)\[@<>]+) \(([^\(\)@<>]*)\) <([\w=\/%.-]*\@[\w.-]*|[\w.-]*\![\w=\/%.-]*)>/",$bits[9],$matches))
                        {
-                         $name=trim(hex2bin($matches[1]));
+                         $name=trim(gpg_hex2bin($matches[1]));
                          $nocomment=0;
-                         $comm=trim(hex2bin($matches[2]));
-                         $mail=trim(hex2bin($matches[3]));
+                         $comm=trim(gpg_hex2bin($matches[2]));
+                         $mail=trim(gpg_hex2bin($matches[3]));
                        }
                        // Name <EMail>
                        elseif(preg_match("/^([^\(\)\[@<>]+) <([\w=\/%.-]*\@[\w.-]*|[\w.-]*\![\w=\/%.-]*)>/",$bits[9],$matches))
                        {
-                         $name=trim(hex2bin($matches[1]));
+                         $name=trim(gpg_hex2bin($matches[1]));
                          $nocomment=1;
                          $comm="";
-                         $mail=trim(hex2bin($matches[2]));
+                         $mail=trim(gpg_hex2bin($matches[2]));
                        }
                        // Unrecognized format
                        else
@@ -357,13 +357,13 @@ function verifyEmail($email)
                                        $pos = strlen($bits[9]);
                                }
 
-                               $name = trim(hex2bin(trim(substr($bits[9], 0, $pos))));
+                               $name = trim(gpg_hex2bin(trim(substr($bits[9], 0, $pos))));
                                $nameok=verifyName($name);
                                if($nocomment == 0)
                                {
                                        $pos += 2;
                                        $pos2 = strpos($bits[9], ")");
-                                       $comm = trim(hex2bin(trim(substr($bits[9], $pos, $pos2 - $pos))));
+                                       $comm = trim(gpg_hex2bin(trim(substr($bits[9], $pos, $pos2 - $pos))));
                                        if($comm != "")
                                                $comment[] = $comm;
                                        $pos = $pos2 + 3;
@@ -374,7 +374,7 @@ function verifyEmail($email)
                                $mail="";
                                if (preg_match("/<([\w.-]*\@[\w.-]*)>/", $bits[9],$match)) {
                                        //echo "Found: ".$match[1];
-                                       $mail = trim(hex2bin($match[1]));
+                                       $mail = trim(gpg_hex2bin($match[1]));
                                }
                                else
                                {