You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by James Tolley <ja...@emarch.net> on 2003/10/08 23:22:34 UTC

$ENV{PATH} and PerlTaintCheck On

Hi,

Date::Manip is used from a module that's used from a handler. Perl dies
when I try to ParseDate or Unixdate a date - saying that $ENV{PATH} is
insecure.

I've tried to set $ENV{PATH} = '...' in a BEGIN block, and I've tried
setting it from PerlSetEnv PATH ...

How can I untaint $ENV{PATH}??

Many Thanks,

James


Re: $ENV{PATH} and PerlTaintCheck On

Posted by Stas Bekman <st...@stason.org>.
James Tolley wrote:
> Hi,
> 
> Date::Manip is used from a module that's used from a handler. Perl dies
> when I try to ParseDate or Unixdate a date - saying that $ENV{PATH} is
> insecure.
> 
> I've tried to set $ENV{PATH} = '...' in a BEGIN block, and I've tried
> setting it from PerlSetEnv PATH ...
> 
> How can I untaint $ENV{PATH}??

Did you localize it in the BEGIN block? Where was this block defined?

You should be able to easily reproduce the problem outside mod_perl, turning 
it into a perl question ;) e.g.:

% perl -wTle 'print `ls`'
Insecure $ENV{PATH} while running with -T switch at -e line 1.

% perl -wTle 'local $ENV{PATH} = "/bin"; print `ls`'
Insecure $ENV{BASH_ENV} while running with -T switch at -e line 1.

% perl -wTle 'local $ENV{PATH} = "/bin"; local $ENV{qw(BASH_ENV)}; print `ls`'
a.out
...



__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: $ENV{PATH} and PerlTaintCheck On

Posted by Ged Haywood <ge...@www2.jubileegroup.co.uk>.
Hi there,

On Wed, 8 Oct 2003, James Tolley wrote:

> Date::Manip is used from a module that's used from a handler. Perl dies
> when I try to ParseDate or Unixdate a date - saying that $ENV{PATH} is
> insecure.
> 
> I've tried to set $ENV{PATH} = '...' in a BEGIN block, and I've tried
> setting it from PerlSetEnv PATH ...
> 
> How can I untaint $ENV{PATH}??

You have to do it in those (appropriate) places where the data appear,
in every request.  Use a substitution command to convert characters
from user input which might become dangerous if your scripts can use
them as input to things like system calls.

See for example:

Perl documentation in 'perldoc perlsec',
Chapter 15 of the mod_perl Developer's Cookbook,
and http://www.gunther.web66.com/FAQS/taintmode.html

73,
Ged.