Developing Secure Web Applications
Introduction Security is definately not an add-on. Security is something that must be concieved and nurtured from the early points of your design. Using SSL and other technologies is noble and useful, but security needs to be a notion that is applied to the very design of your applications. If the roots of your application are not secure, all the technologies you add to it will usually be in vain. As we make this journey, let us remember that total security is illusion. Those advertisments that Oracle makes about their products being unbreakable are foolish. Any seasoned expert in the field of security will laugh at that. Everything is insecure, its simply a matter of how insecure it is. To reduce our risks we should aim at making our products LESS insecure. Any product that says it is unbreakable or unexploitable is not telling the truth about its security. There are many things to worry about. Buggy and blatently insecure software can allow outsiders to potentially do many different things: – execute arbitrary commands on you system – view confidential information – delete important data – dupe your system into thinking they are someone else – gain information about your system and other systems on your network – launch attacks on other servers – intercept data being sent to and from your network As a result of the great risk, it is important that we take a systematic approach to application development that is relatively secure. Four-Layered Web Security When trying to secure a web application, there are four primary layers that we should be concerned with. They are as follows: – OS/Web Server Layer – General Application Layer – Specific Application Layer – Data Layer In case that list isn’t self explanitory, I will go over it quickly. The OS/Web Server layer involves the setup of the operating system and web server. In most cases this involves Linux and Apache. Ideally, this would not be the concern of a developer–but rather a system administrator. This is the first and most crucial step to writing secure web application. The most secure application can be comprimized easily if the server it is running on is insecure. As we move past the first layer, we must move on to the General Application Layer. This layer involves general issues that are in common for just about any web application. The General Application layer involves stuff like GET and POST queries, writing to files, session, etc. This layer includes things that you would deal with in nearly every web application you do. The next thing you should worry about is the Specific Application layer. This layer involves issues that can’t be globally applied to every application you make (ie. WDDX or credit-card transactions). The last layer is the data layer. This is something that a database administrator will probably worry about if you are dealing with large scale implementations. Dividing web security four layers is helpful. Think about these layers and how you can improve the security of each layer. I recommend you stick with the first layer until your are confident with it, then move on to the rest of the layers. It may be a good idea to develop your libraries and classes with second layer security in mind because they will probably be reused alot. The third layer will probably be significantly different in each application, so there is no real way to re-use it in most cases, but there are exception. Disposing of False Untrue Disinformation There are many misconceptions that tend to be generally accepted. Lets expose them! Obscurity does not equal security. hiding your source code is a nice try, but it doesn’t make things more secure. For a vivid example of this, check out the security exploits that have hampered IIS. If the security of your applications relies on its source being hid from prying eyes, your application is not secure. Write your code so that if the whole world would see your source and it would still take them much effort to hack it. Security is not something that can be an add-on. If security was an add-on, everyone who had certain add-ons would have secure applications. That is not the case. You can throw SSL,digital signatures, PGP, and just about any other technology to your system and still have a relatively insecure system. Use technologies to help you to get to your goal of having better security, but don’t think of them as your one-way ticket to perfect security. You may limit access by IP address, but that is not necessarily very secure. What if someone exploits the site which you limit access from? There is also many ways to spoof IP addresses. Following a set of rules will not guarantee your application will be secure. There is no set of standards or rules to follow to ensure that your application are secure. The best you can do is follow a set of PROVEN principles and be ready to adapt to any changes that might be necessary to improve security. Nevertheless,that is not a silver bullet. General Security Principles to Apply There are a set of principles that you can apply to your development activities that will empower you greatly in your ability to write secure applications. Check them out! Control who accesses your web services. Minimalize who knows about about them. If your web application is for internal use only, there is no reason it should be accessible from the outside world. Do less and check/test more. Write minimal applications. Don’t get fancy until you can handle the added complexity. Integrate your changes incrementally and be cautious of what changes you are making to your source. One “fix” can often open upon many other holes. Perform rigorous testing and validation. Use phpUnit (unit testing package) if you are developing a fairly large and complex application or library. Be careful what you borrow. Everybody (even managers) stress the importance of not “rebuilding the wheel”.
Developing Secure Web Applications Read More »