Security and Permissions
Relevant source files
The following files were used as context for generating this wiki page:The PPScan extension is designed as a client-side prototype pollution scanner. To achieve this, it requires extensive permissions to interact with and modify web pages and network requests. The security model is centered around the permissions declared in manifest.json, which grant the extension broad access to user data and browser functionality. This access is necessary for its core purpose of injecting test payloads and observing their effects on visited websites.
The extension's architecture involves background scripts for network monitoring, content scripts for page interaction, and web-accessible resources for payload delivery. The security posture is inherently offensive, as it actively probes for vulnerabilities. User-controlled modes ("Active", "Passive", "Window") allow for some management of how and when these potentially disruptive scans are executed.
Manifest Permissions
The foundation of the extension's capabilities is defined by the permissions requested in the manifest.json file. These permissions grant the extension significant control over the browser's behavior and access to sensitive user data.
Sources: manifest.json:8-16
Permission Breakdown
The following table details each permission and its purpose within the PPScan extension.
| Permission | Description |
|---|---|
tabs | Allows the extension to access information about open tabs, which is used to execute scripts in the context of a specific tab. |
storage | Used to store the extension's state, such as whether Active, Passive, or Window modes are enabled. |
<all_urls> | Grants access to all URLs. This is required for injecting content scripts and intercepting web requests on any website the user visits. |
webRequest | Allows the extension to observe and analyze network traffic. Used in "Passive Mode" to scan script files for vulnerable patterns. |
webRequestBlocking | Allows the extension to block or modify network requests in-flight. This is used in "Active Mode" to modify security headers like CSP and X-Frame-Options. |
activeTab | Provides access to the currently active tab in response to a user gesture (e.g., clicking the browser action). |
Sources: manifest.json:9-15, scripts/popup.js:41-43, scripts/background.js:50-52
Web Request Interception
When "Active Mode" is enabled, the extension uses its webRequestBlocking permission to modify incoming HTTP response headers for all navigated pages. This is a powerful feature designed to bypass certain security policies that would otherwise prevent prototype pollution testing.
Sources: scripts/background.js:48-67
Header Modification Logic
The background script registers a listener on onHeadersReceived that performs the following modifications:
- Content-Security-Policy (CSP): It identifies the
Content-Security-Policyheader and overwrites its value to be extremely permissive (default-src * 'unsafe-inline' 'unsafe-eval' data: blob:;). This is done to allow the execution of inline scripts and dynamic code evaluation, which are often necessary for pollution gadgets to trigger. - X-Frame-Options (XFO): It finds the
X-Frame-Optionsheader, which prevents clickjacking by disallowing a page to be framed, and effectively disables it by renaming the header tofoo. This allows the target page to be loaded inside aniframefor testing. - Caching Headers: It neutralizes caching by renaming headers like
If-None-Matchtofoo, forcing the browser to fetch a fresh version of the resource.
The following diagram illustrates this header modification flow.
Content Script and Payload Injection
The extension's primary mechanism for testing is injecting JavaScript into visited pages. This is managed through a combination of content scripts and web-accessible resources.
Injection Flow
- Content Script:
scripts/content_script.jsis injected into all frames on all pages, as defined inmanifest.json. - Mode Check: The script first checks
chrome.storageto see if "Active Mode" (toggle) is enabled. - Iframe Creation: If active, it creates a hidden
iframeon the page. Thesrcof this iframe points topages/iframe.html, which is a resource made accessible to web pages via theweb_accessible_resourcesmanifest key. - Payload Delivery: The content script sends a
postMessageto the iframe, containing the URL of the parent page. - Payload Execution: The script within the iframe (
scripts/exp.js) receives this message and proceeds to inject various prototype pollution payloads and gadgets into the target page by creating more iframes with tainted URLs (query parameters or hash fragments).
Sources: manifest.json:23-30, 32-35, scripts/content_script.js:1-15, 82-95, scripts/exp.js:75-125
The diagram below shows the interaction between the content script and the payload-delivering iframe.
Web Accessible Resources
To facilitate this injection mechanism, the extension must declare which of its own resources can be accessed by web pages. This is a critical security boundary.
"web_accessible_resources": [
"pages/iframe.html",
"scripts/exp.js"
],
pages/iframe.html: The container for the payload injection script.scripts/exp.js: The script containing the list of prototype pollutionPAYLOADSandGADGETSand the logic to apply them.
Exposing these resources is necessary for the extension's function but means that any web page can potentially load them, although their primary logic is triggered via postMessage from the extension's own content script.
Sources: manifest.json:32-35