diff options
author | Father Chrysostomos <sprout@cpan.org> | 2016-09-03 13:30:22 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2016-09-03 18:51:41 -0700 |
commit | ba0a4150f6f1604df236035adf6df18bd43de88e (patch) | |
tree | 04c01c3acb428079b256a36f99efb832403e68d7 /t | |
parent | fac2c98c83b1d3b5039146aa7b14e3ed41f65cc4 (diff) | |
download | perl-ba0a4150f6f1604df236035adf6df18bd43de88e.tar.gz |
Fix checks for tainted dir in $ENV{PATH}
$ cat > foo
#!/usr/bin/perl
print "What?!\n"
^D
$ chmod +x foo
$ ./perl -Ilib -Te '$ENV{PATH}="."; exec "foo"'
Insecure directory in $ENV{PATH} while running with -T switch at -e line 1.
That is what I expect to see. But:
$ ./perl -Ilib -Te '$ENV{PATH}="/\\:."; exec "foo"'
What?!
Perl is allowing the \ to escape the :, but the \ is not treated as an
escape by the system, allowing a relative path in PATH to be consid-
ered safe.
Diffstat (limited to 't')
-rw-r--r-- | t/op/taint.t | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/t/op/taint.t b/t/op/taint.t index 38a3952366..ca0a58b052 100644 --- a/t/op/taint.t +++ b/t/op/taint.t @@ -17,7 +17,7 @@ BEGIN { use strict; use Config; -plan tests => 808; +plan tests => 812; $| = 1; @@ -187,6 +187,22 @@ my $TEST = 'TEST'; like($@, qr/^Insecure (?:directory in )?\$ENV\{PATH}/); } + # Relative paths in $ENV{PATH} are always implicitly tainted. + SKIP: { + skip "Do these work on VMS?", 4 if $Is_VMS; + skip "Not applicable to DOSish systems", 4 if! $tmp; + + local $ENV{PATH} = '.'; + is(eval { `$echo 1` }, undef); + like($@, qr/^Insecure (?:directory in )?\$ENV\{PATH}/); + + # Backslash should not fool perl into thinking that this is one + # path. + local $ENV{PATH} = '/\:.'; + is(eval { `$echo 1` }, undef); + like($@, qr/^Insecure (?:directory in )?\$ENV\{PATH}/); + } + SKIP: { skip "This is not VMS", 4 unless $Is_VMS; |