Thursday, September 10, 2009

In the wild Flash exploit analysis – part 1

Today, one of my colleagues requested that I provide additional details about a web page that we had blocked for a customer. The blocked URL was ‘hxxp://www.39sys39.cn/htm/ie.html’. He wanted details about the threat present on the page. I downloaded the page and found out that it contained obfuscated JavaScript with heap spray code. I also found that the exploit contained an tag with a source file called “xp.swf”. At first glance, it was clear that the page is trying to exploit a Flash vulnerability. The exploit code is shown below:

The above exploit employed simple obfuscation to evade signature engines. If we decode the above script, we find the following:

It is also spraying the heap on an address of “0x08080808”. Shortly, we will learn why this address is needed to exploit the vulnerability. I downloaded both the “ie.html” and “xp.swf” files for further analysis. I also uploaded the “xp.swf” file to Virustotal to see if it was a known exploit or perhaps zero day content. Only 9 out of 41 antivirus engines detected the file as a virus. Those that did, identified the file as an exploit attacking CVE-2009-1862. This is a recent vulnerability, for which exploit code is currently in the wild, affecting Adobe Reader and Adobe Flash player. To check if the exploit was working properly, I replaced the shellcode in the exploit with simple shellcode that will execute “calc.exe”. I opened this file with both Firefox and Internet Explorer and here is what happened,

The JavaScript code successfully exploited the known vulnerability in Flash and executed our replacement shellcode to open “calc.exe”. This demonstrates just how dangerous the vulnerability is as it requires a victim to simply visit a malicious page containing the Flash exploit. No further user intervention is required. In this case, I had replaced the original shellcode for testing and the exploit opened calculator successfully. Next, I wanted to determine the purpose of the original shellcode, so I then modified the original exploit code to force a crash in order to debug further. I ran the file again, this time with Internet Explorer and received the following popup message:

The referenced memory address in the above figure is “0x08214408. The program is unable to read data from an invalid address, which led to a crash. Now if you remember, the original exploit in the first image of the blog uses the “0x08080808” memory address to spray the heap with shellcode. Bingo! This means the program is crashing may be due to memory corruption. That is why the exploit must spray the heap with an address of “0x08080808”. I then clicked on cancel button to debug further. I wanted to find which instruction actually reads the data and calls the shellcode. Here is the first state of the OllyDbg debugger:

Look at the above instructions. The register EDX is trying to read a value from ESI which points to invalid address 08214408. Let’s analyze the instructions that follow.

MOV EDX,DWORD PTR DS:[ESI]

MOV EAX,DWORD PTR DS:[EDX+44]

PUSH EBP

MOV ECX,ESI

CALL EAX

TEST AL,AL

Let’s assume [ESI] contains some value which is moved to EDX. Then EAX will contain the value [EDX+44]. Then the program will push EBP on the stack, move the ESI address to ECX and look at the next instruction “CALL EAX”. This is where a call has been made to execute the shellcode. We can conclude that if we spray the heap with 08080808 and shellcode, [ESI] will contain 08080808, which will be moved to EDX. EAX will also contain 08080808 which will be called after the “MOV ECX, ESI” command. Then this call will jump to heap memory at an address of 0x08080808 and execute the shellcode. Let’s see if that holds true.

This time I reopened the original exploit in the Firefox, put a breakpoint at the above-mentioned instructions and sure enough, we were right. EAX now points to 08080808 and the heap is sprayed with 08 bytes and shellcode. If I press “F9” to continue, it will jump onto the heap area and will execute the instruction found. The instruction 0808 is effectively a NOP sled. It is simply “OR BYTE PTR DS:[EAX],CL” which will do nothing as CL contains 08. It will reach the shellcode by executing 0808 instructions and ultimately execute the malicious code.

This means some field/value from the malicious Flash file is causing memory corruption. Here is the how original shellcode is loaded into memory,

This is just overview of how this exploit works. In the next part we will see what original shellcode does. Specifically, we will identify the additional content downloaded to the victim’s machine.

This exploit proves that flash exploits can be very dangerous. Such exploits do not require user intervention. Simply by visiting a malicious web page, the victim will be exploited.

That’s for part 1 now. Do come back for part 2 of this blog.

Umesh

Wednesday, September 9, 2009

