(Perhaps you should re-read Re: When not to use taint mode.)

Insecure dependency in open while running with -T switch at /usr/lib64/perl5/IO/File.pm line 187

That's a hint, but not very helpful. So you managed to pass a tainted value to some IO::File method that calls open. In the current version of IO::FIle (v1.48), line 187 is at the end of the IO::File->open() method.

Luckily, the Carp::Always module can help here. I use a simpler example to demonstrate it:

#!/usr/bin/perl -T # This is taint.pl use strict; use warnings; use IO::File; my $fn=$ARGV[0] or die "Missing filename"; my $fh=IO::File->new(); $fh->open($fn,'w') or die "open $fn failed: $!"; $fh->print("This should not happen!");

Note that you need to start perl with the -T flag if it is also in the #! line:

/tmp>perl -T taint.pl /dev/null Insecure dependency in open while running with -T switch at /usr/lib64 +/perl5/IO/File.pm line 184. /tmp>perl -MCarp::Always -T taint.pl /dev/null Insecure dependency in open while running with -T switch at /usr/lib64 +/perl5/IO/File.pm line 184. IO::File::open(IO::File=GLOB(0x1520be8), "/dev/null", "w") cal +led at taint.pl line 10 /tmp>

Now, that's more helpful error message. I messed up line 10 of my test script, passing a tainted $fn to IO::File->open(). 'w' can't be tainted, as it is a constant. Why is $fn tainted? Because it was copied from the tainted list of arguments @ARGV. (In theory, $fh could also be tainted, depending on what IO::File->new() does.)

Update: How to debug CGIs from the command line: Re: Running a CGI script from a command line?

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re: Insecure Dependency in Taint Mode by afoken
in thread Insecure Dependency 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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.