Skip to content

Fix issues found after v1.1.0: context handshake, isolated iframes, waits across navigation, exposeFunction, drop-in alias - #132

Merged
rebrowsernet merged 5 commits into
mainfrom
fix/issues-2026-10-17
Oct 18, 2026
Merged

rebrowsernet merged 5 commits into
mainfrom
fix/issues-2026-10-17

Conversation

@rebrowsernet

@rebrowsernet rebrowsernet commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes for the bugs found while triaging the open issues against v1.1.0 (puppeteer-core 25.14.0, playwright-core 1.64.1, Python 1.64.0). Every fix has a regression test that fails on the published v1.1.0 packages and passes here.

Patch fixes

Nothing for pages to fingerprint

A detector-style audit compared stock, v1.1.0 and this build in default and alwaysIsolated modes: globals sampled every 5 ms, stack traces taken from page getters, and function sources. It found three things, now fixed:

  • Random-named globals (from v1.1.0 and earlier). The binding handshake left 2–4 native functions with random 10–20 character names on window per page, in iframes too. The default mode now finds a frame's main-world context without running anything in the page:

    • Read document in an isolated world.
    • Resolve that node again without a context, which lands in the frame's main world.
    • Take the context id from the remote object id. Workers evaluate this.

    The old handshake is now only a fallback, with cleanup and a one-time Node-side warning. A new leaks gate (globals) fails on v1.1.0 and passes here.

  • Puppeteer app.js in stack traces. That fixed name was something only this patch uses. By default no sourceURL is added now, so frames are plain <anonymous>.

  • Playwright helper name. It's a random 1–2 letter name per process, plus a random line offset, so there is no fixed name or position.

What remains is page-visible only when you opt into exposeFunction / exposeBinding, which stock libraries already expose: the page-side function includes the wait-for-binding retry.

Drop-in packages (#74)

rebrowser-puppeteer / rebrowser-playwright now depend on rebrowser-*-core under their real names. The npm alias they used before ("puppeteer-core": "npm:rebrowser-puppeteer-core@V") was deduped against upstream puppeteer/playwright of the same version, which silently gave the drop-in the unpatched core. build-packages.mjs rewrites the core's module specifiers in the wrapper code and fails if any remain, if nothing matched, or if a rewritten subpath isn't exported.

Tests

  • scenarios: 7 new cases:

    • waitForSelector-across-navigation
    • iframe-srcdoc
    • page-reassigns-self
    • page-scuttles-self
    • iframe-churn-long-evaluate
    • exposeFunction-called-on-load
    • exposeFunction-after-reload

    Unpatched upstream passes 29/29. Patched default mode is now 29/29 for both libraries; only the documented alwaysIsolated limits stay in the baselines.

  • New leaks suite: library names in stack traces, --enable-automation on the command line, what a page sees of the binding while parsing, and any global appearing on window while the library works. Unpatched builds and builds with the opt-out env var serve as controls.

  • New nonchromium suite (opt-in locally, on in CI): the patched Playwright build must still drive Firefox and WebKit ([feature request] WebKit support #105, [Bug]: _sessions is undefined in lib/server/frames.js:437 - this._page._delegate._sessions #112, How to ignore Patches for Webkit and Firefox? #126).

  • smoke: new alias-collision gate. Each drop-in is installed next to its upstream package and must load the patched core. The published 1.52.0 / 24.8.1 drop-ins fail it.

Docs

README updates:

RELEASING.md now describes the test gates.

No version bump here. These patches target the versions already published (25.14.0 / 1.64.1), so they ship either with the next upstream port or as an X.Y.100 re-release.

…exposeFunction

Patches (puppeteer-core 25.14.0, playwright-core 1.64.1 and the Python driver build):
- Call the handshake binding through `window`, not `self`: gbl.com and yara.com reassign
  `self`, and MetaMask's LavaMoat makes reading it throw, so no context id came back
  (#59, #100, #116; a Playwright regression from 1.52).
- Puppeteer: create contexts lazily for late-attached frames in every patched mode, so
  alwaysIsolated reaches same-origin, srcdoc and hCaptcha iframes (#86); enableDisable
  takes the context of the right frame.
- Puppeteer: re-run pending waitForFunction/waitForSelector after a navigation (#129).
- exposeFunction works in the default mode (#69): re-add the CDP binding when a navigation
  commits, let the page side wait for it, and acquire a main world's context id when a
  binding call arrives before it is known. The page only ever sees the native binding.
- Playwright: rename the UtilityScript binding so Error().stack no longer names it (#106).
- Puppeteer: drop --enable-automation, which shows the automation infobar (#119).

Tests: 7 new scenarios (29 per API family; all pass unpatched, all pass patched in the
default mode), a multi-origin storageState restore (#81), a leaks suite (stack names,
--enable-automation, what a page sees of the binding) and an opt-in nonchromium suite
(Playwright on Firefox/WebKit, #105/#112/#126) that CI now installs and runs.
#74)

With "puppeteer-core": "npm:rebrowser-puppeteer-core@V" in the wrapper, a project that also
has upstream puppeteer@V (or playwright@V) got the alias deduped to the upstream core, and
the drop-in silently ran unpatched code. The wrappers now depend on rebrowser-*-core under
its real name, and build-packages rewrites the core's module specifiers in the wrapper code.
The build fails if a specifier is left (including template literals and concatenations),
if nothing matched, or if a rewritten subpath isn't exported by the core.

The smoke suite gains an alias-collision gate: each drop-in is installed next to its
upstream package and must export the patched core's objects, not upstream's.
…cope

Covers #76 (browsers aren't part of the drop-ins), #74, #69/#86 mode limits,
the UtilityScript and --enable-automation changes, Firefox/WebKit behaviour (#105/#112/#126),
a puppeteer-extra-plugin-stealth caveat (#122) and what the patches do and don't cover (#127).
The binding handshake that found a frame's main-world context left a native function with a
random 10-20 character name on window (in the frame and its same-process iframes, two to four
per page) and an init script per lookup. A page could spot those globals by their shape.

The default mode now reads the frame's `document` in an isolated world, resolves that node
again without a context (which lands in the frame's main world) and takes the context id from
the remote object id; workers evaluate `this` in their only context. Nothing runs in the page.
The binding handshake stays as a fallback for a Chrome that changes the object id format; it
now removes its binding, deletes the global in the context it found and removes its init script.

Playwright: the renamed UtilityScript binding is now a short name picked at random per process
instead of a fixed one, so the stack frames don't carry a name only rebrowser-patches uses.

The leaks suite gains a globals gate: a detector page samples window every 5 ms while the library
evaluates, waits for selectors and reads the DOM (main frame, iframe, across a navigation). It
fails on the published v1.1.0 packages (random-named globals) and passes here.
… position in Playwright

- Puppeteer: by default add no sourceURL to evaluated code, so frames read "<anonymous>" like
  any injected script. The previous default, "app.js", was a fixed name only this patch uses.
  REBROWSER_PATCHES_SOURCE_URL=<name> still sets one; =0 keeps Puppeteer's "pptr:" URLs.
- Playwright: besides the random helper name, shift the utility script down by a random number
  of lines per process, so the frames have no fixed position matching a renamed UtilityScript.
- Both: warn once on the console (Node side) if the context lookup has to fall back to the
  binding handshake, since page scripts can notice that one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants