Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Moving A Web Application From Hacky To ... Less Hacky

by beebware (Pilgrim)
on Mar 01, 2002 at 14:46 UTC ( [id://148577]=note: print w/replies, xml ) Need Help??


in reply to Moving A Web Application From Hacky To ... Less Hacky

Ok, security things to consider:
  • Use taint #!usr/bin/perl -t should do it. But always think one step further (Think beyond Taint and warnings)
  • Use strict;
  • Don't use cgi::carp 'fatalstobrowser'; - in production code as it may show things you don't want people to see.
  • Double-check all user entered data and then don't trust it. Do you really need to let them enter a filename? (taint will catch most mistakes, but it's no infalliable).
  • Hardcode important settings. Using stuff like <input type="hidden" name="destination" value="test@example.com"> is just asking for people to send spam through your system - with YOUR name on it!
  • Make sure the script, file and folder it is in has minimum priviledges to do its job. For the sake of your server, never ever ever run a script as root: nor allow it to be. Also, if you are writing files, ensure that they can't be executed or anything. Last thing you want is for someone to upload a file with the contents rm -rf * and then visit the URL of the file
  • The end user has no need to know how or where your files are stored (it's a possible security loophole): having URLs like ?readfile=/usr/myuser/htdocs/files/0102.txt allows them to know where your files are. I'm saying nothing about them being able to alter the query string and read any file they want on your server... (something like ?readfile=0102 would be a lot more secure).
  • use cgi - it's tried, tested and quite secure. Rolling your own form parsing system may allow buglets to slip by... (use CGI or die;)
  • Read things like Essential CGI Security Practices and perlsec.
  • Be careful what error messages you do display to the user. Bad password will allow them to know that they've hit a correct username, Bad username or password doesn't allow them to know quite what went wrong. Lock out (or introduce a time delay) on accounts that have more than X invalid login attempts in a time period.
There's a lot of work you can do to make sure a system is secure (physical access, open telnet ports, default passwords etc etc are all potential problems and security holes), but the above should give you some assistance.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2024-04-23 08:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found