Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Reading ENV variable and using that in taint mode

by sara2005 (Scribe)
on Jun 27, 2006 at 23:24 UTC ( [id://557896] : note . print w/replies, xml ) Need Help??


in reply to Re: Reading ENV variable and using that in taint mode
in thread Reading ENV variable and using that in taint mode

I included /bin to $ENV{PATH} in the script but I still got the error

I still like to use it this way so that I can run some executables by reading from a file

Any thoughts?

Replies are listed 'Best First'.
Re^3: Reading ENV variable and using that in taint mode
by Zaxo (Archbishop) on Jun 27, 2006 at 23:51 UTC

    What I meant is that if you say (in the original code)

    my $runcmd = '/bin/ls -l > test.text';
    then you don't have to worry about the taintedness of PATH. It won't be used to find ls.

    After Compline,
    Zaxo

      What I meant is that if you say (in the original code)

      my $runcmd = '/bin/ls -l > test.text';

      then you don't have to worry about the taintedness of PATH. It won't be used to find ls.

      Problem is, perl does not know that:

      sidhekin@blackbox:~$ perl -wT -Mstrict -e 'system("/bin/ls -l")' Insecure $ENV{PATH} while running with -T switch at -e line 1. sidhekin@blackbox:~$

      In fact, I don't think perl can know what /bin/ls may or may not want to do with PATH. Nor does it matter if the shell is involved in running that command:

      sidhekin@blackbox:~$ perl -wT -Mstrict -e 'system("/bin/ls", "-l")' Insecure $ENV{PATH} while running with -T switch at -e line 1. sidhekin@blackbox:~$

      So, I'm afraid you'll still have to worry about taintedness of PATH -- and any other "potentially dangerous" environment variable. At least using full path gives you an easy way to deal with tainted PATH: Just delete it!

      sidhekin@blackbox:~$ perl -wT -Mstrict -e 'delete $ENV{PATH}; system(" +/bin/ls", "-l")' Insecure $ENV{BASH_ENV} while running with -T switch at -e line 1. sidhekin@blackbox:~$

      Um, er, along with every other "potentially dangerous" environment variable, that is ...

      print "Just another Perl ${\(trickster and hacker)},"
      The Sidhekin proves Sidhe did it!

Re^3: Reading ENV variable and using that in taint mode
by Anonymous Monk on Jul 12, 2006 at 03:54 UTC

    Include full path