Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

G'day Bod,

I didn't see it mentioned anywhere in the thread, so I thought I'd point out a general problem that you could be experiencing.

Here's a taint_test module:

$ cat taint_test.pm package taint_test; use strict; use warnings; chdir +(split /:/, $ENV{PATH})[0];

Here's a script that tries to clean $ENV{PATH}:

$ cat check_taint_1.pl use strict; use warnings; $ENV{PATH} = '/bin:/usr/bin'; use lib '.'; use taint_test;

But that fails:

$ perl -T check_taint_1.pl Insecure dependency in chdir while running with -T switch at taint_tes +t.pm line 6. Compilation failed in require at check_taint_1.pl line 6. BEGIN failed--compilation aborted at check_taint_1.pl line 6. $

The problem here is that the assignment to $ENV{PATH} occurs at runtime, whereas loading taint_test occurs at compile time. The order of the statements makes no difference: compile time happens before runtime.

Here's a subtly different version of the first script:

$ cat check_taint_2.pl use strict; use warnings; BEGIN { $ENV{PATH} = '/bin:/usr/bin'; } use lib '.'; use taint_test;

And this one works:

$ perl -T check_taint_2.pl $

Both assignment and loading occur at compile time; the order of the statements now matters.

Here's a third version of the script with the order of statements changed:

$ cat check_taint_3.pl use strict; use warnings; use lib '.'; use taint_test; BEGIN { $ENV{PATH} = '/bin:/usr/bin'; }

And, as expected, this fails:

$ perl -T check_taint_3.pl Insecure dependency in chdir while running with -T switch at taint_tes +t.pm line 6. Compilation failed in require at check_taint_3.pl line 5. BEGIN failed--compilation aborted at check_taint_3.pl line 5. $

Bear this in mind for things other than untainting $ENV{PATH}.

— Ken


In reply to Re: Insecure CPAN module in taint mode by kcott
in thread Insecure CPAN module in taint mode by Bod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-03-29 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found