Wednesday, August 19, 2009

Safe Search – Not just a content filter

‘Safe search’ is a feature used by search engines to filter out explicit sexual or adult content from search results. Most search engines provide 3 modes of safe search as follows:

  • Strict: Filter all adult web, video, and image results
  • Moderate: Filter adult video and image results only
  • Off: No filtering

By default, most search engines implement a ‘moderate’ setting. Some search engines, such as Yahoo, additionally provide password protected preferences. Any user who is signed in can change the setting and save it for his/her preferences.

Bing, Microsoft’s newly launched search portal, came up with a feature to play a preview of videos directly from the search results. However, by turning off the safe search filter, people were able to play adult content from the search page itself, thus bypassing possible URL filtering controls on the network. Bing later recommended solutions to prevent explicit content from being displayed in the search results. They initially provided a workaround in a blog posting which suggested adding ’&adlt=strict’ to the end of the search query. This forced filtered results even if end users had disabled the feature. Bing later recommended another solution with explicit content being served from a separate domain, thus allowing for explicit content to be blocked simply by filtering access to a single domain. Here is an example of Bing results with safe search turned off:

Now as per the first suggestion on the Bing blog, we can add URL parameter ‘&adlt=strict’ to eliminate explicit content from the search results. Here is how the same query will look,

The search engine did not return any results, because the safe search setting is forced to be in ‘strict’ mode. The above solution of appending a safe search parameter in the URL is definitely a good way to prevent explicit content from being displayed even if safe search is turned off. Remember, you will have to also find out if the safe search parameter used by the search engine website should be appended or prepended to the final URL. This is because filtering can be bypassed by appending the same parameter with a different option. Look at the below result:

I have again appended an ‘&adlt=off’ name/value pair to the end of the URL in the second image. The search engine now takes last parameter i.e. ‘&adlt=off’ as safe search parameter to filter out the result. Imagine, without a proxy or filtering solution in place, a user would be able to add such a safe search parameter at the end of URL to bypass the safe search protection even if his/her search preferences were set to strict mode. But, how would a user do this if a proxy server is altering the URL? They will not have access to the query after it will be altered by the proxy server. In this case, even if a user were to add a safe search parameter anywhere in the URL to bypass safe search protection, the necessary safe search parameter to force strict filtering would then be added at the end of final URL (as shown previously) at the proxy level. This will override the user preferences and the proxy server will return only safe search results.

Almost every search engine implements safe search features but individuals control whether or not it is used, not the enterprise for which they work. Beyond the legal ramifications of allowing users to view inappropriate content while at work, it can also present a security risk as adult websites often contain malicious content. For example, pornographic sites may encourage users to download fake codec or flash applications to view the content of a video, which ultimately results in a system compromise. In the associated image, we are viewing a malicious website and AVG antivirus triggers immediately with message “Exploit Trojan Fake Codec”.

We land on this page because we have turned off the safe search and we searched for adult content. If safe search was on, the user would not have been permitted to visit the site and download the malicious program. This time antivirus identified the threat, but that may not always be the case. This shows the importance of safe search.

Happy Safe Search!!!

Umesh

Tuesday, July 7, 2009

Cloud transparency during a crisis

The beginning of July was a big week for data center outages with some notable Internet impact. I've written before about cloud resiliency and uptime in my 'Changing a tire while going 60mph' and 'Big, white puffy clouds can still evaporate' posts.

Amongst those outages was a Google App Engine interruption, which just goes onto the tally sheet as yet another failure of a supposed infallible cloud platform service. Ted Dziuba has some
interesting viewpoints on the App Engine outage, and brings up a key element that makes all the difference with these types of outages: transparency. If something fails, people like to know why it happened (especially in light of all the resiliency/redundancy claims of the cloud) and what is being done so it doesn't happen again. Google's transparency was a basic statement that something bad happened with GFS, and that affected BigTable, which affected App Engine's DataStore, and they are going to fix it. Now, compare that level of detail to the information offered by Amazon during their S3 outage from July 2008 and February 2008. There is a notable difference. So a message to SaaS vendors: just because customers don't need to know the platform and implementation details behind your SaaS, doesn't mean they don't want to know...especially in light of a catastrophic failure. Telling customers what went wrong let's them enact their own post-mortem and due-diligence analysis processes to ensure they haven't shackled themselves to a SaaS vendor who is experiencing outages due to silly oversights that are likely to repeat as life goes on.

