Title: hash_secret with salt version set to non-bcrypt version returns an empty string instead of raising BCrypt::Errors::InvalidSalt · Issue #133 · bcrypt-ruby/bcrypt-ruby · GitHub
Open Graph Title: hash_secret with salt version set to non-bcrypt version returns an empty string instead of raising BCrypt::Errors::InvalidSalt · Issue #133 · bcrypt-ruby/bcrypt-ruby
X Title: hash_secret with salt version set to non-bcrypt version returns an empty string instead of raising BCrypt::Errors::InvalidSalt · Issue #133 · bcrypt-ruby/bcrypt-ruby
Description: There is some interesting behavior going on when generating a hash with a salt that fits the validation regex, but has a version that doesn't exist, in that it returns the empty string instead of raising: > salt = "$2a$10$TD5b9p9vdGsuEwK...
Open Graph Description: There is some interesting behavior going on when generating a hash with a salt that fits the validation regex, but has a version that doesn't exist, in that it returns the empty string instead of r...
X Description: There is some interesting behavior going on when generating a hash with a salt that fits the validation regex, but has a version that doesn't exist, in that it returns the empty string instead ...
Opengraph URL: https://github.com/bcrypt-ruby/bcrypt-ruby/issues/133
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"hash_secret with salt version set to non-bcrypt version returns an empty string instead of raising BCrypt::Errors::InvalidSalt","articleBody":"There is some interesting behavior going on when generating a hash with a salt that fits the validation regex, but has a version that doesn't exist, in that it returns the empty string instead of raising:\n\n```\n\u003e salt = \"$2a$10$TD5b9p9vdGsuEwKyrtSua.\"\n\u003e BCrypt::Engine.hash_secret(\"test\", salt, 10).to_s\n=\u003e \"$2a$10$TD5b9p9vdGsuEwKyrtSua.sh9lprEf.VOyagv/sm7PbdPVT46i.1K\"\n\n\u003e salt = \"$2x$10$TD5b9p9vdGsuEwKyrtSua.\"\n\u003e BCrypt::Engine.hash_secret(\"test\", salt, 10).to_s\n=\u003e \"$2x$10$TD5b9p9vdGsuEwKyrtSua.sh9lprEf.VOyagv/sm7PbdPVT46i.1K\"\n\n\u003e salt = \"$00$10$TD5b9p9vdGsuEwKyrtSua.\"\n\u003e BCrypt::Engine.hash_secret(\"test\", salt, 10).to_s\n=\u003e \"\"\n```\n\nThis behavior doesn't appear to be covered by specs, and looks to be slightly dangerous if undetected. Would it be a good idea to change the regex at https://github.com/codahale/bcrypt-ruby/blob/master/lib/bcrypt/engine.rb#L81\nfrom \n`/^\\$[0-9a-z]{2,}\\$[0-9]{2,}\\$[A-Za-z0-9\\.\\/]{22,}$/`\nto\n`/^\\$2[abxy]\\$[0-9]{2,}\\$[A-Za-z0-9\\.\\/]{22,}$/`\n, or am I missing some use-case here?\n","author":{"url":"https://github.com/DZittersteyn","@type":"Person","name":"DZittersteyn"},"datePublished":"2016-03-11T14:14:51.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/133/bcrypt-ruby/issues/133"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:709b2c0e-8fdc-c588-6cd5-f31bfc197573 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A010:3930F2:6B8E077:8AA61FD:69759114 |
| html-safe-nonce | bd516f5479711e3b98f385f576203a9518bc54259b259f5697e911bda26a8cf2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMDEwOjM5MzBGMjo2QjhFMDc3OjhBQTYxRkQ6Njk3NTkxMTQiLCJ2aXNpdG9yX2lkIjoiNjg4MjAxNzMwNzc5OTE2MzE1NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fb750299cdf22dd4e2afa9cc09c90ca57eabffe4168492d5c3932ac4732a8b2c |
| hovercard-subject-tag | issue:140193820 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/bcrypt-ruby/bcrypt-ruby/133/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b60c3d0bad6b7811bd41e45ae095ade9682d461192f5c43ca72f58cb5fdeb408/bcrypt-ruby/bcrypt-ruby/issues/133 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b60c3d0bad6b7811bd41e45ae095ade9682d461192f5c43ca72f58cb5fdeb408/bcrypt-ruby/bcrypt-ruby/issues/133 |
| og:image:alt | There is some interesting behavior going on when generating a hash with a salt that fits the validation regex, but has a version that doesn't exist, in that it returns the empty string instead of r... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DZittersteyn |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4a4bf5f4e28041a9d2e5c107d7d20b78b4294ba261cab243b28167c16a623a1f |
| turbo-cache-control | no-preview |
| go-import | github.com/bcrypt-ruby/bcrypt-ruby git https://github.com/bcrypt-ruby/bcrypt-ruby.git |
| octolytics-dimension-user_id | 81594302 |
| octolytics-dimension-user_login | bcrypt-ruby |
| octolytics-dimension-repository_id | 15293 |
| octolytics-dimension-repository_nwo | bcrypt-ruby/bcrypt-ruby |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 15293 |
| octolytics-dimension-repository_network_root_nwo | bcrypt-ruby/bcrypt-ruby |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 488b30e96dfd057fbbe44c6665ccbc030b729dde |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width