Main | March 2007 »

February 2007 Archives

February 5, 2007

A Quick List on Application Security

I once saw a sign on the wall of a car repair shop: "Wisdom comes from experience. Experience comes from making mistakes." It struck me just how true that statement was-- one does loearn an aweful lot from one's mistakes. Here are some of the practices I've learned over the years.
  1. Ensure that all text and all files sent by the user—all—are safe for your system
    1. SQL-safe data: If user-defined text, such as that in URL variables, FORM variables, and even cookies, is used in SQL statements, make absolutely sure that it is either numeric or that it is wrapped in quotes so that it is treated as a string. Otherwise, users can effectively send SQL commands straight to your database.
    2. Uploading executables: If you let users upload files to a directory inside of the webroot, make sure that they can’t upload executables which might run on the server. You can enforce this by either refusing to upload executables, or by changing the web server settings so that it won’t run them. Better yet, keep user uploads outside of the webroot and retrieve them with a "proxy" page.
    3. If for any reason you are allowing the user to submit directory paths or filenames in a URL or FORM, make sure that the information they submit doesn’t give them access to any part of your filesystem outside of the web root. For instance, you need to remove all instances of ‘../’ from such user data. I've seen other sites do this when they want to distribute whitepapers, for instance-- they specify the full path of the whitepaper as a hidden field in the form you're submitting. If you modify the field, you could perhaps download any file you liked from their server.
  2. Ensure that all personalized SQL queries depend on variables the user can’t manipulate.
    If you are querying the database to send personalized data back to a user, you might not think that the user can or will take advantage of the query. Yet if you are passing a user-defined variable (e.g. a URL or FORM variable) into the query, the user could very easily change that variable in an attempt to query the database for someone else’s information. Make sure that ID numbers in queries are passed from the application server so that they can’t be manipulated by users—or that the query depends on at least one user-uncontrolled variable.
  3. Ensure that application error messages don’t give information about the filesystem or web server configuration
    Many application servers give information about the server software and filesystem when an error is produced. This is meant for debugging during development, and it should not be displayed to users when the site is live.
  4. Try to hide administrative backends with unusual URLs, and make sure passwords are very difficult to guess
    Often times web sites are built with administrative backends, where the site managers can control the site’s content or business logic. These backends are a great convenience, but they need to be protected. First of all, make the URL to the backend hard to guess. Second, make absolutely sure that a username and difficult-to-guess password is required to access it. Third, encrypt the access to the backend with SSL.

February 4, 2007

A Quick List on Web Server Security

Through the years I've learned a few strategies for securing web server configurations (often what I learn comes through mistakes). By no means complete or comprehensive, here's my quick list of essential practices.
  1. Ensure that databases and sensitive assets are stored outside of the web root
    Any file, including your database, which sits inside the web root can be downloaded by a user if they figure out the correct URL. Keep your database outside of the web root, and keep sensitive files outside as well. Most application servers provide methods for sensitive files outside of the web root to be served to authenticated users when appropriate.
  2. Ensure that directory browsing is turned off and that default index pages are specified
    If directory browsing is turned on and the web server doesn’t recognize any of the files in a given directory as a default index page, the server will show a list of all of the files to any user. The server may even let the user navigate between directories.
  3. Ensure that all of the latest patches have been applied to all software
    Make sure to constantly check for and apply patches and upgrades for the operating system, web server, database, and application server software. Some programs can do this automatically, such as Windows Update or the Red Hat Network for Linux; if that isn't available, set up a schedule with reminders as a part of your business processes.

April 2008

Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Creative Commons License
This weblog is licensed under a Creative Commons License.