Bug 46644

Summary: Clean way to pass custom environment variables to suexec-ed CGI script
Product: Apache httpd-2 Reporter: Matt McCutchen <matt>
Component: mod_suexecAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: NEW ---    
Severity: enhancement CC: graham
Priority: P2    
Version: 2.5-HEAD   
Target Milestone: ---   
Hardware: All   
OS: All   

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.