Showing posts with label CVE-2014-6271. Show all posts
Showing posts with label CVE-2014-6271. Show all posts

Tuesday, October 7, 2014

#BASHed Evolution of Shellshock Attack payloads

Background
We recently blogged about the GNU Bash arbitrary code execution vulnerability (CVE-2014-6271) dubbed as Shellshock and covered some initial attacks that we captured in the wild during the first week of this vulnerability disclosure. We have continued to monitor the Shellshock exploit attacks and the malicious payloads that were getting dropped over past two weeks.

In this blog, we wanted to share a summary of new exploit attacks and new tricks that cybercriminals have deployed to increase the chances of infection.

Shellshock Attack analysis

The first attack, as reported in our previous blog, involved download and installation of a Linux Backdoor Trojan with DDoS capability detected by us as Unix/Flooder.AN.

Here the attack pattern was straight forward, if the bash exploit was successful then a malware payload was getting downloaded and installed.

Perl IRC bots

Next we saw a series of exploit attempts where a Perl based IRC bot was getting downloaded and executed on the target server. We will share two sample cases here.

In the first case, we saw a Base64 encoded Perl based IRC bot getting downloaded, decoded and executed on the target machine.

Shellshock exploit downloading Perl IRC bot

Base64 encoded Perl IRC bot

In the second case, we saw another Perl IRC bot getting downloaded and executed with a command-line argument which is the IRC server IP.

Shellshock exploit downloading Perl IRC bot

Perl IRC bot

The attacker performs following action here before downloading and running the bot:
  • Terminate all the PHP and PERL instances running on the server.
  • Attempts to delete all the content in the /tmp/ and /var/tmp/ directory.
  • Avoids hardcoding the Command and Control server IP in the bot file that gets downloaded.
Things became more interesting after this when we started seeing attacks involving tricks to add stealth and persistence to the infection. We also saw tricks used to prevent any further exploit attempts on the server by attempting to apply security patches to the server once the exploit infection was successful.

Linux.Tsunami C source code

In the attack case shown below, a bash script gets downloaded and executed on the target server upon successful exploit attempt.

Shellshock exploit downloading C IRC bot

Shell script payload downloaded upon successful exploit

The shell script will perform the following actions:
  • Downloads an IRC bot written in C programming language
  • Attempts to compile the C bot program using gcc compiler on the victim server
  • Executes the newly generated ELF IRC bot binary
  • Creates a crontab entry to download and infect the system on a weekly basis
This is a way of establishing persistence, even if the system administrator identifies and removes the culprit file the system will again get infected when the cronjob triggers. The attacker is also transferring a plain-text file as oppose to an ELF binary in an attempt to evade network perimeter defenses.

Linux.Tsunami ELF binary

In the most recent case, the attacker first ensures that the current bash session does not get recorded to the history file. It then also involved a shell script getting downloaded and executed on the target server as seen below:

Shellshock exploit attempt downloading Linux.Tsunami

Shell script payload downloaded upon successful exploit

The shell script will perform the following actions:
  • Downloads and executes a new variant of Linux.Tsunami DDoS bot
  • Create crontab entry to ensure future update and persistence
  • Attempts to download and patch the Bash vulnerability in an attempt to prevent new infections from competitors?
  • Uses shred command before deleting itself (downloaded shell script)
shred command Overwrite the specified FILE(s) repeatedly, in order to make it harder for even very expensive hardware probing to recover the data.

Conclusion

We have seen a quick evolution in the Shellshock exploit attack payloads that can be broadly classified into following categories:
  • Persistence - achieved by creating cronjob.
  • Evasion - payload Base64 encoding (Perl bot) and plain-text C source code transfer.
  • Stealth - prevents recording of bash session history, usage of shred and rm commands.
  • Competitive Advantage - removing other exploit payloads, installing new payload and applying security patches to prevent further exploit & infection attempts.
It is extremely important for the system administrators to test if their server is vulnerable and apply appropriate security patches as described in our previous blog. It is also important to check for the indicators of compromise mentioned in the above attack cases.

Zscaler customers are protected from this threat and the associated malware payloads. Zscaler ThreatLabZ is actively monitoring this threat and associated attacks in the wild.

Thursday, September 25, 2014

Shellshock attacks spotted in wild [Updated Sept 26]

[Updated Sept 26, 2014: added new analysis and exploit attempts]

Background

GNU Bash is susceptible to an arbitrary code execution vulnerability (CVE-2014-6271) dubbed as Shellshock. The vulnerability is due to failure to properly handle environment variables.

A remote attacker can exploit this flaw by interacting with an application that uses BASH environment variables to override or bypass environment restrictions to execute shell commands. If an attacker can control the value of an environment variable, then code execution can be achieved in the context of the application using the environment variable.

A public advisory was released regarding this vulnerability here:

http://seclists.org/oss-sec/2014/q3/650
https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-6271

Shellshock Attacks - CVE-2014-6271

Within hours of the public disclosure of this vulnerability, we have started seeing incidents of attacks targeting this vulnerability in the wild to download additional malware. It appears that Nginx and Apache web servers configured to use mod_cgi are two potentially vulnerable services that are actively being targeted in the wild. One such incident that we were able to confirm through mining our logs is shown below:


The server involved in the above case was found to be compromised and hosting ELF binaries which belongs to the same Linux Backdoor Trojan family with DDoS capabilities. We believe that the vulnerable Apache servers were resulting in the download of an ELF binary named "apache" whereas vulnerable Nginx servers were getting the ELF binary named "nginx". The only difference we saw in these two binaries was the hardcoded Command and Control server information.

Upon successful exploitation of CVE-2014-6271 vulnerability, the attacker is able to download and install the malicious ELF binary on the target Linux system. The malware connects to a predetermined Command and Control (C2) server on a specific port and awaits further instructions from the attacker. The C2 information can be seen hardcoded in the binary:


The malicious ELF binary named "apache" is leading to a different C2 location "162.253.66.76:53".

This malware family is capable of performing the following actions:
  • BusyBox command injection exploit attempts
  • Collect and send sensitive system information
  • Perform Denial of Service attacks
  • Brute force authentication attempt 
  • Opens a Backdoor connection for remote attacker
List of commands supported by this bot:


The screenshots below show sample command and control communication from this bot:
Initial call back message and command to get system IP address
Shell command & JUNK flooding attempt

Active Shellshock exploit attempts [Updated - September 26, 2014]

Below is a sample list of suspicious headers that we captured in past 12 hours attempting to exploit the Shellshock vulnerability (CVE-2014-6271). While majority of these appear to be testing attempts, some of them look malicious.



Check if your server is vulnerable:

It is extremely important for the system administrators to apply appropriate security patch depending on the Linux distribution they are running. Below is a code snippet posted by Redhat that you could use to determine whether your BASH version is vulnerable or not:

env x='() { :;}; echo vulnerable'  bash -c "echo this is a test"

Conclusion

We rate the severity of this vulnerability to be as critical as that of Heartbleed vulnerability discovered earlier this year. We are still investigating the level of impact associated with this threat.

Zscaler customers are protected from this threat and associated malware family. Zscaler ThreatLabZ is actively monitoring this threat and associated attacks in the wild.