http://www.perlmonks.org?node_id=306565


in reply to Vetting a CGI script

It should reset $ENV{PATH} (which taint mode will force you to do anyway).

You will need to escape any pipe characters in the data from the client before it is printed to the file.

I suggest always using the three-element form of open that was made available in perl 5.6.0, though in this case it's not a big deal.

If you happen to be printing any user input in the e-mail headers, be sure to be very strict about what is allowed into them. About a month ago, we caught a spammer using one of our CGIs. The trick used was to put a new line in the to field followed by To: anyaddress@example.com, which was interpolated into the e-mail header. This would have allowed any address to be spammed, but the CGI appended our own domain name to the to field before sending, so all that happend was a lot of bounces. This made our e-mail admin very grumpy until we ran more strict validation on the fields, but it could have been worse. There were other fields that the spammer could have used that were also placed directly into the headers that didn't have anything appended to them. We are fortunate that the spammer wasn't quite that smart.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

: () { :|:& };:

Note: All code is untested, unless otherwise stated