Cross-Site Scripting (XSS) via Client-Side Filter Bypass
A location tag input field had client-side-only protections (keyboard filtering, paste blocking, and a single-script-tag regex on submit). An attacker could set the field value directly via the browser console, bypass the filters with two script tags, and have the server render raw HTML, executing JavaScript that exposed session cookies.
medium.com
Published on medium.com
I am a Security Analyst who enjoys finding weaknesses before the bad guys do.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application relied entirely on client-side JavaScript validation and rendered user input as raw HTML without server-side sanitisation.
Impact
An attacker could steal session cookies including authentication tokens, user roles, and CSRF tokens, potentially leading to complete account takeover.
What the attacker needed
Victim visits a page with the injected payload; attacker can set the field value via console; no server-side sanitisation
The fix
The application should sanitise user input on the server before rendering it as HTML, mark session cookies as HttpOnly, and add a Content Security Policy to block inline scripts.
How it was found
- Capture the request in Burp Suite and observe that parameters are encrypted, preventing direct server-side manipulation.
- Inspect the Location Tag input field in DevTools and note the client-side event handlers for paste and input validation.
- Open the browser console and set the field's value directly to a script payload, bypassing keyboard and paste filters.
- Submit the form and observe that a single script tag is blocked by a client-side regex filter.
- Set the field value to two consecutive script tags to bypass the single-tag regex.
- Submit the form again and observe the script executes, exposing document.cookie.
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 write-up has not been written yet. The Original tab links to the source.
Cross-site scripting (XSS) is when a website takes something a user typed and puts it into the page without cleaning it first, so any code in that text runs in the browser. Here the site tried to stop bad characters using JavaScript in the browser, but a user can simply change the field's value directly with the browser's developer tools, skipping those checks. The server then displayed the value as raw HTML, so the injected script ran and could read the user's cookies.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.