hash - PHP crypt returns true even with suffix behind password -
so have small leak in login script.
lets have user "david" password "s3cret". if david logs in s3cret, logged in, , works fine. if logs in "oijopij", system won't give him access, expected. however, if tries login "s3crethelloimasuffix", logged in. part create hash crypt:
$salt = //some random salt string $hash = crypt( $user->pass, $salt );
this hash inserted db.
if ( crypt( $this->data->pass, $user->pass ) == $user->pass ) return true; return false;
this part checks password against hash, both password, , hash correct. still returns true if there suffix beghind password.
edit: forgot actual question: how fix problem? seen security leak, though in practice isn't.
crypt
you're using limited 8 character passwords:
php > echo crypt('1234567', 'abc'); ablk9hoaawzxk php > echo crypt('12345678', 'abc'); ab1iba.n.u2c6 php > echo crypt('123456789', 'abc'); ab1iba.n.u2c6 php > echo crypt('1234567890', 'abc'); ab1iba.n.u2c6
note how ...8, ...89, ...890 versions have identical hashes.
crypt
obsolete , should not used password systems anymore. password_hash()
recommended method now, suports multiple hashing methods, including bcrypt
, should used password hashes.
Comments
Post a Comment