Skip to content

Preserve handler setPrototypeOf traps on scriptlet proxies - #69

Open
philipp-classen wants to merge 1 commit into
proxy-cycle-fixfrom
preserve_handler_setPrototypeOf_traps
Open

philipp-classen wants to merge 1 commit into
proxy-cycle-fixfrom
preserve_handler_setPrototypeOf_traps

Conversation

@philipp-classen

@philipp-classen philipp-classen commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

The first commit did not override a handler's own setPrototypeOf trap. The second commit lost that: its cycle check replaced the trap. This commit makes the trap work again.

The cycle check runs first, then the wrapper calls the handler's trap. Page scripts cannot interfere with that call.


Otherwise, something like this would have worked:

self.fetch = new Proxy(self.fetch, {
  apply(target, thisArg, args) { /* filter requests */ },
  setPrototypeOf() { return false; }, // nobody may re-prototype our fetch
});

A page script trying to overwrite the prototype:

Object.setPrototypeOf(fetch, { evil: true });

Without it, the page's version would have won, not the scriptlet's version.


For clarification: this intends to close a hole that we did not have in the beginning (on the current main branch), but would get introduce by the second commit of #67 in 026a6e8

It is not actively exploited in the wild, because the production version is not affected.

@chrmod chrmod left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this going to be used? I couldn't find any scriptlet that sets its own setPrototypeOf trap, so I'm not sure what this change is for.

Ignore - I got it wrong.

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