From CSP to OMG: How a Tiny Misconfigured Header Let Me Run JS An
A search input was reflected into the DOM without encoding, and the site's Content-Security-Policy allowed inline scripts, enabling DOM-based cross-site scripting. The input was also stored in localStorage and re-rendered, making the XSS persistent and allowing session hijacking and data exfiltration.
Free Link 🎈
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 inserted user-controlled input into innerHTML without sanitisation, and the Content-Security-Policy included 'unsafe-inline', allowing inline scripts to execute.
Impact
An attacker could hijack sessions, access internal user data such as email, name, and phone, and potentially extract internal API tokens or admin data if the endpoint is admin-privileged.
What the attacker needed
Victim clicks a link; attacker hosts a script
The fix
The site should sanitise user input before inserting it into the DOM and remove 'unsafe-inline' from the Content-Security-Policy.
How it was found
- The attacker crafts a URL with a script in the search parameter.
- The victim visits the URL.
- The script executes because the input is inserted into innerHTML and the CSP allows inline scripts.
- The script exfiltrates cookies and session data to an attacker-controlled server.
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.
The website took text from the search box and inserted it directly into the page without cleaning it first. Because the site's security policy allowed inline scripts, an attacker could put a script in the search link and it would run in the victim's browser. This let the attacker steal the victim's session and personal data.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.