admin管理员组文章数量:1123197
I'm trying to run taint mode on a Perl website, using mod_perl. This is upgrading an older application to use the latest Perl and libraries; it used to work and mostly still works, but file uploads are suddenly throwing errors.
Trying to upload a file gives the error Insecure dependency in sysopen while running with -T switch at /Perl/lib/File/Temp.pm line 517
. Adding a stacktrace shows this is coming from ModPerl and then CGI, not the application code. CGI is trying to create a temp folder based on $ENV{TEMP}
, but this is tainted so it throws an error.
I tried to fix this by changing $ENV{TEMP} to a hardcoded value in startup.pl within the Apache conf folder:
$ENV{TEMP} = 'C:/Temp/AppTempFolder';
warn "Set TEMP - " . is_tainted($ENV{TEMP}); # At least here $ENV{TEMP} is now untainted
Except it still doesn't work. If I edit CGI.pm (sub read_multipart) to print the same message, I get:
warn "tmp_dir is $tmp_dir - " . is_tainted($tmp_dir);
#tmp_dir is C:/Temp/AppTempFolder - 1
warn "From: $ENV{TEMP} || $ENV{TMP} || $ENV{WINDIR}";
#From: C:/Temp/AppTempFolder || C:\WINDOWS\TEMP || C:\WINDOWS
So it kept the new value of $ENV{TEMP}, but re-tainted it.
perlsec doesn't make any mention of values being re-tainted, and the examples suggest that there's nothing special about %ENV with regards to taint, only that they start out tainted.
Is there a way to either prevent this re-tainting of data, or a different way to set CGI up for reading file uploads to not rely on a tainted %ENV?
本文标签: perlmodperl with taint mode on WindowsStack Overflow
版权声明:本文标题:perl - mod_perl with taint mode on Windows - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736556149a1944580.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论