views:

353

answers:

2

I made a discovery some time back. Just follow these steps:

Create a .doc/.xls/.ppt file in office 2003. Keep some test data in there and close the file. Now rename the file to change it's file extension to a random string, taking care that it is unassociated, like test.asdfghjkl etc. Double click the file and it opens seamlessly in the parent application.

Now AFAIK, windows checks the file extension of the file and uses it to do an action, viz open an application and pass the file to it to open. Then how does the office suite manage to do this?

EDIT: How about the case when the extension is changed to one that is associated with another application. Is there a priority algorithm in place for handling that ?

+4  A: 

Do you have the "View extensions for known types" option on?

EDIT: @Comments.... Yes, its a stupid/insulting question, but when troubleshooting a problem I have learned to assume nothing, and trust the users 0%.

BUT, I tried it, and you're right. Its stupid that MS has this kind of behavior, and it can only lead to security vulnerabilities, which led me on a search for your answer.

From the posts at http://seclists.org/fulldisclosure/2007/Jan/0444.html

"You have stumbled on an age-old quirky behavior of Windows. Office document formats are based on a standard Windows container format, OLE structured storage files, also known as "docfiles". A docfile's name and extension are irrelevant - the file is, conceptually, a serialization of an OLE object, and like all serialization formats it contains the identifier of the application that produced it, in the form of an OLE class id (in GUID format) in this case. You can easily verify that it doesn't work with the newer Office XML formats"

Indeed it doesnt work for the 2007 *X file types, but 2K3 is still a problem. To solve this problem... Upgrade! =)

And here at security focus under TOC point 2.

So, there you go.

StingyJack
Of course. I have changed the extension. Try it for yourself.
Vaibhav Garg
The icon changes to that of an unrecognised file type, a generic file icon. Therefore, it is certain that the extension is being changed
Vaibhav Garg
Actually the only thing that is certain is that the icon has changed. viewing the file in the command prompt dir list would tell you if the file name has changed.
StingyJack
So i guess, the header is parsed by the shell anyway without consideration to the extension. Is that the case?
Vaibhav Garg
the ole structure is read by windows and recognized as being a particular com class. the com app is then called to load the file.The tell is in the footer of the file.
StingyJack
How about the case when the extension is changed to one that is associated with another application. Is there a priority algorithm in place for handling that ?
Vaibhav Garg
It appears to only fire the OLE container structure if the file type is not registered. I'm not good enough with a disassembler to tell for sure. =)
StingyJack
A: 

I can't seem to make this happen now, but I know I saw Windows reading XML processing instructions a few years back. Maybe that is what's going on?

Ned Batchelder