Bug 46644 - Clean way to pass custom environment variables to suexec-ed CGI script
Summary: Clean way to pass custom environment variables to suexec-ed CGI script
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_suexec (show other bugs)
Version: 2.5-HEAD
Hardware: All All
: P2 enhancement with 2 votes (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
Depends on:
Reported: 2009-01-31 13:40 UTC by Matt McCutchen
Modified: 2011-07-11 22:03 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Matt McCutchen 2009-01-31 13:40:31 UTC
It's sometimes desirable to have a suexec-ed CGI script read a custom environment variable to find out what it is supposed to do.  I described my scenario, where a CGI script needed to know which of three RewriteRules called it, at:


The problem is that, for good security reasons, suexec strips out all environment variables except for a whitelist consisting of standard ones set by the Web server.  I would like a safe, supported convention for passing custom environment variables.  (I can stuff them in the HTTP_ namespace, but that's a hack.)  Furthermore, internal redirects should not break the convention.

The obvious solution is to allocate a new namespace.  I previously suggested CGI_, but now I'm thinking SUEXEC_ may be better.  REDIRECT_SUEXEC_ vars could either be passed through or renamed to SUEXEC_REDIRECT_ .  An interesting additional possibility would be to prepend SUEXEC_ to unsafe variables instead of dropping them; this way, the entire environment would be available to suexec-ed CGI scripts (but not in a form that could subvert them) without any extra work on the Apache side.
Comment 1 Graham Laverty 2011-07-11 22:00:27 UTC
Seconded.  This really is a feature request rather than a bug, so I'm updating the version to reflect head.