Diagnosing & Treating Bash "Shellshock"

OS X is a descendant of a long lineage of UNIX operating systems, from which it inherits its incredible stability and enhanced security. However, the past two weeks have uncovered numerous bugs in a core piece of software relied on by many UNIX operating systems, OS X included: bash (Bourne-again shell). It turns out that these bugs have been very long standing and can be exploited in numerous ways to provide unchecked access to a computer (in some cases remotely) with an afflicted version of bash installed. Due to the surprise and scope of this vulnerability, many have dubbed it “Shellshock”, in reference to the combat fatigue experienced by soldiers, but it’s really not a fair comparison to the effects of war.

A “shell” is a program that interprets and acts on textual commands either entered directly by a user at a terminal (or using a virtual terminal like the Terminal app found in /Applications/Utilities on OS X) or from a file containing one or more commands to be run automatically (sort of like a player piano, if that’s even a useful analogy anymore.) Bash is a very common shell program and is the default on many UNIX operating systems, including OS X (as of Mac OS X 10.3 Panther). If you’ve ever opened up the Terminal app and run a command in the last decade, you’ve used bash.

I personally write a fair number of scripts in the bash language to automate various processes on my computers and servers, primarily because it so ubiquitous. It may be partly because I’m a bit of a masochist, but—as a server admin—I also find it helps me perform tasks more efficiently when working in Terminal since it is the default. Needless to say I immediately started investigating the bugs, the attacks, and testing OS X workstations and servers.

Fortunately, without very specific custom configuration, OS X is not vulnerable to remote attacks through the afflicted version of bash, as echoed in the following statement from Apple (given to Jim Dalrymple of The Loop):

The vast majority of OS X users are not at risk to recently reported bash vulnerabilities. […] With OS X, systems are safe by default and not exposed to remote exploits of bash unless users configure advanced UNIX services.

None of the OS X 10.6 Snow Leopard through OS X 10.9 Mavericks systems I tested were vulnerable to remote attacks, however, all versions were susceptible to local attacks. The bugs are such that malicious commands can be inserted into “environment variables” (just what they sound like, data that exists in the environment in which individual shell scripts are run and therefore can be accessed by many scripts) and will be automatically executed upon any bash command or script being run. Not good. Since there are multiple bugs, there are different ways to test for each, but I find running the ‘bashcheck’ script to be very convenient way to test for all of them at once.

The bash developers and community have worked feverishly to investigate and fix these bugs. Apple has released “OS X bash Update 1.0” which includes fixes for the initial pair of bugs, but it unfortunately does not address subsequent bugs. As a further inconvenience, Apple does not provide this update via Software Update or the App Store, so you must download & install the appropriate update for your version of OS X:

OS X bash Update 1.0 – OS X Lion (10.7)
OS X bash Update 1.0 – OS X Mountain Lion (10.8)
OS X bash Update 1.0 – OS X Mavericks (10.9)

For those of you running Mac OS X 10.4 Tiger through 10.6 Snow Leopard on much older Macs, the developers of TenFourFox (an open-source version of the Firefox web browser specifically for older PPC & Intel Macs), provide a download along with detailed instructions to install a version of bash that fixes all the known vulnerabilities at this time. It does require command line experience, so is not for the faint of heart. The updated version provided by the TenFourFox team can also be used on OS X 10.7 Lion through 10.9 Mavericks and actually installs the very latest 4.3.x version of bash as opposed to the older 3.2.x version that Apple includes by default (and provided the partial fix for). This newer version of bash also has some benefits that programmers might enjoy, but it comes at the risk of possibly being downgraded by a future OS X update from Apple.

If you never use the Terminal app, I’d suggest you at least apply the appropriate version of “OS X bash Update 1.0” and any future updates that Apple might release to fix the additional vulnerabilities. For those of you who use Terminal with any frequency, you’ll want to proceed with caution and weigh the pros & cons of relying on Apple’s partial update or manually updating to the latest version of bash for your particular use.

