CVE-2023-4918 Overview
A critical flaw was discovered in the Red Hat Keycloak package, specifically within the org.keycloak.userprofile component. When users register through the registration flow, the "password" and "password-confirm" form fields are incorrectly stored as regular user attributes. This design flaw allows any user or client with proper rights and roles to read user attributes, enabling a malicious actor with minimal access to retrieve user passwords in cleartext and potentially compromise the entire authentication environment.
Critical Impact
User passwords are exposed in cleartext as user attributes, allowing attackers with minimal access to harvest credentials and compromise user accounts across the Keycloak instance.
Affected Products
- Red Hat Keycloak 22.0.2
- Red Hat Keycloak (other versions may be affected)
Discovery Timeline
- September 12, 2023 - CVE-2023-4918 published to NVD
- November 21, 2024 - Last updated in NVD database
Technical Details for CVE-2023-4918
Vulnerability Analysis
This vulnerability represents a significant security flaw in Keycloak's user registration flow handling. The org.keycloak.userprofile component fails to properly sanitize and isolate sensitive credential fields during user registration. Instead of treating password fields as protected credential data with appropriate handling, the system erroneously persists these values as standard user attributes accessible through the user profile API.
The vulnerability is classified under CWE-256 (Unprotected Storage of Credentials) and CWE-319 (Cleartext Transmission of Sensitive Information), indicating both storage and potential transmission security failures. Any authenticated user or OAuth client with user read permissions can enumerate and retrieve these exposed password attributes, effectively bypassing Keycloak's credential protection mechanisms entirely.
Root Cause
The root cause lies in the user registration form processing logic within the org.keycloak.userprofile package. The registration handler does not properly distinguish between credential fields ("password", "password-confirm") and regular user profile attributes. This results in the password values being stored in the user attributes data structure rather than being routed through the secure credential storage system designed to hash and protect sensitive authentication data.
Attack Vector
This vulnerability is exploitable over the network by authenticated attackers with low privileges. An attacker who has registered an account and obtained basic API access permissions can query the user management APIs to enumerate user attributes. By targeting newly registered users or iterating through the user base, the attacker can extract cleartext passwords from the exposed attributes.
The attack sequence involves:
- Attacker registers or obtains a low-privilege account in the Keycloak realm
- Attacker obtains an access token with user read permissions (often available to regular clients)
- Attacker queries the Admin REST API or user profile endpoints to retrieve user attributes
- Password values stored as attributes are returned in the API response
- Attacker harvests credentials for account takeover or lateral movement
Detection Methods for CVE-2023-4918
Indicators of Compromise
- Unusual API calls to user profile or admin endpoints requesting user attributes
- Bulk user enumeration activity from unexpected sources
- Access token requests with elevated user read scopes from untrusted clients
- Audit logs showing repeated access to user attribute data across multiple users
Detection Strategies
- Monitor Keycloak audit logs for excessive user attribute read operations
- Implement alerting on bulk user enumeration patterns via the Admin REST API
- Review OAuth client configurations for overly permissive user read scopes
- Audit user attributes in the database for presence of password-related fields
- Deploy network monitoring to detect unusual data exfiltration from Keycloak endpoints
Monitoring Recommendations
- Enable comprehensive audit logging in Keycloak for all user attribute access events
- Configure SIEM rules to correlate user enumeration with subsequent authentication anomalies
- Implement rate limiting on user profile API endpoints
- Regularly audit stored user attributes for sensitive data exposure
How to Mitigate CVE-2023-4918
Immediate Actions Required
- Upgrade Keycloak to the latest patched version immediately
- Audit existing user accounts for exposed password attributes in the database
- Force password resets for all users who registered while the vulnerable version was active
- Review and restrict OAuth client permissions for user attribute access
- Implement additional access controls on the Admin REST API
Patch Information
Red Hat has released security updates to address this vulnerability. Administrators should apply the latest Keycloak version that includes the fix for CVE-2023-4918. Detailed patch information is available through the Red Hat CVE-2023-4918 Advisory and the GitHub Keycloak Security Advisory. The Red Hat Bug Report #2238588 provides additional technical details on the fix.
Workarounds
- Restrict access to the Admin REST API to only trusted administrative accounts
- Remove or limit OAuth client permissions that allow reading user attributes
- Implement network segmentation to restrict access to Keycloak management interfaces
- Deploy a Web Application Firewall (WAF) to monitor and block suspicious API access patterns
- Manually clean exposed password attributes from the user database if immediate patching is not possible
# Audit user attributes for exposed passwords (example database query)
# Run this against your Keycloak database to identify affected users
# SELECT u.username, ua.name, ua.value
# FROM user_entity u
# JOIN user_attribute ua ON u.id = ua.user_id
# WHERE ua.name IN ('password', 'password-confirm');
# After patching, force password reset for affected users via Keycloak Admin CLI
kcadm.sh update users/{user-id} -r {realm} -s 'requiredActions=["UPDATE_PASSWORD"]'
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


