Using the Popup Interface
Relevant source files
The following files were used as context for generating this wiki page:The popup interface, defined in pages/popup.html, serves as the primary control panel for the PPScan browser extension. It allows users to manage scanning modes, initiate manual prototype pollution gadget searches, and view any vulnerabilities discovered. The interface logic is handled by scripts/popup.js, which communicates with the background and content scripts to control the extension's behavior and display results.
The manifest.json file designates pages/popup.html as the browser_action default popup, making it the main user-facing component of the extension.
Sources: pages/popup.html, scripts/popup.js, manifest.json:28-30
UI Components and Layout
The popup UI consists of several buttons for controlling the scanner's state and a table for displaying found vulnerabilities.
Sources: pages/popup.html:85-110
| Element ID | Type | Label/Value | Description |
|---|---|---|---|
toggle | button | Enable/Disable Active Mode | Toggles the active scanning mode on and off. |
buster | button | Enable/Disable Window Mode | Toggles a special "Window Mode" for active scanning, useful for sites with frame busting. Appears only when Active Mode is on. |
passive | button | Enable/Disable Passive Mode | Toggles the passive scanning mode on and off. |
brute | button | Search | Initiates a brute-force search for gadgets using URL search parameters on the current page. |
brutehash | button | Hash | Initiates a brute-force search for gadgets using the URL hash on the current page. |
clear | anchor | Clear | Clears the list of found vulnerabilities. |
found-list | table | N/A | A table that is dynamically populated with discovered vulnerabilities. It is hidden by default. |
Sources: pages/popup.html:90-104, scripts/popup.js:15-20, 34-38, 49-53, 65-69, 71-75, 77-79
Mode Management
The popup provides controls for three distinct modes, whose states are persisted in chrome.storage.sync. The logger function in popup.js initializes the button states and sets up onclick handlers to toggle these modes.
Sources: scripts/popup.js:5-63
Mode Toggling Flow
The following diagram illustrates how a user action in the popup changes a mode's state.
This diagram shows the user interaction with a mode button, which triggers popup.js to update the state in chrome.storage. Other extension scripts, like background.js, read this stored value to enable or disable features accordingly.
Sources: scripts/popup.js:21-32, scripts/background.js:68-71, scripts/content_script.js:30-31
Scanning Modes
| Mode | Storage Key | Default State | Description - | ----------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Active Mode | toggle | false | When enabled, injects scanning logic into web pages to actively look for prototype pollution vulnerabilities. This mode also modifies CSP and X-Frame-Options headers to facilitate scanning. - |
| Window Mode | buster | false | A sub-mode of Active Mode. When enabled, it opens a new window for scanning instead of an iframe. This is useful for applications that employ frame-busting techniques. - |
| Passive Mode | passive | true | When enabled, the extension passively scans loaded scripts for patterns that might indicate vulnerable code, without actively injecting payloads. - |
Sources: scripts/popup.js:21-63, scripts/background.js:53-67, 78-80, scripts/content_script.js:30-32
Manual Gadget Brute-Forcing
The "Brute Gadgets" section allows the user to manually trigger a search for vulnerable library gadgets on the current page. This is done by injecting a series of payloads defined in scripts/exp.js.
Sources: pages/popup.html:101-104, scripts/popup.js:65-75
Brute-Force Flow
Clicking "Search" (brute) or "Hash" (brutehash) initiates a process that dispatches a custom event on the active page. A content script listens for this event and creates a hidden iframe to run the test payloads.
This diagram shows the flow from the user's click in the popup to the execution of gadget payloads in exp.js within the context of the active tab.
Sources: scripts/popup.js:65-75, scripts/content_script.js:1-29, pages/iframe.html:10, scripts/exp.js:34-62
The brute button triggers the TriggerBrute event, which causes exp.js to inject payloads into the URL's search parameters. The brutehash button triggers TriggerBruteHash, which injects them into the URL's hash.
Sources: scripts/popup.js:65-75, scripts/content_script.js:1-29, scripts/exp.js:39-45, 48-54
Viewing and Clearing Results
The popup is responsible for displaying vulnerabilities found by the scanner and providing a way to clear them.
Data Flow for Displaying Results
When the popup opens, it establishes a connection with the background script to fetch the list of found vulnerabilities.
This sequence shows how popup.js requests data from background.js, which maintains the state of found items, and then uses that data to populate the UI.
Sources: scripts/popup.js:1-3, 81-87, 92-101, scripts/background.js:15-25
Clearing Results
The "Clear" link sends a clearLog message to the background script via the established port connection. The background script then clears its internal found set and resets the badge count to zero.
Sources: scripts/popup.js:77-79, scripts/background.js:18-21
Result Rendering
The listFound function in popup.js is responsible for rendering the results. For each found item, it creates a new table row (<tr>) and populates it with the hostname, vulnerability type, and the location (file and line/column). The table is only made visible if there is at least one result.