Industry


Ads by TechWords

See your link here


Michael Horowitz's picture
Michael Horowitz

Defensive Computing

Testing Microsoft Security Essentials and the Hosts file

Computers on the Internet address each other with numbers. What appears as computerworld.com to a human being is 65.221.110.98 to a computer. The system that translates between names and the underlying numbers (really IP addresses) is called DNS and it works very well. Too well, for some bad guys.

Many years ago, before the Internet, the translation between computer names and numbers was done by a file on each computer called the "hosts" file. Needless to say, as the number of computers got large, maintaining a hosts file on every computer became unrealistic. Now, when a computer is called on to reference another computer by name, it first makes a call into the DNS system to retrieve the underlying IP address.

Why the history lesson?

Microsoft never retired the hosts file* and bad guys abuse it.

For example, screwing up the mapping of names to numbers can prevent antivirus software from self-updating. Another tactic is to change the entry for bank websites. A computer with a maliciously modified hosts file can send someone to a duplicate copy of a bank web site, one that looks totally legit, but is designed to steal userids and passwords.

By default, the hosts file is used before DNS, a poor design decision by Microsoft. Protecting the hosts file from modification is thus a standard practice for antispyware software.

What brings this up, is a recent comment by security expert Steve Gibson on his Security Now podcast. Gibson is the rare techie that actually uses the hosts file for its original intent. One day when he couldn't reference some computers by name, he tracked down the problem to Microsoft's new Security Essentials (MSE).

It turned out that when he installed Security Essentials, it replaced his hosts file. MSE gave him a new empty file after making a backup of the original. This may be a good decision, but it wasn't externalized, Gibson had to figure it out on his own.

MSE doesn't always replace the hosts file. On my test Windows XP computer, an unmodified hosts file was left unchanged by the installation of Security Essentials.

This made me wonder what happens if the hosts file gets modified while MSE is running. It's easy to test and so I did, as described below.

The tests were run under Windows XP SP3 on October 23, 2009 using MSE version 1.0.1611.0. The Virus definitions were created Oct 23, 2009 at 2:49AM. Both the virus and spyware definitions were version 1.69.64.0. Real time protection was enabled during all tests.
 
TESTING

The first thing I noticed was that a restricted user can't modify the hosts file. This protection is provided by Windows, not by Security Essentials. Good thing too, as this is just the sort of thing restricted users shouldn't do.
         
An administrator can modify the hosts file and, surprisingly, Security Essentials didn't prevent the modification and didn't object afterward. A website of mine that I haven't updated in years, computergripes.com, has its own IP address. So I modified the hosts file to send another of my websites, javatester.org to the gripes site. Technically, the change was

216.92.35.29   javatester.org  #really computergripes.com

After saving the hosts file, I verified that javatester.org was indeed, re-directed to computergripes.com. Security Essentials was running the whole time and didn't object.

To try and tell MSE that I was doing something bad, I had it scan the WINDOWS\system32\drivers\etc folder. No complaints. Then I scanned just the hosts file and again, Security Essentials assured me that all was well.

Thinking that MSE just doesn't care about my dinky websites, I more directly mimicked what the bad guys do.

An IP address of 127.0.0.1 always refers to your computer. If you want to insure that a computer can't access a website, you assign the website name to 127.0.0.1 in the hosts file. Some people do this to avoid ads on web pages. Bad guys do this so that antivirus and antispyware software can't download new definitions. I added the following lines to my hosts file:

127.0.0.1   microsoft.com
127.0.0.1   symantec.com   
127.0.0.1   antivirus.com   #really trend micro

Symantec was blocked  and so too was Trend Micro. I tested with both Internet Explorer version 7 and Firefox version 3.5.3.

But, then I almost fell off my chair. I was able to get to microsoft.com. How can this be?

It got redirected to a page at www.microsoft.com and the hosts file is very exact. That is, blocking microsoft.com does not block www.microsoft.com. So, I added an entry for www.microsoft.com, saved the hosts file, restarted the browsers, cleared their cache and was still able to get to Microsoft's website.

The actual web page that was being displayed was www.microsoft.com/en/us/default.aspx. Taking no chances on a typo, I copied this into the hosts file from the browser address bar. No matter, I could still get to the page.

