René's URL Explorer Experiment


Title: Silent Trimming of Passwords Longer Than 72 Characters · Issue #283 · bcrypt-ruby/bcrypt-ruby · GitHub

Open Graph Title: Silent Trimming of Passwords Longer Than 72 Characters · Issue #283 · bcrypt-ruby/bcrypt-ruby

X Title: Silent Trimming of Passwords Longer Than 72 Characters · Issue #283 · bcrypt-ruby/bcrypt-ruby

Description: Description The bcrypt gem silently trims input strings longer than 72 characters during password hashing, which can lead to unexpected behavior. Specifically, when a string longer than 72 characters is provided, BCrypt::Password.create ...

Open Graph Description: Description The bcrypt gem silently trims input strings longer than 72 characters during password hashing, which can lead to unexpected behavior. Specifically, when a string longer than 72 characte...

X Description: Description The bcrypt gem silently trims input strings longer than 72 characters during password hashing, which can lead to unexpected behavior. Specifically, when a string longer than 72 characte...

Opengraph URL: https://github.com/bcrypt-ruby/bcrypt-ruby/issues/283

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Silent Trimming of Passwords Longer Than 72 Characters","articleBody":"## Description\n\nThe `bcrypt` gem silently trims input strings longer than **72** characters during password hashing, which can lead to unexpected behavior.\nSpecifically, when a string longer than **72** characters is provided, **BCrypt::Password.create** truncates the input to **72** characters without warning, allowing different inputs to produce the same hash. This can potentially enable password verification bypasses if an attacker uses a different string that matches the first **72** characters of the original input. (similar behavior has been posted by **OKTA**: https://trust.okta.com/security-advisories/okta-ad-ldap-delegated-authentication-username/ )\n\n## Steps to Reproduce \n1. Install the bcrypt gem (gem install bcrypt).\n2. Run the following Ruby script:\n```\nrequire 'bcrypt'\n\ncost = 12\nuserid = \"b91fa9b4-69f1-4779-8d45-73f8653057f3\"  # 36 characters\nusername = \"my.very.long.username.with.more.characters@kondukto.io\"  # 47 characters\npassword = \"randomStrongPassword\"  # 20 characters\n\ninput = userid + username + password  # Total: 103 characters\n\nbegin\n  my_password = BCrypt::Password.create(input, cost: cost)\n  puts \"Hashed password: #{my_password}\"\n\n  # Validate the correct password\n  is_valid = BCrypt::Password.new(my_password) == input\n  puts \"Correct password validation: #{is_valid ? 'Success' : 'Failure'}\"\n\n  # Validate with a different password\n  wrong_password = \"AAAAAAAAAAAAAAAAAAAA\"\n  bypass_input = userid + username + wrong_password  # Also 103 characters\n  is_valid = BCrypt::Password.new(my_password) == bypass_input\n  puts \"Bypass password validation: #{is_valid ? 'Success' : 'Failure'}\"\nrescue BCrypt::Errors::InvalidCost, BCrypt::Errors::InvalidSalt =\u003e e\n  puts \"Error creating password: #{e.message}\"\nend\n```\n3. Observe the output:\n```\n└\u003e ruby main.rb\nHashed password 1: $2a$12$nefsa21AluV1BF2EXx6Y4.u6ZV4KT3c1ZWXLIOpWV9KZZ2Y1lGQmO\nPassword validation: Success\nPassword validation: Success\n```\n## Expected Behavior\n- The bcrypt gem should either:\n  - Raise an error when an input string exceeds 72 characters, indicating that the input is too long. \n  - Explicitly document the 72-character limit and warn about truncation in the gem's documentation.\n- The validation of bypass_input (which differs from input after the first 72 characters) should return Failure, as it is a different string.\n\n## Actual Behavior\n- The bcrypt gem silently trims the input string to 72 characters.\n- Both input (103 characters) and bypass_input (103 characters, differing after 72 characters) validate successfully against the same hash, indicating that only the first 72 characters are considered.\n- No warning or error is raised about the truncation.\n\n## Suggested Fix\n- Add a check in BCrypt::Password.create to raise an error (e.g., **BCrypt::Errors::InputTooLong**) if the input exceeds 72 characters. _(this is how other programming languages handles it)_\n- Alternatively, log a warning when truncation occurs to alert developers.\n- Update the gem's documentation to clearly state the 72-character limit and the truncation behavior\n\n## Environment\n- Ruby version: ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [x86_64-linux-gnu]\n- bcrypt version: 3.1.13\n- Operating System:  Ubuntu 24.04.2 LTS \n\n## References\n- https://www.usenix.org/legacy/events/usenix99/provos/provos.pdf\n- https://en.wikipedia.org/wiki/Bcrypt\n- https://kondukto.io/blog/okta-vulnerability-bcrypt-auth","author":{"url":"https://github.com/ckalpakoglu","@type":"Person","name":"ckalpakoglu"},"datePublished":"2025-04-29T08:14:38.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/283/bcrypt-ruby/issues/283"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:71f516a8-26e8-7933-0c8c-720e8bb4a5f6
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9FD8:127F38:B07B4B:DE8643:69759094
html-safe-nonce1b13da4b0c6f7543027eb9b07dfe0071ff0d55431825b9272287fd57aa6ea01f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RkQ4OjEyN0YzODpCMDdCNEI6REU4NjQzOjY5NzU5MDk0IiwidmlzaXRvcl9pZCI6IjU1Mjk4NzIzMzY0MTgwODI5NjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacf3613b43c986673df12ad265bede62dc293a0e9f389e59fb5edcd273397d243f
hovercard-subject-tagissue:3027463962
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/bcrypt-ruby/bcrypt-ruby/283/issue_layout
twitter:imagehttps://opengraph.githubassets.com/e44647d49e7383f892d21a8e037f4f44c135cf30225808f91889d8ee42ad6c6c/bcrypt-ruby/bcrypt-ruby/issues/283
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/e44647d49e7383f892d21a8e037f4f44c135cf30225808f91889d8ee42ad6c6c/bcrypt-ruby/bcrypt-ruby/issues/283
og:image:altDescription The bcrypt gem silently trims input strings longer than 72 characters during password hashing, which can lead to unexpected behavior. Specifically, when a string longer than 72 characte...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameckalpakoglu
hostnamegithub.com
expected-hostnamegithub.com
None4a4bf5f4e28041a9d2e5c107d7d20b78b4294ba261cab243b28167c16a623a1f
turbo-cache-controlno-preview
go-importgithub.com/bcrypt-ruby/bcrypt-ruby git https://github.com/bcrypt-ruby/bcrypt-ruby.git
octolytics-dimension-user_id81594302
octolytics-dimension-user_loginbcrypt-ruby
octolytics-dimension-repository_id15293
octolytics-dimension-repository_nwobcrypt-ruby/bcrypt-ruby
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id15293
octolytics-dimension-repository_network_root_nwobcrypt-ruby/bcrypt-ruby
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release488b30e96dfd057fbbe44c6665ccbc030b729dde
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby/issues/283#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fbcrypt-ruby%2Fbcrypt-ruby%2Fissues%2F283
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fbcrypt-ruby%2Fbcrypt-ruby%2Fissues%2F283
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=bcrypt-ruby%2Fbcrypt-ruby
Reloadhttps://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby/issues/283
Reloadhttps://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby/issues/283
Reloadhttps://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby/issues/283
bcrypt-ruby https://patch-diff.githubusercontent.com/bcrypt-ruby
bcrypt-rubyhttps://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fbcrypt-ruby%2Fbcrypt-ruby
Fork 284 https://patch-diff.githubusercontent.com/login?return_to=%2Fbcrypt-ruby%2Fbcrypt-ruby
Star 2k https://patch-diff.githubusercontent.com/login?return_to=%2Fbcrypt-ruby%2Fbcrypt-ruby
Code https://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby
Issues 15 https://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby/issues
Pull requests 2 https://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby/pulls
Actions https://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby/actions
Projects 0 https://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby/projects
Security 0 https://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby/security
Insights https://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby/pulse
Code https://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby
Issues https://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby/issues
Pull requests https://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby/pulls
Actions https://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby/actions
Projects https://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby/projects
Security https://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby/security
Insights https://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/bcrypt-ruby/bcrypt-ruby/issues/283
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/bcrypt-ruby/bcrypt-ruby/issues/283
Silent Trimming of Passwords Longer Than 72 Charactershttps://patch-diff.githubusercontent.com/bcrypt-ruby/bcrypt-ruby/issues/283#top
https://github.com/ckalpakoglu
https://github.com/ckalpakoglu
ckalpakogluhttps://github.com/ckalpakoglu
on Apr 29, 2025https://github.com/bcrypt-ruby/bcrypt-ruby/issues/283#issue-3027463962
https://trust.okta.com/security-advisories/okta-ad-ldap-delegated-authentication-username/https://trust.okta.com/security-advisories/okta-ad-ldap-delegated-authentication-username/
https://www.usenix.org/legacy/events/usenix99/provos/provos.pdfhttps://www.usenix.org/legacy/events/usenix99/provos/provos.pdf
https://en.wikipedia.org/wiki/Bcrypthttps://en.wikipedia.org/wiki/Bcrypt
https://kondukto.io/blog/okta-vulnerability-bcrypt-authhttps://kondukto.io/blog/okta-vulnerability-bcrypt-auth
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.