Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > "if" as modifier causes incorrect tainted messages?

Thread Tools

"if" as modifier causes incorrect tainted messages?
Posts: n/a
I've searched for this issue but did not find any documents or discussions - does anyone know if this is expected, and if so, why?

In a CGI script running with -Tw, a "statement if something" causes script abort with message about insecure dependency while the same thing unrolled in an "if something {statement}" works fine.

Here's the entire runnable cgi script:

use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
$ENV{PATH} = '';

my $query = new CGI;
my $input_boolean = $query->param('boolean');
print $query->header();

print "Test started. ";

print `/bin/echo TRUE. ` if ($input_boolean);
# Insecure dependency in `` while running with -T switch at /usr/lib/cgi-bin/ line 14.

# But this line below is fine:
if ($input_boolean) { print `/bin/echo TRUE. `; }

print "Test done.";

exit (0);
Reply With Quote
Posts: n/a
On Thursday, 28 March 2013 18:37:17 UTC-4, Ben Morrow wrote:
> whole expression is considered tainted (to avoid having to make taint
> checks for every operator) so the eval (in my case) is disallowed. See
> .
> Ben

Thanks, in case anyone from is reading, would be nice if that page explicitly had this particular example.
I should show that if modifier maintains untainted-ness, while an if-statement is fine.
That doc does mention that the phrase you mention above, but it also says that ternary operation ?: works differently: "Since code with a ternary conditional... is essentially an if-statement". From that, some people might make the incorrect jump that and if-modifier is also essentially an if-statement so that should be fine too! But it isn't...
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 7.12 How can I tell if a variable is tainted? PerlFAQ Server Perl Misc 0 01-14-2011 11:00 AM
How to unable the use of tainted mode in a CGI script ? Azol Perl Misc 23 09-29-2008 12:10 PM
Disabling tainted feature in Perl rr_79 Perl Misc 1 01-03-2007 06:46 PM
Strange problem with regular expressions and tainted values Hadmut Danisch Ruby 0 10-27-2005 08:45 PM
tainted symbols? John W. Long Ruby 6 02-22-2004 02:49 AM