KeycloakApplication · Redhat

CVE-2021-20195

CRITICAL · 9.6 CVSS v3.1 Published 2021-05-28
Fix available
A fix is available. Upgrade to 12.0.3 or later.
See remediation →
100/100
Remediation priority · Urgent
Remotely reachable No privileges

Official description Straight from the sourceThe vendor's or NVD's own wording, published unedited. Authoritative, but often terse — it says what broke, rarely what to do.

NVD · unedited
A flaw was found in keycloak in versions before 13.0.0. A Self Stored XSS attack vector escalating to a complete account takeover is possible due to user-supplied data fields not being properly encoded and Javascript code being used to process the data. The highest threat from this vulnerability is to data confidentiality and integrity as well as system availability.

Technical summary Written by usOur analysis, written from the advisory, the CVSS vector and the affected-version data. It adds context the advisory leaves out, and never invents facts that are not in the source.

dbcve analysis · high confidence

A Stored XSS vulnerability in Keycloak versions before 13.0.0 allows attackers to inject malicious JavaScript code through user-supplied data fields that are not properly encoded. Since JavaScript processes the data client-side, an attacker can escalate this to complete account takeover by stealing session tokens or credentials.

MitigationUpgrade Keycloak to version 13.0.0 or later. Additionally, implement output encoding for user-supplied data and validate/sanitize inputs to provide defense-in-depth.

Verify against the referenced sources before acting — the references below are authoritative for this CVE, this summary is not.

Affected products & versions What the vendor confirmedThe version ranges the vendor confirmed as vulnerable. If your version sits inside a range here, treat yourself as exposed until you have upgraded.

NVD · CPE data
KeycloakApplication
Affected:< 12.0.3

CVSS breakdown How the score is builtThe industry scoring standard. It rates how the flaw is reached, what it takes to exploit, and what an attacker gains — the score is derived from those, not the other way round.

From the vector
Attack vector
Network
Complexity
Low
Privileges
None
User interaction
Required
Scope
Changed
Confidentiality
High
Integrity
High
Availability
High

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H

Am I affected? How to checkSteps we derive from the advisory and the affected-version data, so you can decide whether this CVE reaches your setup. They are a guide, not a scan — your own configuration is the authority.

dbcve checks

Work through these to decide whether this CVE applies to you.

  1. Confirm Keycloak is running in your environment
    Check if the Keycloak service is active by running 'systemctl status keycloak' or 'ps aux | grep keycloak' to identify running Java processes related to Keycloak.
    Affected if Keycloak is actively running as your identity provider
  2. Identify the installed Keycloak version
    Check the version by examining the KEYCLOAK_HOME directory, the JAR file names, or by querying the server endpoint at '/authrealms/master' (for Keycloak < 14) or '/realms/master' (for Keycloak 14+). The version is typically visible in server logs at startup or in the 'product.json' file if using Red Hat builds.
    Affected if The version is earlier than 13.0.0 (or earlier than 12.0.3 for Red Hat builds)
  3. Verify user profile or registration endpoints are accessible
    Navigate to the account console endpoints: '/auth/realms/{realm}/account' or '/realms/{realm}/account' and inspect the profile fields (first name, last name, attributes). These are the user-supplied data fields where malicious scripts could be stored.
    Affected if User profile editing or self-registration is enabled and accessible to non-admin users
  4. Check if custom user attributes are being stored and displayed
    Review the Keycloak user federation settings or custom user profile configurations. Examine whether user attributes stored in the user database are reflected back in the account console or admin console without proper encoding.
    Affected if Custom user attributes or profile fields are stored and displayed in the UI without output encoding

You are affected if Keycloak versions before 13.0.0 are running AND user-supplied profile fields are accessible to authenticated users.

Generated from the published advisory. Verify against your own configuration.

Check your environment

Paste your version and any relevant configuration and it will be compared against the affected criteria above. Do not include secrets or credentials.

AI-assisted, checked against the advisory. Informational, not a guarantee.

Remediation Closing itWhat it takes to close this. Where a vendor fix exists we point at it; where none exists we say so plainly, and can build one. Effort estimates are scoped from the advisory, not from your codebase.

dbcve · scoped
Upgrade available Upgrade to 12.0.3 or later
Fixed in 12.0.3
Interim mitigation

Upgrade Keycloak to version 13.0.0 or later. Additionally, implement output encoding for user-supplied data and validate/sanitize inputs to provide defense-in-depth.

Recommended fix High confidence

Keycloak 13.0.0 or later (13.0.0, 13.1.0, etc.)

  1. 1. Backup your current Keycloak configuration and database
  2. 2. Download Keycloak 13.0.0 or later from the official Keycloak releases page
  3. 3. Stop the running Keycloak instance
  4. 4. Upgrade Keycloak by replacing the installation with the new version
  5. 5. Run database migrations if required using the migration scripts provided
  6. 6. Start the new Keycloak instance
  7. 7. Verify the installation by logging in and checking that the XSS vulnerability is no longer present
Caveat Major version upgrades in Keycloak may require configuration changes and database schema updates; review the migration guide for your specific upgrade path

Generated from the published advisory — verify against the referenced sources before acting.

Fix this in Keycloak Scoped from the published advisory
  • Consultation4.0 h
  • Implementation8.0 h
  • Testing8.0 h
  • Review / QA4.0 h
24.0 hours of engineering $4,160
Get the upgrade done

An estimate, not a bill — we confirm scope with you before any work starts. Need it this week? Rush from $6,656.

Scan for this in your stack

Free · runs locally
dbcve dependency scanner

Check whether your project pulls in CVE-2021-20195 — or any other known-vulnerable package — straight from your lock files. Free and open source; it runs locally and uploads nothing.

References Go to the primary sourcePrimary sources — vendor advisories, patches and trackers. Where our summary and a reference disagree, the reference wins.

Primary sources

Practitioner notes

Contributed

Peer-ranked notes from engineers who’ve handled CVE-2021-20195 in production — separate from our analysis above.

No notes yet

Be the first to add a field note for this CVE — a mitigation you’ve verified, a version caveat, or a link to a working fix. Sign in above to contribute.

What this is

A place for practitioners to share what actually worked: a mitigation you’ve tested, a configuration change, a version- or environment-specific caveat, or a link to a verified patch. The most useful notes rise to the top as peers upvote them, so the signal stays high.

What belongs here
  • Verified mitigations, workarounds, and config changes
  • Version or environment caveats, and links to real fixes
  • No weaponised exploit code, or anything meant to cause harm
  • No spam, self-promotion, credentials, or personal data