Chapter 11. Security
Section 11.0. Introduction Recipe 11.1. Hardening Your Systems with Strong Passwords Recipe 11.2. Protecting Queries from SQL Injection Recipe 11.3. Guarding Against Cross-Site Scripting Attacks Recipe 11.4. Restricting Access to Public Methods or Actions Recipe 11.5. Securing Your Server by Closing Unnecessary Ports |
11.0. Introduction
Security is important to some degree in most software, but is
The best approach is to treat all your applications with care when it comes to securing them from
The two big security categories for web applications are
SQL injection
and
cross-site scripting
(XSS). Other attacks could come from your server becoming compromised by some other type of network attack or by a compromised
Keep this basic rule in mind: filter input, escape output. |
Recipe 11.1. Hardening Your Systems with Strong PasswordsProblemShort, guessable passwords represent a serious security risk to your servers and the services that run on them. You want a reliable system for creating sufficiently strong passwords or passphrases, and a way to manage them. SolutionGenerating strong passwords or passphrases is one of the most important things you can do to protect your servers and data. Here are some basic properties of a good passphrase:
To generate sufficiently strong passphrases you can use the Diceware method, which selects
Notice that this command produces a passphrase that is 23
The point of them being easily memorized is to keep you from ever writing them down. However, most developers have dozens of passwords to keep track of. This reality forces people to use the same password for many systems or write down the passwords for each system.
One solution is to use a password managing program that stores and organizes all your passwords in an encrypted format. These programs require a single master password for access, and often allow you to organize usernames and passwords into groups. An
Figure 11-1. The KeePassX password manager
If you choose to use a password manager, the strength of the master password is critical to the security all of the systems that you store information about. Extra care should be taken to keep this password safe. Also, you should always make
Discussion
A passphrase is similar to a password in usage, but is
Password strength can have different meanings depending on the context of the situation in which the password is being used. One factor in gauging a password's strength is the length of time a hacker has in which to crack the password before the information being hidden no longer needs securing. It doesn't matter if a password is cracked after the data it protects has ceased to be
Another factor is the importance of the information being protected by the password. A database containing hundreds of thousands of credit card numbers is worth a lot of money, and someone who wants to steal those numbers will be willing to go to great lengths. Systems that access valuable data like this need very strong passwords, as well as other
See Also
|