Actually, transparency and efficient communication regarding the outage event was also a key issue for some of the other outages last week. Jeremy Irish
blogged about the fire at Fisher Plaza data center that left his systems offline for 29 hours. Apparently news of what exactly was happening, even for the first responders that were physically present at the building, was scarce and little effort was made to keep folks efficiently informed. Eventually they found out that it was a fire in a basement-level electrical room, which triggered the sprinklers and in turn ruined additional electrical equipment and generators, which ultimately caused significant damage to the power infrastructure.

Overall, Murphy and his laws are a fact of life and vendors (cloud, SaaS, or other) must do what is in their power to have contingency plans if you truly want to maintain availability and business continuity. And SaaS vendors, take note: just because you can hide the implementation and platform details of your service, doesn't mean you should hide the operational details of your service...especially during a service disruption.

Until next time,
- Jeff

Thursday, June 25, 2009

State of the industry – June 2009

As the month comes to an end, there were a few interesting happenings of late that I wanted to comment on. First is the state of the spam blacklist SORBS. Apparently the University of Queensland wants to stop hosting SORBS, so SORBS is looking for a new home to immediately host their full 42RU rack of servers and enough bandwidth to cover their 30 billion DNS queries each day. Apparently SORBS has a checkered past, with many feeling that a closure of SORBS would be a good thing since the service apparently incorporates political and other questionable motivation that compromises its technical value. My thought? Spammers should be clamoring to host/buy it (discretely, of course). Think about it: make sure all of your competition is listed, and don't list yourself. Your spam gets a free ticket through the first line of spam defense. If spam is really that lucrative, then buying/hosting SORBS would make financial sense.

Next is the state of Microsoft's anti-virus efforts. Many AV industry experts claim that Microsoft's entry into the AV market would be laughable and minimal. Indeed, Microsoft's previous OneCare suite
left a lot to be desired. But according to AV-Test, Microsoft's new Security Essentials (codename "Morro") actually holds its own (well, the beta version at least). There was also speculation that Microsoft's AV scanner would be cloud-based, but it's confirmed to be a traditional local client application. The Security Essentials site indicates that no more beta downloads are being offered at this time, so we'll probably need to just wait for a full release later this year. In the meantime, Microsoft's AV efforts are readily apparent on their Malware Protection Center page. Also interesting is the quote by the CEO of AVG, another anti-virus company, in the previously linked ComputerWorld article. He basically says that viruses are so yesterday, and incoming web nasties and malware such as browser exploits are the big threats now. True.

Lastly is the state of
man-in-the-middle attacks on public networks. Have you ever noticed that things like wireless hotpots and hotel networks are a huge catch-22 for trust and network security? You connect to a network and get assigned IP, DNS, and routing information from a DHCP server that may or may not be the legitimate DHCP server. Then you could come to a captive portal page that may or may not be the legitimate captive portal. The captive portal page says you must enter in various information (Room number? Credit card? T-mobile login? Daily access code?) before you can use the network, but the information it requests may or may not be the legitimate information that is necessary. And that's assuming you even connected to the legitimate wireless AP in the first place (see more than one AP broadcasting the same SSID? Yeah...) Even SSL doesn't help here, because different places use different hostnames for their captive portal service...so you have no idea whether https://secure.FooBarHotelNetworkServices.com/captiveportal/sheraton/ is the right place or not when asked for your credit card number to get Internet access. An attacker can register any legitimate-looking domain name, get an SSL cert for it, and run their attack, and you would never know. ("Hello? Front desk? Can you please tell me the exact hostname for your captive portal, and whether or not I will need to enter in a credit card number to get Internet access?") In a world of laptop cellular aircards and mobile phone tethering, they are a much safer bet these days.

Until next time,
- Jeff

Friday, June 19, 2009

The most important things on the Internet...A through Z

You may have noticed that Google's front page implements a style of auto-completion as you type in your query, ranked by popularity (although maybe it's not popularity, but it's definitely not relevance; I'm just assuming it is popularity). I've always been amused at what pops up after I type in a word or two, but today I was more curious than usual and started looking at the top terms for shorter and shorter word fragments. Eventually, I sparked on the idea of the most popular terms for the letters A through Z. So, without delay, here they are!

