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

Possible exploit: auto-clicking webapp #6

Closed
vintprox opened this issue Dec 13, 2022 · 7 comments
Closed

Possible exploit: auto-clicking webapp #6

vintprox opened this issue Dec 13, 2022 · 7 comments
Labels
Added enhancement New feature or request

Comments

@vintprox
Copy link

There is a probability of edge case where Mastodon web application might be exploited by some instance admin (or fork by association) to automatically click "boost", "favourite", "follow", etc., which can go undetected for enough time.

To recap, web application will be able to do malicious actions on behalf of the extension's user (there is few that it can do, but still significant). Already seeing a potential for dispatchEvent there.

I don't yet know how to warrant solid safety from this exploit, here are just some options I considered:

  • place a warning in extension's menu;
  • make up a list of possible violators as a blacklist (which is not really an option, given the little age of window for exploit);
  • intercept such clicks, but somehow detect whether they were really done by hand (should find a way that can't be reproduced by a script) - if action is not made by user interation, simply don't mirror it to original instance.
@Lartsch
Copy link
Owner

Lartsch commented Dec 13, 2022

Hi, not sure if I fully understood what you mean. Can you give an example of what an instance admin could to to abuse this?

The API token which is used for the POST requests should not be accessible by the web application.

@vintprox
Copy link
Author

Can you give an example of what an instance admin could to to abuse this?

Given they own what they run, they can insert JavaScript that would trigger click event on "boost", "favorite", "follow" and other buttons for any posts of their choice. That's the gist of it.

The API token which is used for the POST requests should not be accessible by the web application.

Yes, but it doesn't stop from click emulation via dispatchEvent. It is enough for exploitable bug, because it's handed down to extension. The problem is extension doesn't yet discern what is real user interaction and what is scripted.

@Lartsch
Copy link
Owner

Lartsch commented Dec 13, 2022

Okay, get it now. I will look into it. A trivial way to differentiate between a user initiated click and a script initiated click would be to check for mouse coordinates. But with dispatchEvent, these could he faked as well.

I can think of some other ways, but none of them can guarantee that it's a user click.

So not sure yet how to differentiate reliably. Please create a pull request if you come up with sth.

@Lartsch Lartsch added enhancement New feature or request help wanted Extra attention is needed Looking into it labels Dec 13, 2022
@vintprox
Copy link
Author

Found out that Event.isTrusted is one reliable way to check for genuine user click/press.

Even redefining custom event interface with faked isTrusted = true won't pass the error like Uncaught TypeError: can't redefine non-configurable property "isTrusted".

Doing a PR now 😊👍

@Lartsch
Copy link
Owner

Lartsch commented Dec 19, 2022

Now that's a perfect & simple solution! Did not know about this property yet.

@Lartsch
Copy link
Owner

Lartsch commented Dec 19, 2022

I added the required checks with commit 411dc65

Will be included in the next update.

Cheers!

@Lartsch Lartsch closed this as completed Dec 19, 2022
@vintprox
Copy link
Author

Ah, OK, I was very busy lately anyway, so I appreciate you taking it over, @Lartsch. Good stuff!

@Lartsch Lartsch added Added and removed help wanted Extra attention is needed labels Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Added enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants