November 24, 2026
Two XSS Bugs, One Portal: A Responsible Disclosure Story
How a simple address field and a URL parameter led to two Cross-Site Scripting vulnerabilities, and how they were fixed.
By Shahzad Ali
3 min read
๐ก๏ธ Introduction
While testing a web portal (name withheld), I found two Cross-Site Scripting (XSS) vulnerabilities: one stored and one reflected. I reported both responsibly to the owners, and both have now been patched.
In this article I explain what I found, why it happened, and how developers can prevent it. All payloads shown here are generic proof-of-concept examples that appear in any XSS tutorial. No user data was exposed in this write-up.
What Is XSS?
Cross-Site Scripting happens when an application puts untrusted user input into a web page without proper encoding. The browser can't tell the difference between the site's own code and the attacker's input, so it runs the attacker's JavaScript inside the site's origin.
There are three main types:
- Stored XSS: the payload is saved on the server (for example in a database) and runs for everyone who views it.
- Reflected XSS: the payload is part of a request (such as a URL) and is immediately echoed back in the response.
- DOM-based XSS: the vulnerability is in client-side JavaScript that handles input unsafely.
This article covers the first two.
๐พ Finding 1: Stored XSS in the Address Field
The portal allowed users to save an address in their profile. The value was stored in the database and displayed on later pages without output encoding.
To confirm the issue, I used harmless proof-of-concept payloads that only show an alert box:
html
<script>alert(document.domain)</script><script>alert(document.domain)</script>
html
<svg onload="alert(document.domain)"><svg onload="alert(document.domain)">
html
<img src=x onerror="alert(document.domain)"><img src=x onerror="alert(document.domain)">How they work:
<img src=x onerror=...>: The image sourcexis invalid, so loading fails and theonerrorevent handler runs the JavaScript.<svg onload=...>: The browser parses the SVG element and fires theonloadevent as soon as it renders.<script>...</script>: The simplest form. The browser executes the script directly. Many apps block this one, which is why attackers also try event handlers like the two above.
Using alert(document.domain) instead of alert(1) proves the script runs in the target's origin, not in a sandbox.
Why this is serious: because the payload is stored, it runs every time the page is viewed, including by other users or staff members. The victim doesn't need to click anything special.
๐ Finding 2: Reflected XSS in the parent Parameter
The second issue was in a URL parameter named parent. Its value was placed directly into the response page without sanitization.
The same generic payload types confirmed the issue. For example:
https://[target-portal]/page?parent=<svg onload=alert(document.domain)>https://[target-portal]/page?parent=<svg onload=alert(document.domain)>
Why this is serious: if an attacker sends such a link to a victim (by email, chat, or social media) and the victim opens it, the script runs in their session. It needs user interaction, so it relies on social engineering, but it is still a real risk, especially against privileged users.
โ ๏ธ Impact
If exploited by a malicious actor, these bugs could lead to:
- Session hijacking (if cookies are missing the
HttpOnlyflag) - Performing actions on behalf of a logged-in user
- Phishing through fake content injected into the trusted page
- Targeting of administrators who view user-submitted data
๐ Root Cause
- User input was not encoded on output.
- Input validation was weak or missing (an address field has no need for < or >).
- No Content Security Policy (CSP) was in place to limit inline scripts and event handlers.
๐ How to Fix It
- Encode output by context. Use HTML entity encoding for HTML, attribute encoding for attributes, and JavaScript or URL encoding where needed.
- Validate input. Allow only the characters a field really needs.
- Deploy a strict CSP that blocks inline scripts and inline event handlers.
- Set
HttpOnlyandSecureflags on session cookies. - Use frameworks with auto-escaping and avoid dangerous sinks like
innerHTML. - Sanitize rich content with a trusted library (such as DOMPurify) if HTML input is truly required.
๐ Disclosure Timeline
- [Date]: Vulnerabilities discovered
- [Date]: Reported to the owner
- [Date]: Report acknowledged
- [Date]: Fixes confirmed
๐ก Lessons Learned
- Test every input, not just the obvious forms. The
parentparameter was easy to miss. - Try multiple payload types. If
<script>is blocked, event handlers likeonerrorandonloadmay still work. - Write clear, polite reports with reproduction steps. They get faster fixes.
- Wait for confirmation before publishing anything.
โ Conclusion
Both vulnerabilities came from one basic mistake: trusting user input. The fix is simple, but only if it is applied everywhere. Thanks to the security/IT team for their cooperation and quick response. Responsible disclosure makes the web safer for everyone.
This vulnerability has been fixed. This article is for educational purposes only.