shellschock - bash bug

Has anyone heard of the bash bug, shellshock. Google it. I'd like to hear what anyone thinks about how this might affect the average Mac user, as the mac ecosystem runs off linux and many apps us bash, or bourne shell, etc ... and websites that run off apache. Anyone?

GarageBand (Mac) '11, OS X Mavericks (10.9.2)

Posted on Sep 26, 2014 6:46 AM

Reply
16 replies

Sep 26, 2014 7:35 AM in response to Goody7

... I'd like to hear what anyone thinks about how this might affect the average Mac user,


It's doesn't affect the average Mac user. If you are running a web server, apply the patch by downloading it from the GNU project archive. If you don't know what that is, how to obtain it, or how to apply it to your server, then you are not affected.


Apple announced they are "working to quickly provide a software update for our advanced UNIX users."


There are plenty of bad things that could happen to a system due to existing vulnerabilities, known or unknown. There is no reason for any more concern today than there has ever been. Bash has been included with OS X for years, perhaps since its inception.


Similar vulnerabilities may also be discovered and exploited, now or in the future. The resulting effects, if there are any, cannot be accurately predicted.


Until then:


  • Ignore hyperventilating popular media outlets that thrive by promoting fear and discord with entertainment products arrogantly presented as "news". Learn what real threats actually exist and how to arm yourself against them.
  • Do install updates from Apple as they become available. No one knows more about Macs and how to protect them than the company that builds them.

Sep 27, 2014 10:01 AM in response to etresoft

With no small amusement, I ran a few of the proposed ShellShock tests against KSH, and it is immune. 😉


With Apple's aversion to GPL3, we may see patched versions of Bash 3.2 on OS X for the foreseeable future, while Linux platforms offer Bash 4.3.11 and later. So far, I haven't encountered limitations in Bash 3.2 that block me from my script goals, or interfere with an occasional cross-platform script functionality.

Sep 27, 2014 4:34 PM in response to VikingOSX

So far, I haven't encountered limitations in Bash 3.2 that block me from my script goals, or interfere with an occasional cross-platform script functionality.

Is mostly good, but I had issues with command line editing back in some previous Mac OS X (Tiger perhaps), so I built and installed bash 4.0.


Then I ended up building and using my 4.0 bash on Solaris and AIX, as the systems I was using at work, were even older versions of bash 🙂


I would say the biggest addition to the 4.* series was associated arrays (I had to look that up, as I do not use it in my scripts), and a bunch of other less used things.


I took this opportunity to upgrade to bash 4.3.25


The thing I like the most about bash is "Process Substitution"


while

do

...

done < <(some command)


What this does is allow the 'while' loop to remain in the current script context with any variable changes being seen after the loop ends. This is vs


some command | while

do

....

done


where the 'while' is execute in a subshell and all variable changes remain in the subshell and go away when the 'while' loop ends.

Oct 11, 2014 7:02 AM in response to BobHarris

Bob,


Looks like you are committed to Bash 4.x 😉


The following script that incorporates associative arrays and process substitution works fine on Mavericks, and likely ML, and Lion with Bash 3.2.


#!/bin/bash
# Finds and reports Microsoft Document Kinds
# Dependency: Spotlight must have indexed the folders you process
# Author: VikingOSX, 19/08/2014, Apple Support Community


# initialize an array
declare -a msDocs=("Microsoft Word*" "Microsoft Excel*" "Microsoft Power*");
DIR="$HOME/Documents"
OUTDOC="$HOME/Desktop/Wordfiles.txt"
OUTXLS="$HOME/Desktop/Excelfiles.txt"
OUTPPT="$HOME/Desktop/Powerptfiles.txt"


# loop through the array of document kinds
for kind in "${msDocs[@]}"
do
  # process each file from mdfind run
  while read -r filetype
  do


  if [[ "$kind" == *"Microsoft Word*" ]];
  then
  printf "%s\n" "$filetype" >> $OUTDOC
  continue
  elif [[ "$kind" == *"Microsoft Excel*" ]];
  then
  printf "%s\n" "$filetype" >> $OUTXLS
  continue
  elif [[ "$kind" == *"Microsoft Power*" ]];
  then
  printf "%s\n" "$filetype" >> $OUTPPT
  fi


  done < <(mdfind -onlyin "${DIR}" -name 'kMDItemKind == "'"$kind"'"cwd' | sort -d)


done
# release the array
unset msDocs
exit 0

Oct 11, 2014 8:12 AM in response to VikingOSX

Looks like you are committed to Bash 4.x

Mostly I was committed to working working command line editing on very long lines that wrap across multiple lines, and at the time (Tiger) Mac OS X bash was not cutting it, so that is why I built my own newer bash.


The following script that incorporates associative arrays and process substitution works fine on Mavericks, and likely ML, and Lion with Bash 3.2.

I absolutely love process substitution. It solved so many problems, where in the past I would have to implement a complex workaround. When I look at shell scripting books these days, the first thing I do is check if the author has provided any process substitution descriptions and examples.


Your script is good, however, the arrays are the numeric indexed arrays, not associative arrays. NOTE: I only bash arrays numeric indexed (like I said, I only switched to 4.x because of command line editing, not array features. Although thinking about is, if I need an associative array, I'm used awk or perl and spit the processed answer out for bash to use. Maybe I should be thinking about implementing directly in bash. Interesting).


Here is a simple example of associative arrays in bash (it doesn't really do anything useful, just demos associative arrays):


#!/usr/bin/env bash

declare -A a    # create associative array

a["abc_key"]=def
a["qrs_key"]=xyz

echo "${a[@]}"   # display associative array contents
echo "${!a[@]}"  # display associative array keys
echo "${a["abc_key"]}"  # use key to access value
echo "${a["qrs_key"]}"  # use key to access value

exit

$ bash associative_array_example.sh  # run the example
def xyz
abc_key qrs_key
def
xyz

All of my shell scrips, and I have lots of them (one 13,000 lines long) can run in bash 3.2. And for all I know, the very long command line editing issues I had back in Tiger have been cured. But as my 4.x bash isn't broke, and I have copies for Mac OS X, Linux, Solaris, and AIX, it gives me a stable command line environment to work in.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

shellschock - bash bug

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.