Payload Script (exp.js)
Relevant source files
The following files were used as context for generating this wiki page:The exp.js script is the core engine for actively testing and exploiting client-side prototype pollution vulnerabilities within the PPScan browser extension. It is not injected directly into the target page but is loaded into a dedicated, sandboxed iframe (pages/iframe.html). This script listens for messages from the content script containing a target URL and instructions, then proceeds to create a series of iframes or new windows, each with a specific prototype pollution payload or gadget appended to the URL as a query parameter or hash fragment.
This component is responsible for two main functions: initial scanning for vulnerable parsers using a small set of test payloads, and brute-forcing a wide range of known gadgets to achieve execution (e.g., XSS) if a vulnerability is suspected. Its operation is controlled via postMessage events, isolating the payload injection logic from the main content script.
Sources: scripts/exp.js, pages/iframe.html:10, scripts/content_script.js:1-25
Architecture and Execution Flow
The exp.js script operates entirely within the context of iframe.html, which is declared as a web_accessible_resources in the extension's manifest. This allows the content script to create an iframe and set its source to this local page. The entire process is initiated by the content script, which in turn can be triggered by user interaction with the extension's popup or automatically when "Active Mode" is enabled.
Sources: manifest.json:23-26, scripts/content_script.js:4-11
Communication Flow
Communication with exp.js is handled via the window.postMessage API. The content script sends a message containing the target url and a command (foo: "bar" for initial scan, foo: "baz" for gadget brute-force).
The following sequence diagram illustrates the flow for initiating a gadget brute-force test.
This diagram shows the chain of events from the user interface to the final payload delivery by exp.js.
Sources: scripts/popup.js:71-75, scripts/content_script.js:1-11, scripts/exp.js:71-85
Core Logic
The script's logic is contained within a single message event listener. It checks the content of the received message to decide which testing routine to execute.
Sources: scripts/exp.js:71-129
Message Handler
The main handler routes traffic based on the event.data.foo property.
This flowchart depicts the primary decision-making process within exp.js.
Sources: scripts/exp.js:72, scripts/exp.js:99
Initial Scan (foo: "bar")
This mode is triggered to perform a basic check for prototype pollution vulnerabilities. It iterates through a small list of PAYLOADS and injects them into both the URL's search parameters and its hash fragment.
- Standard Mode: Creates a new
iframefor each payload combination. - Window Mode (
buster): If thebusterflag is enabled inchrome.storage, it opens a new window (window.open) instead of an iframe. This is designed to bypass pages that use frame-busting techniques. Adummyparameter is added to the URL to prevent recursion.
A recursion check (window.name.search("ppdeadbeef1") == -1) is performed to ensure that the iframes or windows created by exp.js do not trigger the scanning logic on themselves.
Sources: scripts/exp.js:99-128, scripts/background.js:26-28
Gadget Brute-Force (foo: "baz")
This mode is used to test a wide variety of known exploitation gadgets against a potentially vulnerable page. It is triggered manually from the extension popup via the "Search" or "Hash" buttons.
- It iterates through the
GADGETSarray. - Based on the
event.data.type('search'or'hash'), it appends each gadget to the target URL's search parameters or hash. - For each gadget, a new
iframeis created and appended to the document, with a 500ms delay between each to avoid overwhelming the browser. - The same recursion check (
window.name.search("ppdeadbeef1") == -1) is used here.
Sources: scripts/exp.js:72-98, scripts/popup.js:71-79
Payloads and Gadgets
exp.js defines two constant arrays that form the basis of its testing capabilities: PAYLOADS for detection and GADGETS for exploitation.
PAYLOADS Array
This array contains a few fundamental patterns to test if an object's prototype can be modified through URL parsing.
| Name | Parameter Key | Parameter Value |
|---|---|---|
| XSS Prototype #3 | __proto__[e32a5ec9c99] | ddcb362f1d60 |
| XSS Prototype #4 | __proto__.e32a5ec9c99 | ddcb362f1d60 |
// scripts/exp.js:1-8
var PAYLOADS = [
// ...
['XSS Prototype #3', '__proto__[e32a5ec9c99]', 'ddcb362f1d60', ],
['XSS Prototype #4', '__proto__.e32a5ec9c99', 'ddcb362f1d60', ],
// ...
];
The content_script.js later checks if Object.prototype.e32a5ec9c99 has been set to confirm a vulnerability.
Sources: scripts/exp.js:1-8, scripts/content_script.js:58-61
GADGETS Array
This is a comprehensive list of known client-side prototype pollution gadgets that can lead to Cross-Site Scripting (XSS) or other unintended behavior in various JavaScript libraries. The script attempts to trigger a debugger statement, which would pause execution in the developer tools, indicating successful exploitation.
A small sample of the gadgets is shown below:
// scripts/exp.js:10-39
var GADGETS = [
'__proto__[innerHTML]=<img/src/onerror=debugger>',
'__proto__[context]=<img/src/onerror%3ddebugger>&__proto__[jquery]=x',
'__proto__[url][]=data:,debugger//&__proto__[dataType]=script',
'__proto__[srcdoc][]=<script>debugger</script>',
"__proto__[v-if]=_c.constructor('debugger')()",
'__proto__[template]=<script>debugger</script>',
// ... and many more
];
These gadgets target vulnerabilities in libraries like jQuery, Vue.js, and others by polluting properties such as innerHTML, url, or template.
Sources: scripts/exp.js:10-70
Conclusion
The exp.js script is a critical component of PPScan's active scanning functionality. By operating within a dedicated iframe and controlled via postMessage, it provides a robust and isolated environment for injecting a wide array of prototype pollution payloads and exploitation gadgets. Its dual-mode operation—a broad initial scan and a targeted gadget brute-force—allows the extension to both discover and confirm the exploitability of prototype pollution vulnerabilities on the client side.