【问题标题】:I don't understand the Perl Taint mode error message我不明白 Perl Taint 模式的错误信息
【发布时间】:2017-10-16 21:16:35
【问题描述】:

有人告诉我,我有一些旧的 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; 的污染错误

【问题讨论】:

  • 我将更新问题以包含这些行。谢谢。

标签: perl taint


【解决方案1】:

您是否有 use lib 语句将不安全变量添加到包含路径?

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

注意,如果在@INC中添加了一个被污染的字符串,会报如下问题:

Insecure dependency in require while running with -T switch

【讨论】:

  • 我有use lib。我需要做什么?只是注释掉那行会导致问题。
  • @RedCricket 它可能是 FindBin。你必须清除$Bin
  • 我想我不明白如何清除 $Bin。我已经按问题更新了,你能看看,让我知道我做错了什么吗?
猜你喜欢
  • 2013-09-24
  • 2023-03-03
  • 1970-01-01
  • 2011-12-19
  • 1970-01-01
  • 1970-01-01
  • 2017-10-01
  • 2016-04-13
  • 2016-10-09
相关资源
最近更新 更多