php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62488 Invalid bcrypt hash
Submitted: 2012-07-06 03:06 UTC Modified: -
Votes:7
Avg. Score:4.6 ± 0.7
Reproduced:6 of 6 (100.0%)
Same Version:4 (66.7%)
Same OS:2 (33.3%)
From: smt837784 at yahoo dot com Assigned:
Status: Open Package: *Encryption and hash functions
PHP Version: 5.3.14 OS: Fedora 16 (3.3.4-1.fc16.x86_64)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: smt837784 at yahoo dot com
New email:
PHP Version: OS:

 

 [2012-07-06 03:06 UTC] smt837784 at yahoo dot com
Description:
------------
If the salt is less than 128 bits (22 characters in base 64) it is padded with "$" instead of ".". Which is an invalid bcrypt hash.

Test script:
---------------
echo crypt('', '$2y$04$......................') . '<br>';
echo crypt('', '$2y$04$....') . '<br>';
echo crypt('', '$2y$04$....$$$$$$$$$$$$$$$$$.'); // keep backwards compatibility

Expected result:
----------------
$2y$04$......................w74bL5gU7LSJClZClCa.Pkz14aTv/XO
$2y$04$......................w74bL5gU7LSJClZClCa.Pkz14aTv/XO
$2y$04$....$$$$$$$$$$$$$$$$$.w74bL5gU7LSJClZClCa.Pkz14aTv/XO

Actual result:
--------------
$2y$04$......................w74bL5gU7LSJClZClCa.Pkz14aTv/XO
$2y$04$....$$$$$$$$$$$$$$$$$.w74bL5gU7LSJClZClCa.Pkz14aTv/XO
$2y$04$....$$$$$$$$$$$$$$$$$.w74bL5gU7LSJClZClCa.Pkz14aTv/XO

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-21 02:28 UTC] daniel at heath dot cc
Allowing these '$' characters without reporting any errors is confusing; these 
hashes cannot be decoded by any standard-compliant implementation of bcrypt.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Jun 27 08:01:40 2019 UTC