Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

taint checking and @INC

by coolmichael (Deacon)
on Jul 19, 2001 at 09:01 UTC ( #97987=perlquestion: print w/ replies, xml ) Need Help??
coolmichael has asked for the wisdom of the Perl Monks concerning the following question:

I've read perlsec. I didn't see anything in the sections about taint checking that mentioned how @INC changes with -T. I read in CGI Programming with Perl on page 210 that the PATH must be secure and ./ isn't included in the PATH, because they can be modified by their owner.

I'm wondering how much of a security risk is it to do this:

#!perl -Tw ... use lib '.';
in a CGI script? Will Perl even let me do that?

Comment on taint checking and @INC
Download Code
Re: taint checking and @INC
by LD2 (Curate) on Jul 19, 2001 at 09:06 UTC
    coolmichael, you may want to check this site out: CGI/Perl Taint Mode FAQ - mainly the section named - How do I fix problems with require or use statements in taint mode?

    From this FAQ, I believe you can do this:
    use lib qw(.);
Re: taint checking and @INC
by HyperZonk (Friar) on Jul 19, 2001 at 09:15 UTC
    $ENV{PATH} is tainted because it is obtained from "outside" your program. In taint mode, you can't use something from outside your program to affect something else outside your program. Your '.' is explicitly defined within your program, it is not obtained from an outside source (such as a file, an environment variable, or STDIN). Also, use lib is not attempting to affect something outside of the program, it is changing where the program looks for modules. Because of both, this is taint-free (I'm sure about the first part, and pretty sure about the second).

    Note that there are a few kinds of data obtained from outside the program that are not tainted. See perlsec for details.
(tye)Re: taint checking and @INC
by tye (Cardinal) on Jul 19, 2001 at 19:39 UTC

    I see no problem with adding "use lib '.';" provided you:

    • preceed it by BEGIN { chdir("/abs/path") or die "Can't chdir to /abs/path: $!\n" }
    • be very careful to prevent "others" from getting "write" access to /abs/path
    This last item could even involve checking the permissions on the directory from within the script.

            - tye (but my friends call me "Tye")

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://97987]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2014-07-25 07:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (169 votes), past polls