Microsoft seems to have put special rules in Windows for its own website.

While testing access to Microsoft's website, I finally got warned by Security Essentials about the modifications I had made to the hosts file. The warning, however, came quite a while after the first change. I had updated the hosts file a few times before MSE picked up on it.

As had been reported elsewhere, Security Essentials did not do a good job of cleaning up the hosts file. Specifically, it removed the entries for microsoft.com and symantec.com but left entries for antivirus.com and avira.com, both of which where were pointed to 127.0.0.1. It also left the entry for javatester.org.

I wondered if bad guys could prevent antivirus software from downloading new definitions by assigning vendor websites to other sites rather than nulling them out (the net effect of assigning them to 127.0.0.1). 

To test this, I added still more antivirus related websites to the hosts file and waited for MSE to object again. It did, and after cleaning the hosts file, left these entries behind
 
216.92.35.29   microsoft.com
216.92.35.29   www.microsoft.com
216.92.35.29   symantec.com
216.92.35.29   www.symantec.com

Sure enough, preventing access to Symantec's site (by assigning it to 127.0.0.1) is considered bad, but assigning it to computergripes.com is just fine.

Then I made additional changes to the hosts file and again let Security Essentials clean it up. As with Symantec, it left behind entries for avg.com and avira.com that pointed to my gripes site.

Until this changes, bad guys can redirect antivirus websites to any other website on the Internet to prevent them from self-updating.

 

RESTRICTED USER

The cleanups happened while logged on as an administrator. Next, I wondered if Security Essentials could clean up the hosts file while logged on as a restricted user. So, I zapped it again and rebooted.

Since there was quite a delay between the first modification of the hosts file and the first warning, I guessed that Security Essentials only checked it periodically. After logging on as a restricted user, I waited. And waited. And waited. A couple hours went by and no warning about the hosts file modifications.

As before, the heavily modified hosts file got a clean bill of health when scanned directly. Specifically, these are the modifications that were not considered a problem:  
 
216.92.35.29  javatester.org  #really computer gripes
127.0.0.1  www.microsoft.com/en/us/default.aspx
127.0.0.1   antivirus.com
216.92.35.29   avg.com
216.92.35.29   www.avg.com
216.92.35.29   avira.com
216.92.35.29   www.avira.com
127.0.0.1  www.microsoft.com
127.0.0.1  microsoft.com
127.0.0.1  ftp.microsoft.com
127.0.0.1  symantec.com
127.0.0.1  www.symantec.com
127.0.0.1  security.symantec.com  

Again, I deleted the browser cache and verified that www.symantec.com was unreachable. Still, Security Essentials was all green. I waited some more. Still green. I even opened the file in Notepad, even though I couldn't save it. Still no objection from MSE.
 
Could it be that Security Essentials works differently when logged on as an Administrator vs. a restricted user? The same entries that it removed when running as an Administrator, it ignores when running as a restricted user.

To test this, I logged back on as an Administrator and scanned the hosts file again. All green. I used the system for a while doing other work and never got warned about the modified hosts file.

If there's a pattern here, I can't find it.

You may want to opt for a more mature product.

Update: October 24, 2009. To try and get MSE to detect the modified hosts file while logged on as restricted user, I tried a quick scan. It found nothing.


 
*On Windows XP and Vista the hosts file is called "hosts". On both systems it can be found in
C:\WINDOWS\system32\drivers\etc
 

 

What People Are Saying

Wow. People. Get a grip.

Wow. People. Get a grip. First, before you level this much criticism, read Michael's bio. He has been around the block more than once. Second, any regular reader of this blog would know that members of the target audience are small companies with little to no IT staff, and the IT knowledge levels to match. Myself, I enjoyed the article, because it taught me something about the hosts file that I had not known previously. Regardless of MS involvement, it's good to know that the file can be used maliciously, and that AV software of any stripe may be rendered incapable when the real issue lies in the file's unauthorized modification.

Michael - keep up the good work, and don't let the buggers grind you down.

Need more explaination from author

"The actual web page that was being displayed was www.microsoft.com/en/us/default.aspx. Taking no chances on a typo, I copied this into the hosts file from the browser address bar. No matter, I could still get to the page."

