Options Page (options.html)
Relevant source files
The following files were used as context for generating this wiki page:The options.html file is the designated options page for the PPScan browser extension, as declared in the manifest.json file. While the HTML file itself is a minimal placeholder that only loads a script, the extension's options system is a distributed feature. The user-facing controls are located in the extension's popup (popup.html), state is managed via chrome.storage.sync, and the behavior of background and content scripts is altered based on the stored option values.
The primary function of the options system is to control the various scanning modes of the extension: Active Mode, Passive Mode, and a special "Window Mode" for handling frame-busting sites.
Sources: manifest.json:5, pages/options.html
Options Configuration and Management
The extension's settings are not managed within options.html but are controlled from the browser action popup and persisted in chrome.storage.sync. This allows different parts of the extension to react dynamically to user-configured settings.
Sources: scripts/popup.js, scripts/background.js
User Interface (popup.html)
The user interacts with the extension's settings through a series of buttons in the popup window. These buttons do not lead to the options.html page but instead directly toggle the state of features by communicating with popup.js.
| ID | Button Value | Purpose |
|---|---|---|
toggle | Disable Active Mode / Enable Active Mode | Toggles the active prototype pollution scanning feature. |
buster | Disable Window Mode / Enable Window Mode | Toggles a special mode for active scanning to handle frame-busting. Only visible when Active Mode is enabled. |
passive | Disable Passive Mode / Enable Passive Mode | Toggles the passive scanning feature which checks for vulnerable libraries. |
Sources: pages/popup.html:49-60, scripts/popup.js:24-26
State Management (popup.js)
The popup.js script is responsible for handling user interactions within the popup. It attaches onclick event listeners to the buttons and uses the chrome.storage.sync API to get and set the boolean values for toggle (Active Mode), buster (Window Mode), and passive (Passive Mode).
The following diagram illustrates the flow of updating an option when a user clicks a button in the popup.
Sources: scripts/popup.js:18-53
Core Options and Their Functionality
The extension's behavior is primarily driven by three configuration flags stored in chrome.storage.sync.
| Storage Key | UI Control | Default Value | Description |
|---|---|---|---|
toggle | toggle button | false | Enables/disables Active Mode scanning. |
buster | buster button | false | Enables/disables Window Mode for frame-busting, a sub-option of Active Mode. |
passive | passive button | true | Enables/disables Passive Mode scanning for vulnerable script patterns. |
Sources: scripts/background.js:29-37, scripts/popup.js:18-53
toggle (Active Mode)
When toggle is set to true, the extension actively attempts to find prototype pollution vulnerabilities by injecting payloads. This setting has two main effects:
- Content Script Injection: The
content_script.jschecks this flag. If true, it injects logic into the web page to test for vulnerabilities by manipulating the URL and checkingObject.prototype. - Header Modification: The
background.jsscript modifiesContent-Security-PolicyandX-Frame-Optionsheaders on-the-fly to facilitate testing within iframes.
The diagram below shows the logic flow based on the toggle option.
buster (Window Mode)
The buster flag is a sub-option for Active Mode, intended for sites that use frame-busting techniques. When both toggle and buster are true, the payload testing script (exp.js) will open a new window (window.open) to conduct its tests, rather than using an iframe.
Sources: scripts/popup.js:24-26, scripts/exp.js:63-75
passive (Passive Mode)
When passive is true, the background script enables a listener that passively scans JavaScript files. It downloads each script, matches its content against a database of known vulnerable patterns (database.csv), and reports any findings.
Initialization and Default Values
Upon first installation, the extension sets default values for all options using the chrome.runtime.onInstalled event listener in the background script. This ensures a consistent starting state for all users.
// scripts/background.js:29-37
chrome.runtime.onInstalled.addListener(() => {
chrome.storage.sync.set({ toggle: false }, () => {
console.log('[*] Toggle: disabled');
});
chrome.storage.sync.set({ buster: false }, () => {
console.log('[*] Buster: disabled');
});
chrome.storage.sync.set({ passive: true }, () => {
console.log('[*] Passive: enabled');
});
});
The default configuration disables Active Mode (toggle: false, buster: false) and enables Passive Mode (passive: true).
Sources: scripts/background.js:29-37