Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent malicious pages from tampering with element picker #3497

Closed
taviso opened this issue Feb 9, 2018 · 4 comments
Closed

Prevent malicious pages from tampering with element picker #3497

taviso opened this issue Feb 9, 2018 · 4 comments

Comments

@taviso
Copy link

taviso commented Feb 9, 2018

Describe the issue

The element picker works by creating an about:blank iframe in the page to display the dialog. Because the same origin policy does not prevent the page from editing the form fields, it can inject malicious rules like ||*.com or whatever.

It's not the end of the world, but if the frame were a web_accessible_resource page instead, the same origin policy would protect it from tampering by the page. That would minimize the damage possible by a malicious page, at worst they would be able to stop you using the picker on their domain.

I don't think a page can trigger the element picker themselves, they have to wait for the user to do it. Untrusted click events are dropped, but that's not that important, a page could add their own handler to modify the contents on a trusted click, or just rearrange and hide elements so that clicking anywhere on the screen triggers the event.

Steps for anyone to reproduce the issue

  1. Start the element picker.
  2. Do something like
document.querySelector("iframe").contentWindow.document.querySelector("textarea").value = "||*.com";
// Do something like this to make it impossible not to click
create = document.querySelector("iframe").contentWindow.document.querySelector("[id=create]"); 
create.parentElement.removeChild(create);
document.body.appendChild(create);
create.style.cssText = "position: fixed; top: 0; left: 0; height: 100%; width: 100%"

Your settings

  • Linux
  • Chrome64
@Thorin-Oakenpants
Copy link

Injecting web accessible resources could?/does? lead to leaking your UUID 1372288

@taviso
Copy link
Author

taviso commented Feb 10, 2018

I don't see how, the location of the frame wouldn't be accessible. I think in that bug they're discussing an extension that injects a <link rel=stylesheet> tag, and then they're pointing out that would be accessible via document.styleSheets.

That wouldn't apply to this case.

@MNGrrrl
Copy link

MNGrrrl commented Feb 22, 2018

[Off-topic comment collapsed -- gorhill] **Partial workaround** I've encountered this in the wild several times. It's part of anti-adblock some adblock solutions and others have been incorporating it into their own apps.

I've only seen the element blocker getting disabled via javascript f***ery. The logger still works fine on these sites.. Find everything of connection type 'script', as well as any 'xhtmlrequest' or 'other' which have a .js filename. I haven't run into servers that hide them any better than that. Find the script causing the problems, and then nuke it from within the logger.

Once the script is identified and blocked there should be no further problems with the element picker. If you want to submit your rule for inclusion in a list, hunt down what elements the script attaches to and block those if possible.

This doesn't fix the vulnerability, it just restores uBlock Origin's ability to block

Repository owner locked and limited conversation to collaborators Feb 22, 2018
@gorhill
Copy link
Owner

gorhill commented Sep 1, 2020

Fixed with 9eb455a.

Repository owner unlocked this conversation Sep 1, 2020
pull bot pushed a commit to netorica/uBlock that referenced this issue Sep 1, 2020
Related issues:
- gorhill#3497
- uBlockOrigin/uBlock-issues#1215

To solve above issues, the element picker's dialog is now
isolated from the page content in which it is embedded.

The highly interactive, mouse-driven part of the element
picker is still visible by the page content.
@gorhill gorhill closed this as completed Sep 7, 2020
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

No branches or pull requests

4 participants