shimmyshack wrote:
> On 14 Mar, 22:21, "Richard Cornford" wrote:
>
>> Bart Van der Donck wrote:
>
>>> One-way encryption from client on beforehand is secure
>>> to change the password on one Conditio, which is that
>>> the user must know the previous (encrypted) password.
>
>>> E.g. if one posts the following to newpass.php:
>>> oldEncPW=gH4tGhKLNx
>>> newEncPW=yHjke4c5Wu
>
>>> Then compare the old (stored) string to the sent
>>> 'gH4tGhKLNx'. If it matches, replace it by 'yHjke4c5Wu'.
>>> No encryption needed at server side, and safe if it goes
>>> over HTTPS.
> yes I fear that this is NOT secure. Take for instance the
> condition that the user knows the previous password.
It's the same as saying that the application can trust the user.
Anyone who knows the previous password, may change it to a new one.
> The old password is stored in the mysql database as SHA1
> hash. (let us say for argument's sake the old password was
> 'fred' and that the new is 'newpassword' so the database
> contains the sha1 hash
> $db_data = sha1('fred')
> now the user typed in fred which with a salt was sha1'd by
> the client and sent to the server.
> js-> sha1(salt+sha1('fred'))
> then sends this as hashed_data
> the server must check that the user entered fred, but can
> only do this by copying the procedure server-> sha1($salt .
> $db_data ) and seeing if it is equal to what was
> in the $_POST var $_POST['hashed_data'].
In my scheme, the server doesn't know anything about the plaintext
password because nothing plaintext is sent from js or received at
server. All it gets is the already js-hashed string to do stuff with.
The server doesn't do any hashing, all it does is compare the hashed
string to what's stored.
- user types current password
- js hashes it (irreversibly)
- js sends only hash to server, not plaintext (yes, over HTTPS)
- server compares if it matches to its own stored (hashed) string
- if it matches, authentication succeeded (so he can enter application
or change password etc.)
I don't see a leak in this scheme, but, please, I'ld be very happy to
know, I'm running a whole university based on this
> Now what you are proposing is that the server checks this
> and when the user has indeed verified that they know the old
> password, you then _replace the old hash with sha1('newpassword')
Yes, with sha1('newpassword') encrypted by javascript.
> now anyone listening to the traffic as Richard says now knows
> the new hash they have eaves dropped sha1('newpassword')
You're right, but that's why the traffic should go over HTTPS. Then
this can't happen.
> so the attacker just requests the logon page, gets given a
> new salt and can now send this POST data (using some proxy or
> other or a header editor)
> $_POST['hashed_data'] = sha1( newsalt+sha1('newpassword') )
> the attacker doesnt need to know the password.
Okay, but he does need to know the hashed string. I don't see how he
can get that information if the traffic goes over HTTPS.
> The server accepts this and compares it against the database
> entry by the smae method as before
> server-> sha1($newsalt . $new_db_data )
> where $new_db_data is sha1('newpassword')
> they match and the attacker gets in
Yes he's in then, but he must always know the hashed password for
that. Sure, if that is known, one can get in. But I don't see how an
attacker could get his hands on it, assumed that the traffic goes over
HTTPS.
--
Bart