[██████] Reflected XSS via Keycloak on ██████
A Keycloak instance reflected an attacker-supplied value from a POST request path into an HTML response without encoding it, potentially allowing script to run and cookie-based credentials to be stolen.
Originally disclosed on HackerOne
- Disclosed after 32 days
Description: Keycloak 8.0 and prior contains a cross-site scripting vulnerability. An attacker can execute arbitrary script and thus steal cookie-based authentication credentials and launch other attacks. A lack of proper input validation made it possible for an attacker to execute malicious JavaScript code on ████████ This reflected XSS would execute after making a POST request with an XSS payload in the path of the request. As a result, the server would directly insert the payload into the response, allowing the XSS to trigger on the page.
References
https://cure53.de/pentest-report_keycloak.pdf https://hackerone.com/reports/87040
Impact
If successful, a cross site scripting attack can severely impact websites and web applications, damage their reputation and relationships with customers. XXS can deface websites, can result in compromised user accounts, and can run malicious code on web pages, which can lead to a compromise of the user's device.
System Host(s)
███
Affected Product(s) and Version(s)
█████
CVE Numbers
Steps to Reproduce
- Navigate visit URL https://████/
- Second step as long as I use recconaisetool I can find hidden directory path
403/200 - Found directory on "/auth/realms/master/clients-registrations/openid-connect"
- I see this server used keycloack. and lets see the versions used
chrome-extentions - The server is vulnerable to (XSS) Keycloack
8.0 - Intercept request to burp-suite and change
GETRequest toPOSTRequest
Here's the HTTP Parameter request that the issue:
POST /auth/realms/master/clients-registrations/openid-connect HTTP/1.1
Host: █████
Sec-Ch-Ua:
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: ""
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.5790.171 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Connection: close
Content-Type: application/json;charset=UTF-8
Content-Length: 63
{"<img onerror=confirm('xss_poc_unexpectedbufferc0n') src/>":1}
Used the payloads is {"<img onerror=confirm('xss_poc_unexpectedbufferc0n') src/>":1} boom is executed / effected.
█████████
██████████
Suggested Mitigation/Remediation Actions
It is recommended not to have error messages rendering as HTML (i.e. having thecontent-type of text/html), but to rather use plain-text (text/plain) instead. Additionally,HTML characters should be HTML-encoded in the response to prevent MIME-sniffingissues. https://cure53.de/pentest-report_keycloak.pdf
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the response rendered the request path as HTML without encoding, so markup in it was interpreted by the browser.
Impact
If successful, the reflected script could run in a victim's browser and may allow theft of cookie-based authentication credentials, though the report gives no working victim-delivery scenario.
What the attacker needed
Keycloak 8.0 or earlier; Crafted POST request with payload in the path
The fix
Error responses should be served as plain text rather than HTML, and HTML characters in the response should be encoded.
How it was found
- Visit the Keycloak server and locate the openid-connect client registration endpoint.
- Intercept a request to that endpoint in a proxy.
- Change the GET request into a POST request.
- Send a POST request with an HTML image tag with an event handler in the path.
- Observe the script executing in the response.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.