Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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


In reply to Re: Insecure Dependency in Taint Mode by kcott
in thread Insecure Dependency in Taint Mode by Bod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (9)
As of 2024-04-23 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found