Web Application Security

Only available on StudyMode
  • Topic: PHP, Web server, Web development
  • Pages : 6 (1495 words )
  • Download(s) : 138
  • Published : March 4, 2013
Open Document
Text Preview
Web Application Security
By: Darkvengance Date: November 25, 2011

Introduction Throughout the years many aspiring programmers and many amazing web applications have surfaced. Though these applications and websites had amazing functionality and were very user-friendly they all shared one common flaw: A lack of attention to security. Due to this reason many of them were rejected by the public community or were even taken offline by malicious attackers. Due to these reasons the creation of this paper came to be. This paper will touch on many topics including: good coding practices, insecure hashing and encryption methods, SQL injections, session fixation, cross-site scripting (XSS), file inclusion, and arbitrary command injection. Please remember that while reading this PHP will be the primary language referenced, however if you use other server side languages the same concepts may still be applied. Throughout this writing it is assumed that the reader will have a basic working knowledge of PHP, HTML, Javascript, and MySQL, as well as knowledge of the basic workings of web applications (database connections, content presentation, etc). By the end of this paper you will be equipped with the knowledge of efficient coding practices which will allow you to program and develop secure applications, protected against the most widely applied techniques used by the majority of black-hat crackers and white-hat penetration testers.

Coding Practices

Even the most basic of all application security, whether it be web, desktop, server or cloud based, starts with good coding practices. The definition of “good” coding practices varies from programmer to programmer however, they all revolve around two primary concepts: efficiency and “looks”. The main goal here is to learn the

very basics, however as everyone has their own way of doing things, you should find what works best for YOU and stick with it. First we'll start with looks. You may be thinking to yourself “who cares how my code looks?”, well, you should! If you code looks good and is well commented then you, as well as anyone you ask for assistance, will be able to easily scan through the code and quickly pin-point any errors in it. Let's look at an example. Quickly review both of the codes below and identify the error (you should not spend more then 10 seconds on each).

Example #1

Example #2

Did you notice the error? Both examples were the exact same code, and had the exact same error in them (missing a period after the $key variable in the foreach loop); however, as you may have noticed example two was a lot easier to read, thus making it that much easier to identify errors. The most common method is to indent blocks of code that are already within blocks, this especially proves true with anything that uses curly brackets (ex. Functions, if statements, while statements, etc.). Indenting is the one thing that nearly all programmers, regardless of what language they are using, agree on. Some languages (such as python) even require indenting code. As stated earlier, all programmers have their own way of doing things, however, the most common method is simply one indent per level, with the exception of level one. When the word “level” is mentioned, it means every block of code that is within another block, for simplicity's sake, the opening and closing PHP tags denote the start and end of level one and every time you encounter an opening curly bracket a new level begins and a closing curly bracket denotes the end of a level. Take the following code for example:

The above script will eliminate the risk of RFI by limiting the input to only two colors, although it is still not wise to trust user input for functions such as include or require. Directory Transversal

Directory Transversal was one of the first web site attacks, and still remains fairly popular among hackers today. Directory transversal is an attack which involves “working backwards” through...
tracking img