in reply to Re: Why do I need -w in a cgi script
in thread Why do I need -w in a cgi script

Heh - actually, I'd be willing to change my 'e.g.' to an 'i.e.'. Whilst bugs are a part of life, allowing a script to accept 3 params, but only testing with 2 prior to disabling taint would be, well, pretty dumb.

And face it, anyone dumb enough to do that will probably have screwed up cleaning the user input anyway...

Tom Melly, tom@tomandlu.co.uk
  • Comment on Re: Re: Why do I need -w in a cgi script

Replies are listed 'Best First'.
Re: Why do I need -w in a cgi script
by Abigail-II (Bishop) on Oct 10, 2003 at 12:55 UTC
    What's pretty dumb is to assume you can write perfect tests.

    Abigail

      True, but then, as I said, we're still screwed since taint doesn't force you to get the cleaning right

      Look, it's a moot point (who the hell turns off taint checking?), but a valid one. Turning off taint checking on a production script shouldn't make any difference

      Consider - you develop a script, and when you test with taint on, the following generates a warning:

      foreach(@ARGV){ `$_`; }
      So you correct it:
      foreach(@ARGV){ /(\w*)/; $foo = `ls -l $1`; }
      Is this going to be any less secure for running without taint once you've got it to run with taint?

      foreach(@ARGV){ /(.*)/; $foo = `$1`; }
      and is this going to be any less insecure for running with taint?

      Tom Melly, tom@tomandlu.co.uk
        Let's say, you have the following program:
        #!/usr/bin/perl -T use strict; use warnings; my $file = shift; open my $fh => $file or die $!; while (<$fh>) {print} close $fh; __END__

        A fairly trivial one. Takes only one parameter. You test it with a million files. It all works fine. You remove the '-T' and put it in production, where it's going to be run suid or called by a CGI program, or whatever.

        Then some joker passes "> /some/important/file" as argument. With "-T", perl would not have wiped the content of the file. Without, it will.

        Abigail