Understanding Scan Results
Relevant source files
The following files were used as context for generating this wiki page:The PPScan extension is designed to detect client-side prototype pollution vulnerabilities. It operates in two primary modes: a passive mode that scans scripts for known vulnerable patterns, and an active mode that injects payloads to confirm vulnerabilities. The results from these scans are collected, stored, and displayed to the user through the extension's popup interface and a browser action badge.
Understanding how these results are generated, what they mean, and how they are presented is key to effectively using PPScan. This document details the entire lifecycle of a scan result, from detection to display.
How Results Are Generated
Scan results originate from two distinct scanning mechanisms: Passive Scanning and Active Scanning. A third mechanism, Gadget Brute-forcing, is a manually triggered form of active scanning.
Passive Mode Scanning
In passive mode, the extension listens for completed script requests and scans their content for patterns matching a database of known vulnerabilities.
This diagram illustrates the passive scanning flow.
Initiation*: If "Passive Mode" is enabled, background.js calls updateDB() from utils.js.
- Database:
updateDB()fetches a list of vulnerability patterns fromdatabase.csvand populates an in-memorydatabasearray. - Listener: Once the database is ready, a listener
chrome.webRequest.onCompletedis attached to intercept all completed script requests. - Scanning: For each script, the
scanfunction inutils.jsdownloads its content and usespatternMatchto check for matches against the loaded database patterns. - Logging: If a match is found, a result object is created and added to the
foundset inbackground.js. The browser action badge is then updated.
Sources: scripts/background.js:50-52, scripts/utils.js:63-91, 98-103
Active Mode Scanning
When "Active Mode" is enabled, the extension injects a content script into every page. This script attempts to pollute the Object.prototype by manipulating the URL and creating iframes.
This diagram shows the sequence for an active scan.
- Injection:
content_script.jsis injected into the main page. - Orchestration: It creates a hidden iframe (
/pages/iframe.html) and sends it a message (foo: "bar"). - Payload Injection: The iframe's script,
exp.js, receives this message and iterates through a list ofPAYLOADS. For each payload, it creates another iframe, setting its source URL to the original page's URL but with the prototype pollution payload appended as a query parameter or a hash fragment. - Detection: The
content_script.jsrunning inside this new, polluted iframe periodically checks ifObject.prototypehas been modified (e.g.,Object.prototype.e32a5ec9c99 == "ddcb362f1d60"). - Logging: If pollution is detected, the script dispatches a
PPLogevent, which is caught and sent as a message tobackground.js. Thebackground.jsscript then adds an entry to thefoundset with the type "Active Mode".
Sources: scripts/content_script.js:84-97, 100-103, scripts/exp.js:46-64, scripts/background.js:8-12
Gadget Brute-forcing
From the popup, a user can manually trigger a brute-force scan for known gadgets. This is a targeted form of active scanning.
- Trigger: The user clicks the "Search" or "Hash" button in the popup UI.
- Event Dispatch:
popup.jsexecutes a script in the active tab to dispatch aTriggerBruteorTriggerBruteHashcustom event. - Handling:
content_script.jslistens for these events. It creates a hidden iframe (/pages/iframe.html) and posts a message (foo: 'baz') containing the current page URL and the type (searchorhash). - Gadget Testing:
exp.jsin the iframe receives the message and iterates through theGADGETSarray. It creates a new iframe for each gadget, appending it to the URL's search parameters or hash. - Result: The results of this brute-force attempt are not automatically logged to the
foundlist. Instead, they are logged to the browser's developer console, and successful exploitation typically triggers thedebuggerstatement.
Sources: scripts/popup.js:58-67, scripts/content_script.js:1-24, scripts/exp.js:38-55
Storing and Managing Results
All confirmed findings from Active and Passive scans are stored centrally in the background script.
Result Storage
A Set named found in background.js serves as the in-memory database for all detected vulnerabilities during a browser session. Using a Set prevents duplicate entries.
// scripts/background.js:4
const found = new Set();
Sources: scripts/background.js:4
The results can be cleared by clicking the "Clear" link in the popup, which sends a clearLog message to the background script, calling found.clear().
Sources: scripts/popup.js:69-71, scripts/background.js:17-20
Result Data Structure
Each item added to the found set is a JSON string representing a vulnerability. The object has a consistent structure:
| Field | Type | Description | Example |
|---|---|---|---|
domain | String | The origin of the page where the vulnerability was found. | https://example.com |
type | String | The type of finding. "Active Mode" for active scans, or the library name (e.g., "jQuery") for passive scans. | Active Mode or jQuery 1.12.4 |
file | String | The full URL of the resource (page or script) where the vulnerability was detected. | https://example.com/vuln.js |
lineCol | String | The line and column number in the file for passive findings. 0 for active findings. | 25:10 |
Sources: scripts/background.js:9, scripts/utils.js:88, scripts/popup.js:84-86
Displaying Scan Results
The extension provides two primary ways to view scan results: the browser action badge and the popup UI.
This flowchart shows how results are processed for display.
Browser Action Badge
The number displayed on the extension's icon indicates the total count of unique vulnerabilities found. The setBadgeCount function is called every time a new vulnerability is added to the found set. The badge color is red if findings exist and transparent otherwise.
// scripts/utils.js:105-110
const setBadgeCount = (len) => {
chrome.browserAction.setBadgeText({ "text": '' + len });
chrome.browserAction.setBadgeBackgroundColor({ color: len > 0 ? [255, 0, 0, 255] : [0, 0, 255, 0] });
return;
};
Sources: scripts/utils.js:105-110, scripts/background.js:11
Popup Interface
The main interface for viewing detailed results is the popup window, defined in pages/popup.html.
- Requesting Data: When the popup is opened,
popup.jssends a message tobackground.jsrequesting the list of found URLs. - Displaying Data: The background script responds with the contents of the
foundset. ThelistFoundfunction inpopup.jsthen iterates through the results, parses the JSON strings, and dynamically creates and appends table rows to thefound-listtable in the popup's HTML.
The table displays the host, type, and location of each finding, with links to the relevant domain and file.
// scripts/popup.js:81-88
function listFound(found) {
// ...
found.forEach((str) => {
const line = JSON.parse(str)
const tr = document.createElement("tr");
tr.innerHTML = `<td><a target="_blank" href="${line['domain']}">${new URL(line['domain']).hostname}</a></td><td>${line['type']}</td><td><a target="_blank" href="${line['file']}">${line['file']}:${line['lineCol']}</a></td>`;
foundList.appendChild(tr);
});
}
Sources: pages/popup.html:84-91, scripts/popup.js:75-77, 81-88