LWN: Comments on "A remotely exploitable hole in bash" https://lwn.net/Articles/613032/ This is a special feed containing comments posted to the individual LWN article titled "A remotely exploitable hole in bash". en-us Thu, 25 Sep 2025 19:33:50 +0000 Thu, 25 Sep 2025 19:33:50 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net A remotely exploitable hole in bash https://lwn.net/Articles/614972/ https://lwn.net/Articles/614972/ k8to <div class="FormattedComment"> Yeah I was thinking of AIX where there is no unsetenv.<br> </div> Sun, 05 Oct 2014 04:39:10 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/614046/ https://lwn.net/Articles/614046/ mathstuf <div class="FormattedComment"> <font class="QuotedText">&gt; …a decent unsetenv.</font><br> <p> FTFY :) . Apparently some implementations just unset the first instance of the variable in the environment, not all of them.<br> </div> Mon, 29 Sep 2014 17:05:38 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613975/ https://lwn.net/Articles/613975/ k8to <div class="FormattedComment"> good thing you're on a platform that supports unsetenv :-D<br> </div> Mon, 29 Sep 2014 11:08:19 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613973/ https://lwn.net/Articles/613973/ nye <div class="FormattedComment"> <font class="QuotedText">&gt;&gt; There is no other interface that is anywhere near as easy to use.</font><br> <font class="QuotedText">&gt;There is no doubt that insecure is always more convenient, actually most of the time insecure is *much* more convenient. The question was: how many more security scandals are required before secure coding starts being seriously rewarded and laziness punished by the market place? No simple answer I'm afraid.</font><br> <p> Imagine the alternative: that there is no standardised way to pass variables across processes and every program needs to implement its own custom parser. That would be a nightmare, and you'd be making pretty much the same complaint, probably suggesting that the only sensible thing to do is to have it done exactly as it is now, so that the parsing is implemented in one shared implementation.<br> <p> You're a very judgemental person, but in the real world it's likely that anyone reading code you've written would be bitching just as much about your scandalous laziness.<br> </div> Mon, 29 Sep 2014 10:55:37 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613971/ https://lwn.net/Articles/613971/ nye <div class="FormattedComment"> <font class="QuotedText">&gt;$ export A='() { echo "My func"; }'</font><br> <font class="QuotedText">&gt;$ bash</font><br> <font class="QuotedText">&gt;$ A</font><br> <font class="QuotedText">&gt;My func</font><br> <font class="QuotedText">&gt;$ echo $A</font><br> <font class="QuotedText">&gt;[nothing here]</font><br> <p> $type A<br> A is a function<br> A ()<br> {<br> echo "My func"<br> }<br> <p> <font class="QuotedText">&gt;Thus make me think that way of the storage is implementation detail</font><br> <p> Almost certainly. This behaviour looks exactly like if the function had been defined in the subshell in the traditional way - functions aren't variables, so variable substitution isn't a meaningful thing to do, but 'type' knows exactly what's up, and so does 'set'.<br> <p> The implementation leaks slightly though, in that the definition is visible in the environment unlike a locally defined function.<br> </div> Mon, 29 Sep 2014 10:34:59 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613916/ https://lwn.net/Articles/613916/ mathstuf <div class="FormattedComment"> <font class="QuotedText">&gt; Stuff like FastCGI has traction in certain areas, but it's already much more complicated.</font><br> <p> I've found using spawn-fcgi works really nicely for keeping CGI services in a separate jail from the webserver itself. So you can write your CGI program then just use the wrapper.<br> </div> Sun, 28 Sep 2014 18:29:37 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613882/ https://lwn.net/Articles/613882/ marcH <div class="FormattedComment"> <font class="QuotedText">&gt; There is no other interface that is anywhere near as easy to use.</font><br> <p> There is no doubt that insecure is always more convenient, actually most of the time insecure is *much* more convenient. The question was: how many more security scandals are required before secure coding starts being seriously rewarded and laziness punished by the market place? No simple answer I'm afraid.<br> <p> <p> <font class="QuotedText">&gt; Offhand I can't think of any other case of something being executed out of an environment variable. Most programs just look at the variables they're interested in and ignore the rest.</font><br> <p> "Most" does not work a security perspective. All details here:<br> <a href="http://www.dwheeler.com/secure-class/Secure-Programs-HOWTO/environment-variables.html">http://www.dwheeler.com/secure-class/Secure-Programs-HOWT...</a><br> <p> </div> Sun, 28 Sep 2014 16:09:01 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613873/ https://lwn.net/Articles/613873/ kleptog <div class="FormattedComment"> The CGI interface is still around because it happens to work really really well. It's allows the webserver to be flexible about which parameters it sends. The CGI script doesn't have to do any fancy parsing, because every parameter is just a getenv() away. It's supported by every programming language.<br> <p> Offhand I can't think of any other case of something being executed out of an environment variable. Most programs just look at the variables they're interested in and ignore the rest. What bash is doing here (looping over variables to find those whose *value* match a particular pattern) is I think pretty rare.<br> <p> There is no other interface that is anywhere near as easy to use. Stuff like FastCGI has traction in certain areas, but it's already much more complicated.<br> </div> Sun, 28 Sep 2014 14:29:49 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613849/ https://lwn.net/Articles/613849/ bronson <div class="FormattedComment"> Not sure what you're arguing... Don't you remember all the breakage reports caused by the devfs removal? And Greg KH's unapologetic emails? (IMO rightfully so, good times) If not, no big deal, there are other user-visible deprecations to be found in feature-removal-schedule.txt.<br> <p> Linux's backward compatibility is nothing short of stellar. It's part of what makes using Linux such a pleasure. But, on the rare occasion that a mistake is made, we don't have to live with it forever. It can be fixed.<br> </div> Sun, 28 Sep 2014 07:25:18 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613840/ https://lwn.net/Articles/613840/ raven667 <div class="FormattedComment"> devfs may not be there but /dev certainly is which is the user facing API. There is no attempt at internal kernel API stability so how things get done are constantly in flux (devfs vs. udev vs. static /dev) but the syscall interface and even /proc and /dev are maintained so that old software can continue to run.<br> </div> Sun, 28 Sep 2014 04:25:23 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613806/ https://lwn.net/Articles/613806/ bronson <div class="FormattedComment"> Nah, features get removed after deprecation periods, even in the Linux Kernel. Can you imagine being burdened with devfs forever?<br> </div> Sat, 27 Sep 2014 23:28:05 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613557/ https://lwn.net/Articles/613557/ marcH <div class="FormattedComment"> <p> After 5 seconds googling:<br> <p> <a href="http://www.dwheeler.com/secure-class/Secure-Programs-HOWTO/environment-variables.html">http://www.dwheeler.com/secure-class/Secure-Programs-HOWT...</a><br> <p> <p> </div> Fri, 26 Sep 2014 23:51:15 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613550/ https://lwn.net/Articles/613550/ sitaram <div class="FormattedComment"> Yes it's blocking more than needed, but I don't see any of the needlessly blocked variants as being useful in real life so it doesn't matter.<br> </div> Fri, 26 Sep 2014 23:04:01 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613535/ https://lwn.net/Articles/613535/ foom <div class="FormattedComment"> There is no way anyone would expect that passing arbitrary user data in the VALUE of controlled environment-variables would cause arbitrary code execution.<br> <p> It is not "drunk" to expect that passing arbitrary values in controlled names is a perfectly reasonable thing to do.<br> <p> I mean, same issue occurs with SSH -- it sets SSH_ORIGINAL_COMMAND to the command that the remote user presented to a restricted command. How could that be insecure?<br> <p> *Clearly* nothing would be trying to eval that as code! That'd be insane!<br> <p> </div> Fri, 26 Sep 2014 21:24:03 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613527/ https://lwn.net/Articles/613527/ raven667 <div class="FormattedComment"> <font class="QuotedText">&gt; had people generally realized that some people on the Internet were not going to be nice</font><br> <p> That viewpoint was out there but wasn't a widely heeded, what we consider normal security engineering today would be considered high paranoia at the time. Packet-filtering firewalls were a new technology at the time and adding DMZs to networks was a radical new thing that people argued about. Having open SMTP relays was considered good form as well 8-)<br> <p> <font class="QuotedText">&gt; feedback I usually get to "get it done" </font><br> <p> Yep.<br> <p> Also passing data in environment variables is a very UNIX-y way to do things which was dominant at the time.<br> </div> Fri, 26 Sep 2014 21:00:37 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613486/ https://lwn.net/Articles/613486/ mpr22 Remote exploits were (in principle) already a known thing, since the <a href="http://en.wikipedia.org/wiki/Morris_worm">Morris worm</a> was unleashed in 1988. Fri, 26 Sep 2014 18:06:19 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613471/ https://lwn.net/Articles/613471/ marcH <div class="FormattedComment"> <font class="QuotedText">&gt; It's easy to point fingers and say that they were stupid or did a bad job in retrospect with 20+ years of experience behind us</font><br> <p> I think it all comes down to this: when CGI was invented (20 years ago already?!) had people generally realized that some people on the Internet were not going to be nice? This is a genuine question.<br> <p> (Answering it might reveal your age, sorry)<br> <p> <p> <font class="QuotedText">&gt; but it's harder to say that given the constraints of the system and the knowledge of the time that you wouldn't have made the same decisions given the same inputs.</font><br> <p> Based on the beat... feedback I usually get to "get it done" I could still be reasonably optimistic :-)<br> <p> More revelant: why the hell is CGI still in use in the same sorry state 20 years and a millions of (not related) security scandals later? OK: now I guess I just need to google "Worse is Better" and do some reading.<br> <p> <p> </div> Fri, 26 Sep 2014 17:36:45 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613466/ https://lwn.net/Articles/613466/ raven667 <div class="FormattedComment"> This is the application of the "Worse is Better(tm)" principal, CGI is a very simple interface that existing systems of the day could easily support. It's easy to point fingers and say that they were stupid or did a bad job in retrospect with 20+ years of experience behind us but it's harder to say that given the constraints of the system and the knowledge of the time that you wouldn't have made the same decisions given the same inputs.<br> </div> Fri, 26 Sep 2014 17:03:20 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613464/ https://lwn.net/Articles/613464/ raven667 <div class="FormattedComment"> <font class="QuotedText">&gt; I don't see any way the benefit of the feature can outweigh all this effort.</font><br> <p> This is an instance of what is a hard and fast rule in the kernel, "Don't Break Userspace(tm)" It doesn't matter how dumb the feature is in retrospect, it has to continue working even after you refactor the implementation, someone out there could be depending on it, probably without even being aware of it.<br> </div> Fri, 26 Sep 2014 16:59:52 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613463/ https://lwn.net/Articles/613463/ cesarb <div class="FormattedComment"> That regexp seems underconstrained. From what I've read, the condition to trigger the vulnerability is the precise four characters "() {" at the beginning of the environment variable; any extra whitespace and bash treats it as a normal environment variable.<br> <p> So it should probably be (untested): /^\(\) \{/.<br> </div> Fri, 26 Sep 2014 16:35:06 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613461/ https://lwn.net/Articles/613461/ bronson <div class="FormattedComment"> Still trying to fix it... First two fixes failed, this third one is in a gray area.<br> <p> <a href="http://seclists.org/oss-sec/2014/q3/741">http://seclists.org/oss-sec/2014/q3/741</a><br> <p> I don't see any way the benefit of the feature can outweigh all this effort.<br> </div> Fri, 26 Sep 2014 16:32:01 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613450/ https://lwn.net/Articles/613450/ marcH <div class="FormattedComment"> So the CGI guys were even drunker.<br> <p> </div> Fri, 26 Sep 2014 15:08:35 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613397/ https://lwn.net/Articles/613397/ gb <div class="FormattedComment"> So bash, by putting multiple instances of the variable with same name into environment of the programs it run, forces that programs into undefined behavior state. Hm...<br> $ bash<br> $ f() { aaa; }<br> $ export -f f<br> $ export f=3<br> $ ksh<br> $ cat /proc/$$/environ |xargs -0 -n1|grep -w f<br> f=3<br> f=() { aaa<br> $ echo $f<br> 3<br> <p> <p> <p> </div> Fri, 26 Sep 2014 14:15:27 +0000 For Debian users https://lwn.net/Articles/613386/ https://lwn.net/Articles/613386/ dskoll <p>Debian users may be slightly better off than other distros if they've kept the default /bin/sh =&gt; dash symlink. <p>Also, the fix in <a href="https://www.debian.org/security/2014/dsa-3032">DSA-3032</a> was not complete. New update is <a href="https://www.debian.org/security/2014/dsa-3035">DSA-3035</a>. Fri, 26 Sep 2014 13:53:15 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613364/ https://lwn.net/Articles/613364/ niner <div class="FormattedComment"> It's not only running bash script through CGI. It's also every other CGI script that uses system() which may end up running bash.<br> </div> Fri, 26 Sep 2014 11:41:16 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613363/ https://lwn.net/Articles/613363/ marcH <div class="FormattedComment"> <font class="QuotedText">&gt; The CGI specification maps all parts to environment variables.</font><br> <p> So, they were drunk.<br> <p> Security rule number 1: sanitize your inputs. CGI's interpretation: let's dump all this random and unfiltered input into the highly sensitive process environment.<br> <p> Like most accidents this is not caused by just one mistake but a combination of them. I'm still not convinced bash is the most to blame. People running bash scripts through CGI should definitely blamed too.<br> <p> </div> Fri, 26 Sep 2014 11:30:12 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613359/ https://lwn.net/Articles/613359/ marcH <div class="FormattedComment"> <font class="QuotedText">&gt; Cool - hidden environment variables. Nice implementation detail.</font><br> <p> Just found this in the standard:<br> <p> <a href="http://pubs.opengroup.org/onlinepubs/7908799/xbd/envvar.html">http://pubs.opengroup.org/onlinepubs/7908799/xbd/envvar.html</a><br> <p> "If more than one string in a process' environment has the same name the consequences are undefined."<br> <p> </div> Fri, 26 Sep 2014 11:05:44 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613346/ https://lwn.net/Articles/613346/ sitaram I took David Wheeler's quote to heart and added one more layer of indirection while the big boys figure out what is the correct patch.<br /> <br /> Copy /bin/bash to /bin/oldbash, put this script in as /bin/bash, and fix up permissions: <pre> #!/usr/bin/perl # env safe bash use strict; use warnings; for (keys %ENV) { delete $ENV{$_} if $ENV{$_} =~ /^\s*\(\s*\)\s*\{/; } exec "/bin/oldbash", @ARGV; </pre> Fri, 26 Sep 2014 08:46:29 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613249/ https://lwn.net/Articles/613249/ gb <div class="FormattedComment"> Thank you for the explanation... Just never thought about it.<br> </div> Thu, 25 Sep 2014 20:31:01 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613232/ https://lwn.net/Articles/613232/ proski I would not say the patch for the original issue is buggy. It's a separate issue that requires <a href="http://seclists.org/oss-sec/2014/q3/690">a separate patch</a>. The new issue doesn't involve passing functions through the environment. It is the parser recovery after invalid function definitions. Thu, 25 Sep 2014 18:55:14 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613229/ https://lwn.net/Articles/613229/ madscientist <div class="FormattedComment"> The "environment" is just an array of nul-terminated strings. Each string is expected to have the form "NAME=VALUE"; so the name of an environment variable is the characters up to and not including the first equals sign. There's no reason that more than one of these strings can't have the same "NAME" part.<br> <p> The typical functional API to the environment provided by C and other languages treats the environment as a set of key/value pairs, so using those functions it's usually not possible to have two variables with the same name. But, if you start a program with execve() for example you give your own list of strings as the environment for the child process, and the members of that list can be whatever you want.<br> </div> Thu, 25 Sep 2014 18:15:48 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613228/ https://lwn.net/Articles/613228/ gb <div class="FormattedComment"> I reached full stop here. Never knew that it's possible to have two environment variables with same name.<br> </div> Thu, 25 Sep 2014 17:52:20 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613226/ https://lwn.net/Articles/613226/ gb <div class="FormattedComment"> Cool - hidden environment variables. Nice implementation detail.<br> <p> $ cat /proc/$$/environ |xargs -0 -n1|grep -w A<br> A=() { echo "My func"<br> <p> <p> $ env|grep -w A<br> A=3<br> A=() { echo "My func"<br> <p> Means that if someone sets such function in HTTP or something.. you would never see it if you just do $ABCD, only if you do env|grep ABCD<br> </div> Thu, 25 Sep 2014 17:43:58 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613220/ https://lwn.net/Articles/613220/ raven667 <div class="FormattedComment"> I'm not sure about that, you can instantly get a shell as the httpd user on any system running CGI that ever executes a sub-process. That's ripe for a worm. Additionally dhcpclient shells out to apply config statements received in a dhcp response, so if you can get in and run a rogue dhcp server, you can take over the workstations in a network as well.<br> </div> Thu, 25 Sep 2014 16:25:54 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613219/ https://lwn.net/Articles/613219/ raven667 <div class="FormattedComment"> <font class="QuotedText">&gt; this is only an issue if your CGI script is actually written as a bash shell script, right?</font><br> <p> No, the way that the httpd passes any variables to the CGI is through the environment, which is inherited across sub-processes, so a CGI in any language that forks a shell due to running system() or `backticks` or implicitly as part of file globbing, even if you are just running a fixed command, is vulnerable.<br> </div> Thu, 25 Sep 2014 16:23:27 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613215/ https://lwn.net/Articles/613215/ gb <div class="FormattedComment"> A funny thing that you can't detect this variables in your subshell:<br> <p> $ export A='() { echo "My func"; }'<br> $ bash<br> $ A<br> My func<br> $ echo $A<br> [nothing here]<br> $ bash<br> $ A<br> My func [still???]<br> $ export A=3<br> $ bash<br> $ A<br> My func<br> $ echo $A<br> 3<br> <p> Thus make me think that way of the storage is implementation detail and it _may be_ backdoor since day 1 15 years ago.<br> And how does bash passed both A and My func to subshell here?<br> </div> Thu, 25 Sep 2014 16:21:08 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613210/ https://lwn.net/Articles/613210/ cortana <div class="FormattedComment"> AIUI this allows anyone on the internet to inject code into the environment of any CGI script with something like:<br> <p> <font class="QuotedText">&gt; curl -H 'foo: () { evil; }' <a href="http://foo.example/cgi-bin/somebashscript">http://foo.example/cgi-bin/somebashscript</a></font><br> <p> Now somebashscript has an attacker-supplied shell function, HTTP_foo. I am deeply uncomfortable with the fact that the script is only one typo away from running it. I would prefer this feature to be ripped out entirely, or at least disabled unless a script runs 'shopt -p terrifying_code_injection'.<br> </div> Thu, 25 Sep 2014 15:57:19 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613208/ https://lwn.net/Articles/613208/ foom <div class="FormattedComment"> This feature should not exist. It's insane to be inspecting the values of arbitrary env vars for a special starting string.<br> <p> If one actually WANTS to eval code from an env var, it's trivial to do so, either by setting BASH_ENV to point to a file you want run, or by starting your subscript with a call to 'eval "$BASH_EVAL_ME_FIRST"'. There's no need for it to be part of bash at all.<br> <p> I'd really vote for simply killing this misguided "export -f" feature entirely.<br> <p> But if not, the best way to implement this feature is probably to have bash itself call 'eval "$BASH_EVAL_ME_FIRST"' at startup, and have "export -f" simply append all exported functions into a shell script fragment in that one variable.<br> <p> Then at least it's clear that allowing that variable to be set allows arbitrary code execution (like BASH_ENV being set to a filename does). Don't need to worry about parser vulnerabilities, or potentially overriding existing functions/binaries.<br> <p> And it's unlikely that remote users will be able to set such a varible.<br> </div> Thu, 25 Sep 2014 15:51:30 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613209/ https://lwn.net/Articles/613209/ cortana <div class="FormattedComment"> Out of interest--what do you use it for?<br> </div> Thu, 25 Sep 2014 15:48:09 +0000 A remotely exploitable hole in bash https://lwn.net/Articles/613204/ https://lwn.net/Articles/613204/ thedevil <div class="FormattedComment"> I use it. Please do not remove it 8-0<br> <p> If "sounds dangerous" was a reason not to use something, I don't think I'd be typing this now on my computer ...<br> <p> </div> Thu, 25 Sep 2014 15:28:00 +0000