Quick Start Guide
Relevant source files
The following files were used as context for generating this wiki page:PPScan is a browser extension designed as a client-side prototype pollution scanner. It actively and passively tests visited websites for vulnerabilities related to prototype pollution, specifically focusing on vulnerable location parsers. The extension operates by injecting payloads, scanning scripts for known vulnerable patterns, and providing tools to brute-force gadget chains.
This guide provides instructions on how to install and use the PPScan extension, and explains its core features and architecture based on the source code.
Installation
To use PPScan, you must load it as an unpacked extension in a Chromium-based browser.
- Clone the repository to your local machine.
- Navigate to
chrome://extensionsorMore Tools -> Extensionsin your browser. - Enable "Developer Mode".
- Click "Load unpacked" and select the root folder of the cloned repository.
- The extension is now installed. Visit any website to begin testing.
Sources: README.md:10-18
Core Architecture
The extension is composed of several key components that work together to identify prototype pollution vulnerabilities.
Sources: manifest.json
| Component | File(s) | Description |
|---|---|---|
| Browser Action | pages/popup.html, scripts/popup.js | The main user interface, allowing control over scanning modes and displaying results. |
| Background Script | pages/background.html, scripts/background.js | A persistent script that manages state, handles web request interception, and orchestrates communication between components. |
| Content Script | scripts/content_script.js | Injected into all web pages to perform active scanning and facilitate gadget brute-forcing. |
| Payload/Experiment Script | scripts/exp.js, pages/iframe.html | A web-accessible resource used within an iframe to inject payloads and test for vulnerabilities in an isolated context. |
| Utilities | scripts/utils.js | Contains helper functions for passive scanning, including downloading a pattern database and matching against script content. |
The following diagram illustrates the high-level interaction between these components.
Scanning Modes
PPScan offers several modes of operation, which can be controlled from the extension's popup window.
Sources: pages/popup.html:27-41, scripts/popup.js:7-53
Passive Mode
When enabled, Passive Mode scans JavaScript files for patterns associated with known vulnerable libraries. This mode is enabled by default on installation.
- The
background.jsscript callsupdateDB()fromutils.js. utils.jsfetches a signature database from/database.csv.- A
webRequest.onCompletedlistener is registered to intercept all script requests. - For each completed script request, the
scanfunction downloads the script's content. - The
patternMatchfunction compares the content against the database of regex and text patterns. - If a match is found, the vulnerability details (domain, type, file) are added to the
foundset inbackground.jsand the badge count is updated.
This flow is visualized below.
Active Mode
Active Mode directly tests the current page for prototype pollution vulnerabilities by injecting payloads.
- When enabled via the popup,
background.jsregisters awebRequest.onHeadersReceivedlistener. - This listener modifies response headers to bypass security measures like
Content-Security-PolicyandX-Frame-Options. - The
content_script.jsis activated, which injects an invisible iframe pointing topages/iframe.html. - The iframe, which loads
exp.js, receives the page's URL viapostMessage. exp.jsconstructs new URLs with prototype pollution payloads (e.g.,__proto__[e32a5ec9c99]=ddcb362f1d60) and loads them in new iframes.- A separate script injected by
content_script.json the main page periodically checks ifObject.prototypehas been polluted (e.g.,Object.prototype.e32a5ec9c99). - If pollution is detected, a
PPLogcustom event is dispatched, which is caught and sent as a message tobackground.jsto be recorded.
Window Mode
Window Mode is a sub-feature of Active Mode, designed to bypass frame-busting mechanisms. When enabled, instead of using iframes to test payloads, exp.js will use window.open to launch the test URL in a new window. This is particularly useful for sites like https://msrkp.github.io/pp/3.html.
Sources: README.md:27-29, scripts/exp.js:75-82, scripts/popup.js:28-37
Brute-Forcing Gadgets
The extension provides a mechanism to test a list of known gadget chains against a potentially vulnerable page. This is initiated from the popup UI.
Sources: pages/popup.html:42-47, scripts/popup.js:55-66
| Button | Action |
|---|---|
| Search | Triggers a brute-force attack using the GADGETS list, applying each as a URL search parameter. |
| Hash | Triggers a brute-force attack using the GADGETS list, applying each as a URL hash fragment. |
The process is as follows:
- User clicks "Search" or "Hash" in the popup.
popup.jsexecutes a script on the active tab, dispatching aTriggerBruteorTriggerBruteHashcustom event.content_script.jslistens for these events and creates an invisible iframe loadingpages/iframe.html.- It sends a
postMessageto the iframe containing the page's URL and the type of attack ('search' or 'hash'). exp.jsin the iframe receives the message and iterates through theGADGETSarray.- For each gadget, it creates and appends a new iframe with the target URL modified to include the gadget payload. A
setTimeoutof 500ms is used between each attempt.
// A sample of gadgets from exp.js
var GADGETS = [
'__proto__[innerHTML]=<img/src/onerror=debugger>',
'__proto__[context]=<img/src/onerror%3ddebugger>&__proto__[jquery]=x',
'__proto__[url][]=data:,debugger//&__proto__[dataType]=script',
// ... and many more
];
Sources: scripts/exp.js:10-42
This flow is illustrated below.
Viewing Results
Vulnerabilities found by any of the scanning modes are collected in the background.js script.
- The number of found vulnerabilities is displayed as a badge on the extension icon.
- Opening the popup displays a list of all found vulnerabilities in a table.
- The table shows the host, the type of vulnerability (e.g., 'Active Mode' or a library name from passive scan), and the location (link to the file and line/column number).
- A "Clear" button is available to clear all stored results.
Sources: scripts/background.js:7-13, 19-25, scripts/popup.js:74-91, pages/popup.html:49-58