• On CBS MoneyWatch: 20 Worst-Paying College Degrees
advertisement
February 21, 2006 11:30 AM PST

Explanation, fixes for "Safari Automatically Executes Shell Scripts" vulnerability; similar to Widget vulnerability

by CNET staff

Originally posted February 21st

As we noted below in "Odds and Ends", the "Safari Automatically Executes Shell Scripts" vulnerability that has recently garnered increased discussion is extremely similar in nature to a bug we discussed in the middle of last year, where Safari would automatically open a compressed .zip file and execute a potentially malicious Widget.

The scenario for that vulnerability went like this:

You click on a seemingly innocuous link, and view the resulting page's content. Meanwhile, a meta tag embedded in the page (META HTTP-EQUIV="Refresh") downloads a Widget in the background, and Safari -- which is, by default, set to automatically open "trusted" files, including Widgets -- quietly places the newly downloaded Widget in the ~/Library/Widgets folder. The next time you access Dashboard, the Widget is loaded in the Dashboard storage bar, and executed when you click it or drag it out of the bar. The only indication you will receive in Safari indicating that this process is happening is a generally unnoticeable refresh of the URL address bar.

The vulnerability was fixed in Mac OS X 10.4.1.

The new issue is virtually identical to the Widget vulnerability, except this time shell scripts without a "shebang" line -- which tells the script which shell to execute in -- are implicated. Without the aforementioned line, Safari no longer recognizes the content as potentially dangerous and executes shell commands without a confirmation prompt.

As we noted previously and in our coverage of the Widget vulnerability, there are some effective ways to mitigate this threat:

Turn off "Open 'safe... Turn off the option "Open 'safe' files after downloading" in the "General" pane of Safari's preferences.

Use a different browser Use an alternative browser like Firefox

Make Terminal ask for permission This is the most involved workaround, and probably the most effective. It involves replacing the Terminal application with an automator script that will intercept calls to Terminal and seek your permission to run Terminal before executing.

  1. First you will need to download the Automator script, created by a MacFixIt reader, by going to the "Go" menu in the Finder, navigating to the "iDisk" sub-menu, selecting "Other User's Folder" then typing "pehowland" (without quotes) and pressing return.
  2. Next, download the file named "Terminal.app.zip" and unstuff it. The resulting file will be an Automator script application named "Terminal.app" or just "Terminal" if you have file extension display turned off.
  3. Next, using the Finder, go to /Applications/Utilities and rename Terminal.app to _Terminal.app.
  4. Copy the replacement Terminal.app (the Automator script) into /Applications/Utilities
  5. Now every time a shell script attempts to launch the Terminal, the automator script will launch instead and demand user permission before the actual Terminal is launched.

If you want to undo this process, just delete my new Terminal.app and rename _Terminal.app back to Terminal.app.

The author of the script writes:

"This fix works on my machine and seems completely harmless. However, use it at you own risk - I am not responsible for any unintended side effects.

"The paranoid amongst you should also verify my script inside Automator before installing - after all, I could just be playing a nasty social engineering joke on you."

Feedback? Late-breakers@macfixit.com.

