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

Re: disable taint for just one sub

by wine (Scribe)
on Jul 23, 2001 at 18:36 UTC ( [id://99032]=note: print w/replies, xml ) Need Help??


in reply to disable taint for just one sub

From perlsec: Once taint mode is on, it's on for the remainder of your script.

So, alas. Perlsec also describes how to "launder" tainted data:

Here's a test to make sure that the data contains nothing but "word" characters (alphabetics, numerics, and under­ scores), a hyphen, an at sign, or a dot. if ($data =~ /^([-\@\w.]+)$/) { $data = $1; # $data now untainted } else { die "Bad data in $data"; # log this somewhere } This is fairly secure because "/\w+/" doesn't normally match shell metacharacters, nor are dot, dash, or at going to mean something special to the shell. Use of "/.+/" would have been insecure in theory because it lets every­ thing through, but Perl doesn't check for that. The les­ son is that when untainting, you must be exceedingly care­ ful with your patterns. Laundering data using regular expression is the only mechanism for untainting dirty data, unless you use the strategy detailed below to fork a child of lesser privilege.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-26 04:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found