It works for me, I mean I get the error about insecure dependency.
#!/usr/bin/perl -T use strict; use warnings; use DBI; use CGI; use Data::Dumper; my $cgi = CGI->new; print $cgi->header(-type => 'text/plain'); my $dbh = DBI->connect(qw(dbi:mysql:test user pass), {RaiseError=>1, T +aint=>0, TaintIn=>1, TaintOut=>0}); my $id; ($id = $cgi->param('id')) ? get_user() : normal_page(); sub get_user { my $sth = $dbh->prepare('select * from user where id = ?'); #($id) = $id =~ /^(\d+)$/; $sth->execute($id); my $user = $sth->fetchrow_hashref; $sth->finish; die "There's no such user id ($id)\n" unless defined $user; print Dumper($user); } sub normal_page { print 'Hello there'; }
And I got this from the error log when calling user.cgi?id=1:
Insecure dependency in parameter 1 of DBI::st=HASH(0x8265f88)->execute + method call while running with -T switch at /path/to/user.cgi line 2 +0.
If I uncomment the untainting line, I got this on the browser (as found in the table):
$VAR1 = { 'pass' => 'perl', 'location' => undef, 'name' => 'perl', 'id' => '1' };

Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!


In reply to Re^3: Taint and get params by naikonta
in thread Taint and get params by jatill

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.