Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

How do I get scripts to run with Taint mode on IIS?

( #421751=categorized question: print w/ replies, xml ) Need Help??
Contributed by radiantmatrix on Jan 12, 2005 at 20:25 UTC
Q&A  > CGI programming


Description:

IIS doesn't respect the #! line, so one would normally have to edit the association for Perl CGI to all run in taint mode (using the -T switch). However, this can break other people's code. Thanks to diotalevi, there is a way to turn on Taint checking for one particular script, at a slight performance cost:
BEGIN { unless ( ${^TAINT} ) { exec $^X, '-T', $0 } }
Placed as the very first line in the script (even before you 'use' anything), this will re-call the Perl interpreter on one's script, and even preserves the CGI parameters in the process. There is a small hit on speed, as the interpreter loads twice, but the hit is better than running without tainting.

Of course, the real solution is to use a better-equipped web server; but as that's not always an option...

Answer: How do I get scripts to run with Taint mode on IIS?
contributed by legato

Unfortunately, IIS doesn't respect the shebang in CGI or ISAPI mode. One can change the CGI association from C:\Perl\bin\perl.exe "%s" %s to C:\Perl\bin\perl.exe -T "%s" %s -- but that may break other scripts, as it turns tainting on for all Perl scripts. Also, it can be very hard to do that when one doesn't have admin rights on a given server, but still wants to use the benefits associated with tainting.

Answer: How do I get scripts to run with Taint mode on IIS?
contributed by Ovid

Is it that IIS doesn't respect the switches on the command line or ISAPI ignores the switches because it already has a Perl interpreter running? If you setup IIS to run scripts as CGIs instead of ISAPI, do you get the same behavior? I don't believe you do.

Answer: How do I get scripts to run with Taint mode on IIS?
contributed by gellyfish

A further discussion of Tainting with respect to IIS is given in the NMS FAQ

/J\

Answer: How do I get scripts to run with Taint mode on IIS?
contributed by sithsasquatch

I had the same problem (and asked about it a week ago, b/c I somehow missed this post in the Q&A when I searched). What I did was configure IIS to use taint mode Perl (using C:\Perl\bin\perl.exe -T "%s" %s ) with a specific file extension, such as .tcgi or .tpl. Then to make the scripts run taint mode, simply change the extension to whatever you set up in IIS, such as .tcgi or .tpl.

Answer: How do I get scripts to run with Taint mode on IIS?
contributed by saskaqueer

There is a small hit on speed, as the interpreter loads twice, but the hit is better than running without tainting.

I have to disagree in respect to the performance hit being better than running sans taint mode. If you as a programmer really know what you are doing in a public environment such as CGI, then taint mode is not that necessary. As long as you take all the proper precautions as you would while under taint mode, then you will be fine.

Now, someone will most likely counter this claim with the "well, what if you forget to check for something?" question. Quite true, but like I said, such a thing wouldn't likely occur to someone who knows what they are doing.

Please (register and) log in if you wish to add an answer



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (3)
    As of 2014-09-22 00:00 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (176 votes), past polls