我不明白Perl污点模式错误消息

时间:2017-10-16 21:16:36

标签: perl taint

我有一些旧的Perl代码我被告知易受跨站点脚本攻击或SQL注入攻击。我想通过将shebang从#!/usr/local/bin/perl更改为#!/usr/local/bin/perl -T来启用污点模式,现在我收到此错误消息:

Insecure dependency in require while running with -T switch at <big long path>/main.cgi line 26.

代码如下所示:

  1 #!/usr/local/bin/perl  -T
.
.
.
 12 use strict;
 13
 14 use vars qw( %opt $VERSION );
 15
 16 use CGI qw/:standard *table start_ul/;
 17 use CGI qw(:debug);
 18 use CGI::Carp qw( fatalsToBrowser );
 19 #use CGI::Pretty qw( :html3 );
 20 $CGI::Pretty::INDENT = "    ";
 21 use Tie::IxHash;
 22 use FindBin qw($Bin); 
 23 use lib "$Bin/../../lib";
 24 use lib "$Bin/../lib";
 25
 26 use Common::Config;

Common :: Config具有以下所有权和权限:

$ ls -l lib/Common/Config.pm
-r--r--r--. 1 someguy example 5840 Oct  9 20:08 lib/Common/Config.pm

我尝试将所有权更改为apache但我仍然收到了污点错误消息。

更新:

我试图解开我的$Bin变量,如下所示:

use FindBin qw($Bin);           # Where are we ?
if ($Bin =~ /^([-\@\w.]+)$/) {
        $Bin = $1;                      # $data now untainted
} else {
        die "Bad data in '$Bin'";       # log this somewhere
}

但我仍然得到关于use Common::Config;

的污点错误

1 个答案:

答案 0 :(得分:4)

你有一个use lib语句,其中一个不安全的变量被添加到包含路径?

https://perldoc.perl.org/perlsec.html

  

请注意,如果将受污染的字符串添加到@INC,则会报告以下问题:

Insecure dependency in require while running with -T switch
相关问题