Information gathering and application security
The first stage of many potential attacks against your web application involves information gathering. The stage where an attacker investigates the attack surface. There's so much information that can be gathered about your web application and its environment without much effort. Lets look at a very basic example. We'll use a Linux command shell and the telnet utility just to show you how simple and easy information gathering can be.
The first step is to run the telnet command and open up an http session on port 80. As an example we'll use the address www.yourwebapplication.com as the web applications fully qualified domain name.
alex@desktop:~$ telnet www.yourwebapplication.com 80
Trying 10.0.0.8
Connected to www.yourwebapplication.com.
Escape character is '^]'.
The command happily establishes an http session. Now we'll run the http GET command and we'll see what comes back.
GET /
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://www.yourwebapplication.com/">here</a>.</p>
<hr>
<address>Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.1 with Suhosin-Patch mod_ssl/2.2.11 OpenSSL/0.9.8g Server at www.yourwebapplication.com Port 80</address>
</body></html>
Connection closed by foreign host.
Look at all the information thats available to us. We now know that the server is running Apache, PHP, OpenSSL, and Ubuntu Linux. We even know what versions of Apache, PHP, and OpenSSL are running. We also know that everything that hits port 80 is redirected to port 443.
Are there other ways to gather this information? Absolutely but thats not the issue. This was a simple illustration to show you that less than 1 minute with a telnet utility can yield some very useful information.
A great deal of the attack surface has been exposed. Now we know that we can launch attacks against PHP, Apache, OpenSSL, or Linux. So how do you defend against this type of information gathering? The answer is simple but not necessarily easy. Obscure or remove what your web application and its environment are revealing. I'm definitely not a proponent of security by obscurity and thats not what I'm promoting here. I'm simply saying make things harder to find. Always remember that security is a process and any steps you take to make it harder for the bad guys can be circumvented. You have to continually audit, test, and implement mechanisms based on your results. Configure your environment to only return necessary information. Compile your tools from scratch after editing source code if necessary. Change the default error information that your environment is returning. You might have some debugging information enabled by default that could reveal a great deal more about your environment. Information about your back end database for instance or what framwork/s you're using.
When performing security audits against your web application take the time to investigate how much information can be gathered, as you can see sometimes it doesn't take very much skill or effort just a healthy dose of curiosity.