Bod has asked for the wisdom of the Perl Monks concerning the following question:
I am putting a unique string of text onto a PDF document using PDF::API2. Here is the minimal code to demonstrate:
This works as expected when taint mode is off. But, once taint mode is turned on I get:#!/usr/bin/perl -T use CGI::Carp qw(fatalsToBrowser); use FindBin qw($RealBin); my $safepath; BEGIN { if ($RealBin =~ m!^(/home/...path.to.site.../(test|uk)/www)!) { $safepath = "$1/../lib"; } else { die "Insecure access!"; } } use lib "$safepath"; use cPanelUserConfig; use PDF::API2; use strict; use warnings; my $pdf = PDF::API2->open("$ENV{'DOCUMENT_ROOT'}/../data/xmas/GiftSub +scription.pdf"); my $font = $pdf->font("$ENV{'DOCUMENT_ROOT'}/../data/xmas/Merriweather +.ttf"); my $page = $pdf->open_page(1); my $text = $page->text; $text->font($font, 36); $text->position(656, 403); $text->text('ABC-123'); $pdf->save("$ENV{'DOCUMENT_ROOT'}/test.pdf"); print "Content-type: text/plain\n\n"; print "$ENV{'HTTP_HOST'}/test.pdf\n";
Insecure dependency in open while running with -T switch at /usr/lib64 +/perl5/IO/File.pm line 187
I have replaced $ENV{'DOCUMENT_ROOT'} with hardcoded paths to ensure that it is not this that is causing the problem.
Is it possible to use PDF::API2 in taint mode or do I have to choose between finding another module or turning off taint mode?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Insecure Dependency in Taint Mode
by kcott (Archbishop) on Nov 05, 2022 at 01:15 UTC | |
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 | |
Re: Insecure Dependency in Taint Mode
by pryrt (Abbot) on Nov 05, 2022 at 19:19 UTC | |
by Bod (Parson) on Nov 05, 2022 at 20:36 UTC | |
by pryrt (Abbot) on Nov 05, 2022 at 22:29 UTC | |
by Bod (Parson) on Nov 05, 2022 at 22:47 UTC | |
Re: Insecure Dependency in Taint Mode
by afoken (Chancellor) on Nov 06, 2022 at 11:52 UTC |