i recently upgraded an old redhat 7.2 box to perl 5.8.4 (from 5.8.0) and have encountered some weirdness with taint-checking and IO::Socket. here's the smallest test-case i could come up with:

i have the following XML file:

<?xml version="1.0"?> <settings> <base>http://www.google.com</base> </settings>

and the following perl:

#!/usr/bin/perl -wT use strict; use LWP::Simple; use XML::Simple; my $config = XML::Simple::XMLin("test.xml"); my $base = $config->{base}; if ($base =~ m{^(http://[\w\.\/\-]+)$}) { $base = $1; } else { print $base, " didn't match\n"; } print get("$base/index.html");

when i run it under perl 5.8.4, i get:

Insecure dependency in connect while running with -T switch at /usr/lo +cal/lib/perl5/5.8.4/i686-linux/IO/Socket.pm line 114.

if i run it under 5.8.0, it works as expected.

so how on earth does it still consider $base to be tainted? it passes through the conditional without printing anything, so it certainly looks like it should be untainted.

if i don't get $base through XML::Simple, and instead just say $base = "http://www.google.com", it works. if i don't do any string interpolation in the last line it works. ie, if i change the last line to just:

print get($base);

it works.

it looks like some Twiki users have encountered the same problem but haven't found any solution other than turning off taint-checking (which i don't consider a legitimate option on a public server).

so is this a perl bug, or am i missing something really stupid and obvious? can anyone else duplicate it?


In reply to perl 5.8.4, IO::Socket, and taint checking by thraxil

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.