From Prototype Pollution to DOM-based XSS: A Real-World Exploit W
The application used an outdated DataTables library vulnerable to prototype pollution, allowing an attacker to inject properties into Object.prototype. By overriding the toString method, the attacker could trigger DOM-based XSS when the polluted object was rendered via innerHTML.
Published on medium.com
my social handles : linkdin , instagram
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 used a vulnerable version of the DataTables library that allowed prototype pollution via unsafe object merging, and then rendered objects with innerHTML without sanitisation.
Impact
An attacker could execute arbitrary JavaScript in the victim's browser, potentially leading to session hijacking, credential theft, DOM injection, or privilege escalation if the XSS fires in an admin context.
What the attacker needed
Victim visits a page using vulnerable DataTables; attacker can inject prototype pollution payload
The fix
The application should be updated to a secure version of DataTables, avoid rendering raw objects via innerHTML, and sanitise input to block dangerous keys like __proto__, constructor, and prototype.
How it was found
- Identify that the application uses DataTables version 1.10.9.
- Confirm prototype pollution by testing payloads that inject into Object.prototype.
- Pollute Object.prototype by overriding the toString method.
- Trigger the XSS by assigning an object to document.body.innerHTML, which calls the polluted toString.
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.
Prototype pollution is a flaw where an attacker can add or change properties on a fundamental JavaScript object that many other objects inherit from. Here, the attacker used an old library to change how objects turn into text, so when the page tried to display an object, it ran the attacker's script instead. This is called DOM-based cross-site scripting (XSS), where malicious code runs in the victim's browser.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.