diff options
author | Michael Tänzer <neo@nhng.de> | 2011-06-17 18:34:11 +0200 |
---|---|---|
committer | Michael Tänzer <neo@nhng.de> | 2011-06-17 18:34:11 +0200 |
commit | 9516e1d117d1dcf88db7ead53f950c66850c6fcb (patch) | |
tree | 12c677e0038b8f169831f84228c6e1a8f367c491 | |
parent | 7c2327209cb81339d7e9a55d175c59786a2853b9 (diff) | |
download | cacert-9516e1d117d1dcf88db7ead53f950c66850c6fcb.tar.gz cacert-9516e1d117d1dcf88db7ead53f950c66850c6fcb.tar.xz cacert-9516e1d117d1dcf88db7ead53f950c66850c6fcb.zip |
Source code taken from cacert-20110616.tar.bz2
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | includes/account.php | 157 | ||||
-rw-r--r-- | includes/account_stuff.php | 357 | ||||
-rw-r--r-- | scripts/36us-ate-ny-email.txt | 34 | ||||
-rw-r--r-- | scripts/36us-ate-ny-mail.php.txt | 109 | ||||
-rw-r--r-- | scripts/DumpWeakCerts.pl | 179 | ||||
-rw-r--r-- | scripts/mail-weak-keys.php | 161 | ||||
-rw-r--r-- | scripts/perl_mysql.sample | 6 | ||||
-rw-r--r-- | www/api/ccsr.php | 6 | ||||
-rw-r--r-- | www/logos/CAcert-logo-colour-1000.png | bin | 0 -> 24317 bytes | |||
-rw-r--r-- | www/logos/CAcert-logo-mono-1000.png | bin | 0 -> 19406 bytes |
11 files changed, 994 insertions, 16 deletions
@@ -9,6 +9,7 @@ PHP GetText UFPDF - PDF generation library from http://acko.net/node/56 OpenSSL - X.509 toolkit from http://www.openssl.org/ +openssl-vulnkey including blacklists for all common key sizes GnuPG - OpenPGP toolkit from http://www.gnupg.org/ whois - whois client from http://www.linux.it/~md/software/ XEnroll - Enrollment Active-X control for IE5/6 from Microsoft (search for xenroll.cab) diff --git a/includes/account.php b/includes/account.php index 685b53a..14702b9 100644 --- a/includes/account.php +++ b/includes/account.php @@ -299,6 +299,15 @@ $_SESSION['_config']['rootcert'] = 1; $emails .= "SPKAC = $spkac"; + if (($weakKey = checkWeakKeySPKAC($emails)) !== "") + { + $id = 4; + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; + } + $query = "insert into emailcerts set `CN`='$defaultemail', `keytype`='NS', @@ -330,6 +339,16 @@ } else if($_REQUEST['keytype'] == "MS" || $_REQUEST['keytype'] == "VI") { if($csr == "") $csr = "-----BEGIN CERTIFICATE REQUEST-----\n".clean_csr($_REQUEST['CSR'])."\n-----END CERTIFICATE REQUEST-----\n"; + + if (($weakKey = checkWeakKeyCSR($csr)) !== "") + { + $id = 4; + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; + } + $tmpfname = tempnam("/tmp", "id4CSR"); $fp = fopen($tmpfname, "w"); fputs($fp, $csr); @@ -613,17 +632,23 @@ if($process != "" && $oldid == 10) { $CSR = clean_csr($_REQUEST['CSR']); - $_SESSION['_config']['tmpfname'] = tempnam("/tmp", "id10CSR"); - $fp = fopen($_SESSION['_config']['tmpfname'], "w"); if(strpos($CSR,"---BEGIN")===FALSE) { // In case the CSR is missing the ---BEGIN lines, add them automatically: - fputs($fp,"-----BEGIN CERTIFICATE REQUEST-----\n".$CSR."\n-----END CERTIFICATE REQUEST-----\n"); + $CSR = "-----BEGIN CERTIFICATE REQUEST-----\n".$CSR."\n-----END CERTIFICATE REQUEST-----\n"; } - else + + if (($weakKey = checkWeakKeyCSR($CSR)) !== "") { - fputs($fp, $CSR); + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; } + + $_SESSION['_config']['tmpfname'] = tempnam("/tmp", "id10CSR"); + $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:"`); @@ -658,6 +683,23 @@ if($process != "" && $oldid == 11) { + if(!file_exists($_SESSION['_config']['tmpfname'])) + { + showheader(_("My CAcert.org Account!")); + 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>"); + showfooter(); + exit; + } + + if (($weakKey = checkWeakKeyCSR(file_get_contents( + $_SESSION['_config']['tmpfname']))) !== "") + { + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; + } + $id = 11; if($_SESSION['_config']['0.CN'] == "" && $_SESSION['_config']['0.subjectAltName'] == "") { @@ -731,13 +773,6 @@ mysql_query("insert into `domlink` set `certid`='$CSRid', `domid`='$dom'"); $CSRname=generatecertpath("csr","server",$CSRid); - if(!file_exists($_SESSION['_config']['tmpfname'])) - { - showheader(_("My CAcert.org Account!")); - 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>"); - showfooter(); - exit; - } rename($_SESSION['_config']['tmpfname'], $CSRname); chmod($CSRname,0644); mysql_query("update `domaincerts` set `CSR_name`='$CSRname' where `id`='$CSRid'"); @@ -780,8 +815,17 @@ printf(_("Invalid ID '%s' presented, can't do anything with it.")."<br/>\n", $id); continue; } - mysql_query("update `domaincerts` set `renewed`='1' where `id`='$id'"); + $row = mysql_fetch_assoc($res); + + if (($weakKey = checkWeakKeyX509(file_get_contents( + $row['crt_name']))) !== "") + { + echo $weakKey, "<br/>\n"; + continue; + } + + mysql_query("update `domaincerts` set `renewed`='1' where `id`='$id'"); $query = "insert into `domaincerts` set `domid`='".$row['domid']."', `CN`='".mysql_real_escape_string($row['CN'])."', @@ -946,8 +990,17 @@ printf(_("Invalid ID '%s' presented, can't do anything with it.")."<br>\n", $id); continue; } - mysql_query("update `emailcerts` set `renewed`='1' where `id`='$id'"); + $row = mysql_fetch_assoc($res); + + if (($weakKey = checkWeakKeyX509(file_get_contents( + $row['crt_name']))) !== "") + { + echo $weakKey, "<br/>\n"; + continue; + } + + mysql_query("update `emailcerts` set `renewed`='1' where `id`='$id'"); $query = "insert into emailcerts set `memid`='".$row['memid']."', `CN`='".mysql_real_escape_string($row['CN'])."', @@ -1378,6 +1431,15 @@ $_SESSION['_config']['rootcert'] = 1; $emails .= "SPKAC = $spkac"; + if (($weakKey = checkWeakKeySPKAC($emails)) !== "") + { + $id = 17; + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; + } + $query = "insert into `orgemailcerts` set `CN`='$defaultemail', `keytype`='NS', @@ -1408,6 +1470,16 @@ mysql_query("update `orgemailcerts` set `csr_name`='$CSRname' where `id`='$emailid'"); } else if($_REQUEST['keytype'] == "MS" || $_REQUEST['keytype']=="VI") { $csr = "-----BEGIN CERTIFICATE REQUEST-----\n".clean_csr($_REQUEST['CSR'])."-----END CERTIFICATE REQUEST-----\n"; + + if (($weakKey = checkWeakKeyCSR($csr)) !== "") + { + $id = 17; + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; + } + $tmpfname = tempnam("/tmp", "id17CSR"); $fp = fopen($tmpfname, "w"); fputs($fp, $csr); @@ -1514,8 +1586,17 @@ printf(_("Invalid ID '%s' presented, can't do anything with it.")."<br>\n", $id); continue; } - mysql_query("update `orgemailcerts` set `renewed`='1' where `id`='$id'"); + $row = mysql_fetch_assoc($res); + + if (($weakKey = checkWeakKeyX509(file_get_contents( + $row['crt_name']))) !== "") + { + echo $weakKey, "<br/>\n"; + continue; + } + + mysql_query("update `orgemailcerts` set `renewed`='1' where `id`='$id'"); if($row['revoke'] > 0) { printf(_("It would seem '%s' has already been revoked. I'll skip this for now.")."<br>\n", $row['CN']); @@ -1625,6 +1706,16 @@ if($process != "" && $oldid == 20) { $CSR = clean_csr($_REQUEST['CSR']); + + if (($weakKey = checkWeakKeyCSR($CSR)) !== "") + { + $id = 20; + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; + } + $_SESSION['_config']['tmpfname'] = tempnam("/tmp", "id20CSR"); $fp = fopen($_SESSION['_config']['tmpfname'], "w"); fputs($fp, $CSR); @@ -1674,6 +1765,23 @@ if($process != "" && $oldid == 21) { $id = 21; + + if(!file_exists($_SESSION['_config']['tmpfname'])) + { + showheader(_("My CAcert.org Account!")); + 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>"); + showfooter(); + exit; + } + + if (($weakKey = checkWeakKeyCSR(file_get_contents( + $_SESSION['_config']['tmpfname']))) !== "") + { + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; + } if($_SESSION['_config']['0.CN'] == "" && $_SESSION['_config']['0.subjectAltName'] == "") { @@ -1799,8 +1907,17 @@ printf(_("Invalid ID '%s' presented, can't do anything with it.")."<br>\n", $id); continue; } - mysql_query("update `orgdomaincerts` set `renewed`='1' where `id`='$id'"); + $row = mysql_fetch_assoc($res); + + if (($weakKey = checkWeakKeyX509(file_get_contents( + $row['crt_name']))) !== "") + { + echo $weakKey, "<br/>\n"; + continue; + } + + mysql_query("update `orgdomaincerts` set `renewed`='1' where `id`='$id'"); if($row['revoke'] > 0) { printf(_("It would seem '%s' has already been revoked. I'll skip this for now.")."<br>\n", $row['CN']); @@ -2497,6 +2614,14 @@ showfooter(); exit; } + + if (($weakKey = checkWeakKeyCSR($CSR)) !== "") + { + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; + } $query = "insert into `domaincerts` set `CN`='".$_SESSION['_config']['0.CN']."', diff --git a/includes/account_stuff.php b/includes/account_stuff.php index fa6757b..7c8980c 100644 --- a/includes/account_stuff.php +++ b/includes/account_stuff.php @@ -284,4 +284,361 @@ function hideall() { </body> </html><? } + + /** + * Produces a log entry with the error message with log level E_USER_WARN + * and a random ID an returns a message that can be displayed to the user + * including the generated ID + * + * @param $errormessage string + * The error message that should be logged + * @return string containing the generated ID that can be displayed to the + * user + */ + function failWithId($errormessage) { + $errorId = rand(); + trigger_error("$errormessage. ID: $errorId", E_USER_WARNING); + return sprintf(_("Something went wrong when processing your request. ". + "Please contact %s for help and provide them with the ". + "following ID: %d"), + "<a href='mailto:support@cacert.org?subject=System%20Error%20-%20". + "ID%3A%20$errorId'>support@cacert.org</a>", + $errorId); + } + + /** + * Checks whether the given CSR contains a vulnerable key + * + * @param $csr string + * The CSR to be checked + * @param $encoding string [optional] + * The encoding the CSR is in (for the "-inform" parameter of OpenSSL, + * currently only "PEM" (default) or "DER" allowed) + * @return string containing the reason if the key is considered weak, + * empty string otherwise + */ + function checkWeakKeyCSR($csr, $encoding = "PEM") + { + // non-PEM-encodings may be binary so don't use echo + $descriptorspec = array( + 0 => array("pipe", "r"), // STDIN for child + 1 => array("pipe", "w"), // STDOUT for child + ); + $encoding = escapeshellarg($encoding); + $proc = proc_open("openssl req -inform $encoding -text -noout", + $descriptorspec, $pipes); + + if (is_resource($proc)) + { + fwrite($pipes[0], $csr); + fclose($pipes[0]); + + $csrText = ""; + while (!feof($pipes[1])) + { + $csrText .= fread($pipes[1], 8192); + } + fclose($pipes[1]); + + if (($status = proc_close($proc)) !== 0 || $csrText === "") + { + return _("I didn't receive a valid Certificate Request, hit ". + "the back button and try again."); + } + } else { + return failWithId("checkWeakKeyCSR(): Failed to start OpenSSL"); + } + + + return checkWeakKeyText($csrText); + } + + /** + * Checks whether the given X509 certificate contains a vulnerable key + * + * @param $cert string + * The X509 certificate to be checked + * @param $encoding string [optional] + * The encoding the certificate is in (for the "-inform" parameter of + * OpenSSL, currently only "PEM" (default), "DER" or "NET" allowed) + * @return string containing the reason if the key is considered weak, + * empty string otherwise + */ + function checkWeakKeyX509($cert, $encoding = "PEM") + { + // non-PEM-encodings may be binary so don't use echo + $descriptorspec = array( + 0 => array("pipe", "r"), // STDIN for child + 1 => array("pipe", "w"), // STDOUT for child + ); + $encoding = escapeshellarg($encoding); + $proc = proc_open("openssl x509 -inform $encoding -text -noout", + $descriptorspec, $pipes); + + if (is_resource($proc)) + { + fwrite($pipes[0], $cert); + fclose($pipes[0]); + + $certText = ""; + while (!feof($pipes[1])) + { + $certText .= fread($pipes[1], 8192); + } + fclose($pipes[1]); + + if (($status = proc_close($proc)) !== 0 || $certText === "") + { + return _("I didn't receive a valid Certificate Request, hit ". + "the back button and try again."); + } + } else { + return failWithId("checkWeakKeyCSR(): Failed to start OpenSSL"); + } + + + return checkWeakKeyText($certText); + } + + /** + * Checks whether the given SPKAC contains a vulnerable key + * + * @param $spkac string + * The SPKAC to be checked + * @param $spkacname string [optional] + * The name of the variable that contains the SPKAC. The default is + * "SPKAC" + * @return string containing the reason if the key is considered weak, + * empty string otherwise + */ + function checkWeakKeySPKAC($spkac, $spkacname = "SPKAC") + { + /* Check for the debian OpenSSL vulnerability */ + + $spkac = escapeshellarg($spkac); + $spkacname = escapeshellarg($spkacname); + $spkacText = `echo $spkac | openssl spkac -spkac $spkacname`; + if ($spkacText === null) { + return _("I didn't receive a valid Certificate Request, hit the ". + "back button and try again."); + } + + return checkWeakKeyText($spkacText); + } + + /** + * Checks whether the given text representation of a CSR or a SPKAC contains + * a weak key + * + * @param $text string + * The text representation of a key as output by the + * "openssl <foo> -text -noout" commands + * @return string containing the reason if the key is considered weak, + * empty string otherwise + */ + function checkWeakKeyText($text) + { + /* Which public key algorithm? */ + if (!preg_match('/^\s*Public Key Algorithm: ([^\s]+)$/m', $text, + $algorithm)) + { + return failWithId("checkWeakKeyText(): Couldn't extract the ". + "public key algorithm used"); + } else { + $algorithm = $algorithm[1]; + } + + + if ($algorithm === "rsaEncryption") + { + if (!preg_match('/^\s*RSA Public Key: \((\d+) bit\)$/m', $text, + $keysize)) + { + return failWithId("checkWeakKeyText(): Couldn't parse the RSA ". + "key size"); + } else { + $keysize = intval($keysize[1]); + } + + if ($keysize < 1024) + { + return sprintf(_("The keys that you use are very small ". + "and therefore insecure. Please generate stronger ". + "keys. More information about this issue can be ". + "found in %sthe wiki%s"), + "<a href='//wiki.cacert.org/WeakKeys#SmallKey'>", + "</a>"); + } elseif ($keysize < 2048) { + // not critical but log so we have some statistics about + // affected users + trigger_error("checkWeakKeyText(): Certificate for small ". + "key (< 2048 bit) requested", E_USER_NOTICE); + } + + + $debianVuln = checkDebianVulnerability($text, $keysize); + if ($debianVuln === true) + { + return sprintf(_("The keys you use have very likely been ". + "generated with a vulnerable version of OpenSSL which ". + "was distributed by debian. Please generate new keys. ". + "More information about this issue can be found in ". + "%sthe wiki%s"), + "<a href='//wiki.cacert.org/WeakKeys#DebianVulnerability'>", + "</a>"); + } elseif ($debianVuln === false) { + // not vulnerable => do nothing + } else { + return failWithId("checkWeakKeyText(): Something went wrong in". + "checkDebianVulnerability()"); + } + + if (!preg_match('/^\s*Exponent: (\d+) \(0x[0-9a-fA-F]+\)$/m', $text, + $exponent)) + { + return failWithId("checkWeakKeyText(): Couldn't parse the RSA ". + "exponent"); + } else { + $exponent = $exponent[1]; // exponent might be very big => + //handle as string using bc*() + + if (bccomp($exponent, "3") === 0) + { + return sprintf(_("The keys you use might be insecure. ". + "Although there is currently no known attack for ". + "reasonable encryption schemes, we're being ". + "cautious and don't allow certificates for such ". + "keys. Please generate stronger keys. More ". + "information about this issue can be found in ". + "%sthe wiki%s"), + "<a href='//wiki.cacert.org/WeakKeys#SmallExponent'>", + "</a>"); + } elseif (!(bccomp($exponent, "65537") >= 0 && + (bccomp($exponent, "100000") === -1 || + // speed things up if way smaller than 2^256 + bccomp($exponent, bcpow("2", "256")) === -1) )) { + // 65537 <= exponent < 2^256 recommended by NIST + // not critical but log so we have some statistics about + // affected users + trigger_error("checkWeakKeyText(): Certificate for ". + "unsuitable exponent '$exponent' requested", + E_USER_NOTICE); + } + } + } + + /* No weakness found */ + return ""; + } + + /** + * Reimplement the functionality of the openssl-vulnkey tool + * + * @param $text string + * The text representation of a key as output by the + * "openssl <foo> -text -noout" commands + * @param $keysize int [optional] + * If the key size is already known it can be provided so it doesn't + * have to be parsed again. This also skips the check whether the key + * is an RSA key => use wisely + * @return TRUE if key is vulnerable, FALSE otherwise, NULL in case of error + */ + function checkDebianVulnerability($text, $keysize = 0) + { + $keysize = intval($keysize); + + if ($keysize === 0) + { + /* Which public key algorithm? */ + if (!preg_match('/^\s*Public Key Algorithm: ([^\s]+)$/m', $text, + $algorithm)) + { + trigger_error("checkDebianVulnerability(): Couldn't extract ". + "the public key algorithm used", E_USER_WARNING); + return null; + } else { + $algorithm = $algorithm[1]; + } + + if ($algorithm !== "rsaEncryption") return false; + + /* Extract public key size */ + if (!preg_match('/^\s*RSA Public Key: \((\d+) bit\)$/m', $text, + $keysize)) + { + trigger_error("checkDebianVulnerability(): Couldn't parse the ". + "RSA key size", E_USER_WARNING); + return null; + } else { + $keysize = intval($keysize[1]); + } + } + + // $keysize has been made sure to contain an int + $blacklist = "/usr/share/openssl-blacklist/blacklist.RSA-$keysize"; + if (!(is_file($blacklist) && is_readable($blacklist))) + { + if (in_array($keysize, array(512, 1024, 2048, 4096))) + { + trigger_error("checkDebianVulnerability(): Blacklist for ". + "$keysize bit keys not accessible. Expected at ". + "$blacklist", E_USER_ERROR); + return null; + } + + trigger_error("checkDebianVulnerability(): $blacklist is not ". + "readable. Unsupported key size?", E_USER_WARNING); + return false; + } + + + /* Extract RSA modulus */ + if (!preg_match('/^\s*Modulus \(\d+ bit\):\n'. + '((?:\s*[0-9a-f][0-9a-f]:(?:\n)?)+[0-9a-f][0-9a-f])$/m', + $text, $modulus)) + { + trigger_error("checkDebianVulnerability(): Couldn't extract the ". + "RSA modulus", E_USER_WARNING); + return null; + } else { + $modulus = $modulus[1]; + // strip whitespace and colon leftovers + $modulus = str_replace(array(" ", "\t", "\n", ":"), "", $modulus); + + // when using "openssl xxx -text" first byte was 00 in all my test + // cases but 00 not present in the "openssl xxx -modulus" output + if ($modulus[0] === "0" && $modulus[1] === "0") + { + $modulus = substr($modulus, 2); + } else { + trigger_error("checkDebianVulnerability(): First byte is not ". + "zero", E_USER_NOTICE); + } + + $modulus = strtoupper($modulus); + } + + + /* calculate checksum and look it up in the blacklist */ + $checksum = substr(sha1("Modulus=$modulus\n"), 20); + + // $checksum and $blacklist should be safe, but just to make sure + $checksum = escapeshellarg($checksum); + $blacklist = escapeshellarg($blacklist); + exec("grep $checksum $blacklist", $dummy, $debianVuln); + if ($debianVuln === 0) // grep returned something => it is on the list + { + return true; + } elseif ($debianVuln === 1) { // grep returned nothing + return false; + } else { + trigger_error("checkDebianVulnerability(): Something went wrong ". + "when looking up the key with checksum $checksum in the ". + "blacklist $blacklist", E_USER_ERROR); + return null; + } + + // Should not get here + return null; + } ?> diff --git a/scripts/36us-ate-ny-email.txt b/scripts/36us-ate-ny-email.txt new file mode 100644 index 0000000..6cd1ef1 --- /dev/null +++ b/scripts/36us-ate-ny-email.txt @@ -0,0 +1,34 @@ +CAcert Assurer Training Event -- New York / Rutgers / Piscataway, NJ
+::::::::::::::::::::::::::::::::::::::::::::::::::
+
+Dear Member of the CAcert Community,
+
+Much has happened during recent years. The old way of orally-transmitted procedures has now gone, and our rules have been cast into formal policies. New procedures (e.g. the Assurer Challenge) and obligations (e.g. in the CAcert Community Agreement) have been approved.
+
+The Assurer Training Events bring all this to you, the Assurer, and the Community:
+
+- What do you have to add onto the CAP form if you assure minors ?
+- What are the 2 essential CCA points you have to present an Assuree ?
+- Who can access the Member's privacy information?
+
+Answers to these and many other questions typically faced by Assurers are given at the Assurer Training Events (ATEs). Bring your ID for assurances. Especially note that Tverify/Thawte people need to boost up their Assurance Points.
+
+ATE-NY takes place at:
+* Monday, June 20th, 2011
+* Rutgers Department of Computer Science, Piscataway, NJ
+* 1pm - 4pm
+
+For Registration please reply: 'I will attend ATE-NY'
+
+Don't forget your ID!
+
+We are looking forward to hearing from you.
+
+
+- Best regards from the Event Team!
+
+
+PS: Contact: events@cacert.org
+Location, Transportation and other event details at
+[https://wiki.cacert.org/Events/20110620ATE-NewYork]
+
diff --git a/scripts/36us-ate-ny-mail.php.txt b/scripts/36us-ate-ny-mail.php.txt new file mode 100644 index 0000000..1f75bb1 --- /dev/null +++ b/scripts/36us-ate-ny-mail.php.txt @@ -0,0 +1,109 @@ +#!/usr/bin/php -q +<? /* + 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"); + + $lines = ""; + $fp = fopen("36us-ate-ny-email.txt", "r"); + while(!feof($fp)) + { + $line = trim(fgets($fp, 4096)); + $lines .= wordwrap($line, 75, "\n")."\n"; + } + fclose($fp); + + +// $locid = intval($_REQUEST['location']); +// $maxdist = intval($_REQUEST['maxdist']); +// maxdist in [Km] + $maxdist = 200; + + +// location location.ID +// verified: 29.4.09 u.schroeter +// $locid = 7902857; // Paris +// $locid = 238568; // Bielefeld +// $locid = 715191; // Hamburg +// $locid = 1102495; // London +// $locid = 520340; // Duesseldorf +// $locid = 1260319; // Muenchen +// $locid = 606058; // Frankfurt +// $locid = 1775784; // Stuttgart +// $locid = 228950; // Berlin +// $locid = 606058; // Frankfurt +// $locid = 599389; // Flensburg +// $locid = 61065; // Amsterdam, Eemnes +// $locid = 228950; // Berlin +// $locid = 2138880; // Baltimore (Baltimore (city)), Maryland, US +// $locid = 1486658; // Potsdam +// $locid = 664715; // Goteborg, Vastra Gotaland, Sweden +// $locid = 2094781; // Mission Hills (Los Angeles), California, US +// $locid = 423655; // Copenhagen, Kobenhavn*, Denmark +// $locid = 2257312; // Sydney, New South Wales, Australia +// $locid = 572764; // Essen, Nordrhein-Westfalen, Germany +// $locid = 78; // Aachen, Nordrhein-Westfalen, Germany +// $locid = 266635; // Bonn, Nordrhein-Westfalen, Germany + +// ATE Washington DC, US, Jun 18th 2011 +// $locid = 2102723; // Washington (District of Columbia, ..., US +// $eventname = "ATE-Washington-DC getting closer"; +// $city = "June 18th, 2011"; + +// ATE Washington DC, US, Jun 18th 2011 + $locid = 2177566; // New York (Bronx), New York, United States + $eventname = "ATE-New York / Rutgers / Piscataway, NJ"; + $city = "June 20th, 2011"; + + + $query = "select * from `locations` where `id`='$locid'"; + $loc = mysql_fetch_assoc(mysql_query($query)); + + $query = "SELECT ROUND(6378.137 * ACOS(0.9999999*((SIN(PI() * $loc[lat] / 180) * SIN(PI() * `locations`.`lat` / 180)) + + (COS(PI() * $loc[lat] / 180 ) * COS(PI() * `locations`.`lat` / 180) * + COS(PI() * `locations`.`long` / 180 - PI() * $loc[long] / 180)))), -1) AS `distance`, sum(`points`) as pts, `users`.* + FROM `locations` + inner join `users` on `users`.`locid` = `locations`.`id` + inner join `alerts` on `users`.`id`=`alerts`.`memid` + inner join `notary` on `users`.`id`=`notary`.`to` + WHERE (`alerts`.`general`=1 OR `alerts`.`country`=1 OR `alerts`.`regional`=1 OR `alerts`.`radius`=1) + GROUP BY `users`.`id` + HAVING `distance` <= '$maxdist' + ORDER BY `distance` "; + echo $query; + + // comment next line when starting to send mail not only to me + // $query = "select * from `users` where `email` like 'cacerttest%'"; + + $res = mysql_query($query); + $xrows = mysql_num_rows($res); + + while($row = mysql_fetch_assoc($res)) + { + // uncomment next line to send mails ... + sendmail($row['email'], "[CAcert.org] $eventname - $city", $lines, "events@cacert.org", "", "", "CAcert Events Organisation", "returns@cacert.org", 1); + } + // 1x cc to events.cacert.org + sendmail("events@cacert.org", "[CAcert.org] $eventname - $city", $lines, "events@cacert.org", "", "", "CAcert Events Organisation", "returns@cacert.org", 1); + // 1x mailing report to events.cacert.org + sendmail("events@cacert.org", "[CAcert.org] $eventname - $city Report", "invitation sent to $xrows recipients.", "support@cacert.org", "", "", "CAcert Events Organisation", "returns@cacert.org", 1); + + // 1x mailing report to Arbitrator of case http://wiki.cacert.org/wiki/Arbitrations/a20090525.1 + sendmail("p.dunkel@cacert.org", "[CAcert.org] $eventname - $city Report", "invitation sent to $xrows recipients.", "support@cacert.org", "", "", "CAcert Events Organisation", "returns@cacert.org", 1); + echo "invitation sent to $xrows recipients.\n"; + +?> diff --git a/scripts/DumpWeakCerts.pl b/scripts/DumpWeakCerts.pl new file mode 100644 index 0000000..85648fe --- /dev/null +++ b/scripts/DumpWeakCerts.pl @@ -0,0 +1,179 @@ +#!/usr/bin/perl +# Script to dump weak RSA certs (Exponent 3 or Modulus size < 1024) according to https://bugs.cacert.org/view.php?id=918 +# and https://wiki.cacert.org/Arbitrations/a20110312.1 + +use strict; +use warnings; + +use DBI; + +my $cacert_db_config; +my $cacert_db_user; +my $cacert_db_password; + +# Read database access data from the config file +eval `cat perl_mysql`; + +my $dbh = DBI->connect($cacert_db_config, $cacert_db_user, $cacert_db_password, { RaiseError => 1, AutoCommit => 0 } ) || die "Cannot connect database: $DBI::errstr"; + +my $sth_certs; +my $sth_userdata; + +my $cert_domid; +my $cert_userid; +my $cert_orgid; +my $cert_CN; +my $cert_expire; +my $cert_filename; +my $cert_serial; + +my $user_email; +my $user_firstname; + +my $reason; + +my @row; + +sub IsWeak($) { + my ($CertFileName) = @_; + + my $ModulusSize = 0; + my $Exponent = 0; + my $result = 0; + + # Do key size and exponent checking for RSA keys + open(CERTTEXT, '-|', "openssl x509 -in $CertFileName -noout -text") || die "Cannot start openssl"; + while (<CERTTEXT>) { + if (/^ +([^ ]+) Public Key:/) { + last if ($1 ne "RSA"); + } + if (/^ +Modulus \((\d+) bit\)/) { + $ModulusSize = $1; + } + if (/^ +Exponent: (\d+)/) { + $Exponent = $1; + last; + } + } + close(CERTTEXT); + if ($ModulusSize > 0 && $Exponent > 0) { + if ($ModulusSize < 1024 || $Exponent==3) { + $result = "SmallKey"; + } + } + + if (!$result) { + # Check with openssl-vulnkey + # This is currently not tested, if you don't know what you are doing leave it commented! + if (system("openssl-vulnkey -q $CertFileName") != 0) { + $result = "openssl-vulnkey"; + } + } + + return $result; +} + +# Select only certificates expiring in more than two weeks, since two weeks will probably be needed as turnaround time +# Get all domain certificates +$sth_certs = $dbh->prepare( + "SELECT `dc`.`domid`, `dc`.`CN`, `dc`.`expire`, `dc`.`crt_name`, `dc`.`serial` ". + " FROM `domaincerts` AS `dc` ". + " WHERE `dc`.`revoked`=0 AND `dc`.`expire` > DATE_ADD(NOW(), INTERVAL 14 DAY)"); +$sth_certs->execute(); + +$sth_userdata = $dbh->prepare( + "SELECT `u`.`email`, `u`.`fname` ". + " FROM `domains` AS `d`, `users` AS `u` ". + " WHERE `d`.`memid`=`u`.`id` AND `d`.`id`=?"); + +while(($cert_domid, $cert_CN, $cert_expire, $cert_filename, $cert_serial) = $sth_certs->fetchrow_array) { + if (-f $cert_filename) { + $reason = IsWeak($cert_filename); + if ($reason) { + $sth_userdata->execute($cert_domid); + ($user_email, $user_firstname) = $sth_userdata->fetchrow_array(); + print join("\t", ('DomainCert', $user_email, $user_firstname, $cert_expire, $cert_CN, $reason, $cert_serial)). "\n"; + $sth_userdata->finish(); + } + } +} +$sth_certs->finish(); + +# Get all email certificates +$sth_certs = $dbh->prepare( + "SELECT `ec`.`memid`, `ec`.`CN`, `ec`.`expire`, `ec`.`crt_name`, `ec`.`serial` ". + " FROM `emailcerts` AS `ec` ". + " WHERE `ec`.`revoked`=0 AND `ec`.`expire` > DATE_ADD(NOW(), INTERVAL 14 DAY)"); +$sth_certs->execute(); + +$sth_userdata = $dbh->prepare( + "SELECT `u`.`email`, `u`.`fname` ". + " FROM `users` AS `u` ". + " WHERE `u`.`id`=?"); + +while(($cert_userid, $cert_CN, $cert_expire, $cert_filename, $cert_serial) = $sth_certs->fetchrow_array) { + if (-f $cert_filename) { + $reason = IsWeak($cert_filename); + if ($reason) { + $sth_userdata->execute($cert_userid); + ($user_email, $user_firstname) = $sth_userdata->fetchrow_array(); + print join("\t", ('EmailCert', $user_email, $user_firstname, $cert_expire, $cert_CN, $reason, $cert_serial)). "\n"; + $sth_userdata->finish(); + } + } +} +$sth_certs->finish(); + +# Get all Org Server certificates, notify all admins of the Org! +$sth_certs = $dbh->prepare( + "SELECT `dc`.`orgid`, `dc`.`CN`, `dc`.`expire`, `dc`.`crt_name`, `dc`.`serial` ". + " FROM `orgdomaincerts` AS `dc` ". + " WHERE `dc`.`revoked`=0 AND `dc`.`expire` > DATE_ADD(NOW(), INTERVAL 14 DAY)"); +$sth_certs->execute(); + +$sth_userdata = $dbh->prepare( + "SELECT `u`.`email`, `u`.`fname` ". + " FROM `users` AS `u`, `org` ". + " WHERE `u`.`id`=`org`.`memid` and `org`.`orgid`=?"); + +while(($cert_orgid, $cert_CN, $cert_expire, $cert_filename, $cert_serial) = $sth_certs->fetchrow_array) { + if (-f $cert_filename) { + $reason = IsWeak($cert_filename); + if ($reason) { + $sth_userdata->execute($cert_orgid); + while(($user_email, $user_firstname) = $sth_userdata->fetchrow_array()) { + print join("\t", ('OrgServerCert', $user_email, $user_firstname, $cert_expire, $cert_CN, $reason, $cert_serial)). "\n"; + } + $sth_userdata->finish(); + } + } +} +$sth_certs->finish(); + +# Get all Org Email certificates, notify all admins of the Org! +$sth_certs = $dbh->prepare( + "SELECT `ec`.`orgid`, `ec`.`CN`, `ec`.`expire`, `ec`.`crt_name`, `ec`.`serial` ". + " FROM `orgemailcerts` AS `ec` ". + " WHERE `ec`.`revoked`=0 AND `ec`.`expire` > DATE_ADD(NOW(), INTERVAL 14 DAY)"); +$sth_certs->execute(); + +$sth_userdata = $dbh->prepare( + "SELECT `u`.`email`, `u`.`fname` ". + " FROM `users` AS `u`, `org` ". + " WHERE `u`.`id`=`org`.`memid` and `org`.`orgid`=?"); + +while(($cert_orgid, $cert_CN, $cert_expire, $cert_filename, $cert_serial) = $sth_certs->fetchrow_array) { + if (-f $cert_filename) { + $reason = IsWeak($cert_filename); + if ($reason) { + $sth_userdata->execute($cert_orgid); + while(($user_email, $user_firstname) = $sth_userdata->fetchrow_array()) { + print join("\t", ('OrgEmailCert', $user_email, $user_firstname, $cert_expire, $cert_CN, $reason, $cert_serial)). "\n"; + } + $sth_userdata->finish(); + } + } +} +$sth_certs->finish(); + +$dbh->disconnect(); diff --git a/scripts/mail-weak-keys.php b/scripts/mail-weak-keys.php new file mode 100644 index 0000000..018bd64 --- /dev/null +++ b/scripts/mail-weak-keys.php @@ -0,0 +1,161 @@ +#!/usr/bin/php -q +<? # Companion script to DumpWeakCerts.pl, takes output and sends a mail to each owner of a weak cert + + function SendServerCertMail($cert_type, $cert_email, $owner_name, $cert_expire, $cert_CN, $reason, $cert_serial, $action_date) { + $mail_text = +"Dear $owner_name, + +CAcert recently became aware that some of the certificates signed by CAcert pose a security +risk because they are backed by private keys that are vulnerable to attack. + +The security issues identified are: +Private keys with a small key size. These keys are vulnerable to brute force attack. +Private keys with an unsafe exponent. These keys are vulnerable to some specialised attacks. +Private keys generated by a compromised version of OpenSSL distributed by Debian. + +You received this email because a certificate issued to you is vulnerable: + +Server Certificate, Serial $cert_serial, expiring $cert_expire, CN $cert_CN + +To rectify the problem CAcert will revoke all vulnerable certificates (including yours) on $action_date. +CAcert will no longer accept vulnerable certificate requests for signing. In future all Certficate +Signing Requests must be backed by private keys with a key length at least 2048 bits and no other known vulnerabilities. + +You should submit a new Certificate Signing Request of acceptable strength as soon as possible +and replace your existing certificate. + +If you are interested in background information on this change please refer to this document: +http://csrc.nist.gov/publications/nistpubs/800-78-3/sp800-78-3.pdf + +Kind regards +CAcert Suport Team +"; + mail($cert_email, "[CAcert.org]CAcert Server Certificate - Urgent Action Required", $mail_text, "From: CAcert Support <support@cacert.org>\nReply-To: returns@cacert.org"); + } + + function SendClientMail($cert_type, $cert_email, $owner_name, $cert_expire, $cert_CN, $reason, $cert_serial, $action_date) { + $mail_text = +"Dear $owner_name, + +CAcert recently became aware that some of the certificates signed by CAcert pose a security +risk because they are backed by private keys that are vulnerable to attack. + +The security issues identified are: +Private keys with a small key size. These keys are vulnerable to brute force attack. +Private keys with an unsafe exponent. These keys are vulnerable to some specialised attacks. +Private keys generated by a compromised version of OpenSSL distributed by Debian. + +You received this email because a certificate issued to you is vulnerable: + +Client Certificate, Serial $cert_serial, expiring $cert_expire, CN $cert_CN + +To rectify the problem CAcert will revoke all vulnerable certificates (including yours) on $action_date. +CAcert will no longer accept vulnerable certificate requests for signing. In future all +client certficates must be backed by private keys with a key length at least 1024 bits +and no other known vulnerabilities. + +This means that you should replace your current certificate with a new one of acceptable strength. +If you use Firefox or Chrome, select 'Keysize: High Grade' before 'Create Certificate Request'. +If you use Internet Explorer, select 'Microsoft Strong Cryptographic Provider'. If you select an +option that generates a weak key (eg 'Microsoft Base Cryptographic Provider v1.0') your certficate +request will be rejected. + +Kind regards +CAcert Suport Team +"; + mail($cert_email, "[CAcert.org]CAcert Client Certificate - Urgent Action Required", $mail_text, "From: CAcert Support <support@cacert.org>\nReply-To: returns@cacert.org"); + } + + function SendOrgServerCertMail($cert_type, $cert_email, $owner_name, $cert_expire, $cert_CN, $reason, $cert_serial, $action_date) { + $mail_text = +"Dear $owner_name, + +CAcert recently became aware that some of the certificates signed by CAcert pose a security +risk because they are backed by private keys that are vulnerable to attack. + +The security issues identified are: +Private keys with a small key size. These keys are vulnerable to brute force attack. +Private keys with an unsafe exponent. These keys are vulnerable to some specialised attacks. +Private keys generated by a compromised version of OpenSSL distributed by Debian. + +You received this email because a certificate issued to you is vulnerable: + +Organisation Server Certificate, Serial $cert_serial, expiring $cert_expire, CN $cert_CN + +To rectify the problem CAcert will revoke all vulnerable certificates (including yours) on $action_date. +CAcert will no longer accept vulnerable certificate requests for signing. In future all Certficate +Signing Requests must be backed by private keys with a key length at least 2048 bits and no other known vulnerabilities. + +You should submit a new Certificate Signing Request of acceptable strength as soon as possible +and replace your existing certificate. + +If you are interested in background information on this change please refer to this document: +http://csrc.nist.gov/publications/nistpubs/800-78-3/sp800-78-3.pdf + +Kind regards +CAcert Suport Team +"; + mail($cert_email, "[CAcert.org]CAcert Organisation Server Certificate - Urgent Action Required", $mail_text, "From: CAcert Support <support@cacert.org>\nReply-To: returns@cacert.org"); + } + + function SendOrgClientMail($cert_type, $cert_email, $owner_name, $cert_expire, $cert_CN, $reason, $cert_serial, $action_date) { + $mail_text = +"Dear $owner_name, + +CAcert recently became aware that some of the certificates signed by CAcert pose a security +risk because they are backed by private keys that are vulnerable to attack. + +The security issues identified are: +Private keys with a small key size. These keys are vulnerable to brute force attack. +Private keys with an unsafe exponent. These keys are vulnerable to some specialised attacks. +Private keys generated by a compromised version of OpenSSL distributed by Debian. + +You received this email because a certificate issued to you is vulnerable: + +Organisation Client Certificate, Serial $cert_serial, expiring $cert_expire, CN $cert_CN + +To rectify the problem CAcert will revoke all vulnerable certificates (including yours) on $action_date. +CAcert will no longer accept vulnerable certificate requests for signing. In future all +client certficates must be backed by private keys with a key length at least 1024 bits +and no other known vulnerabilities. + +This means that you should replace your current certificate with a new one of acceptable strength. +If you use Firefox or Chrome, select 'Keysize: High Grade' before 'Create Certificate Request'. +If you use Internet Explorer, select 'Microsoft Strong Cryptographic Provider'. If you select an +option that generates a weak key (eg 'Microsoft Base Cryptographic Provider v1.0') your certficate +request will be rejected. + +Kind regards +CAcert Suport Team +"; + mail($cert_email, "[CAcert.org]CAcert Organisation Client Certificate - Urgent Action Required", $mail_text, "From: CAcert Support <support@cacert.org>\nReply-To: returns@cacert.org"); + } + + # Main + + $num_domain = 0; + $num_client = 0; + $num_orgdomain = 0; + $num_orgclient = 0; + $action_date = '2011-04-??'; + $in = fopen("php://stdin", "r"); + while($in_string = rtrim(fgets($in, 255))) { + list($cert_type, $cert_email, $owner_name, $cert_expire, $cert_CN, $reason, $cert_serial) = explode("\t", $in_string); + + if ($cert_type == "DomainCert") { + SendServerCertMail($cert_type, $cert_email, $owner_name, $cert_expire, $cert_CN, $reason, $cert_serial, $action_date); + $num_domain++; + } else if ($cert_type == "EmailCert") { + SendClientMail($cert_type, $cert_email, $owner_name, $cert_expire, $cert_CN, $reason, $cert_serial, $action_date); + $num_client++; + } else if ($cert_type == "OrgServerCert") { + SendOrgServerCertMail($cert_type, $cert_email, $owner_name, $cert_expire, $cert_CN, $reason, $cert_serial, $action_date); + $num_orgdomain++; + } else if ($cert_type == "OrgEmailCert") { + SendOrgClientMail($cert_type, $cert_email, $owner_name, $cert_expire, $cert_CN, $reason, $cert_serial, $action_date); + $num_orgclient++; + } + } + fclose($in); + echo "Mails sent: $num_domain server certs, $num_client client certs, $num_orgdomain Org server certs, $num_orgclient Org client certs.\n"; +?> diff --git a/scripts/perl_mysql.sample b/scripts/perl_mysql.sample new file mode 100644 index 0000000..4800289 --- /dev/null +++ b/scripts/perl_mysql.sample @@ -0,0 +1,6 @@ +# This file contains the data needed to connect to the database to be +# used in perl scripts + +$cacert_db_config = 'DBI:mysql:database=cacert;host=127.0.0.1'; +$cacert_db_user = 'cacert'; +$cacert_db_password = '<put_password_here>';
\ No newline at end of file diff --git a/www/api/ccsr.php b/www/api/ccsr.php index e81c738..a4ec71e 100644 --- a/www/api/ccsr.php +++ b/www/api/ccsr.php @@ -59,6 +59,12 @@ $codesign = 1; $CSR = trim($_REQUEST['optionalCSR']); + + if (($weakKey = checkWeakKeyCSR($CSR)) !== "") + { + die("403, $weakKey"); + } + $incsr = tempnam("/tmp", "ccsrIn"); $checkedcsr = tempnam("/tmp", "ccsrOut"); $fp = fopen($incsr, "w"); diff --git a/www/logos/CAcert-logo-colour-1000.png b/www/logos/CAcert-logo-colour-1000.png Binary files differnew file mode 100644 index 0000000..a6dd6ac --- /dev/null +++ b/www/logos/CAcert-logo-colour-1000.png diff --git a/www/logos/CAcert-logo-mono-1000.png b/www/logos/CAcert-logo-mono-1000.png Binary files differnew file mode 100644 index 0000000..1beeb43 --- /dev/null +++ b/www/logos/CAcert-logo-mono-1000.png |