diff options
author | Father Chrysostomos <sprout@cpan.org> | 2017-02-23 08:34:07 +0000 |
---|---|---|
committer | Steve Hay <steve.m.hay@googlemail.com> | 2017-02-23 08:34:27 +0000 |
commit | 1addf2f85380133ce4aa5f2f1d35bac377e0d90a (patch) | |
tree | 6dd74e1f90d243b186734d627cfa66a58bc7bda4 /t/op | |
parent | 93e39480947573cb85e287907a745faf061002f6 (diff) | |
download | perl-1addf2f85380133ce4aa5f2f1d35bac377e0d90a.tar.gz |
Fix checks for tainted dir in $ENV{PATH}
$ cat > foo
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.
(cherry picked from commit ba0a4150f6f1604df236035adf6df18bd43de88e)
Diffstat (limited to 't/op')
-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 101c6da427..846ac23f0d 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; |