<?xml version="1.0" encoding="UTF-8"?> 
<?xml-stylesheet href="https://dev.horde.org/themes/horde//default/feed-rss.xsl" type="text/xsl"?> 
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 
 <channel> 
  <title>Poor salt generation for crypt-*</title> 
  <pubDate>Fri, 10 Apr 2026 17:52:44 +0000</pubDate> 
  <link>https://bugs.horde.org/ticket/8425</link> 
  <atom:link rel="self" type="application/rss+xml" title="Poor salt generation for crypt-*" href="https://bugs.horde.org/ticket/8425/rss" /> 
  <description>Poor salt generation for crypt-*</description> 
 
   
   
  <item> 
   <title>In lib/Horde/Auth.php, the function getSalt uses a poor algo</title> 
   <description>In lib/Horde/Auth.php, the function getSalt uses a poor algorithm for generating salts for crypt-*. crypt allows, at the very least, all Base64 characters in the salt, but the current algorithm only generates hexadecimal digits. Furthermore, for crypt-md5, 8 bytes of salt is permitted, so there are 64^8 = 2^48 possible salt values (if we only allow Base64 characters), but on most systems, mt_rand() only generates 2^31 different values, so the current algorithm generates at most 2^31 different salt values.



A better algorithm would use, for example, base64_encode(md5(sprintf(&#039;%08X%08X&#039;, mt_rand(), mt_rand()), TRUE)) instead of just md5(mt_rand()).</description> 
   <pubDate>Fri, 10 Jul 2009 05:50:12 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8425#t54894</link> 
  </item> 
   
  <item> 
   <title>I think the code has changed a bit in the latest version. I&#039;</title> 
   <description>I think the code has changed a bit in the latest version. I&#039;ve got this for the crypt-md5 case:



diff --git a/framework/Auth/lib/Horde/Auth.php b/framework/Auth/lib/Horde/Auth.php

index 8a5695a..fce7771 100644

--- a/framework/Auth/lib/Horde/Auth.php

+++ b/framework/Auth/lib/Horde/Auth.php

@@ -266,7 +266,7 @@ class Horde_Auth

         case &#039;crypt-md5&#039;:

             return $seed

                 ? substr(preg_replace(&#039;|^{crypt}|i&#039;, &#039;&#039;, $seed), 0, 12)

-                : &#039;$1$&#039; . substr(hash(&#039;md5&#039;, mt_rand()), 0, 8) . &#039;$&#039;;

+                : &#039;$1$&#039; . base64_encode(hash(&#039;md5&#039;, sprintf(&#039;%08X%08X&#039;, mt_rand(), mt_rand()), true)) . &#039;$&#039;;

 

         case &#039;crypt-blowfish&#039;:

             return $seed



What would you suggest for crypt and crypt-des? It&#039;s currently:



        case &#039;crypt&#039;:

        case &#039;crypt-des&#039;:

            return $seed

                ? substr(preg_replace(&#039;|^{crypt}|i&#039;, &#039;&#039;, $seed), 0, 2)

                : substr(hash(&#039;md5&#039;, mt_rand()), 0, 2);



Thanks!</description> 
   <pubDate>Sat, 11 Jul 2009 16:57:59 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8425#t54905</link> 
  </item> 
   
  <item> 
   <title>Also crypt-blowfish</title> 
   <description>Also crypt-blowfish</description> 
   <pubDate>Sat, 11 Jul 2009 16:58:22 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8425#t54906</link> 
  </item> 
   
  <item> 
   <title>A similar thing should be fine - 

substr(base64_encode(hash</title> 
   <description>A similar thing should be fine - 

substr(base64_encode(hash(&#039;md5&#039;, mt_rand(), true)), 0, 2) for example. (It would be best to not use a MD5 at all and just use the random numbers directly, but I&#039;m not sure how to do that.) I don&#039;t know what the salt requirements for crypt-blowfish are.</description> 
   <pubDate>Sun, 12 Jul 2009 02:22:36 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8425#t54921</link> 
  </item> 
   
  <item> 
   <title>Committed the crypt-md5 change:

http://git.horde.org/diff.p</title> 
   <description>Committed the crypt-md5 change:

http://git.horde.org/diff.php/framework/Auth/lib/Horde/Auth.php?rt=horde-git&amp;r1=83ba16e6c0ec3c989eab0a81fcda06978ddef8a1&amp;r2=e57680006a7a0c33f08a94e05ebf7c69b486d401</description> 
   <pubDate>Mon, 20 Jul 2009 18:23:43 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8425#t55004</link> 
  </item> 
   
  <item> 
   <title>Added changes for crypt, crypt-des, and crypt-blowfish also.</title> 
   <description>Added changes for crypt, crypt-des, and crypt-blowfish also. Thanks!</description> 
   <pubDate>Tue, 08 Sep 2009 03:01:13 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8425#t55684</link> 
  </item> 
   
  <item> 
   <title>More salt improvements - use all base64 characters (not just</title> 
   <description>More salt improvements - use all base64 characters (not just hex) for crypt,
crypt-des, and crypt-blowfish (Bug #8425).

</description> 
   <pubDate>Tue, 08 Sep 2009 08:41:00 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8425#t55686</link> 
  </item> 
   
  <item> 
   <title>Changes have been made in CVS for this ticket:

More salt im</title> 
   <description>Changes have been made in CVS for this ticket:

More salt improvements - use all base64 characters (not just hex) for crypt,
crypt-des, and crypt-blowfish (Bug #8425).


http://git.horde.org/diff.php/framework/Auth/lib/Horde/Auth.php?rt=horde-git&amp;r1=4ef82a9d67556dda442771964a32ce5d8a6a581d&amp;r2=7a49e649d831346749ac5ddb0a8e4ef16f11d414</description> 
   <pubDate>Tue, 08 Sep 2009 09:08:43 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8425#t55687</link> 
  </item> 
   
   
 
 </channel> 
</rss> 
