LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Tainted variable problem (PERL) (https://www.linuxquestions.org/questions/programming-9/tainted-variable-problem-perl-211097/)

rajatgarg 07-29-2004 12:24 PM

Tainted variable problem (PERL)
 
Hi all,

some unusual problem. I have written a script without any -T but still it is doing taint checking...

I am passing directory name like /abc/foo/ as command line param, then it is accessed in the script using ARGV[1];

e.g. my $a = $ARGV[1];

when I use $a, it gives Insecure dependency in `` while running with -T switch.

Why ??? I am not using -T either.

Any help will be appreciated.

Code snippet is below:


my $ROOT_FS = $ARGV[1];

# setting some initial environment settings

# first changing to root

my $ruid = $<;
$<=$>;
# executing priveleged commands
system ("chown", "-R", "root:root", $ROOT_FS);
system ("chmod", "-R", "777", $ROOT_FS);
my $logfile = $ROOT_FS."temp/root_fs2/mnt/tmp/resultlog";
system (">$logfile");
# restoring ruid
$<=$ruid;


it gives error messages from all system commands. It is executed y user apache and the script needs root privilege to run the commands.


rajat garg

aluser 07-29-2004 01:54 PM

Is your script suid (or sgid)? perl understands -T whenever you run your script suid. If you are quite sure that what is in $ROOT_FS is safe, you can do this:
Code:

$ROOT_FS =~ /(.*)/;
$ROOT_FS = $1;

to untaint it. But make sure it's safe!


All times are GMT -5. The time now is 04:04 PM.