Handling Insecure Data
Perl makes it easy to program securely, even when your program is being used by someone less trustworthy than the program itself. That is, some programs need to grant limited privileges to their users without giving away other privileges. Setuid and setgid programs fall into this category on Unix, as do programs running in various privileged modes on other operating systems that support such notions. Even on systems that don’t, the same principle applies to network servers and to any programs run by those servers (such as CGI scripts, mailing list processors, and daemons listed in /etc/inetd.conf). All such programs require a higher level of scrutiny than normal.
Even programs run from the command line are sometimes good
candidates for taint mode, especially if they’re meant to be run by a
privileged user. Programs that act upon untrusted data, like those
that generate statistics from log files or use LWP::* or Net::* to fetch remote data, should probably
run with tainting explicitly turned on; programs that are not prudent
risk being turned into “Trojan horses”. Since programs don’t get any
kind of thrill out of risk taking, there’s no particular reason for
them not to be careful.
Compared with Unix command-line shells, which are really just frameworks for calling other programs, Perl is easy to program securely because it’s straightforward and self-contained. Unlike most shell programming languages, which are based on multiple, mysterious substitution passes ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access