LWN.net Logo

Greasemonkey gets into trouble

July 27, 2005

This article was contributed by Joe 'Zonker' Brockmeier.

The ability to add extensions to Firefox has proven to be a popular feature. One of the most popular extensions for Firefox, inspiring countless user scripts, is the Greasemonkey extension, which allows users change the behavior of web sites.

A serious vulnerability was found in Greasemonkey last week by Mark Pilgrim, author of the upcoming book "Greasemonkey Hacks," and Dive Into Greasemonkey. Pilgrim discovered that a combination of two flaws in Greasemonkey could allow user data to be transmitted to virtually any site.

We spoke to Pilgrim about the vulnerabilities, and the security of Greasemonkey in general. According to Pilgrim, Greasemonkey's first flaw would allow a web page access to the APIs to call remote pages. A page with an exploit for this vulnerability would allow the exploit to call code from other sites without the user being aware of it. This could include posting data to another site.

The second exploit allowed pages to access file URLs, which could allow a remote site to browse the content of a user's hard drive. In conjunction with the first vulnerability, "remote pages could access any file on your system... [they could] recurse through the entire hard drive and post it anywhere in the world, really. And that's bad."

These vulnerabilities are fixed in the 3.5 version of Greasemonkey, though it is a "neutered" version that lacks the Greasemonkey APIs. Pilgrim said that a beta had been released that should retain functionality and clear up the security holes that he had found.

The new version disables file URLs altogether for that API function, so even user scripts are not allowed to do that anymore, and second of all, closes the hole that allows remote page you're browsing to trap the API call. The pages you browse now no longer have access to any of the Greasemonkey internals. User scripts can still use it... but the page you're browsing can't steal access to those pages.

Even though the vulnerability has been closed in the latest versions of Greasemonkey, Pilgrim said that users could still be vulnerable to malicious user scripts. "Greasemonkey is very powerful, and people need to be aware what they're installing." Indeed, there does seem to be a level of concern that the problems with Greasemonkey are in its features, not its vulnerabilities. The concept of allowing users to run scripts in the browser developed by third parties, who may not have the users' best interests in mind, opens up some scary possibilities.

Since Firefox and Greasemonkey are becoming increasingly popular with less technical users, we asked Pilgrim how those users could verify that the scripts they install were safe, and if there was any way for the Greasemonkey team to protect those users.

Basically, there's no technical solution to that, Greasemonkey allows you so much power, that you can't stop people from writing malicious scripts...without making Greasemonkey useless.

We also asked Chris Hofmann, director of engineering for Mozilla, about the Greasemonkey vulnerability and whether the Mozilla developers could do anything to make extensions safer for users. Hofmann also said that much of the responsibility lies with the user to verify the source and function of extensions. "Users should take caution for any extensions they download, and to authenticate the source of the extension." He also explained that the default operation of the browser was to warn users before installing any software, to prevent any extensions or scripts from being installed without the user's knowledge.

It's worth noting that Firefox is not unique in allowing extensions or add-ons like Greasemonkey. Pilgrim noted that Turnabout for Internet Explorer performed the same function for IE, by allowing users to run scripts to change the function of websites. Just as with Firefox, Turnabout users could easily run malicious scripts if they're not careful about where they acquire them.

There's really nothing unique about the Greasemonkey situation, though. Spyware and adware have propagated in large part because users have been willing to download and install software without questioning the source of the software or any possible side-effects. The best that the Greasemonkey team can do is ensure that their software is not subject to vulnerabilities like the two that Pilgrim discovered. Beyond that, the responsibility will remain with the user to verify that extensions, scripts and other software is suitable for use.


(Log in to post comments)

Confused deputy

Posted Jul 28, 2005 3:55 UTC (Thu) by bignose (subscriber, #40) [Link]

This problem is endemic in the security model of most mainstream operating systems and application environments. It is known as the "confused deputy" problem:

http://en.wikipedia.org/wiki/Confused_deputy_problem

and the prime candidate for solution is a candidate-based security model:

http://en.wikipedia.org/wiki/Capability-based_security

Confused deputy

Posted Jul 28, 2005 4:45 UTC (Thu) by jwb (guest, #15467) [Link]

No, it really isn't. The problem here is that greasemonkey works by injecting strings into an untrusted markup stream, when it should have been programmatically fiddling the model using priviledged APIs. Mozilla already has the the security model you recommend, but greasemonkey poked a big hole in it.

Greasemonkey gets into trouble

Posted Jul 28, 2005 9:35 UTC (Thu) by sdalley (subscriber, #18550) [Link]

"Users should take caution for any extensions they download, and to authenticate the source of the extension."
Hmm. Some distributions don't exactly make this easier. Every time I use the default Synaptic package update on my Ubuntu 2005.4 installation, it displays the dire warning "You are about to install software that can't be authenticated" for ALL the out-of-date packages, including those in the core ubuntu and the latest Firefox update. Most of us would be prepared to trust core packages more than multiverse etc, why cry wolf for all of them? TThis will only result in users becoming inured to the warning when it might actually matter.

Greasemonkey gets into trouble

Posted Jul 29, 2005 7:35 UTC (Fri) by nedrichards (guest, #23295) [Link]

If you import the GPG key of those repositories then the warning will go away. Plus you'll be a lot more sure that you aren't subject to a man in the middle attack on your packages. Whilst I agree that the UI of synaptic could be altered to make this much more obvious and easy the theory behind it is still good.

Copyright © 2005, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds