News for hackers. Stuff that matters.
Re:Bash 'shellshock' bug is wormable by cperciva on Thursday September 25, 2014 @12:25AM (#8365617)
I run no Linux/Unix/MacOS/compatible/etc machine which connects other machines

How about "I don't run bash"? There are other perfectly good shells, you know...

Re:Bash 'shellshock' bug is wormable by quesera on Thursday September 25, 2014 @12:58AM (#8365698)
Or "I don't run UNIXes that default to bash, or hide it under /bin/sh, etc."

Unfortunately, bash shows up in surprising places, including default Solaris installs nowadays.

On OSX and Solaris, I've chmod'ed 0000 /bin/bash with no apparent ill effect so far. I'll put more effort into establishing its acceptability as a solution tomorrow.

BSDs won't have bash unless someone has gone out of their way to install it, which can be undone straightforwardly.

But it could be a long night for our Linux brethren and sistren.

Good luck, and remember to stay hydrated. :)

EDIT: obviously, don't chmod 0000 your login shell! Fix that first. Make sure whatever you switch to isn't a symbolic or hard link to bash.

Re:Bash 'shellshock' bug is wormable by bodyfour on Thursday September 25, 2014 @04:09AM (#8366146)
> On OSX and Solaris, I've chmod'ed 0000 /bin/bash with no apparent ill effect so far.

In the case of OSX, /bin/sh is also bash. For some reason they are separate binaries (at least on my laptop running 10.9.5) but they're both really bash inside:

    $ ls -ld /bin/sh /bin/bash
    -r-xr-xr-x  1 root  wheel  1228240 Sep 21 21:37 /bin/bash
    -r-xr-xr-x  1 root  wheel  1228304 Sep 21 21:37 /bin/sh
    $ /bin/sh --version
    GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)
    Copyright (C) 2007 Free Software Foundation, Inc.
    $ /bin/bash --version
    GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)
    Copyright (C) 2007 Free Software Foundation, Inc.
So even if you chmod bash to 0 you could still be exposed by anything that uses /bin/sh -- system(), popen(), most shell scripts, etc

(ETA: as I've mentioned elsewhere in this thread most people running OSX probably aren't badly impacted since they're not running CGI-based web software or other high-risk activity. I'm just pointing out that your bash-ectomy of OSX isn't as complete as you think it was)

Re:Bash 'shellshock' bug is wormable by quesera on Thursday September 25, 2014 @10:24AM (#8367297)
Yikes, yes. Thanks for pointing that out!

There might be more of an impact than expected on OSX, too -- no telling what Apple does with their system services.

We've seen mention of dhcp-client and CUPS. The latter, at least, could also be an issue on OSX.

Re:Bash 'shellshock' bug is wormable by patio11 on Thursday September 25, 2014 @12:53AM (#8365688)
You and Thomas can ignore everything I say about security. J. Random Rails Developer, on the other hand, probably gets useful signal if I start panicking. (Am I panicking? YES.)
Re:Bash 'shellshock' bug is wormable by inportb on Thursday September 25, 2014 @12:54AM (#8365691)
I suspect that many folks who "don't run bash" actually do use bash quite a bit, e.g. in initscripts and various software packages.
Re:Bash 'shellshock' bug is wormable by stephenr on Thursday September 25, 2014 @02:34AM (#8365908)
Any decent shell script is written to use "sh" not bash, and on debian/etc sh is provided by dash not bash.

So while a lot of people are affected, your reasoning points to other issues that are very solveable

Re:Bash 'shellshock' bug is wormable by erikb on Thursday September 25, 2014 @03:11AM (#8366002)
This more of a "should be", right? Maybe most shell scripts should use "sh" but I see "bash" way more often.
Re:Bash 'shellshock' bug is wormable by stephenr on Thursday September 25, 2014 @03:50AM (#8366100)
I guess it comes down to how you interpret things.

I specifically said any decent shell script. My logic is that if it is not using "sh", but instead relying on bash (or any other specific shell really), it's not a decent shell script.

If I were to amend the sentence to make the meaning clearer, I would still not use "should be", I would use "must be".

Re:Bash 'shellshock' bug is wormable by eropple on Thursday September 25, 2014 @12:23PM (#8367974)
You're overreaching. I write scripts against bash, not sh, because it's a better scripting language for what I need. It's more readable and its constructs are easier (for me) to follow. I don't care about POSIX-compatibility when bash can be installed literally anywhere. It's a dependency for the devops stuff that I run and maintain, much like Ruby is a dependency and all the gems in my Gemfile.

It's a considered decision, not a sign of "indecency".

Re:Bash 'shellshock' bug is wormable by stephenr on Thursday September 25, 2014 @12:45PM (#8368098)
I suggest you read the accepted answer at http://stackoverflow.com/questions/19428418/what-is-the-use-... for a brief look at why portable shell scripts are a better solution than bash specific scripts.
Re:Bash 'shellshock' bug is wormable by eropple on Thursday September 25, 2014 @01:04PM (#8368212)
I suggest you read my post and maybe let it roll around your head that I've considered my environment and the domain of my problems in a way you aren't giving me credit for. Perhaps even, with that whole mention of devops, I do something such as--crazy thought incoming--install an updated version of bash on every system I must provision, just as I do Ruby, Python, etc.?

"Decent shell script" is not a synonym for "portable shell script" and the presumption therein is what I was addressing.

Re:Bash 'shellshock' bug is wormable by sigzero on Thursday September 25, 2014 @02:09PM (#8368621)
Exactly so. If I want PORTABLE, I write to "sh". If I want BASH, I write to BASH. The term "decent shell script" is wrong the way he uses it.
Re:Bash 'shellshock' bug is wormable by mysidia on Friday September 26, 2014 @06:21PM (#8375207)
Perhaps he didn't deliver the point... but BASH is not a good or safe language to write to.

Writing to '/bin/sh' is understandable due to its ubiquitousness.

Bash is a superset that is not so ubiquitous, so it doesn't have the advantage that writing to /bin/sh does.

If you don't want portable, then don't write to shell script. Write to Perl Ruby or Python, which is also safer and more secure.

Re:Bash 'shellshock' bug is wormable by eropple on Monday September 29, 2014 @01:27PM (#8383905)
/bin/bash is on literally every machine I ever touch. It is on every Debian machine. It is on every Ubuntu machine. It is on every OS X machine. It is on every Windows (!) machine. And there are plenty of operations that are significantly more cumbersome to write in Ruby--otherwise, sure, I would do so. Backticks are nice, but there's no `set -e` (that I am aware of) and it becomes a huge hassle to do things in a smart, error-checking way.
Re:Bash 'shellshock' bug is wormable by stephenr on Monday September 29, 2014 @01:43PM (#8384012)
No-one claimed Bash isn't widely distributed and installed by default.

However, unless you are patching and compiling the same version of Bash, you absolutely do not have the same version on all those machines, and that is the whole reason NOT to target Bash in shell scripts - its features are not always consistent/compatible across versions.

Re:Bash 'shellshock' bug is wormable by lutusp on Monday September 29, 2014 @01:38PM (#8383987)
> /bin/bash is on literally every machine I ever touch. It is on every Debian machine. It is on every Ubuntu machine. It is on every OS X machine. It is on every Windows (!) machine.

Yes. Yes. Yes. Yes. No (unless Cygwin is installed).

Re:Bash 'shellshock' bug is wormable by eropple on Monday September 29, 2014 @05:06PM (#8385300)
/bin/bash is on literally every machine I ever touch. Did you miss the operative phrase?

(I have init scripts for Cygwin, too, because I need Windows but life is too short for CSRSS.)

Re:Bash 'shellshock' bug is wormable by lutusp on Monday September 29, 2014 @09:09PM (#8386255)
> /bin/bash is on literally every machine I ever touch. Did you miss the operative phrase?

You intended that subjunctive clause to apply to all the sentences, an intent I missed. My mistake. :)

This may soon become a tempest in a teapot, as patched Bash versions are now appearing. I just patched all my machines.

Re:Bash 'shellshock' bug is wormable by stephenr on Thursday September 25, 2014 @03:54PM (#8369369)
> "Decent shell script" is not a synonym for "portable shell script"

Only for you. For me and a lot of others I suspect, if it isn't portable it isn't worth the trouble.

If you have to re-compile a newer/older version of a shell to get the same results across machines, any potential benefits start to seem insignificant compared to the effort involved.

Re:Bash 'shellshock' bug is wormable by eropple on Thursday September 25, 2014 @05:32PM (#8369849)
How? I already am running Chef on every machine I touch.
Re:Bash 'shellshock' bug is wormable by stephenr on Thursday September 25, 2014 @09:38PM (#8370874)
So you have a chef recipe to download and compile the same version of bash on every platform you use?

How do you handle situations where bash is included by default?

Do you remove the package or just push your binary over the top?

If you don't remove it, what happens when a package update then replaces your binary?

How often do you update the recipe to make sure it's getting the latest stable version and applying security patches?

Re:Bash 'shellshock' bug is wormable by eropple on Monday September 29, 2014 @01:41PM (#8384004)
> So you have a chef recipe to download and compile the same version of bash on every platform you use?

No, I have a chef recipe to install the newest version of bash 4 everywhere. How is an implementation detail. (I use Ubuntu packages and Homebrew, I only compile on cygwin.)

> How do you handle situations where bash is included by default? Do you remove the package or just push your binary over the top?

On OS X, the only place that's the case, I replace the binary (by using the Homebrew-compiled one).

> How often do you update the recipe to make sure it's getting the latest stable version and applying security patches?

I've written the Chef recipe to not need regular updates. I run my Chef update stuff on a weekly basis. I can do so manually if I need to.

Re:Bash 'shellshock' bug is wormable by stephenr on Monday September 29, 2014 @03:00PM (#8384567)
Bash is known to have version/compatibility issues - Homebrew reports Bash 4.3, but Ubuntu only has 4.3 available for the most recent version - anything from before April will only get 4.2.

This is my whole point - targeting /bin/sh means targeting a POSIX compliant shell, which may be implemented by any number of different codebases, with a defined standard to meet. Posix mode in Bash 4.3 should be the same as Posix mode in Bash 3.9, etc. - targeting /bin/bash means targeting whatever specific bash oddities come with the version installed.

Re:Bash 'shellshock' bug is wormable by eropple on Monday September 29, 2014 @05:10PM (#8385318)
That's a fair point for bash ultra-power users. It doesn't really reflect on my use case. I don't exactly pull out all the stops. I use [[ ]] and set -e, which have very familiar semantics that haven't changed for a long time, and that's about it. I am very confident in my selection of "portable bash"-isms as far back as 3.2 (running 4.x on OS X has only come on recent, I added it a couple months ago).

Don't get me wrong: I could use /bin/sh. But I would have to write worse code to do it. I'll take the possibility of a bash regression over writing all my shell scripts in sh.

Re:Bash 'shellshock' bug is wormable by SamReidHughes on Saturday September 27, 2014 @05:47PM (#8378307)
Gosh, you are so clever.
Re:Bash 'shellshock' bug is wormable by yen223 on Thursday September 25, 2014 @04:16AM (#8366163)
If you can confidently assert that every shell script your system runs is "decent", then you'll have no problem. The thing is, very few of us can confidently make that assertion.
Re:Bash 'shellshock' bug is wormable by stephenr on Thursday September 25, 2014 @05:29AM (#8366336)
That all depends where your shell scripts come from.

In my experience most of the shell scripts provided by packages for debian, do use /bin/sh.

A quick check of .sh files on a couple of squeeze/wheezy installs showed that the vast majority of shell scripts using Bash come from node modules, which quite frankly is not surprising.

Re:Bash 'shellshock' bug is wormable by dllthomas on Monday September 29, 2014 @02:23PM (#8384289)
There is tremendous range in what a "shell script" might be. I vastly prefer bash to sh as a user shell. Often times, I have bits of logic I express in a command that I want to capture and reuse, and they get grabbed and dropped in a (frequently context specific) bin directory. I would contend that these "save me from typing it out" shell scripts should mimic what I would type myself. Once they wind up being more general, I usually rewrite them in a different language entirely. That's a very different context than something like an init script, though.
Re:Bash 'shellshock' bug is wormable by TeMPOraL on Thursday September 25, 2014 @08:08AM (#8366710)
Still, isn't sh quite often implemented as an alias/symlink for bash nowdays?
Re:Bash 'shellshock' bug is wormable by samuellb on Thursday September 25, 2014 @09:50AM (#8367089)
Yes, but Debian and Ubuntu has changed their default shell to Dash (in 2006 I think), and embedded systems usually use some lightweight shell such as BusyBox. So far from all systems do.
Re:Bash 'shellshock' bug is wormable by stephenr on Thursday September 25, 2014 @10:38AM (#8367382)
Just to clarify a little:

By default Debian still uses Bash for interactive user shells, but since Squeeze (early 2011), /bin/sh is provided by Dash.

Dash is used because it's faster than Bash and has less dependencies so its more resilient to failures.

for more info see https://wiki.debian.org/Shell, https://wiki.debian.org/DashAsBinSh and https://packages.debian.org/wheezy/dash

Re:Bash 'shellshock' bug is wormable by TeMPOraL on Thursday September 25, 2014 @09:56AM (#8367132)
Thanks for clarification!
Re:Bash 'shellshock' bug is wormable by wiredfool on Thursday September 25, 2014 @01:02AM (#8365710)
Someone is going to be going through busybox soon, and then there (potentially) will be a whole bunch more exploitable boxes that don't have a generally have a regular update cycle.
Re:Bash 'shellshock' bug is wormable by smellf on Thursday September 25, 2014 @12:55PM (#8368161)
You're right, of course. Exploitable weaknesses in busybox are going to be killer - I think shellshock will turn out to be the start of something really big.

But, to clarify for others, the existing shellshock PoC doesn't work on the busybox environment I tested (v1.20.2).

Re:Bash 'shellshock' bug is wormable by count on Thursday September 25, 2014 @11:40AM (#8367705)
As you well know, as long as your system doesn't use bash for anything, even implicitly :) Many folks are thinking that just because they switched their user's login shell to 'ksh' to be one of the cool ruby kids, that they're safe.