Welcome to PPScan
Relevant source files
The following files were used as context for generating this wiki page:PPScan is a browser extension for Google Chrome designed to detect Client-Side Prototype Pollution (CSPP) vulnerabilities. It operates by scanning visited websites for potential weaknesses using both passive and active methods. The extension identifies vulnerable location parsers and known vulnerable library patterns, and provides tools for manual gadget brute-forcing.
The system is composed of several key components: a background script for passive scanning and state management, a content script for injecting active payloads into web pages, a popup interface for user control and viewing results, and an exploit script that manages the delivery of test payloads. These components work together to provide comprehensive scanning capabilities.
Architecture Overview
PPScan is structured as a standard Chrome extension with several interacting scripts. The manifest.json file defines the core architecture, permissions, and entry points for the extension's functionality.
Sources: manifest.json
The following diagram illustrates the high-level relationship between the main components of the PPScan extension.
Core Features & Modes
PPScan offers three primary modes of operation, which can be configured through the extension's popup window.
| Mode | Default State | Description |
|---|---|---|
| Passive Mode | Enabled | Automatically scans JavaScript files for known vulnerable patterns in the background. |
| Active Mode | Disabled | Actively probes the current page for prototype pollution vulnerabilities by injecting payloads. |
| Window Mode | Disabled | A sub-mode of Active Mode that uses a new window instead of an iframe to bypass frame-busting techniques. |
Sources: scripts/background.js:28-33, scripts/popup.js:7-15, README.md:25-26
Passive Scanning Mode
This mode is enabled by default and operates transparently in the background. It intercepts network requests for JavaScript files and scans their content for patterns indicative of prototype pollution vulnerabilities.
- When passive mode is enabled, the background script downloads a list of vulnerability patterns from
database.csv. - It registers a listener on the
chrome.webRequest.onCompletedevent, filtering for requests of typescript. - For each completed script request, the
scanfunction is triggered. - The script's content is downloaded and matched against the patterns in the database using regex or simple text matching.
- If a match is found, the vulnerability details (domain, type, file location) are added to a
foundset, and the extension's badge count is updated.
Sources: scripts/background.js:61-63, scripts/utils.js:93-96, scripts/utils.js:12-34
This diagram shows the workflow for the passive scanning mode.
Sources: scripts/utils.js:93-115
Active Scanning Mode
Active Mode must be manually enabled. When active, it modifies HTTP response headers to bypass security measures like CSP and X-Frame-Options, allowing it to inject and test payloads more effectively.
- The user enables "Active Mode" in the popup.
- The
content_script.js, injected into the page, detects that the mode is active. - It injects a hidden
<iframe>pointing to the extension'spages/iframe.html. - The content script sends a
postMessageto this iframe, providing the current page's URL. - The
exp.jsscript within the iframe receives the message and begins creating new iframes, targeting the original URL but appending various prototype pollution payloads from itsPAYLOADSarray to the URL's search parameters and hash. - A separate injected script on the target page periodically checks
Object.prototypefor properties set by the payloads (e32a5ec9c99,a0def12bce). - If a property is found, a
PPLogcustom event is dispatched, which the content script captures and reports to the background script.
Sources: scripts/background.js:47-60, scripts/content_script.js:27-46, 73-86, scripts/exp.js:68-85
The following sequence diagram illustrates the active scanning process.
Window Mode
Window Mode is an alternative to the default iframe-based injection in Active Mode. It is designed to circumvent "frame busting" code that prevents a page from being loaded within an iframe. When enabled, exp.js will use window.open() to launch the test URLs in a new window instead of a hidden iframe.
Sources: README.md:25-26, scripts/exp.js:58-65
Gadget Brute-Forcing
From the popup, a user can manually trigger a brute-force scan using a predefined list of exploit "gadgets". These are known payload chains that can lead to XSS or other impacts when a prototype pollution vulnerability is present.
- Clicking "Search" or "Hash" in the popup triggers a
TriggerBruteorTriggerBruteHashevent on the current page. - The content script listens for these events and initiates the process, similar to Active Mode.
exp.jsreceives a message withtype: 'search'ortype: 'hash'and iterates through theGADGETSarray, injecting each one into the page's URL search parameters or hash via new iframes.
Sources: scripts/popup.js:51-60, scripts/content_script.js:1-24, scripts/exp.js:35-56
Key Components
background.js
This script is the central coordinator of the extension.
- State Management: It maintains the set of
foundvulnerabilities and initializes default settings (toggle,buster,passive) on installation. - Event Listeners: It listens for messages from content scripts (
chrome.runtime.onMessage), connections from the popup (chrome.extension.onConnect), and web requests (chrome.webRequest). - Header Modification: In Active Mode, it modifies
Content-Security-PolicyandX-Frame-Optionsheaders to facilitate testing. - Badge Updates: It controls the number displayed on the extension icon using
chrome.browserAction.setBadgeText.
Sources: scripts/background.js
content_script.js
This script is the bridge between the extension and the web pages being tested.
- Injection: It is injected into all frames on all URLs as defined in
manifest.json. - Active Scan Initiation: When Active Mode is on, it creates the initial iframe that kicks off the payload injection process.
- Vulnerability Detection: It injects a checker function into the page's own script context to monitor
Object.prototypefor pollution. - Communication: It listens for custom events from the popup (
TriggerBrute) and sends findings back to the background script.
Sources: scripts/content_script.js, manifest.json:20-27
exp.js
This is the payload delivery engine, running inside a sandboxed iframe.
- Payload Storage: It contains two key arrays:
PAYLOADSfor basic pollution checks andGADGETSfor known exploit chains. - Payload Injection: Based on messages received from the content script, it dynamically creates iframes or windows with URLs crafted to include the pollution payloads.
- Mode Handling: It differentiates its behavior based on the message type, triggering either a standard active scan or a gadget brute-force.
Sources: scripts/exp.js, pages/iframe.html:9
popup.js
This script powers the user-facing popup.
- User Controls: It handles clicks for enabling/disabling modes and triggering manual scans.
- Configuration: It reads and writes settings to
chrome.storage.sync. - Results Display: It communicates with the background script to fetch the list of found vulnerabilities and dynamically renders them in a table in
popup.html.
Sources: scripts/popup.js, pages/popup.html
Configuration Management
Extension settings are managed via chrome.storage.sync and controlled through the popup UI.
| Setting | Storage Key | Description |
|---|---|---|
| Active Mode | toggle | A boolean that enables or disables active scanning and header modification. |
| Window Mode | buster | A boolean that switches Active Mode from using iframes to new windows. |
| Passive Mode | passive | A boolean that enables or disables background scanning of script files. |
These settings are initialized on installation and can be modified at any time. The background and content scripts read these values to determine their behavior.