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

Security: Smuggle arbitrary CSS inside cosmetic uBlock filters #1806

Closed
8 tasks done
hackvertor opened this issue Nov 8, 2021 · 6 comments
Closed
8 tasks done

Security: Smuggle arbitrary CSS inside cosmetic uBlock filters #1806

hackvertor opened this issue Nov 8, 2021 · 6 comments
Labels
bug Something isn't working fixed issue has been addressed

Comments

@hackvertor
Copy link

Prerequisites

I tried to reproduce the issue when...

  • uBO is the only extension
  • uBO with default lists/settings
  • using a new, unmodified browser profile

Description

uBlock origin allows you to use cosmetic filters to change content on the page. It allows some CSS but disallows making requests such as using background:url(). I've found a way to bypass these restrictions and execute arbitrary CSS:

*#$#* /* { font-family: ' background-color:red;'; }
*#$#* /*/ {background:url(https://hackvertor.co.uk/images/logo.gif)} */ { font-family: ' background-color:red;'; }

A specific URL where the issue occurs

https://portswigger-labs.net/

Steps to Reproduce

  1. Go to my filters and add the following rule:
*#$#* /* { font-family: ' background-color:red;'; }
*#$#* /*/ {background:url(https://hackvertor.co.uk/images/logo.gif)} */ { font-family: ' background-color:red;'; }
  1. Visit https://portswigger-labs.net or any website and you should see that the background image has changed for every element.

Expected behavior

You should not be allowed to make background requests inside cosmetic filters

Actual behavior

The background url request is made.

uBlock Origin version

1.38.7b15

Browser name and version

Chrome 95.0.4638.69

Operating System and version

MacOS 10.15.7

@u-RraaLL
Copy link
Contributor

u-RraaLL commented Nov 8, 2021

No need to make duplicates. If you think #1794 wasn't addressed, you should've followed up in there.

@gorhill
Copy link
Member

gorhill commented Nov 8, 2021

It's fine reporting in a new issue, the issue is in a different code path.

@uBlock-user uBlock-user added the bug Something isn't working label Nov 8, 2021
@gorhill
Copy link
Member

gorhill commented Nov 8, 2021

This is a clever trick, and I learned that querySelector('* /*') does not fail when the selector contains an open-ended comment.

gorhill added a commit to gorhill/uBlock that referenced this issue Nov 8, 2021
@gwarser gwarser added the fixed issue has been addressed label Nov 8, 2021
@gwarser gwarser closed this as completed Nov 8, 2021
@hackvertor
Copy link
Author

@gorhill Wow cool you patched it so quickly. Could be a bypass:

*#$#* {background:url(https://hackvertor.co.uk/images/logo.gif);x{  background-color: red;}

@gorhill gorhill reopened this Nov 8, 2021
@gwarser gwarser removed the fixed issue has been addressed label Nov 8, 2021
@gorhill
Copy link
Member

gorhill commented Nov 8, 2021

Interesting, I didn't expect that this would be parsed as a valid CSS declaration:

* {background:url(https://hackvertor.co.uk/images/logo.gif);x{color:red}

But it is, and I see the browser not failing at parsing the declaration and silently just discarding the x{color:red} part -- and not minding the unmatched {.

gorhill added a commit to gorhill/uBlock that referenced this issue Nov 8, 2021
@gwarser gwarser added the fixed issue has been addressed label Nov 8, 2021
@gwarser gwarser closed this as completed Nov 8, 2021
@gorhill
Copy link
Member

gorhill commented Dec 6, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed issue has been addressed
Projects
None yet
Development

No branches or pull requests

5 participants