Return-Path: X-Original-To: apmail-httpd-dev-archive@www.apache.org Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E30F01776D for ; Mon, 29 Sep 2014 09:08:07 +0000 (UTC) Received: (qmail 36901 invoked by uid 500); 29 Sep 2014 09:08:07 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 36823 invoked by uid 500); 29 Sep 2014 09:08:07 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 36813 invoked by uid 99); 29 Sep 2014 09:08:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Sep 2014 09:08:07 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [209.20.83.52] (HELO gungnir.webthing.com) (209.20.83.52) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Sep 2014 09:08:02 +0000 Received: from [192.168.0.5] (cpc14-newt30-2-0-cust22.newt.cable.virginm.net [92.232.45.23]) by gungnir.webthing.com (Postfix) with ESMTPSA id 353C61280DB for ; Mon, 29 Sep 2014 09:07:41 +0000 (UTC) Message-ID: <1411981660.20431.62.camel@mimir.webthing.com> Subject: Re: Proposed simple shell-shock protection From: Nick Kew To: dev@httpd.apache.org Date: Mon, 29 Sep 2014 10:07:40 +0100 In-Reply-To: References: <20140926154143.64f5f81f@baldur> <54287938.8060308@kippdata.de> <1411970347.20431.49.camel@mimir.webthing.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.4.4-3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On Mon, 2014-09-29 at 09:43 +0200, Yann Ylavic wrote: > On Mon, Sep 29, 2014 at 7:59 AM, Nick Kew wrote: > > On Sun, 2014-09-28 at 23:10 +0200, Rainer Jung wrote: > > > >> IMHO it is a useful approach. Whan I looked at the CGI topic, I noticed > >> that the safest thing is cleaning up in ap_create_environment(), because > >> you can be sure to get every env var in your hands there, not only the > >> ones coming from headers. > > > > The "shellshock" recipe for mod_taint takes a bit of a kitchen-sink > > approach: > > - The Request headers > > - The Request fields that haven't always been fully sanitised > > and that might try to smuggle something: PATH_INFO and > > QUERY_STRING (r->args). > > - subprocess_env > > mod_taint uses the header_parser hook to untaint the request > headers/fields, but this is too early for subprocess_env. Yes. It's catching potential attacks in r->headers_in. The rest is paranoia-mode afterthoughts: PATH_INFO/QUERY_STRING because they could contain something interesting, subprocess_env just "because it's there" (there's a code comment about "just to be paranoid"). > As Rainer noticed httpd is probably missing a env_parser hook that > could be called by ap_create_environment(), but still that would not > apply to [fs]cgi (which don't use it). > > So maybe rather than defining a hook that would work on the whole char > **env, we could have one working on any key/value pair like : > > AP_IMPLEMENT_HOOK_RUN_ALL(int, env_parser, > (apr_pool_t *p, const char **key, const char > **value), (p, key, value), OK, DECLINED) > > This seems quite costly though... Agreed. A whole new hook, just to catch a bug that isn't ours! The taint principle is to focus precisely on data coming from the untrusted source - i.e. over the Web. That's what mod_taint does. If it's missing anything, it would have to be something that happens before header_parser: for example, could a RewriteMap invoke a shell somewhere early? The other vector if something in HTTPD parses input and puts the parsed data into env. For example, if a custom module decrypts an encrypted identity token and puts it into the subprocess environment. I was going to say that's beyond the scope of anything we can/should do, but I guess REMOTE_USER is indeed our business. -- Nick Kew