Role of iframe.html
Relevant source files
The following files were used as context for generating this wiki page:iframe.html serves as an isolated environment for orchestrating prototype pollution scans. It is a minimal HTML page whose primary purpose is to load scripts/exp.js. This script listens for messages from the main page's content script and, based on the instructions received, dynamically creates additional iframes. These nested iframes load the target URL appended with various prototype pollution payloads or gadgets for vulnerability detection and exploitation testing.
This page is a crucial component, acting as a sandboxed intermediary that prevents infinite recursion and manages the timed dispatch of multiple test payloads against a target application. It is declared as a web_accessible_resources in the extension's manifest, allowing it to be loaded by content scripts running on any webpage.
Sources: pages/iframe.html, scripts/exp.js, manifest.json:25-28, scripts/content_script.js:4-10
Architecture and Initiation Flow
The iframe.html is not loaded directly by the user. Instead, it is injected into the currently viewed page by content_script.js. This process is triggered either automatically when "Active Mode" is enabled or manually when the user initiates a "Brute Gadgets" scan from the extension's popup.
Once injected, content_script.js sends a postMessage to the iframe, providing the target URL and the type of scan to perform.
Sources: scripts/content_script.js:1-21, 88-97, scripts/popup.js:58-69
The following diagram illustrates the sequence of events for initiating a scan.
Scan Orchestration Logic
The core logic resides in scripts/exp.js, which is loaded by iframe.html. It uses a message event listener to receive commands from content_script.js. Based on the message payload, it initiates one of two scanning modes.
Sources: pages/iframe.html:9, scripts/exp.js:41-110
Message Handling
The script's behavior is determined by the foo property in the received event.data.
event.data Property | Value | Action |
|---|---|---|
foo | "bar" | Initiates a prototype pollution vulnerability scan using the PAYLOADS array. |
foo | "baz" | Initiates a gadget brute-force scan using the GADGETS array. |
url | string | The target URL to be tested. |
type | "hash" / "search" | (Only for foo: "baz") Determines whether to append gadgets to the URL's hash or search parameters. |
Sources: scripts/exp.js:42, 60, 78
The logic flow within exp.js is as follows:
This diagram shows the decision-making process inside exp.js upon receiving a postMessage.
Sources: scripts/exp.js:41-110
Vulnerability Scanning (foo: "bar")
When foo is "bar", the script iterates through a predefined list of PAYLOADS. For each payload, it creates two new iframes: one with the payload in the URL's search parameters and another with the payload in the URL's hash. This mode is used to discover if a target application is vulnerable to prototype pollution from URL parsing.
A recursion guard (window.name.search("ppdeadbeef1") == -1) ensures that the newly created iframes do not also start scanning, preventing an infinite loop.
// scripts/exp.js:90-104
if (window.name.search("ppdeadbeef1") == -1) { // avoiding recurssion
var url = event.data.url;
for (i = 0; i < PAYLOADS.length; i++) {
for (j = 0; j < 2; j++) {
var locasdf = new URL(url);
// debugger;
var iframe = document.createElement("iframe");
j ? locasdf.searchParams.append(PAYLOADS[i][1], PAYLOADS[i][2]) : locasdf.hash = "#" + PAYLOADS[i][1] + "=" + PAYLOADS[i][2];
iframe.name = "ppdeadbeef1"
console.log(decodeURI(locasdf.href));
iframe.src = decodeURI(locasdf.href);
// iframe.sandbox="allow-forms allow-scripts allow-same-origin"
document.documentElement.appendChild(iframe);
}
}
}
Sources: scripts/exp.js:1-8, 88-106
Gadget Brute-Forcing (foo: "baz")
When foo is "baz", the script iterates through a much larger list of GADGETS. These are known client-side script gadgets that can lead to Cross-Site Scripting (XSS) if a prototype pollution vulnerability exists. Depending on the type property in the message ('hash' or 'search'), the script appends each gadget to the target URL's hash or search string, respectively.
Each gadget is tested in a new iframe, created with a 500ms delay between each one to avoid overwhelming the browser or server.
// scripts/exp.js:46-56
for (let idx in GADGETS) {
if (event.data.type != 'hash') {
setTimeout(() => {
let iframe = document.createElement("iframe");
let target_url = new URL(url);
target_url.search = GADGETS[idx];
iframe.name = "ppdeadbeef1"
iframe.src = target_url;
console.log(`[search:${+idx + 1}] `, target_url.href);
document.documentElement.appendChild(iframe);
}, 500 * idx);
} // ... else for 'hash'
}
Sources: scripts/exp.js:10-40, 44-76
Security Context and Dependencies
For iframe.html and its child iframes to function correctly, especially on sites with strict security policies, the extension's background script (background.js) modifies HTTP response headers when "Active Mode" is enabled. It removes X-Frame-Options and overwrites the Content-Security-Policy to allow framing and script execution from any source. This is critical for the nested iframes, which load the target site, to be rendered.
Sources: scripts/background.js:40-58
Conclusion
iframe.html is a central, albeit simple, component of the PPScan extension. It acts as a dedicated and isolated orchestrator for launching prototype pollution attacks. By loading exp.js, it provides the necessary sandboxed environment to receive commands, manage the creation of numerous payload-bearing iframes, and avoid recursive scanning loops, making it fundamental to both the vulnerability detection and gadget testing capabilities of the tool.