Resources

  • "Odds and Ends"
  • Late-breakers@macfixit.com
  • More from Late-Breakers
  • Recent posts from MacFixIt
    iTunes 10 user interface sees some minor changes
    Apple seeds iOS 4.1 Gold Master to developers
    Possible fix for Harman Kardon iSub problems with PowerPC Macs
    Precautions to take before installing iTunes 10
    A reminder on how to reset your Mac's system password
    Mail messages appearing blank
    Adobe Lightroom update brings direct Facebook publishing; Camera Raw 6.2 released
    Weekly troubleshooting utilities update
    Add a Comment (Log in or register) (12 Comments)
    • prev
    • next
    by iGreg February 21, 2006 12:28 PM PST
    I thought there was free program that could do this to protect Terminal. I forgot
    its name.

    ---
    iMac G5, 17", 1.8 GHz, 1GB RAM
    PowerBook G4, 12", 1.5 GHz, 768 MB RAM
    Both OS 10.4.5
    Reply to this comment
    by iGreg February 21, 2006 12:28 PM PST
    <class="merchant"><span>&#62;</span><div class="datestamp"><i>This is a reply to a previous comment by iGreg</i></div></class><br />
    I found the name of the application that I think would do this, "RC Default." But,
    I am not sure how to set it to accomplish this.

    http://www.versiontracker.com/dyn/moreinfo/macosx/22977

    ---
    iMac G5, 17&quot;, 1.8 GHz, 1GB RAM
    PowerBook G4, 12&quot;, 1.5 GHz, 768 MB RAM
    Both OS 10.4.5
    Reply to this comment
    by iGreg February 21, 2006 12:28 PM PST
    <class="merchant"><span>&#62;&#62;</span><div class="datestamp"><i>This is a reply to a previous comment by iGreg</i></div></class><br />
    I have since found out from author of RC Default that it is NOT a solution to this issue.

    ---
    iMac G5, 17&quot;, 1.8 GHz, 1GB RAM
    PowerBook G4, 12&quot;, 1.5 GHz, 768 MB RAM
    Both OS 10.4.5
    Reply to this comment
    by paintmastercollision February 21, 2006 12:31 PM PST
    In <b>Make Terminal ask for permission</b> above, you should know that you
    in Finder you want to choose: Go --> iDisk --> Other Users Public Folder to
    access the Terminal.app Automator Script.
    Reply to this comment
    by Gordon Alley February 21, 2006 12:31 PM PST
    <class="merchant"><span>&#62;</span><div class="datestamp"><i>This is a reply to a previous comment by paintmastercollision</i></div></class><br />
    The substitute Terminal.app fix works fine for now. But as soon as the exploit
    writers are aware of it, it will be pretty easy to circumvent.

    On my Mac, I've modified the Automator workflow to use a different name for
    the "real" Terminal program, and renamed the app appropriately. It can still be
    circumvented, but not quite so easily now.
    Reply to this comment
    by VL-Tone February 21, 2006 6:53 PM PST
    Is it really so similar to the Widget vulnerability?

    The Widgets were only installed, not run automatically.
    Reply to this comment
    by mattwhiting February 22, 2006 2:21 AM PST
    If the fix relies on hiding Terminal.app by prefixing it with an underscore, and
    this is made publicly available, surely any malware writer need simply adapt the
    code to search for this as an alternative, and the fix is rendered useless?
    Reply to this comment
    by Jean-Luc February 22, 2006 2:21 AM PST
    <class="merchant"><span>&#62;</span><div class="datestamp"><i>This is a reply to a previous comment by mattwhiting</i></div></class><br />
    You are correct
    lets hope Apple fix it properly in the next security update or system update
    Reply to this comment
    by xmrocks February 22, 2006 2:21 AM PST
    <class="merchant"><span>&#62;&#62;</span><div class="datestamp"><i>This is a reply to a previous comment by Jean-Luc</i></div></class><br />
    You're right that it doesn't make sense to have others to tell you what to name
    your Terminal application. However, that's not the only name you can name it.
    You can name it whatever you please and it will still work.

    That way, the "bad people in this world" can't just send out a generic script
    allowing attacks on _Terminal.app because they have no idea what your
    Terminal has been renamed to.

    -Ryan
    Reply to this comment
    by jdrake777 February 22, 2006 2:21 AM PST
    <class="merchant"><span>&#62;</span><div class="datestamp"><i>This is a reply to a previous comment by mattwhiting</i></div></class><br />
    And surely anyone that is going to use this proceedure will be (should be) smart enough to change the lead character to something else, even to go so far as to also change the name of the real Terminal app. Then unless the malware goombas are smart or patient enough to write their code to look for any and all possible combinations (how many lines of code would that take?) you'd be safe.
    Reply to this comment
    by gpell February 22, 2006 12:57 PM PST
    For those users who are not interested in running Terminal, there?s an easy solid solution.

    1. Do your browsing in a non-admin account (as has been suggested elsewhere). (Create an admin account just for system maintenance work and set your current account to non-admin.)

    2. In the System Preferences Accounts pane set up parental controls for the non-admin account to deny usage of Terminal and maybe a few other utilities. (The system won?t let you do this on an admin account.)
    Reply to this comment
    by bperry1 February 22, 2006 5:46 PM PST
    If you do rename the terminal app, (or move it to a new location) be sure to CHANGE THE NAME BACK to Terminal.app and/or move it back to User/applications/utilities before running any System Updates or the updater may not update your Terminal, yes?
    Reply to this comment
    (12 Comments)
    • prev
    • next
    advertisement

    About MacFixIt

    MacFixIt is CNET's troubleshooting resource for all things Mac. The information here helps you navigate the ins-and-outs of Mac ownership with how-tos, troubleshooting information, news, reviews, and more.

    Add this feed to your online news reader