I've run into something odd with taint. I've reduced it to a minimal case. If I have an assignment that is a hash or an array reference and it contains more than one set of backticks, $$ suddently becomes tainted within the assignment. Take the code below...


Update: Code moved below

If you comment either backtick out, it passes taint. If you have two variables getting assigned two backticks containing $$, it also works. Why is $$ only tainted when inside hashref and arrayref declarations and after it is used once?

Any ideas?
Update The problem seems to be with any variables whether they were used in a backtick previously or not.
<code> #!/usr/bin/perl -T use strict; use warnings; # Original code $ENV{PATH} = '/usr/bin:/usr/local/bin:/bin'; $ENV{ENV} = ''; my $temp_fails = [ `mktemp /tmp/temp.$$.XXXXXX`, `mktemp /tmp/temp2.$$.XXXXXX`, ]; #!/usr/bin/perl -T use strict; use warnings; # This fails as well.. $ENV{PATH} = '/usr/bin:/usr/local/bin:/bin'; $ENV{ENV} = ''; my $untainted = 'foo'; my $also_untainted = 'foobar'; my $temp_fails = [ `mktemp /tmp/temp.$untainted.XXXXXX`, `mktemp /tmp/temp.$also_untainted.XXXXXX`, ]; #This is perl, v5.6.1 built for sparc64-linux # The following works ok sub do_nothing { @_ }; $ENV{PATH} = '/usr/bin:/usr/local/bin:/bin'; $ENV{ENV} = ''; my $temp_fails = [ do_nothing(`mktemp /tmp/temp.$untainted.XXXXXX`), do_nothing(`mktemp /tmp/temp.$also_untainted.XXXXXX +`), ];


-Lee

"To be civilized is to deny one's nature."

In reply to Taint bug with backticks in variable assignments by shotgunefx

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.