FirstBlood-#1498 — Redirect url vulnerable to XSS and Open redirect
This issue was discovered on FirstBlood v3
On 2022-12-10, pichik Level 4 reported:
Hi,
DESCRITPION:
There are 2 vulnerable endpoints:
- endpoint is
about.html
, which instantly redirects you to about.php
.
- endpoint is
book-appointment.html
, which instantly redirects you to book-appointment.php
Not sure if these are two separated bugs, or just one, so I am reporting both of them here.
If we inspect this endpoint there is script:
<script>
var curUrl = window.location.search;
var params = new URLSearchParams(curUrl);
var redirect_url = params.get('redirect_url');
if (redirect_url == null) {
top.location.href='about.php';
} else {
top.location.href=redirect_url;
}
</script>
This script reveal new query parameter redirect_url
, which then is passed to top.location.href
without any sanitization and thus vulnerable to XSS.
We can use simple payload for href with javascript protocol: javascript:alert(document.domain)
POC LINK:
Reflected XSS:
https://0a3942517b17-pichik.a.firstbloodhackers.com/about.html?redirect_url=javascript:alert(document.domain)
https://0a3942517b17-pichik.a.firstbloodhackers.com/book-appointment.html?redirect_url=javascript:alert(document.domain)
Open Redirect:
https://0a3942517b17-pichik.a.firstbloodhackers.com/about.html?redirect_url=https://google.com
https://0a3942517b17-pichik.a.firstbloodhackers.com/book-appointment.html?redirect_url=https://google.com
IMPACT:
Attacker can send this to doctors and steal their cookies
REMEDIATION:
Remove this endpoint entirely, or add html encoding of special characters to prevent XSS
and filter external urls to prevent Open Redirects.
P3 Medium
Endpoint: /about.html
Parameter: redirect_url
Payload: javascript:alert(1)
FirstBlood ID: 45
Vulnerability Type: Reflective XSS
The endpoint about.php was introduced to replace about.html, but code on about.html introduces an XSS vulnerability via the javascript: URI
FirstBlood ID: 46
Vulnerability Type: Reflective XSS
The endpoint book-appointment.php was introduced to replace book-appointment.html, but code on book-appointment.html introduces an XSS vulnerability via the javascript: URI