# Your agent's borrowed Chrome profile lets other extensions write into the page it reads

> Driving a user's real Chrome profile keeps logins but also injects every installed extension's DOM into what the agent reads. A five-minute check for it.

- Author: Chad Priest
- Published: 2026-10-11
- Canonical URL: https://blog.awe.run/your-agents-borrowed-chrome-profile-lets-other-extensions-write-into-the-page-it-reads/
- Tags: ai, chrome, security, agents

---

My browser agent drives the user's real Chrome profile, so a reservation site recognizes them and doesn't ask for a login. I thought of the profile as a bag of cookies, and I was wrong. It holds cookies plus every extension the person ever installed, and any of those extensions that matches a page can run content scripts in it and add nodes to it. [browser-bridge](https://github.com/vitalysim/browser-bridge) states the trade plainly: "No fresh profile. No re-login." Everything in that profile comes along. The general failure: **when an agent borrows a human's browser for its sessions, it also borrows that human's extensions, and whatever they write into a page becomes part of what the agent perceives.**

## Another extension's frame cost me the debugger, not just the text

The first sign wasn't polluted text. It was losing control of the tab. My agent ran as a Chrome extension and drove tabs through the `chrome.debugger` extension API. On a booking page, debugger calls started failing with `Cannot access a chrome-extension:// URL of different extension`. Some unrelated extension had put its own `chrome-extension://` iframe into the page, and `chrome.debugger` refuses to work on a tab that contains another extension's frame. That was enough to cut off the agent's hands mid-task. I didn't write down the Chrome version, and I didn't count how many runs it broke, so I won't give you either.

This is a restriction in the extension API. If you drive Chrome over `--remote-debugging-port` with the raw DevTools Protocol, the way the script below does, you won't see this error. You'll still get the polluted page, though.

That's the second problem, and so far it's a hypothesis, not a finding. Once I looked, coupon popovers, password-manager badges and grammar overlays sat in the DOM next to the site's own content, and nothing in my pipeline told the model which nodes the site wrote. I haven't caught an extension's text steering an agent step. I also didn't record how many extensions that profile had or how many nodes they added, and I'm not going to reconstruct numbers after the fact. The probe below prints those numbers for your profile.

## Isolated worlds protect the page, not the agent

[SuperSurf](https://liquidbuiltit.github.io/Supersurf/) reads the DOM from Chrome's isolated world so "page JS never sees the automation," but isolated worlds only split the JavaScript heaps. Every extension shares the same DOM, so their nodes land in the tree your agent reads.

## Check for execution contexts you didn't create

The invariant: **no execution context you didn't create touches the page your agent serializes.** Session state is allowed to differ. Nothing else is.

The direct test is to ask Chrome which contexts and frames exist on the page. Every content script runs in an isolated execution context whose origin is `chrome-extension://<id>`, and every injected extension iframe shows up in the frame tree. As a second check, the script does a set-diff of the DOM against a clean Chrome profile, walking open shadow roots, with the noise floor measured by loading the clean profile twice.

Setup:

- Pick a **public** page your agent visits, because the clean profile is logged out.
- Since Chrome 136, `--remote-debugging-port` is ignored on the default user data directory. If your agent uses the default profile, quit Chrome, copy the profile directory somewhere else and launch the **same Chrome binary** against the copy. The extensions come with the copy.
- The clean run uses the same installed Chrome (`channel="chrome"`, headed), not Playwright's headless shell. The headless shell has a different user agent and runs into bot walls more often, which would put a second variable into the comparison.

```python
# pip install playwright   (uses your installed Google Chrome)
# "/path/to/Google Chrome" --user-data-dir=/tmp/agent-profile-copy --remote-debugging-port=9222
# python probe.py https://some-public-page-your-agent-visits
import asyncio, sys
from collections import Counter
from playwright.async_api import async_playwright

URL = sys.argv[1]
SIGS = r"""() => { const out = [];
  const walk = root => { for (const e of root.querySelectorAll('*')) {
    const cls = typeof e.className === 'string'
      ? e.className.trim().split(/\s+/).filter(Boolean).sort().join('.') : '';
    out.push(e.tagName.toLowerCase() + (e.id ? '#' + e.id : '') + (cls ? '.' + cls : ''));
    if (e.shadowRoot) walk(e.shadowRoot);       // open shadow roots only
  } };
  walk(document); return out; }"""

async def visit(context):
    page = await context.new_page()
    cdp = await context.new_cdp_session(page)
    foreign = set()
    def on_ctx(ev):
        c = ev["context"]
        if c["origin"].startswith("chrome-extension://"):
            foreign.add(f'{c["origin"]} {c.get("name", "")}')
    cdp.on("Runtime.executionContextCreated", on_ctx)
    await cdp.send("Runtime.enable")
    await page.goto(URL, wait_until="load")
    await page.wait_for_timeout(5000)           # content scripts and overlays arrive late
    frames = set()
    def walk(node):
        if node["frame"]["url"].startswith("chrome-extension://"):
            frames.add(node["frame"]["url"])
        for child in node.get("childFrames", []):
            walk(child)
    walk((await cdp.send("Page.getFrameTree"))["frameTree"])
    frames |= {f.url for f in page.frames if f.url.startswith("chrome-extension://")}
    sigs = Counter(await page.evaluate(SIGS))
    await page.close()
    return sorted(foreign), sorted(frames), sigs

async def main():
    async with async_playwright() as p:
        agent = await p.chromium.connect_over_cdp("http://localhost:9222")
        a_ctx, a_frames, a_sigs = await visit(agent.contexts[0])
        clean = await p.chromium.launch(channel="chrome", headless=False)  # temp profile, extensions off
        _, _, c1 = await visit(await clean.new_context())
        _, _, c2 = await visit(await clean.new_context())
        noise = sum(((c1 - c2) + (c2 - c1)).values())
        extra = a_sigs - (c1 | c2)
        print("foreign execution contexts:", a_ctx or "none")
        print("extension frames:", a_frames or "none")
        print(f"noise floor, clean vs clean: {noise} elements")
        print(f"elements only in the agent's page: {sum(extra.values())}")
        for sig, n in extra.most_common(20):
            print(f"  {n:4}  {sig}")
        ok = not a_ctx and not a_frames and sum(extra.values()) <= noise
        print("PASS" if ok else "FAIL")
        await clean.close()

asyncio.run(main())
```

The pass rule is strict on purpose. Any `chrome-extension://` execution context or frame is a FAIL, because something you didn't install is running in the page. The DOM diff fails when the agent's page has more unexplained elements than two clean loads differ from each other. Ad slots, A/B tests and timestamps produce that noise, and the second clean load is there to measure it. Read the listed signatures before you trust a FAIL from the diff alone: an account menu that appears because you're logged in is session state, which is allowed. A `grammarly-desktop-integration` or a coupon tool's host element is not.

The two checks cover for each other. Content scripts often add custom elements with no `chrome-extension://` URL anywhere, which an attribute search misses and the set-diff catches. Closed shadow roots are invisible to the set-diff, but the script that built them still shows up as a foreign execution context.

Switching your agent from DOM to accessibility-tree snapshots doesn't get you out of this. The accessibility tree is built from what renders, and that includes extension overlays and the contents of closed shadow roots.

## A dedicated profile with an extension allowlist, logged in once by hand

I now give the agent its own `--user-data-dir` with zero extensions, and the person logs into the sites it needs one time in that profile. That also keeps you clear of the Chrome 136 default-profile restriction. If your agent is itself an extension, you need everything except yours turned off. `--disable-extensions-except=<path>` exists for that, but recent branded Chrome builds have been removing command-line extension loading, so test it on your version before relying on it. The approach that holds up is policy: `ExtensionInstallBlocklist` set to `["*"]` with your agent's ID in `ExtensionInstallAllowlist`. Policy applies to the whole Chrome install, not one profile, so this belongs on a machine or Chrome channel set aside for the agent.

This fixes what the agent perceives, not its secrets. The profile's tokens are still readable by anything running as the same OS user, and that needs its own fix. Either way, the rule carries over to any stack: run the probe, and if a context you didn't create shows up in the page your agent reads, treat that page as untrusted input.

---

Source: [Your agent's borrowed Chrome profile lets other extensions write into the page it reads](https://blog.awe.run/your-agents-borrowed-chrome-profile-lets-other-extensions-write-into-the-page-it-reads/) by Chad Priest, from Building awe in Public.