Similar Posts

  • Hulu Plus Now Available On Apple TV

    There has been a lot of talk about the Apple TV recently thanks to the addition of AirPlay Mirroring functionality to Mountain Lion….

  • Create an AirPlay Speaker

    Apple’s AirPlay is one of the best technologies out there for media lovers. AirPlay allows you to control/play your favorite media to devices…

  • Weekly Apple News Recap | 2/13-2/17

    Apple had some notable news this week (but no, the iPad 3 isn’t out yet): Apple Releases Mountain Lion Developer Preview Apple announced…

  • Here come the controllers!

    When I’m playing a game on my iPhone, there are times where I’m thinking, “you know what?” “actual buttons would make this game…

  • Migrate Your Data to a New Mac

    When a customer buys a new Mac, there’s often a question of what to do about the old data. All that old data is all that stuff that made your old machine yours: it’s the settings, the pictures, saved web page bookmarks, documents, spreadsheets…all that stuff.

    Frequently a Mac-to-Mac data transfer can be done without any special equipment or advanced knowledge. The easiest way is to use Apple’s Migration Assistant which is a program built into OS X, and is on every new Mac. When setting up a new Mac (or any Mac that’s been reset to factory settings, generally from the disk being wiped and the OS being reinstalled) it’ll prompt you to make a decision.

    The top option is to transfer data from a start up disk or Time Machine backup. If you’re already doing a Time Machine backup to an external HDD this is the best option, just make sure your backup is completely up to date. If it’s behind, any changes you’ve made won’t show up on your new machine when the transfer completes. Once you’ve identified the drive you want the data to come from it goes through and calculates the sizes of everything on that older drive. You’ve got a little control of what comes over, like whether or not you want the entire Applications folder, but nothing more specific than that. It’ll also tell you how much available space will be left over, or if there’s more data on the source drive than the destination.

    I recommend using a Time Machine backup drive (any external HDD that has a Time Machine backup on it) because it’ll be useful for backups on the new machine. It’ll even see that it’s a new machine that has all the same data and ask if you want to keep using the same Time Machine backup; this is call inheriting.

    Alternatively, you can put the source machine into Target Disk Mode by pressing the T key when the machine is booting and having it connected to the destination machine through Thunderbolt or FireWire. Target disk mode only works through Thunderbolt and FireWire, don’t bother trying anything else. I’ve wasted enough time for us all: it’s not supported. If you’re transferring data from a machine with FireWire but no Thunderbolt to a new Mac that only has Thunderbolt you can get a Thunderbolt to Firewire adapter, but that’ll run you $30 and you might not have another use for it after the data migration. You could also use a Thunderbolt cable, but that’ll also run you at least $30, and again, you might not have another use for it, that’s why I recommend an external HDD. If you’re not doing a backup, it’s worth the peace of mind, and simplifies data transfers.

  • Zoom and Voiceover in iOS

    Working at the Service Check-in Counter, I often have customers asking me how to get out of Zoom and/or Voiceover on their iOS devices. While most people have Zoom and Voiceover disabled, it still shows up now and again.

    If you have used Zoom, the image to the right may seem familiar. If this happens, you can try to enter your passcode and navigate to Settings to turn off Zoom but this can be difficult. An easier way out is a simple 3 finger tap twice which will Zoom you back out.

    If you have seen the image above, then you also must have experienced Voiceover. Instead of using your finger to select individual apps, the screen is sectioned into rectangles, and you select that shape as whole. It is very hard to navigate, and the whole time a voice is instructing your movement. Voiceover is helpful for the visually impaired, but can be a hinderance if turned on. You must navigate back to Settings > Accessibility and turn Voiceover off if you do not wish to use it. If you have the shortcut enabled, you can try triple clicking the home button. This will turn off Voiceover. I would recommend turning off both Zoom and Voiceover, unless of course you need them and are familiar with their commands.