# Injected script shares page JS context

Security-product scripts injected into untrusted pages that expose command or UI interfaces to page JavaScript

_Area: Web injection and code execution. Seen in 3 disclosed reports; latest 2019-11-24. Updated 2026-11-07._

## How it works
A security product (AV web protection, password manager) needs to run code inside web pages, so it injects its own script or UI into the page. The broken assumption is that this injected code runs in a trusted space. In practice it shares the page's JavaScript context: the same globals, the same built-in prototypes, the same DOM. Any script the page loads can therefore observe, hook, or call the injected code's internals. The vendor's protections (hiding the script address, pre-injecting before page scripts, hardening a few globals) only raise the cost; they do not create a boundary.

## Where it shows up
- A product injects a script into pages as a fallback when no browser extension is installed [E1](https://bugbountylibrary.com/r/h1%3A470544.md).
- An add-on's injected script executes in page context, with only selected globals (e.g. WebSocket) protected [E2](https://bugbountylibrary.com/r/h1%3A470547.md).
- Injected code calls standard built-ins (String.indexOf, Array/JSON methods) that the page can replace [E2](https://bugbountylibrary.com/r/h1%3A470547.md).
- Autofill or other UI is rendered directly into untrusted pages without shadow DOM or iframe isolation [E3](https://bugbountylibrary.com/r/h1%3A430854.md).
- Injected code exposes a command interface or namespace reachable from page script [E1](https://bugbountylibrary.com/r/h1%3A470544.md)[E2](https://bugbountylibrary.com/r/h1%3A470547.md).

## How to review
Identify every place the product puts code or UI into a page the product does not control. The invariant: no page-reachable reference may lead to privileged operations, and no privileged value may be readable by page script. Check concretely:
- Can the page obtain a reference to the injected script or its namespace (re-fetching the script, hooking built-ins it calls, walking globals)? [E1](https://bugbountylibrary.com/r/h1%3A470544.md)[E2](https://bugbountylibrary.com/r/h1%3A470547.md)
- Does the injected code call any built-in the page can override before it captures what it needs? [E2](https://bugbountylibrary.com/r/h1%3A470547.md)
- Is the UI isolated (shadow DOM, iframe, separate context) so page script cannot instrument it or trigger actions like autofill? [E3](https://bugbountylibrary.com/r/h1%3A430854.md)
- Does the command interface authenticate the caller, or does it trust anything running in the page? [E1](https://bugbountylibrary.com/r/h1%3A470544.md)[E2](https://bugbountylibrary.com/r/h1%3A470547.md)
Hardening a handful of globals is not the property; the property is that nothing page-reachable reaches privileged code or data.

## How finders spotted it
- Noted the product falls back to injecting a script when no extension is present, then reasoned the address-hiding and pre-injection defenses could be defeated by having the page re-download itself and by swapping stored object references before re-running the script [E1](https://bugbountylibrary.com/r/h1%3A470544.md).
- After a prior report showed re-injection, checked which globals were hardened (WebSocket) versus not, and hypothesized that hooking a built-in like String.indexOf would leak the injected namespace [E2](https://bugbountylibrary.com/r/h1%3A470547.md).
- Observed the extension injects its UI into untrusted pages with no protections, and hypothesized page scripts could instrument that UI to trigger autofill and read the values [E3](https://bugbountylibrary.com/r/h1%3A430854.md).

## Variants seen
- Script injection fallback with a command interface exposed to pages [E1](https://bugbountylibrary.com/r/h1%3A470544.md).
- Browser add-on sharing page context, leaking its namespace through hookable built-ins [E2](https://bugbountylibrary.com/r/h1%3A470547.md).
- In-page autofill UI with no isolation, scriptable to read stored data [E3](https://bugbountylibrary.com/r/h1%3A430854.md).

## Impact and severity
Sites could disable protections (Anti-Banner, Private Browsing) and reach the product's command interface; bugs in that internal processing could become code execution at SYSTEM privilege [E1](https://bugbountylibrary.com/r/h1%3A470544.md)[E2](https://bugbountylibrary.com/r/h1%3A470547.md). The password manager variant let any website read stored addresses and deanonymize users [E3](https://bugbountylibrary.com/r/h1%3A430854.md). Severity is raised by how far the exposed interface reaches into privileged native code and by whether user data is readable, not just actions triggerable.

## Evidence
- E1: https://bugbountylibrary.com/r/h1%3A470544.md
- E2: https://bugbountylibrary.com/r/h1%3A470547.md
- E3: https://bugbountylibrary.com/r/h1%3A430854.md
