perl -T
Do you use it? Does it helps you to find security holes in your Perl scripts?
perl -T
Do you use it? Does it helps you to find security holes in your Perl scripts?
More than that :) it stops your security issues before they become one. It is not a security silver bullet of course... we used to use it (a few years back when I was involved in Perl projects) in any script that was exposed externally (i.e. any mod_perl app) and we found it very useful and made it our policy. It does a few checks and it is handy.. (anything makes things automated)
Perl Security - perlsec recommends it strongly too:
This flag [Taint mode] is strongly suggested for server programs and any program run on behalf of someone else, such as a CGI script. Once taint mode is on, it's on for the remainder of your script.
Most definitely!
$ echo '`rm -rf /`' | perl -Te 'eval while <>' Insecure dependency in eval while running with -T switch at -e line 1, <> line 1.
I think taint mode would work best when new code is being developed that everyone is familiar with.
If you have someone else's code that is poorly written, and you run it in Taint mode -- perl will die rather than perform what by the tainting rules are 'unsafe' operations.
In taint mode perl some holes are patched but not all. system("$unfiltered_user_input") will die but Perl could still write $unfiltered_user_input data to a file with a fixed name (because printing tainted data is considered 'safe') and then execute that file with system(). But nothing can check everything.
There's a tradeoff there for using it on legacy apps. When Perl finds an unsafe operation on tainted data it will die -- which means someone must go in and decide what it means to untaint the data, what regexp are needed, before the application will be reliable again.
Some people would prefer insecure, reliable, low cost (for now) to -- secure, broken, need to find the developers. Not that thats good in the long run... but it is not unusual.
The "Secure Programming Techniques" chapter of Mastering Perl is almost completely devoted to taint checking and how you should use it.