VYPR
Critical severityNVD Advisory· Published May 28, 2021· Updated Aug 3, 2024

CVE-2021-20195

CVE-2021-20195

Description

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.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
org.keycloak:keycloak-coreMaven
< 13.0.013.0.0

Affected products

1

Patches

1
717d9515fa13

KEYCLOAK-16890: Stored XSS attack on new acct console (#7867)

https://github.com/keycloak/keycloakStan SilvertMar 22, 2021via ghsa
2 files changed · +25 1
  • testsuite/integration-arquillian/tests/other/base-ui/src/test/java/org/keycloak/testsuite/ui/account2/PersonalInfoTest.java+18 0 modified
    @@ -250,4 +250,22 @@ public void updateProfileWithAttributePresent() {
     
             ApiUtil.removeUserByUsername(testRealm, "keycloak-15634");
         }
    +
    +    @Test
    +    // https://issues.redhat.com/browse/KEYCLOAK-16890
    +    // Stored personal info triggers attack via the display of user name in header.
    +    // If user name is left unsanitized, this test will fail with
    +    // org.openqa.selenium.UnhandledAlertException: unexpected alert open: {Alert text : XSS}
    +    public void storedXSSAttack() {
    +        personalInfoPage.navigateTo();
    +        testUser.setFirstName("<img src=x onerror=\"alert('XSS');\">");
    +        personalInfoPage.setValues(testUser, false);
    +        personalInfoPage.clickSave();
    +
    +        personalInfoPage.header().clickLogoutBtn();
    +        accountWelcomeScreen.header().clickLoginBtn();
    +        loginPage.form().login(testUser);
    +        personalInfoPage.navigateTo();
    +    }
    +
     }
    
  • themes/src/main/resources/theme/keycloak.v2/account/resources/welcome-page-scripts.js+7 1 modified
    @@ -55,7 +55,13 @@ function loggedInUserName() {
                 userName = (givenName || familyName) || preferredUsername || userName;
             }
         }
    -    return userName;
    +    return sanitize(userName);
    +}
    +
    +function sanitize(dirtyString) {
    +    let element = document.createElement("span");
    +    element.textContent = dirtyString;
    +    return element.innerHTML;
     }
     
     var toggleMobileDropdown = function () {	
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

4

News mentions

0

No linked articles in our index yet.