Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Is this safe??

by SilverB1rd (Scribe)
on Feb 07, 2001 at 01:08 UTC ( [id://56789]=note: print w/replies, xml ) Need Help??


in reply to Re: Is this safe??
in thread Is this safe??

I was trying to copy the way this other cgi that my company was using, that stoped working for who knows why, this is way it uses file names passed in by the user.

"I would say it's fairly unlikely you'll have a query string AND posted data at the same time"
The mail program uses a template for the email it sends, this txt file is specified in the action line like so action="https://www.mydomain.com/cgi-bin/mail.cgi?/myfolder/template.txt" The form data is sent via the post method.

This script works fine, I just dont want to miss anything. What do I need to check to make sure I'm not letting anything slip by? is it the data being used to open files? or all the data being sent?

Replies are listed 'Best First'.
Re: Re: Re: Is this safe??
by AgentM (Curate) on Feb 07, 2001 at 01:29 UTC
    What do I need to check to make sure I'm not letting anything slip by?

    As described above, use both taint mode and CGI.pm as follows:

    #!/usr/bin/perl -wT #warnings and taint mode now enabled use CGI; #you may now use the CGI methods.
    It would scare me greatly if you copied this code from a company web page since those pages are now vunerable to a variety of DoS and hack attacks. CGI has tested-true functions for nearly everything you do above. It looks like you could reduce that program to 10 lines or less OF SECURE CODE!

    On CGI security: If you're not using the inputted data in shell calls, then you're relatively safe. Taint mode specifically checks for this. Of course, some loser can still input some random schlop, so work your CGI with "valid entry or reject"/deny-allow in mind. As I said earlier, CGI.pm provides numerous functions for EXACTLY what you are doing (and doing incompletely), including character escaping, so click that link and read the docs on it.

    AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.
      I'm working on a new scritp with the CGI stuff and its giving me this error when I run it on my pc that says "Too late for the "-T" option at mailer.cgi line 1." Is this just because on running it on a pc?

        It's probably because you're running it as

        perl foo.pl

        When the first line of the script looks something like:

        #!c:\perl\bin\perl -T

        Just change the command line to perl -T foo.pl, or execute the script directly (i.e. don't run it through the interpreter on the command line) and you're golden.

        P.S. "P.C." usually refers to the archictecture (i386), I understand you as meaning "Windows," my apologies if that assumption is incorrect.

        HTH

        Philosophy can be made out of anything. Or less -- Jerry A. Fodor

      Thanks I'll do that and let you all know how it works! I wrote that script.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://56789]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2024-04-24 11:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found