Amazon
Best buy
Craigslist
Dictionary
Ebay
Facebook
Gmail
Hotmail
Irs
Jcpenney
Kohls
Lowes
Myspace
Netflix
Orbitz
Photobucket
Quotes
Realtor.com
Southwest airlines
Target
Usps
Verizon wireless
Walmart
Xm radio
Youtube
Zillow

Other than 'Quotes' and 'Dictionary', the remaining words are large well-known sites or brands. We sure do live in a commerce and media-driven world, don't we? Hopefully people aren't using Google to find out the web address of Youtube; it reminds me of
the Little Rascals quote "Quick, what's the number for 911?"

I've also noticed that the results can vary at different times, so the list you get might be slightly (or majorly) different. And different languages/locales provide different results (I just checked with www.google.fr). Which I suppose adds to the fun. I'll also leave the list of numbers (0-9) for you to look up yourself. Oh, the suspense!

Until next time,
- Jeff

Monday, June 15, 2009

Patches, auto-updating, and convenience

June has been a busy month for web-centric security patches. Microsoft fixed 31 different vulnerabilities (many affecting IE and Office), Adobe patches critical vulnerabilities in Adobe Acrobat and QuickTime, Google plugged some WebKit holes in Chrome, Apple released over 50 security fixes for Safari, and Firefox had 11 security vulnerabilities fixed, half of which were rated critical. With a lineup like this, a majority of the world is going to need to install patches to keep safe.

Despite the patches being available, history has shown that people don't always install them. Installing patches is an inconvenience; it interrupts the use of the system and potentially requires reboots. In enterprise environments, all of this can be semi-automated with patch management and deployment systems, centralized patch repositories like WSUS, and policies that dictate the employee just sit tight while mandatory patches are applied. But for home users, computer use is often casual--which means convenience has a very strong influence. If they get on the computer to check email or surf MySpace, they are likely to not want to postpone those computing desires in order to deal with installing patches first. That's assuming they even know about the availability of patches in the first place.

Recently
some folks from Google and their partners released an analysis of web browser auto-update approaches. The analysis looked at the different effectiveness of how quickly patches gained widespread deployment due to the different patching processes they offer. For example, Chrome does "silent updates"--it will download patches/new versions and automatically install them without telling you. Firefox will automatically download updates, but then you have to still manually agree to the installation via a prompt given to you by Firefox. Safari tells you that an update is available, but then you have to manually agree to download and then install the update. Opera will inform you of a new version, but then you have to manually download the update yourself and proceed through the install wizard. Internet Explorer relies on Windows Automatic Update agent to download and install patches.

Overall, the Google analysis found that Chrome’s silent update approach resulted in the widest spread of update deployment (97% of systems patched/updated) within a fixed period (three weeks). Firefox wound up with 85% of systems patched/updated after three weeks, and Safari and Opera wound up with some pretty low numbers. The conclusion? Badgering the user to be involved in the update process causes them to interrupt, abort, or ignore the process, leaving the patches/updates unapplied. That is non-ideal when security is involved.

But just because there are auto-update mechanisms available (Chrome, Windows), doesn't solve the problem per se. I've encountered situations on numerous occasions where the user has disabled the automatic updating process because the software they were using was, well, "borrowed." Microsoft has been struggling with this issue for years now: whether to allowed pirated copies of Windows to be eligible for service pack updates and other patches. They have slipped various anti-piracy checks into their update process under the moniker Windows Genuine Advantage, which means only legitimate copies of Windows have access to the collection of updates. But even if the software vendor doesn't implement technical restrictions to prevent pirated versions from updates, the user's conscience might still prevent it. A person who "borrows" a commercial software application from their friend is less likely to run to the vendor asking for support and updates, because they do not want to get their friend in trouble for handing out pirated copies; so such people are more likely to disable anything that automatically alerts the vendor to the second copy, and/or will ignore any updates (where they might be asked how they got the software in the first place) and just stick with the original (now outdated and insecure) version.

Overall this whole timely security patching business is a tough problem to solve, because it's not simply just a matter of expecting users to download an installation file off a website and double-clicking it.

Until next time,
- Jeff