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 widely used for securing applications and services. The issue arises from the handling of one-time passcodes (OTPs) generated by FreeOTP when the OTP token period is set to the default 30 seconds. Normally, OTPs expire after 30 seconds, ensuring a narrow window for authentication and reducing the risk of replay attacks. However, due to this vulnerability, 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 valid simultaneously, increasing the attack window and the likelihood that an attacker could reuse an OTP to gain unauthorized access. The vulnerability affects Keycloak versions up to and including 25.0.0. The CVSS 3.1 base score is 4.8 (medium severity), reflecting a network attack vector with high attack complexity, no privileges required, no user interaction, and limited impact on confidentiality and integrity but no impact on availability. The flaw does not currently have known exploits in the wild, but it represents a significant risk in environments where OTP-based two-factor authentication is critical for security. The root cause is improper enforcement of OTP expiration timing, which should strictly invalidate tokens after their designated period. This vulnerability increases the risk of replay attacks and unauthorized access, particularly in high-security environments relying on Keycloak and FreeOTP for authentication.
Potential Impact
For European organizations, the primary impact of CVE-2024-7318 is the increased risk of unauthorized access due to the extended validity of OTP tokens. Organizations using Keycloak with FreeOTP for two-factor authentication may experience a higher likelihood of successful replay attacks, potentially compromising user accounts and sensitive data. This can lead to breaches of confidentiality and integrity, especially in sectors such as finance, healthcare, government, and critical infrastructure where strong authentication is mandatory. The extended token validity also undermines compliance with strict regulatory frameworks like GDPR and NIS Directive, which require robust access controls. Although the vulnerability does not affect availability, the potential for account compromise can lead to lateral movement within networks and subsequent data exfiltration or service disruption. The medium CVSS score reflects that exploitation requires network access and has high complexity, but no privileges or user interaction, making it a realistic threat in exposed environments. Organizations with large user bases or those integrating Keycloak into cloud or hybrid environments should be particularly vigilant.
Mitigation Recommendations
To mitigate CVE-2024-7318, European organizations should first verify their Keycloak version and upgrade to a patched release once available, as no official patch links are currently provided but are expected. In the interim, administrators can reduce the OTP token period below 30 seconds if configurable, minimizing the window of token validity overlap. Alternatively, consider switching to a different OTP application or method that strictly enforces token expiration. Implement additional monitoring and alerting for suspicious authentication attempts, focusing on repeated or out-of-window OTP usage. Enforce multi-factor authentication policies that do not solely rely on OTPs, such as hardware tokens or biometric factors, to reduce reliance on vulnerable OTP mechanisms. Conduct regular security audits and penetration tests to identify potential exploitation attempts. Educate users about the importance of timely OTP usage and the risks of token reuse. Finally, restrict network access to Keycloak authentication endpoints to trusted IP ranges to limit exposure to remote attackers.
Affected Countries
Germany, France, United Kingdom, Netherlands, Italy, Spain, Sweden, Belgium
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
Technical Analysis
CVE-2024-7318 is a vulnerability identified in Keycloak, an open-source identity and access management solution widely used for securing applications and services. The issue arises from the handling of one-time passcodes (OTPs) generated by FreeOTP when the OTP token period is set to the default 30 seconds. Normally, OTPs expire after 30 seconds, ensuring a narrow window for authentication and reducing the risk of replay attacks. However, due to this vulnerability, 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 valid simultaneously, increasing the attack window and the likelihood that an attacker could reuse an OTP to gain unauthorized access. The vulnerability affects Keycloak versions up to and including 25.0.0. The CVSS 3.1 base score is 4.8 (medium severity), reflecting a network attack vector with high attack complexity, no privileges required, no user interaction, and limited impact on confidentiality and integrity but no impact on availability. The flaw does not currently have known exploits in the wild, but it represents a significant risk in environments where OTP-based two-factor authentication is critical for security. The root cause is improper enforcement of OTP expiration timing, which should strictly invalidate tokens after their designated period. This vulnerability increases the risk of replay attacks and unauthorized access, particularly in high-security environments relying on Keycloak and FreeOTP for authentication.
Potential Impact
For European organizations, the primary impact of CVE-2024-7318 is the increased risk of unauthorized access due to the extended validity of OTP tokens. Organizations using Keycloak with FreeOTP for two-factor authentication may experience a higher likelihood of successful replay attacks, potentially compromising user accounts and sensitive data. This can lead to breaches of confidentiality and integrity, especially in sectors such as finance, healthcare, government, and critical infrastructure where strong authentication is mandatory. The extended token validity also undermines compliance with strict regulatory frameworks like GDPR and NIS Directive, which require robust access controls. Although the vulnerability does not affect availability, the potential for account compromise can lead to lateral movement within networks and subsequent data exfiltration or service disruption. The medium CVSS score reflects that exploitation requires network access and has high complexity, but no privileges or user interaction, making it a realistic threat in exposed environments. Organizations with large user bases or those integrating Keycloak into cloud or hybrid environments should be particularly vigilant.
Mitigation Recommendations
To mitigate CVE-2024-7318, European organizations should first verify their Keycloak version and upgrade to a patched release once available, as no official patch links are currently provided but are expected. In the interim, administrators can reduce the OTP token period below 30 seconds if configurable, minimizing the window of token validity overlap. Alternatively, consider switching to a different OTP application or method that strictly enforces token expiration. Implement additional monitoring and alerting for suspicious authentication attempts, focusing on repeated or out-of-window OTP usage. Enforce multi-factor authentication policies that do not solely rely on OTPs, such as hardware tokens or biometric factors, to reduce reliance on vulnerable OTP mechanisms. Conduct regular security audits and penetration tests to identify potential exploitation attempts. Educate users about the importance of timely OTP usage and the risks of token reuse. Finally, restrict network access to Keycloak authentication endpoints to trusted IP ranges to limit exposure to remote attackers.
Affected Countries
For access to advanced analysis and higher rate limits, contact root@offseq.com
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: 11/21/2025, 8:37:48 AM
Last updated: 12/3/2025, 11:56:01 PM
Views: 66
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.
Related Threats
CVE-2025-62173: CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') in FreePBX security-reporting
HighCVE-2025-64055: n/a
UnknownCVE-2025-66404: CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection') in Flux159 mcp-server-kubernetes
MediumCVE-2025-66293: CWE-125: Out-of-bounds Read in pnggroup libpng
HighCVE-2025-65868: n/a
UnknownActions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.