in reply to Insecure Dependency in Taint Mode
G'day Bod,
"Is it possible to use PDF::API2 in taint mode ..."
I'd say the short answer is "yes".
Obviously, I can't reproduce your environment — apart from anything else, there's insufficient information, such as your Apache? configuration — however, the following test works fine.
ken@titan ~/tmp/www $ perl -Mstrict -Mwarnings -Mautodie=:all -MCarp::Always -T -E ' use FindBin qw{$RealBin}; my $safepath; BEGIN { if ($RealBin =~ m!^(/home/.+?/(tmp|xyz)/www)!) { $safepath = "$1/../lib"; } else { die "Insecure access!"; } } use lib "$safepath"; use PDF::API2; my $pdf = PDF::API2->new("some.pdf"); $pdf->save("some.pdf"); '
Changing the last two (new() & save()) lines to:
my $pdf = PDF::API2->open("some.pdf");
also works without any problems. I checked:
ken@titan ~/tmp/www $ file some.pdf some.pdf: PDF document, version 1.4, 0 pages
I'm running Perl v5.36.0 and PDF::API2 v2.043.
You've included completely unknown code with "use cPanelUserConfig;". Clearly, we're unable to test that. Try removing all of the code related to PDF::API2 and see if cPanelUserConfig is the cause of your taint issue. Your report suggests that you think PDF::API2 is the source of the problem, but you don't say why; you could be working from a false premise.
I'd move strict and warnings to the start of your code. Was there a reason for putting these in the middle of the script?
It's been 10-20 years since I last wrote any CGI code; my knowledge is certainly not current. I seem to recall that its documentation included troubleshooting tips involving running a CGI script from the command line. Perhaps look into that and see if it's any help.
Have a look at "FindBin: KNOWN ISSUES" and what it says about issues with mod_perl. I'm very much guessing with this — I don't even know if you're using mod_perl — but it may be worth a look.
Take a look through "perlsec - Perl security" for anything that might help. Perhaps the suggested:
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
If none of those suggestions help, you'll have to step through your code to find out where problems are occurring.
— Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Insecure Dependency in Taint Mode
by Bod (Parson) on Nov 05, 2022 at 11:45 UTC | |
by kcott (Archbishop) on Nov 05, 2022 at 14:13 UTC | |
by pryrt (Abbot) on Nov 05, 2022 at 18:47 UTC | |
by kcott (Archbishop) on Nov 05, 2022 at 23:43 UTC | |
by Bod (Parson) on Nov 05, 2022 at 20:27 UTC | |
by AnomalousMonk (Archbishop) on Nov 05, 2022 at 13:14 UTC | |
by tobyink (Canon) on Nov 05, 2022 at 17:29 UTC |