Navigation Menu

Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Implement BcryptSha Hashing & Harden Verification Checks #7141

Closed
wants to merge 3 commits into from

Conversation

padraic
Copy link
Member

@padraic padraic commented Jan 20, 2015

This PR, as discussed, implements several security improvements:

  1. Offers a new Zend\Crypt\Password\BcryptSha class which is functionally identical to the Bcrypt class but will pre-hash incoming passwords using SHA256. This small step allows for passwords exceeding 72 bytes to have all 72 bytes utilised in a starting hash. At present, the use of Bcrypt will truncate any input to 72 bytes and effectively discard the remainder of the string. This is perfectly normal and valid behaviour in the bcrypt algorithm, but obviously not what users might expect when allowed to use long passwords.
  2. It replaces the current set of identical comparisons with the pre-existing fixed time compare functionality to offset any risk of timing leaks about the hashes being compared.

Noting PR is against master at present.

@padraic padraic changed the title Implement BcryptSha1 Hashing & Harden Verification Checks Implement BcryptSha Hashing & Harden Verification Checks Jan 20, 2015
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2015

@Ocramius Ocramius added this to the 2.4.0 milestone Jan 25, 2015
@Ocramius Ocramius self-assigned this Jan 25, 2015
@weierophinney
Copy link
Member

For the inevitable commenters who have read: http://blog.ircmaxell.com/2015/03/security-issue-combining-bcrypt-with.html — this patch follows the practices outlined in Anthony's post already. Hash::compute() takes up to three arguments, the last of which is $output, which is a constant indicating whether the returned hash should be in string or binary format. By default, string is used, which is equivalent to passing a boolean false to the hash() function's third argument, making the returned strings safe for re-hashing.

weierophinney added a commit that referenced this pull request Mar 12, 2015
Implement BcryptSha Hashing & Harden Verification Checks
weierophinney added a commit that referenced this pull request Mar 12, 2015
@weierophinney
Copy link
Member

Merged to develop for release with 2.4; @padraic — please provide documentation in the zf2-documentation repo. :)

@padraic padraic deleted the passsecimprov branch March 12, 2015 21:18
weierophinney added a commit to zendframework/zend-crypt that referenced this pull request May 15, 2015
…secimprov

Implement BcryptSha Hashing & Harden Verification Checks
weierophinney added a commit to zendframework/zend-crypt that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants