Current Perl versions put '.' at the end of the library search path
@INC, although this will be fixed in a future Perl release. This means
that when software loads an optionally-present module, it will be
looked for in the current working directory before giving up. An
attacker could use this to execute arbitrary Perl code from ikiwiki's
current working directory.
Removing '.' from the library search path in Perl is the correct
fix for this vulnerability, but is not trivial to do due to
backwards-compatibility concerns. Mitigate this (even if ikiwiki is run
with a vulnerable Perl version) by explicitly removing '.' from the
search path, and instead looking for ikiwiki's own modules relative
to the absolute path of the executable when run from the source
directory.
In tests that specifically want to use the current working directory,
use "-I".getcwd instead of "-I." so we use its absolute path, which
is immune to the removal of ".".
18 files changed:
use warnings;
use strict;
use warnings;
use strict;
-use lib '.'; # For use in nonstandard directory, munged by Makefile.
+use FindBin; use lib $FindBin::Bin; # For use in nonstandard directory, munged by Makefile.
use IkiWiki;
use IkiWiki::Setup;
use Getopt::Long;
use IkiWiki;
use IkiWiki::Setup;
use Getopt::Long;
use warnings;
use strict;
use warnings;
use strict;
-use lib '.'; # For use in nonstandard directory, munged by Makefile.
+use FindBin; use lib $FindBin::Bin; # For use in nonstandard directory, munged by Makefile.
use IkiWiki;
use IkiWiki::Plugin::comments;
use Getopt::Long;
use IkiWiki;
use IkiWiki::Plugin::comments;
use Getopt::Long;
use warnings;
use strict;
use warnings;
use strict;
use warnings;
use strict;
use warnings;
use strict;
-use lib '.'; # For use in nonstandard directory, munged by Makefile.
+use FindBin; use lib $FindBin::Bin; # For use in nonstandard directory, munged by Makefile.
use IkiWiki;
use HTML::Entities;
use IkiWiki;
use HTML::Entities;
#!/usr/bin/perl -t
# Add a user to the system wide wikilist.
# This script can safely be made suid or put in /etc/sudoers.
#!/usr/bin/perl -t
# Add a user to the system wide wikilist.
# This script can safely be made suid or put in /etc/sudoers.
use warnings;
use strict;
use English;
use warnings;
use strict;
use English;
#!/usr/bin/perl
package IkiWiki;
#!/usr/bin/perl
package IkiWiki;
use warnings;
use strict;
use warnings;
use strict;
-use lib '.'; # For use in nonstandard directory, munged by Makefile.
+use FindBin; use lib $FindBin::Bin; # For use in nonstandard directory, munged by Makefile.
use IkiWiki 3.00;
sub usage () {
use IkiWiki 3.00;
sub usage () {
elsif (/VERSION_AUTOREPLACE/) {
$_=qq{our \$version="$ver";};
}
elsif (/VERSION_AUTOREPLACE/) {
$_=qq{our \$version="$ver";};
}
+elsif (/^(?:use FindBin; *)?use lib/) {
# The idea here is to figure out if the libdir the Makefile.PL
# was configured to use is in perl's normal search path.
# If not, hard code it into ikiwiki.
# The idea here is to figure out if the libdir the Makefile.PL
# was configured to use is in perl's normal search path.
# If not, hard code it into ikiwiki.
#!/usr/bin/perl
use warnings;
use strict;
#!/usr/bin/perl
use warnings;
use strict;
use Test::More;
my $installed = $ENV{INSTALLED_TESTS};
use Test::More;
my $installed = $ENV{INSTALLED_TESTS};
else {
ok(! system("make -s ikiwiki.out"));
ok(! system("make underlay_install DESTDIR=`pwd`/t/tmp/install PREFIX=/usr >/dev/null"));
else {
ok(! system("make -s ikiwiki.out"));
ok(! system("make underlay_install DESTDIR=`pwd`/t/tmp/install PREFIX=/usr >/dev/null"));
- @command = qw(env LC_ALL=C perl -I. ./ikiwiki.out
+ @command = (qw(env LC_ALL=C perl), "-I".getcwd, qw(./ikiwiki.out
--underlaydir=t/tmp/install/usr/share/ikiwiki/basewiki
--set underlaydirbase=t/tmp/install/usr/share/ikiwiki
--underlaydir=t/tmp/install/usr/share/ikiwiki/basewiki
--set underlaydirbase=t/tmp/install/usr/share/ikiwiki
- --templatedir=templates);
+ --templatedir=templates));
}
foreach my $plugin ("", "listdirectives") {
}
foreach my $plugin ("", "listdirectives") {
#!/usr/bin/perl
use warnings;
use strict;
#!/usr/bin/perl
use warnings;
use strict;
use Test::More;
use IkiWiki;
use Test::More;
use IkiWiki;
}
else {
ok(! system("make -s ikiwiki.out"));
}
else {
ok(! system("make -s ikiwiki.out"));
- @command = qw(perl -I. ./ikiwiki.out
+ @command = ("perl", "-I".getcwd, qw(./ikiwiki.out
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
- --templatedir=templates);
+ --templatedir=templates));
# Tests for bugs relating to conflicting files in the srcdir
use warnings;
use strict;
# Tests for bugs relating to conflicting files in the srcdir
use warnings;
use strict;
use Test::More tests => 106;
my $installed = $ENV{INSTALLED_TESTS};
use Test::More tests => 106;
my $installed = $ENV{INSTALLED_TESTS};
}
else {
ok(! system("make -s ikiwiki.out"));
}
else {
ok(! system("make -s ikiwiki.out"));
- @command = qw(perl -I. ./ikiwiki.out
+ @command = ("perl", "-I".getcwd, qw(./ikiwiki.out
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
- --templatedir=templates);
+ --templatedir=templates));
use warnings;
use strict;
use warnings;
use strict;
use Test::More;
plan(skip_all => "Image::Magick not available")
unless eval q{use Image::Magick; 1};
use Test::More;
plan(skip_all => "Image::Magick not available")
unless eval q{use Image::Magick; 1};
}
else {
ok(! system("make -s ikiwiki.out"));
}
else {
ok(! system("make -s ikiwiki.out"));
- @command = qw(perl -I. ./ikiwiki.out
+ @command = ("perl", "-I".getcwd, qw(./ikiwiki.out
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
- --templatedir=templates);
+ --templatedir=templates));
}
push @command, qw(--set usedirs=0 --plugin img t/tmp/in t/tmp/out --verbose);
}
push @command, qw(--set usedirs=0 --plugin img t/tmp/in t/tmp/out --verbose);
#!/usr/bin/perl
use warnings;
use strict;
#!/usr/bin/perl
use warnings;
use strict;
use Test::More;
use IkiWiki;
use Test::More;
use IkiWiki;
}
else {
ok(! system("make -s ikiwiki.out"));
}
else {
ok(! system("make -s ikiwiki.out"));
- @command = qw(perl -I. ./ikiwiki.out
+ @command = ("perl", "-I".getcwd, qw(./ikiwiki.out
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
- --templatedir=templates);
+ --templatedir=templates));
}
push @command, qw(--set usedirs=0 --plugin inline
}
push @command, qw(--set usedirs=0 --plugin inline
#!/usr/bin/perl
use warnings;
use strict;
#!/usr/bin/perl
use warnings;
use strict;
use Test::More;
use IkiWiki;
use Test::More;
use IkiWiki;
}
else {
ok(! system("make -s ikiwiki.out"));
}
else {
ok(! system("make -s ikiwiki.out"));
- @command = qw(perl -I. ./ikiwiki.out
+ @command = ("perl", "-I".getcwd, qw(./ikiwiki.out
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
- --templatedir=templates);
+ --templatedir=templates));
}
push @command, qw(--plugin meta --disable-plugin htmlscrubber);
}
push @command, qw(--plugin meta --disable-plugin htmlscrubber);
#!/usr/bin/perl
use warnings;
use strict;
#!/usr/bin/perl
use warnings;
use strict;
use Test::More;
my $installed = $ENV{INSTALLED_TESTS};
use Test::More;
my $installed = $ENV{INSTALLED_TESTS};
}
else {
ok(! system("make -s ikiwiki.out"));
}
else {
ok(! system("make -s ikiwiki.out"));
- @command = qw(perl -I. ./ikiwiki.out
+ @command = ("perl", "-I".getcwd, qw(./ikiwiki.out
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
- --templatedir=templates);
+ --templatedir=templates));
}
ok(! system("rm -rf t/tmp"));
}
ok(! system("rm -rf t/tmp"));
}
else {
ok(! system("make -s ikiwiki.out"));
}
else {
ok(! system("make -s ikiwiki.out"));
- @base_command = qw(perl -I. ./ikiwiki.out
+ @base_command = ("perl", "-I".getcwd, qw(./ikiwiki.out
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
- --templatedir=templates);
+ --templatedir=templates));
}
else {
ok(! system("make -s ikiwiki.out"));
}
else {
ok(! system("make -s ikiwiki.out"));
- @command = qw(perl -I. ./ikiwiki.out
+ @command = ("perl", "-I".getcwd, qw(./ikiwiki.out
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
- --templatedir=templates);
+ --templatedir=templates));
}
sub parse_cgi_content {
}
sub parse_cgi_content {
#!/usr/bin/perl
use warnings;
use strict;
#!/usr/bin/perl
use warnings;
use strict;
use Test::More;
use IkiWiki;
use Test::More;
use IkiWiki;
}
else {
ok(! system("make -s ikiwiki.out"));
}
else {
ok(! system("make -s ikiwiki.out"));
- @command = qw(perl -I. ./ikiwiki.out
+ @command = ("perl", "-I".getcwd, qw(./ikiwiki.out
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
- --templatedir=templates);
+ --templatedir=templates));
}
push @command, qw(--set usedirs=0 --plugin trail --plugin inline
}
push @command, qw(--set usedirs=0 --plugin trail --plugin inline
}
else {
ok(! system("make -s ikiwiki.out"));
}
else {
ok(! system("make -s ikiwiki.out"));
- @command = qw(env PERL5LIB=t/tmp:blib/lib:blib/arch perl -I. ./ikiwiki.out
+ @command = (qw(env PERL5LIB=t/tmp:blib/lib:blib/arch perl),
+ "-I".getcwd, qw(./ikiwiki.out
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
- --templatedir=templates);
+ --templatedir=templates));
}
writefile("test.setup", "t/tmp", <<EOF
}
writefile("test.setup", "t/tmp", <<EOF