News for hackers. Stuff that matters.
Re:CVE-2014-6271: Remote code execution through bash by agwa on Wednesday September 24, 2014 @12:24PM (#8362345)
The API for system() is not great, but the execve family of functions are not drop-in replacements since they don't take care of forking, changing the signals, and waiting. As long as you're not passing arguments from outside sources to the command, using system() should be OK.
Re:CVE-2014-6271: Remote code execution through bash by __david__ on Wednesday September 24, 2014 @02:47PM (#8363329)
> the execve family of functions are not drop-in replacements since they don't take care of forking, changing the signals, and waiting.

Maybe not in C, but they are a drop-in replacement in just about every scripting language. Perl, Ruby, Python, all have nice high level calls that mostly mimic system() but use execve underneath—You simply pass system() multiple arguments instead of a single string. `system("")` in your production web app server code is almost certainly incorrect.

Sadly I think PHP still doesn't have this.

> As long as you're not passing arguments from outside sources to the command, using system() should be OK.

Very true, but think about whether you really need a shell to launch your command (are you using any shell features?). If not, why not just launch the command directly?

Re:CVE-2014-6271: Remote code execution through bash by clarry on Wednesday September 24, 2014 @12:28PM (#8362370)
And in some cases invoking the shell and letting it do its thing is expected, intended and desirable.
Re:CVE-2014-6271: Remote code execution through bash by wahern on Wednesday September 24, 2014 @07:31PM (#8364733)
Would you execute random Perl or Python code from the internet? No, you wouldn't, even if you tried to sanitize it a thousand ways from Sunday. So why would you do so for the shell?

Defense must use different strategies than offense. An engineer's goal should be to reduce the problem space to something as small as possible, so he has a better chance at implementing a correct solution. Allowing the shell to be invoked is a good way to explode your exploitable surface area.

Anybody who coded in the 1990s knows to stay away from the shell like the plague, even though the syntax parsing and evaluation components in modern shells have improved considerably. Sadly this particular bug harks back to the bad days, when it was more difficult to tell how certain constructs would be evaluated.

It's not that you can't theoretically do it securely, it's just that you're gratuitously playing with fire--fire that has burned countless engineers in the past. The cost+benefit is so indisputably skewed toward little cost and huge risk that it's unprofessional to suggest otherwise.

The shell shouldn't come anywhere near network-facing software, period.

Re:CVE-2014-6271: Remote code execution through bash by asveikau on Wednesday September 24, 2014 @01:16PM (#8362701)
> are not drop-in replacements since they don't take care of forking, changing the signals, and waiting.

I never claimed it as a drop-in replacement. I think you know the solution to these problems. (I guess maybe someone who naively uses system() might not, so perhaps I need to work on a better spiel.)

> As long as you're not passing arguments from outside sources to the command, using system() should be OK.

Personally I've seen too many bad uses of system() to make that a thing. Maybe they'll not realize it's subject to PATH and that PATH can be untrusted. Maybe they'll not realize they sometimes have asterisks and spaces in a filename. And so forth...