Window Mode for Frame Busting
Relevant source files
The following files were used as context for generating this wiki page:Window Mode is a specialized scanning feature in PPScan designed to test for client-side prototype pollution vulnerabilities on websites that employ frame-busting techniques. Standard scanning methods, which rely on injecting iframes, fail when a target application prevents itself from being embedded in a frame. Window Mode circumvents this by opening the target URL in a new browser window to perform its tests.
This mode is manually activated through the extension's popup UI. When enabled, it alters the scanning flow to use window.open instead of creating an iframe. A series of URL manipulations and reloads are then performed within this new window to check for prototype pollution vulnerabilities.
Sources: README.md:20-22, scripts/exp.js:84-91
Architecture and Flow
The Window Mode feature is coordinated across several components of the extension: the popup UI, a background script, a content script, and an experiment script loaded into a temporary iframe.
Enabling Window Mode
Window Mode is not active by default. It must be enabled after first enabling "Active Mode".
- The user clicks the extension's browser action icon to open
popup.html. - The user clicks the "Enable Active Mode" button. This makes the "Enable Window Mode" button visible.
- The user clicks the "Enable Window Mode" button.
popup.jshandles the click event and updates abusterflag totrueinchrome.storage.sync.
This flow is depicted in the diagram below.
This diagram shows the user interaction sequence to enable Window Mode.
Sources: pages/popup.html:56-57, scripts/popup.js:29-38, scripts/background.js:27-29
Scanning Process
Once Window Mode is enabled, the scanning process for a visited page is altered. Instead of injecting test payloads into an iframe, the extension opens a new window to conduct the test.
The high-level flow is as follows:
- The main
content_script.json the target page creates a hidden iframe (pages/iframe.html), which loadsscripts/exp.js. - The content script sends a message to this iframe containing the page's URL.
exp.jsreceives the message and checkschrome.storagefor thebusterflag.- Since
busteris true,exp.jsopens the target URL in a new window (window.open) namedppdeadbeef1win. It appends adummyparameter to the URL to track the state and prevent recursion. - The new window loads the target page, and
content_script.jsis injected into it. - The content script in the new window detects the
dummyparameter in its URL and initiates a "hack for frame busting". - It injects prototype pollution payloads (
__proto__[e32a5ec9c99]) into the URL's search parameters and reloads the page. - After reloading, it injects a second payload (
__proto__[a0def12bce]) into the URL hash and reloads again. - During this process, it periodically checks if
Object.prototypehas been polluted. If pollution is detected, it logs the finding and closes the window.
The following diagram illustrates this detailed process.
This flowchart shows the step-by-step logic of the Window Mode scan.
Sources: scripts/exp.js:84-91, scripts/content_script.js:34-60
Key Components
UI and State Management
The user interface for controlling Window Mode is defined in popup.html and managed by popup.js.
| Element ID | File | Description |
|---|---|---|
buster | pages/popup.html | The "Enable/Disable Window Mode" button. Initially hidden. |
toggle | pages/popup.html | The "Enable/Disable Active Mode" button. Must be enabled to show the buster button. |
The state is managed via chrome.storage.sync:
toggle: A boolean that enables or disables active scanning.buster: A boolean that enables or disables Window Mode. It is set tofalseiftoggleis disabled.
Sources: pages/popup.html:56-57, scripts/popup.js:18-38
Frame Busting Logic
The core logic for bypassing frame busters resides in scripts/exp.js and scripts/content_script.js.
scripts/exp.js
This script acts as the trigger. When it receives a message from the content script and detects that the buster flag is enabled, it initiates the Window Mode scan.
// File: scripts/exp.js:84-91
chrome.storage.sync.get("buster", function(data) {
if (data.buster) {
var url = event.data.url;
console.log(url)
if (url.search("dummy") == -1 && window.name.search("ppdeadbeef1") == -1) { // avooiding recursion
var locasdf = new URL(url);
locasdf.searchParams.append('dummy', 'dummy') // avoiding recursion(twitter removes window.name)
locasdf.hash = "#dummy"
var a = window.open(locasdf.href, "ppdeadbeef1win");
}
}
// ...
});
This snippet shows the window.open call that is central to Window Mode. It opens the target URL in a new window named ppdeadbeef1win and adds dummy parameters to the search query and hash.
Sources: scripts/exp.js:84-91
scripts/content_script.js
This script contains the payload injection logic that runs inside the new window. It's designed as a multi-step process that modifies the URL and reloads the page to test different injection vectors.
// File: scripts/content_script.js:36-55
if (loc.indexOf('e32a5ec9c99') >= 0 && loc.search('a0def12bce') == -1) {
if ((typeof(Object.prototype.e32a5ec9c99)!='undefined')) {
logger(location.href);
}
var url = new URL(location.origin + location.pathname);
url.hash = "__proto__[a0def12bce]=ddcb362f1d60&__proto__.a0def12bce=ddcb362f1d60&__proto__=&0[a0def12bce]=ddcb362f1d60&dummy"
location = url.href;
} else if (loc.search('a0def12bce') != -1) {
setTimeout(function() {
if ((typeof(Object.prototype.a0def12bce)!='undefined')) {
logger(location.href);
}
window.close();
}, 5 * 1000)
} else {
var url = new URL(loc);
url.searchParams.append('__proto__[e32a5ec9c99]', 'ddcb362f1d60')
// ...
location = url.href;
}
This code block demonstrates the state machine-like logic within the new window. It checks the current URL for specific payloads (e32a5ec9c99, a0def12bce) to determine the next step: either inject the next payload and reload, or check for pollution and close the window.
Sources: scripts/content_script.js:34-60
Summary
Window Mode is a crucial feature of PPScan that extends its testing capabilities to modern web applications that actively block iframe embedding. By leveraging window.open and a multi-step URL manipulation process within a new window, it can effectively probe for prototype pollution vulnerabilities that would otherwise be missed. The feature is controlled by the user and relies on a coordinated effort between the extension's content script, experiment script, and UI components.
Sources: README.md:20-22, scripts/exp.js:84-91