Well, to be honest it looks to me that this is a planned technique used by Microsoft to avoid any security attacks on their site. I would like to know whether anybody else can do the same ie make their homepage url as long as it is in this case of Microsoft. There seems to be more to this long url than what has been pointed out as absurd by the blog author. I would love to know as to what technical thinking could have gone behind this. Thanks

John

I've never had any antivirus

I've never had any antivirus product ever pick up changes to the hosts file. Maybe you should try to do the same thing with Norton Antivirus or McAfee antivirus, or any of the other strictly antivirus programs out there (not the bundled security suites either) and see if they also "fail" your stupid test, as I'm sure they will.

Aside from the observations

Aside from the observations below that this author is utterly lacking in technical competence in this area, and aside from his testing only on XP, what is further troubling is his illogical suggestion to "opt for a more mature product," presumably based on the assumption that the "problem" he is so uninformed about will be remedied later on.

I couldn't agree more. If

I couldn't agree more. If security and reliability mean anything (and it should to IT execs charged with caring for dozens of PC's), then spending some more money on SSD is a pure and simple insurance policy. Waiting for a "mature product," and hoping a problem will be fixed is poor IT strategy because even if that problem is resolved, others will take its place. Best to bypass any product with innate issues.

Author doesn't understand the material

From the article:

"The actual web page that was being displayed was www.microsoft.com/en/us/default.aspx. Taking no chances on a typo, I copied this into the hosts file from the browser address bar. No matter, I could still get to the page."

Other people have commented on the author's lack of appreciation of the pre-Microsoft history of internet standards and of the use of /etc/hosts in particular. This statement stands out even more in that it reveals that the author lacks even the most basic understanding of how IP networking operates today (whether on Windows or any other OS).

It would behoove ComputerWorld to seek out authors who are subject matter experts in what they write about, or at minimum, if none of the editorial staff qualifies, run articles past an IDG IT guy for a sanity check.

This article falls below even the mediocre standards of technical accuracy expected from generic writers at a daily newspaper who hold BA's in Social Studies.

"flaccid LEO" indeed :-)

Horribly Misleading Article

The first part of this article is horribly misleading. It places the blame of the “hosts” file solely at Microsoft. In fact, the hosts file is as implemented in the Windows Operating Systems is in accordance with RFC-952.

The method in which the hosts file works is consistent with Unix, Linux, Mac OS, and virtually any other operating system that access the Internet or use IP based Resources. Any of these operating systems can fall to the same pitfalls of rogue hosts file entries.

Microsoft’s use of protecting the hosts file in Vista or Windows 7 via UAC is a better alternative than retiring the hosts file as the author suggests. Retiring the hosts file would contradict that standards set forth in RFC-952 and possibly several others.

The only positive point of this article, where the author is correct, is that Microsoft should not assume to make changes to the hosts file without notifying the user. Modifying the hosts file is not as “rare” as the author suggests. Although most desktop users may never have a need to modify their own hosts file.

What a bunch of crap and

What a bunch of crap and misinformation !

You'd better get YOUR OWN hands on stuff and ensure to understand it and to know computer history before writing stuff

The HOSTS file and the "resolver bahaviour" was there BEFORE Microsoft even released the first network stack; looking up the hosts file before running a DNS lookup is the usual way most if not ALL stacks work

The fact that inserting microsoft.com inside the hosts file didn't block access to microsoft is just because some addresses are hardcoded into the system to ensure that, even if a DNS is poisoned or the hosts file manipulated the system will still be able to contact Microsoft to run windows update, pick the malware cleaning tool and so on

The remainder of the article is just plain vanilla crap; the hosts file can't be edited or modified by a non-admin user (assuming one didn't change the default permissions) so, if you aren't running the system "as admin" that won't be a problem at all; more, if a piece of crapware will try to modify your hosts file MSE will most probably INTERCEPT it using heuristic/behavioural analysis

Bottom line, better rethinking the whole article, as it is, it just sounds like another attempt from big AV vendors to make MSE look bad ... and like all the other attempts it just looks like a bunch of crap

In Vista the hosts file is protected

In Vista the hosts file is already protected because writing in that location requires administrative privileges i.e. elevation via UAC

as usual another brilliant

as usual another brilliant articul. JUst want to know though if all of this applies to Vista and Windows 7, and why you're still testing things using only XP?