CVE-2024-8796Insufficient Default OTP Shared Secret Length
Under the default configuration, Devise-Two-Factor versions >= 2.2.0 & < 6.0.0 generate TOTP shared secrets that are 120 bits instead of the 128-bit minimum defined by RFC 4226. Using a shared secret shorter than the minimum to generate a multi-factor authentication code could make it easier for an attacker to guess the shared secret and generate valid TOTP codes.
What to do
Fixed builds are available from RubyGems: see the table below for the fixed version per release.
Debian, Ubuntu have not shipped a fix for every release yet.
Is your server affected? One read-only command checks every installed package against this CVE and all others, using each vendor's fixed versions. Get started or get a free API key.
curl -sS "https://api.cvefocus.com/v1/check?format=text" -H "Authorization: Bearer $CVEFOCUS_KEY" \ -H "Content-Type: text/plain" --data-binary @inventory.txt
Vendor status at a glance
Status by vendor and release
From each vendor's own security data and VEX statements. "Fixed" means a fixed build is published for that release.
| Release | Package | Status | Fixed version | Advisory |
|---|---|---|---|---|
| Ubuntu 24.04 | ruby-devise-two-factor | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | ruby-devise-two-factor | Fix pending | 4.0.0-2ubuntu0.1~esm1 (Ubuntu Pro) | UBUNTU-CVE-2024-8796 |
| Ubuntu 20.04 | ruby-devise-two-factor | Fix pending | 3.1.0-2ubuntu0.1~esm1 (Ubuntu Pro) | UBUNTU-CVE-2024-8796 |
| Ubuntu 16.04 | ruby-devise-two-factor | Fix pending | UBUNTU-CVE-2024-8796 | |
| Debian 12 | ruby-devise-two-factor | Fix pending | DEBIAN-CVE-2024-8796 | |
| RubyGems library | devise-two-factor | Fixed | 6.0.0 | GHSA-qjxf-mc72-wjr2 |
What the vendor says
As published in the CVE record by SNPS, the CVE's assigner (usually the vendor). Check the vendor's advisory before acting.
- devise-two-factor: affected: 4.0.0 to before 6.0.0, 1.0.0; fixed in
6.0.0
Solution: Devise-Two-Factor should be upgraded to version v6.0.0 as soon as possible. After upgrading, the length of shared secrets and TOTP URLs generated by the library will increase since the new shared secrets will be longer. After upgrading or implementing the workaround, applications using Devise-Two-Factor may wish to migrate users to the new OTP length to provide increased protection for those accounts. Turning off OTP for users by setting otp_required_for_login to false is not recommended since it would leave accounts unprotected. However, you may wish to implement application logic that checks the length of a user's shared secret and prompts users to re-enroll in OTP.
Workaround: If upgrading is not possible, you can override the default otp_secret_length attribute in the model when configuring two_factor_authenticable and set it to a value of at least 26 to ensure newly generated shared secrets are at least 128-bits long.
Vendor advisories:
- https://github.com/devise-two-factor/devise-two-factor/security/advisories/GHSA-qjxf-mc72… (vendor-advisory)
References
About this page
Compiled by CVEfocus from the CVE List, the security data and VEX statements of Ubuntu, Debian, Red Hat, AlmaLinux, Rocky Linux and Microsoft, CISA's Known Exploited Vulnerabilities catalog and FIRST EPSS, refreshed several times a day (data status). Information only; see the disclaimer. Official record: cve.org · NVD.