November 10, 2003

The Dark Side of NTFS (Microsoft’s Scarlet Letter)

If you run on a Windows platform you no doubt have heard about NTFS. Its a fast, stable and secure file system that has worked great since the old NT 3.51 days.

This morning I read an excellent article on NTFS Alternate Data streams (ADs), and how they can be used as an attack vector to hide malicious code.

This isn't new, but I like how its described in the article. If you didn't know, you can hide alternate data in a NTFS file. This little trick has been used in the past for indexing files, store secondary data and even used to store particular security tag information (this was a very weak approach, which was quickly dropped).

There is a good example of how to create hidden ADs, so I won't bore you here. Instead I will comment on its use.

If you were to write out a malicious code segment into an ADs, the presentation layer of the operating system won't see it. Don't believe me? Watch this:

c:\> echo Alice knows Bob's secret > foo.txt
c:\> dir foo.txt
10/11/2003 08:25 AM 28 foo.txt

Ok, so we know its 28 bytes. Now watch this.

c:\> echo Alice know's Bob's secret > foo2.txt:hidden
c:\> dir foo2.txt
10/11/2003 08:26 AM 0 foo2.txt

Thats right you read that correctly. 0 bytes. The system doesn't see it. Can you see the possibilties here? You can easily hide an attack script in the ADs and execute arbitrarily later. The article shows a few examples where using the built in WSH scripting engine (on by default in XP BTW *shutter*) to do just that.

What is worse is that most (read: All but 1 or 2 I believe) anti-virus products in the field do NOT scan ADs for malicious code, which means some meathead will eventually embed their virii within the alternate data stream. Yippe. :(

Today I placed a "Request for Engineering Change" order in my IPS for a next release. (Not the version currently in RC1) I think I am going to add a checkbox to "Deny all alternate data stream reads" and "Deny all alternate data stream writes" to prevent my clients from getting nailed by this. When I get back from my trip to Microsoft I will need to test this first and make sure the OS isn't doing some hidden stuff with ADs that may be compromised if I ship this enabled. If it all works out, I will stop this in kernel mode right at the I/O manager. Gotta love ring0!

Fun stuff. Enjoy the article.

Posted by SilverStr at November 10, 2003 08:37 AM | TrackBack
Comments

It's already happening. The latest variant of CoreFlood used ADS with devastating effect.

http://bmonday.com/posts/321.aspx

Beau

Posted by: Beau Monday at November 11, 2003 11:10 AM

Interesting post, and blog. I have added you to my aggregator.

Today I showed some people at Microsoft about this. Hopefully some good will come of it.

Posted by: SilverStr at November 11, 2003 08:47 PM