6.0.0-beta1
7/6/25

[#9275] crypt-md5 password with show_encryption doesn't work
Summary crypt-md5 password with show_encryption doesn't work
Queue Passwd
Queue Version Git master
Type Bug
State Not A Bug
Priority 2. Medium
Owners
Requester tonton (at) bdefracte (dot) org
Created 09/29/2010 (5394 days ago)
Due
Updated 03/26/2014 (4120 days ago)
Assigned 03/13/2011 (5229 days ago)
Resolved 03/26/2014 (4120 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
03/26/2014 12:58:35 PM Jan Schneider Comment #8
State ⇒ Not A Bug
Version ⇒ Git master
Patch ⇒ No
Reply to this comment
If passwords are encrypted with crypt-md5, then they should be 
prefixed with {crypt-md5} not {crypt}.
03/13/2011 03:26:59 AM Chuck Hagenbuch State ⇒ Assigned
 
10/21/2010 08:40:44 PM tonton (at) bdefracte (dot) org Comment #7 Reply to this comment
Ok, let's try to be clear.

I want password to be stored with crypt-md5 method, so it's already 
the case in the database, and the format is {crypt}$1$xxxxxxxxxxxxxxx 
(but it can be another method also, that's why it's prefixed)

Then I want to provide user a way to change their password and keep 
storing them with crypt-md5 method.

I've set encryption to crypt-md5 in passwd and show_encryption to true 
(I can have put encryption to any other method I think I'll get the 
same result as my password are already crypt-md5)

So to change the password the old one is reqested from the user, and 
the problem lie here:

In passwd/lib/Driver.php, in function comparePasswords
there is a call to Auth::getCryptedPassword to get the encrypted 
version of the old password given by the user that need to match the 
stored version.
As the method is stored with the password, 'crypt' is use as 
encryption for the old password, so the params given to 
Auth::getCryptedPassword are ('password', 
'{crypt}$1$1a9668b1$5uJT0BQW24EEtrVj/c4R2/', 'crypt', false)

And in lib/Horde/Auth.php in getCryptedPassword, the first task done 
is to recompute $salt, and if 'crypt' is used instead of 'crypt-md5' 
it reduce it to 3 chars instead of 13 (see the getSalt function).
If the salt is not recomputed, it works (I've tested).
So the call to crypt have to be done with the encrypted old password 
as second paremeter (or it's first 13 chars as it's done when 
'crypt-md5' is used as parameter in this function).

Hope this is clearer.
10/21/2010 08:07:01 PM Jan Schneider Comment #6
State ⇒ Feedback
Reply to this comment
Sorry, I lost you. Can you explain again, which 
strings/salts/passwords are passed where, and where you think this is 
a bug?
10/21/2010 06:23:40 PM tonton (at) bdefracte (dot) org Comment #5 Reply to this comment
So the problem of not passing the right encryption to 
Auth::getCryptedPassword is the Auth::getSalt function not the crypt 
one. The salt generated is not the same for crypt-md5 and crypt, so 
the old password given is encrypted with the crypt method and it 
cannot match the one previously stored that is a crypt-md5 one.

Maybe the Auth::getSalt shouldn't be called at all in the compare 
password case.
10/21/2010 06:03:36 PM tonton (at) bdefracte (dot) org Comment #4 Reply to this comment
Indeed there is a bug as you cannot use crypt-md5 encryption even if 
the password was saved with passwd as the matching of the old password 
doesn't work.

But the correction has maybe to be done elsewhere, I check that.
10/21/2010 04:06:16 PM Jan Schneider Comment #3
State ⇒ Not A Bug
Reply to this comment
This is not how crypt() works: http://php.net/crypt
crypt() should figure out itself from the salt which crypt algorithm 
to choose. If it doesn't, then PHP is broken, or the crypt method you 
are using is not supported by the system.
09/29/2010 10:02:14 PM tonton (at) bdefracte (dot) org Comment #2 Reply to this comment
Here is a fix that works:

diff -urb passwd.old/lib/Driver.php passwd/lib/Driver.php
--- passwd.old/lib/Driver.php   2010-09-30 00:00:35.000000000 +0200
+++ passwd/lib/Driver.php       2010-09-29 23:39:17.000000000 +0200
@@ -3,7 +3,7 @@
   * Passwd_Driver:: defines an API for implementing password change 
systems for
   * Passwd.
   *
- * $Horde: passwd/lib/Driver.php,v 1.44.2.9 2008/10/24 16:48:50 jan Exp $
+ * $Horde: passwd/lib/Driver.php,v 1.44.2.10 2009-01-06 15:25:15 jan Exp $
   *
   * Copyright 2000-2009 The Horde Project (http://www.horde.org/)
   *
@@ -54,6 +54,9 @@
              if ($this->_params['driver'] == 'ldap' && $encryption == 'md5') {
                  $encryption = 'md5-base64';
              }
+           if ($encryption == 'crypt' && substr($encrypted, 0, 3) == '$1$') {
+               $encryption = 'crypt-md5';
+           }
          } else {
              $encryption = $this->_params['encryption'];
          }

09/29/2010 10:01:31 PM tonton (at) bdefracte (dot) org Comment #1
Patch ⇒ Yes
State ⇒ Unconfirmed
Milestone ⇒
Queue ⇒ Passwd
Summary ⇒ crypt-md5 password with show_encryption doesn't work
Type ⇒ Bug
Priority ⇒ 2. Medium
Reply to this comment
when using show_encryption parameter, if the stored encryption is 
crypt, it cannot work with crypt-md5 as it will use the crypt method 
to compare password instead of crypt-md5

(it will not work with crypt-blowfish also)

Saved Queries