Skip to content

Reflected XSS (JavaScript context) in EndSessionUtils

Critical
moabu published GHSA-vxgw-mxhf-2m6f Jul 10, 2026

Package

maven io.jans.jans-auth-server (Maven)

Affected versions

<=2.1.0

Patched versions

>=2.2.0, 0.0.0-nightly

Description

File: jans-auth-server/server/src/main/java/io/jans/as/server/session/       ws/rs/EndSessionUtils.java:77-101
createFronthannelHtml concatenates the attacker-controlled state
parameter into the body of a <script> block that calls window.location:

    if (!Util.isNullOrEmpty(postLogoutUrl)) {
        if (!Util.isNullOrEmpty(state)) {
            if (postLogoutUrl.contains("?")) {
                postLogoutUrl += "&state=" + state;
            } else {
                postLogoutUrl += "?state=" + state;
            }
        }
        html += "<script>" +
                "window.onload=function() {" +
                "window.location='" + postLogoutUrl + "'" +    // <-- JS context
                "}" +
                "</script>";
    }

The state parameter is attacker-controlled by OAuth/OIDC spec design
(it round-trips through the user-agent). Because the injection point is
a JavaScript string literal (not an HTML attribute), HTML-context
escaping does not help — the attacker breaks out of the JS string with
a single quote and executes arbitrary JavaScript in the AS's origin.
Crafted URL (victim with active session follows it):
    /jans-auth/restv1/end_session?id_token_hint=<valid token>         &post_logout_redirect_uri=https://target.example/         &state='+alert(document.cookie)+'
Injected JS runs in the AS's origin. Can exfiltrate cookies/session
tokens, read localStorage (where OAuth client tokens may be stashed),
and issue same-origin fetches with the user's credentials.
Default deployments have no browser-side mitigation. The default Apache
template at community-edition-setup/templates/apache/https_gluu.conf has
the Content-Security-Policy header commented out:
    # Header always set Content-Security-Policy "default-src 'self'
    #     'unsafe-inline' https://%(hostname)s"
Even if uncommented, the proposed value includes 'unsafe-inline' in
script-src and would not block this injection.

Suggested fix:

JS-string-escape state and postLogoutUrl values (the
cleanest approach is to JSON-encode the string, which produces a valid
JS string literal):

    String postLogoutUrlJs = JsonUtil.toJson(postLogoutUrl);
    html += "<script>" +
            "window.onload=function() {" +
            "window.location=" + postLogoutUrlJs + ";" +
            "}" +
            "</script>";

The same applies to the logoutUri values inserted into iframe src
attributes earlier in the method (HTML-attribute context; needs HTML
escape).
Also recommend uncommenting + tightening the CSP in the Apache template,
removing 'unsafe-inline' from script-src.

Severity

Critical

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
Required
Scope
Changed
Confidentiality
High
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:N

CVE ID

No known CVE

Weaknesses

Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. Learn more on MITRE.

Credits