CVE-2026-33306

bcrypt-ruby is a Ruby binding for the OpenBSD bcrypt() password hashing algorithm. Prior to version 3.1.22, an integer overflow in the Java BCrypt implementation for JRuby can cause zero iterations in the strengthening loop. Impacted applications must be setting the cost to 31 to see this happen. The JRuby implementation of bcrypt-ruby (`BCrypt.java`) computes the key-strengthening round count as a signed 32-bit integer. When `cost=31` (the maximum allowed by the gem), signed integer overflow causes the round count to become negative, and the strengthening loop executes **zero iterations**. This collapses bcrypt from 2^31 rounds of exponential key-strengthening to effectively constant-time computation — only the initial EksBlowfish key setup and final 64x encryption phase remain. The resulting hash looks valid (`$2a$31$...`) and verifies correctly via `checkpw`, making the weakness invisible to the application. This issue is triggered only when cost=31 is used or when verifying a `$2a$31$` hash. This problem has been fixed in version 3.1.22. As a workaround, set the cost to something less than 31.
Configurations

Configuration 1 (hide)

cpe:2.3:a:bcrypt-ruby_project:bcrypt-ruby:*:*:*:*:*:ruby:*:*

History

30 Mar 2026, 14:07

Type Values Removed Values Added
First Time Bcrypt-ruby Project
Bcrypt-ruby Project bcrypt-ruby
CVSS v2 : unknown
v3 : unknown
v2 : unknown
v3 : 7.5
References () https://github.com/bcrypt-ruby/bcrypt-ruby/commit/831ce64cb0a9502130fa93a28bfd9527a5fa45c4 - () https://github.com/bcrypt-ruby/bcrypt-ruby/commit/831ce64cb0a9502130fa93a28bfd9527a5fa45c4 - Patch
References () https://github.com/bcrypt-ruby/bcrypt-ruby/releases/tag/v3.1.22 - () https://github.com/bcrypt-ruby/bcrypt-ruby/releases/tag/v3.1.22 - Product, Release Notes
References () https://github.com/bcrypt-ruby/bcrypt-ruby/security/advisories/GHSA-f27w-vcwj-c954 - () https://github.com/bcrypt-ruby/bcrypt-ruby/security/advisories/GHSA-f27w-vcwj-c954 - Mitigation, Vendor Advisory
CPE cpe:2.3:a:bcrypt-ruby_project:bcrypt-ruby:*:*:*:*:*:ruby:*:*
Summary
  • (es) bcrypt-ruby es un enlace Ruby para el algoritmo de hash de contraseñas bcrypt() de OpenBSD. Antes de la versión 3.1.22, un desbordamiento de entero en la implementación Java de BCrypt para JRuby puede causar cero iteraciones en el bucle de fortalecimiento. Las aplicaciones afectadas deben estar configurando el costo en 31 para que esto ocurra. La implementación de JRuby de bcrypt-ruby ('BCrypt.java') calcula el recuento de rondas de fortalecimiento de clave como un entero con signo de 32 bits. Cuando 'cost=31' (el máximo permitido por la gema), el desbordamiento de entero con signo hace que el recuento de rondas se vuelva negativo, y el bucle de fortalecimiento ejecuta cero iteraciones. Esto colapsa bcrypt de 2^31 rondas de fortalecimiento exponencial de clave a una computación en tiempo efectivamente constante — solo quedan la configuración inicial de clave EksBlowfish y la fase final de cifrado 64x. El hash resultante parece válido ('$2a$31$...') y se verifica correctamente a través de 'checkpw', haciendo que la debilidad sea invisible para la aplicación. Este problema se activa solo cuando se usa cost=31 o al verificar un hash '$2a$31$'. Este problema ha sido solucionado en la versión 3.1.22. Como solución alternativa, configure el costo en algo menor que 31.

24 Mar 2026, 01:17

Type Values Removed Values Added
New CVE

Information

Published : 2026-03-24 01:17

Updated : 2026-03-30 14:07


NVD link : CVE-2026-33306

Mitre link : CVE-2026-33306

CVE.ORG link : CVE-2026-33306


JSON object : View

Products Affected

bcrypt-ruby_project

  • bcrypt-ruby
CWE
CWE-190

Integer Overflow or Wraparound