nine9 has asked for the wisdom of the Perl Monks concerning the following question:

Someone said I should be running all my scripts in "Taint" mode... What is it? How do I do it?

Replies are listed 'Best First'.
RE: Taint mode
by Anonymous Monk on Jan 05, 2000 at 00:47 UTC
    Taint.pm is a module that helps ensure that a user doesn't pass your cgi script some input that can do bad things to your server. For instance, if you accepted some input and then did a system( $input ) where the input was 'rm -Rf /' then you could have problems, even if you were running http's as 'nobody' (OK, so this is a unix-centric answer ) I think it basically does string substitution to remove potentially hazardous characters:
    WWW::Taint.pm
    #
    # Utility routines for untainting strings.  All three will accept
    # a single scalar as argument, and return the same scalar back
    # or undef if it flunks.  It's possible to call untaint() directly
    # and supply your own regexp, but probably better to extend the
    # package with your own method if you really need it.
    #
    # the empty string returns an empty string (meaningless but untainted
    # hence defined).  Undef returns undef.
    #
    # the three flavors are slut(), easy() and saint().
    #
    # slut() always returns what you passed it.  a string like
    # "myfilename; cd /; rm -rf *" is totally cool.  Needless to say,
    # this should be used with extreme caution.  Trusted files (like
    # configuration files) and really ugly data (i.e. the comment lines
    # in database references).
    #
    # easy() allows most chars but excludes things known to be hazardous to
    # the shell, i.e. non-displayable chars, '&', ';' '`', '|' '>', '<'
    #
    # saint() allows only alphanumerics and '_', '-', '.', ':' and '/'.
    # It's intended mostly for (unix) file paths.