CVE-2024-7318: Use of a Key Past its Expiration Date
A vulnerability was found in Keycloak. Expired OTP codes are still usable when using FreeOTP when the OTP token period is set to 30 seconds (default). Instead of expiring and deemed unusable around 30 seconds in, the tokens are valid for an additional 30 seconds totaling 1 minute. A one time passcode that is valid longer than its expiration time increases the attack window for malicious actors to abuse the system and compromise accounts. Additionally, it increases the attack surface because at any given time, two OTPs are valid.
AI Analysis
Technical Summary
CVE-2024-7318 is a vulnerability identified in Keycloak, an open-source identity and access management solution, involving the improper expiration handling of one-time passcodes (OTPs) generated by FreeOTP when the OTP token period is set to the default 30 seconds. Normally, OTPs are designed to expire after their designated period to minimize the window of opportunity for attackers. However, due to this flaw, expired OTPs remain valid for an additional 30 seconds, effectively doubling the token validity period to one minute. This means that at any given time, two OTPs are concurrently valid, increasing the attack surface and the window during which an attacker can reuse or intercept OTPs to gain unauthorized access. The vulnerability impacts Keycloak versions up to 25.0.0 and does not require authentication or user interaction to exploit, although the attack complexity is high because precise timing and network access are necessary. The CVSS v3.1 base score is 4.8 (medium severity), reflecting low confidentiality and integrity impact, no availability impact, network attack vector, high attack complexity, and no privileges or user interaction required. No public exploits have been reported yet, but the issue is significant for environments relying on OTP-based multi-factor authentication (MFA) for securing user accounts.
Potential Impact
The primary impact of CVE-2024-7318 is an increased risk of unauthorized account access due to the extended validity of OTP tokens. By allowing OTPs to remain valid for twice their intended duration, attackers have a larger time window to intercept or reuse OTPs, potentially bypassing multi-factor authentication protections. This undermines the security guarantees of time-based OTP systems, which rely on short-lived tokens to limit attack opportunities. Organizations using Keycloak for authentication, especially those employing FreeOTP with default settings, face a heightened risk of account compromise, data breaches, and unauthorized access to sensitive systems. The vulnerability could facilitate lateral movement within networks if attackers gain initial access through compromised OTPs. While the vulnerability does not directly affect system availability, the integrity and confidentiality of user accounts and associated data are at risk. The medium CVSS score reflects moderate severity but should not be underestimated in high-security environments.
Mitigation Recommendations
To mitigate CVE-2024-7318, organizations should first apply any available patches or updates from Keycloak that address the OTP expiration handling. If patches are not yet available, consider the following practical steps: 1) Adjust the OTP token period to a shorter duration if configurable, reducing the window of token validity; 2) Implement additional layers of authentication or anomaly detection to monitor for unusual login patterns or repeated OTP usage; 3) Enforce strict session management and limit the number of concurrent sessions per user; 4) Educate users about the importance of securing their OTP devices and promptly reporting suspicious activity; 5) Consider using alternative MFA methods less susceptible to timing-based vulnerabilities, such as push-based authentication or hardware tokens; 6) Monitor authentication logs for signs of repeated or overlapping OTP usage that could indicate exploitation attempts. These measures help reduce the attack surface and limit potential damage until a formal patch is deployed.
Affected Countries
United States, Germany, United Kingdom, France, India, Canada, Australia, Netherlands, Japan, South Korea
CVE-2024-7318: Use of a Key Past its Expiration Date
Description
A vulnerability was found in Keycloak. Expired OTP codes are still usable when using FreeOTP when the OTP token period is set to 30 seconds (default). Instead of expiring and deemed unusable around 30 seconds in, the tokens are valid for an additional 30 seconds totaling 1 minute. A one time passcode that is valid longer than its expiration time increases the attack window for malicious actors to abuse the system and compromise accounts. Additionally, it increases the attack surface because at any given time, two OTPs are valid.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
CVE-2024-7318 is a vulnerability identified in Keycloak, an open-source identity and access management solution, involving the improper expiration handling of one-time passcodes (OTPs) generated by FreeOTP when the OTP token period is set to the default 30 seconds. Normally, OTPs are designed to expire after their designated period to minimize the window of opportunity for attackers. However, due to this flaw, expired OTPs remain valid for an additional 30 seconds, effectively doubling the token validity period to one minute. This means that at any given time, two OTPs are concurrently valid, increasing the attack surface and the window during which an attacker can reuse or intercept OTPs to gain unauthorized access. The vulnerability impacts Keycloak versions up to 25.0.0 and does not require authentication or user interaction to exploit, although the attack complexity is high because precise timing and network access are necessary. The CVSS v3.1 base score is 4.8 (medium severity), reflecting low confidentiality and integrity impact, no availability impact, network attack vector, high attack complexity, and no privileges or user interaction required. No public exploits have been reported yet, but the issue is significant for environments relying on OTP-based multi-factor authentication (MFA) for securing user accounts.
Potential Impact
The primary impact of CVE-2024-7318 is an increased risk of unauthorized account access due to the extended validity of OTP tokens. By allowing OTPs to remain valid for twice their intended duration, attackers have a larger time window to intercept or reuse OTPs, potentially bypassing multi-factor authentication protections. This undermines the security guarantees of time-based OTP systems, which rely on short-lived tokens to limit attack opportunities. Organizations using Keycloak for authentication, especially those employing FreeOTP with default settings, face a heightened risk of account compromise, data breaches, and unauthorized access to sensitive systems. The vulnerability could facilitate lateral movement within networks if attackers gain initial access through compromised OTPs. While the vulnerability does not directly affect system availability, the integrity and confidentiality of user accounts and associated data are at risk. The medium CVSS score reflects moderate severity but should not be underestimated in high-security environments.
Mitigation Recommendations
To mitigate CVE-2024-7318, organizations should first apply any available patches or updates from Keycloak that address the OTP expiration handling. If patches are not yet available, consider the following practical steps: 1) Adjust the OTP token period to a shorter duration if configurable, reducing the window of token validity; 2) Implement additional layers of authentication or anomaly detection to monitor for unusual login patterns or repeated OTP usage; 3) Enforce strict session management and limit the number of concurrent sessions per user; 4) Educate users about the importance of securing their OTP devices and promptly reporting suspicious activity; 5) Consider using alternative MFA methods less susceptible to timing-based vulnerabilities, such as push-based authentication or hardware tokens; 6) Monitor authentication logs for signs of repeated or overlapping OTP usage that could indicate exploitation attempts. These measures help reduce the attack surface and limit potential damage until a formal patch is deployed.
Technical Details
- Data Version
- 5.1
- Assigner Short Name
- redhat
- Date Reserved
- 2024-07-31T03:04:15.355Z
- Cisa Enriched
- true
- Cvss Version
- 3.1
- State
- PUBLISHED
Threat ID: 682d9837c4522896dcbeb7de
Added to database: 5/21/2025, 9:09:11 AM
Last enriched: 2/28/2026, 3:54:53 AM
Last updated: 3/27/2026, 10:13:37 AM
Views: 91
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.