Troubleshooting
Relevant source files
The following files were used as context for generating this wiki page:This document provides guidance for troubleshooting common issues with the PPScan extension. It covers the different scanning modes, how to interpret results, and solutions for potential problems encountered during use. The information herein is derived exclusively from the extension's source code.
PPScan operates in several modes to detect client-side prototype pollution vulnerabilities. Issues can arise from website-specific security features like Content Security Policy (CSP) or frame busting, or from the configuration of the extension itself. Understanding the extension's architecture is key to diagnosing problems.
Common Issues and Solutions
XFO or CSP Errors
If you encounter X-Frame-Options (XFO) or Content Security Policy (CSP) errors in the developer console, it may interfere with the "Active Mode" scanning, which relies on iframes. The README.md suggests reloading the extension as a first step.
When "Active Mode" is enabled, the extension attempts to mitigate these issues by modifying response headers to remove X-Frame-Options and relax the Content-Security-Policy.
// scripts/background.js:46-58
chrome.webRequest.onHeadersReceived.addListener((response) => {
response.responseHeaders.forEach(header => {
if (isCSPHeader(header)) {
header.value = `default-src * 'unsafe-inline' 'unsafe-eval' data: blob:; `;
};
if (isXFrameEnabled(header)) {
header.name = 'foo';
};
if (isCached(header)) {
header.name = 'foo';
};
});
return {
responseHeaders: response.responseHeaders,
};
}, {
urls: ['<all_urls>']
}, ['blocking', 'responseHeaders', 'extraHeaders']);
If these errors persist, it's possible the header modification is not taking effect for the target page. Reloading the extension can help re-establish the webRequest listeners.
Sources: README.md:21, scripts/background.js:45-62
Application Uses Frame Busting
Some websites employ "frame busting" techniques to prevent themselves from being loaded within an iframe. This will break the default behavior of "Active Mode". To counteract this, PPScan provides a "Window Mode".
When "Window Mode" is enabled, instead of injecting an iframe to test payloads, the extension will open a new window (window.open) for the test. This is particularly useful for sites like https://msrkp.github.io/pp/3.html.
Sources: README.md:18-20, scripts/exp.js:63-70
Understanding Scanning Modes
Troubleshooting often requires verifying which scanning modes are active. The extension's behavior changes significantly based on these settings, which are controlled from the popup UI.
| Mode | UI Button | Storage Key | Description |
|---|---|---|---|
| Active Mode | Enable/Disable Active Mode | toggle (boolean) | When enabled, injects scripts into visited pages to actively probe for prototype pollution vulnerabilities by modifying the URL and checking Object.prototype. |
| Window Mode | Enable/Disable Window Mode | buster (boolean) | A sub-mode of Active Mode. If enabled, uses window.open instead of iframes to test payloads, bypassing frame-busting mechanisms. This button is only visible when Active Mode is enabled. |
| Passive Mode | Enable/Disable Passive Mode | passive (boolean) | When enabled, passively scans the content of JavaScript files loaded by the page against a database of known-vulnerable patterns. |
Sources: scripts/popup.js:6-48, scripts/background.js:33-44, scripts/content_script.js:31-33
The following diagram illustrates the state transitions based on user interaction with the popup.
This diagram shows how the scanning modes are toggled from the popup UI.
Sources: pages/popup.html:47-59, scripts/popup.js:14-48
Debugging Vulnerability Detection
If you suspect a vulnerability is not being detected, understanding the detection flow for each mode is crucial.
Active Scan Flow
Active scanning is initiated if the toggle setting is true. A content script is injected into all frames.
- The
content_script.jschecks thetogglestate. - If true, it creates a hidden
iframepointing topages/iframe.html. - It posts a message to this iframe containing the page's URL.
- The script
exp.jsinsideiframe.htmlreceives the message and proceeds to create more iframes (or windows, if in "Window Mode") with prototype pollution payloads in the URL search parameters or hash. - Another part of
content_script.jsinjects a script directly into the page to check ifObject.prototypehas been polluted (e.g.,Object.prototype.e32a5ec9c99). - If pollution is detected, a
PPLogcustom event is dispatched. - The content script listens for this event and sends a message to the
background.jsscript, which records the finding.
The sequence diagram below details the communication flow for active scanning.
This diagram shows the process of active vulnerability detection.
Sources: scripts/content_script.js:31-107, scripts/exp.js:59-90, scripts/background.js:9-13
Passive Scan Flow
Passive scanning is enabled if the passive setting is true. It works by inspecting network requests for scripts.
- On startup, if
passiveis true,background.jscallsupdateDB(). updateDB()inutils.jsdownloads a pattern database from/database.csv.- Once the database is loaded, a listener is attached to
chrome.webRequest.onCompletedfor all requests of typescript. - When a script finishes loading, the
scanfunction is triggered. scandownloads the script content and passes it topatternMatch.patternMatchiterates through the database patterns (regex or text) and checks for a match in the script content.- If a match is found, the finding is added to the
foundset inbackground.jsand the badge count is updated.
The flowchart below outlines the passive scan logic.
This flowchart shows the workflow for the passive scanning feature.
Sources: scripts/background.js:64-66, scripts/utils.js:10-141
Gadget Brute-forcing
The "Brute Gadgets" feature (Search and Hash buttons) allows for manual testing of known post-pollution gadgets.
- Clicking "Search" or "Hash" in the popup dispatches a
TriggerBruteorTriggerBruteHashcustom event on the active page. content_script.jslistens for these events and creates a hiddeniframe(pages/iframe.html).- It posts a message to the iframe, specifying the URL and the type (
searchorhash). exp.jsin the iframe receives the message and iterates through a predefined list ofGADGETS.- For each gadget, it creates a new iframe, appending the gadget payload to the target URL's search parameters or hash, respectively.
Sources: scripts/popup.js:50-59, scripts/content_script.js:1-30, scripts/exp.js:42-58
Interpreting Results
Detected vulnerabilities are displayed in the extension popup and indicated by a number on the extension icon.
- Badge Count: The number on the icon represents the total number of unique vulnerabilities found. This is updated by
setBadgeCount. A count of 0 means nothing has been found.
Sources: scripts/utils.js:143-148, scripts/background.js:6 - Results Table: The popup displays a table with the following columns:
host: The domain where the vulnerability was found.type: The type of scan that found it ('Active Mode' or a pattern name from the passive scan).location: The specific file and line/column number of the vulnerable code (for passive scans) or the URL that triggered the pollution (for active scans).
If the table is empty, it means no vulnerabilities have been detected. You can clear all findings by clicking the "Clear" link in the popup.
Sources: pages/popup.html:78-86, scripts/popup.js:84-93