Firefox and Self-XSS

I still remember the good old days when I would just write “javascript:alert(document.cookie)” in my address bar and the browser would happily show me the JavaScript-accessible cookie values for the current domain. These were simpler days…

Mid-2011 the developers of Firefox decided that allowing the “javascript” directive in the URL bar was being abused by attackers to conduct self-XSS attacks more than it was being used for legitimate purposes. If you are not familiar with self-XSS fear not… they are quite easy to explain.

In short, self-XSS happens when an attacker convinces a user to copy-paste some malicious JavaScript code in his URL bar and hit ‘Enter’. This was used a lot in Facebook, since people there are usually very willing to follow instructions in order to get access to some sort of “video”, or “application” or information about how many people checked-out their profile today. Matt Jones has made a nice video demonstrating the attack which you can check out right here. The effect of this, is exactly the same as an attacker injecting malicious JavaScript by exploiting the usual and well-known XSS bugs (reflected, stored, DOM-based).

Self-XSS before the Internet

Self-XSS before the Internet

Back to Firefox… so Firefox decided to disallow the use of JavaScript in the URL bar. So no more self-XSS right? Wrong! In the newer versions of Firefox, there is a pretty ‘Web console’ which a user can access and type in arbitrary JavaScript that will again run in the context of the current domain.

Firefox's Web Console

While people have accepted this, they believe that it is a greater hassle to users who will not do it as easily as they used to do the self-XSS through the browser URL bar. The purpose of this post, is to claim that this is not true.

The ‘Web console’ of Firefox has a handy default keyboard shortcut from which it is accessible: Ctrl+Shift+K. Now compare the list of instructions that an attacker would use to conduct self-XSS in the past, and the list of instructions now.


  1. Select the following text: javascript:alert('Welcome to a world of pain');
  2. Hit the following:
    1. Ctrl+C
    2. Ctrl+L
    3. Ctrl+V
    4. Enter

New (you can actually follow along):

  1. Select the following text: alert('Welcome to a world of pain');
  2. Hit the following:
    1. Ctrl+C
    2. Ctrl+L
    3. Ctrl+Shift+K
    4. Ctrl+V
    5. Enter

The only extra action needed to perform the attack is the Ctrl+Shift+K between the selection of the location bar (Ctrl+L) and the pasting of code (Ctrl+V). If anything I would claim that this is a smoother attack because the word “javascript” doesn’t need to be written as part of the malicious vector since the Web Console expects JavaScript and thus doesn’t need to be told: “Interpret the rest as JavaScript”.

In short I don’t  believe that this is a step in the right direction. Call me pessimistic but executing an extra step as part of getting access to “Virtual Carrots” or “Hot girls” doesn’t look like it would stop the kind of people that would fall for this attack in the first place.

Nick Nikiforakis

P.S. Happy New Year! :)

This entry was posted in Breaking stuff. Bookmark the permalink.

4 Responses to Firefox and Self-XSS

  1. mfukar says:

    Next week, the Ctrl-Shift-K shortcut gets removed. :-)

  2. Arcanis says:

    Could you please give me the following code using web console instead of js protocole ?

    {a href=”javascript:alert(document.cookie)”}click here for free ipod{/a}

  3. AlK says:

    Nice article. I think Ctrl+L is useless in the new version. Also, on chrome :
    * Ctrl+C
    * F12
    * Escape
    * Ctrl+V

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>