FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

BCrypt::Engine.hash_secret method is generating unexpected long hash string on Fedora 28 · Issue #165 · bcrypt-ruby/bcrypt-ruby · GitHub

Repository navigation

BCrypt::Engine.hash_secret method is generating unexpected long hash string on Fedora 28 #165

Description

I tried to generate a new password with Password.create('test') but it throws BCrypt::Errors::InvalidHash (invalid hash) error. Then i try to generate hash with BCrypt::Engine.hash_secret('secret', BCrypt::Engine.generate_salt(1)) to see what's wrong there and i noticed the code generated 32767 character long string as the following

$2a$04$tk0ZskJEMxKW5Zx0OIMy/Ot5z.Vleg7SXfRV9.GryPpKRchRK/S3m\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\............

Because of unexpected long hash string the valid_hash? method returns nil and broke the app.

I test the problem against to ruby 2.4.1, 2.5.0 and 2.5.1 on Fedora 28. All of them were failing.

I check the GCC version and noticed that it upgraded to 8.x on Fedora 28. I am not sure, but it could be a compiler related bug..

Activity

  1. ai commented on Apr 22, 2018

    @tjschuck I confirm this issue in our Rails app

    I fixed it just with:

    - __bc_crypt(secret.to_s, salt)
    + __bc_crypt(secret.to_s, salt).gsub(/(\n|\x00).*/, '')
  2. ai commented on Apr 22, 2018

    @tjschuck Seems like this PR could fix the problem #164

  3. tjschuck commented on May 15, 2018

    Collaborator

    I have just pushed version 3.1.12.rc1 to RubyGems.org which should solve this problem.

    Can someone please confirm that gem install bcrypt --prerelease now works on Fedora 28? If so, I'll push out the final version.

  4. Xenosb commented on May 16, 2018

    Hi,
    i have tested with my application. It failed on 3.1.11 while it works perfectly on 3.1.12.rc1
    Using ruby 2.5.1 and rails 5.1.5 on Fedora 28

  5. tjschuck commented on May 16, 2018

    Collaborator

    Version 3.1.12 of the bcrypt gem, which should fix this issue, was just pushed to RubyGems.

    You should now be able to gem install bcrypt on Fedora with none of the above workarounds.

    Thanks, everyone!

  6. m13m commented on Aug 10, 2018

    @tjschuck I am still getting the issue BCrypt::Errors::InvalidHash: invalid hash

    OS : Fedora 28
    Rails: 5.1.6
    Ruby: 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL