R
rallabs
Hello: I have a series of cgi scripts which I use to set up an input
file for a compiled C program. I use cookies extensively to keep track
of what parameters the users have chosen or typed into the forms they
see as they negotiate the site. I have been worrying a lot about
security and although I check all user input textboxes when they are
parsed, all the books I read say that using the taint mode is supposed
to be a very good idea. All the scripts I have written have been
successfully 'untainted' except for one that contains a system
command. I used the same procedure to untaint this script as I did
for all my others: I ran it through a search pattern and checked that
it's the proper format. The scripts all work fine when I do this
except the one with the system command. I pasted the script below. It
runs successfully if the -T is removed, but when -T is present I get
the famous 'Internal Server Error'. The error log says: "Insecure
$ENV{PATH} while running with -T switch"
The perl script is:
#!/usr/bin/perl -wT
use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI qwstandard -no_xhtml);
use diagnostics;
my %cookhash=cookie('bigcook');#retrieve cookie 'bigcook'; put into
hash 'cookhash'
my $newID=$cookhash{'newID'};
if ($newID =~ /([\w][\w][\w][\w][\d][\d][\d][\d])/){ #untainting
$newID
my $good=$1;
$newID=$good;
}else { die("Bad data: $newID");
}
system "~/runsgood.exe<hold.$newID >/dev/null"; #execute the compiled
program 'runsgood.exe'
print STDOUT redirect('done.cgi');
I don't understand what to do about the problem if I've untainted the
one piece of external data used.
perlsec says I've got to supply a good path for the script to use, but
I don't know how to do it. I can't figure out how to print out the
environment variable $ENV{PATH} anywhere.
I've been pulling out my hair all day long with this problem, and I'm
about to just give up and turn off the $%*! taint switch.
Mike
file for a compiled C program. I use cookies extensively to keep track
of what parameters the users have chosen or typed into the forms they
see as they negotiate the site. I have been worrying a lot about
security and although I check all user input textboxes when they are
parsed, all the books I read say that using the taint mode is supposed
to be a very good idea. All the scripts I have written have been
successfully 'untainted' except for one that contains a system
command. I used the same procedure to untaint this script as I did
for all my others: I ran it through a search pattern and checked that
it's the proper format. The scripts all work fine when I do this
except the one with the system command. I pasted the script below. It
runs successfully if the -T is removed, but when -T is present I get
the famous 'Internal Server Error'. The error log says: "Insecure
$ENV{PATH} while running with -T switch"
The perl script is:
#!/usr/bin/perl -wT
use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI qwstandard -no_xhtml);
use diagnostics;
my %cookhash=cookie('bigcook');#retrieve cookie 'bigcook'; put into
hash 'cookhash'
my $newID=$cookhash{'newID'};
if ($newID =~ /([\w][\w][\w][\w][\d][\d][\d][\d])/){ #untainting
$newID
my $good=$1;
$newID=$good;
}else { die("Bad data: $newID");
}
system "~/runsgood.exe<hold.$newID >/dev/null"; #execute the compiled
program 'runsgood.exe'
print STDOUT redirect('done.cgi');
I don't understand what to do about the problem if I've untainted the
one piece of external data used.
perlsec says I've got to supply a good path for the script to use, but
I don't know how to do it. I can't figure out how to print out the
environment variable $ENV{PATH} anywhere.
I've been pulling out my hair all day long with this problem, and I'm
about to just give up and turn off the $%*! taint switch.
Mike