Closed Bug 890162 Opened 9 years ago Closed 9 years ago

Javascript Cookie Stealing Injection In URL


(Firefox :: Untriaged, defect)

22 Branch
Not set





(Reporter: coolsamar207, Unassigned)


User Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:22.0) Gecko/20100101 Firefox/22.0 (Beta/Release)
Build ID: 20130627161504

Steps to reproduce:

- Encode the payload containing document.cookie theft script in XSS vulnerable URL (base64 alone or base64+javaobfuscator hex based encoding)
- Visit the payload injected URL

Below are all the examples tested:

Javascript/Cookie Stealing injection possible in Mozilla Firefox <= 22

Tested under: Firefox 22, 18
This bug does not affect chromium browser

Simple test script:

	echo $_GET['param'];

A GET request trying to steal cookie but does not work on firefox:

Obfuscated above payload using and firefox still prevents the execution:


Base64 encoded payload which bypasses and works like a charm:


However, base64 payload failed in some cases. But the variation below works for every case.

Yet another variation works which is to first base64 encode the payload and then use the obfuscation tool from The URL would be something like below:


This has been tested in real web app in the local environment and known to be working in firefox only. Chromium however filters all of the above injections and prevents redirect to prevent cookie theft. Note that IE and other browsers having less browser market share have not been tested.

Actual results:

Cookie theft javascript injection is successful. The redirection is successful thus leading to cookie theft.  Javascript injection is possible in firefox that lets users steal cookies if the cross site scripting bug exists in web applications. While XSS is a bug in web apps and not actually in firefox, firefox is known for preventing execution of client side scripts in URL to prevent possible cookie theft.

Expected results:

On finding document.cookie (or its encoded form), no redirection should have happened.
Your test page has an XSS "bug" (on purpose, I realize) which needs to be fixed in the page. Some browsers attempt to detect and filter XSS payloads found in the URL but Firefox is not one of them. At the moment the only tool we offer to help sites prevent XSS is support for the Content-Security-Policy header.

If your test site had a reasonable policy it would prevent all of these examples. Even the extremely lax policy "Content-Security-Policy: default-src *" would prevent this.

I am not sure why your script didn't run in the first examples... I suspect it did run but threw errors which you might be able to see on the error console
Group: core-security
Closed: 9 years ago
Flags: sec-bounty-
Resolution: --- → DUPLICATE
Duplicate of bug: xssfilter
You need to log in before you can comment on or make changes to this bug.