Classic ASP Design Mistakes
- 1 Overview
- 2 ASP Pages Execution Order Issues
- 3 Other Issues
There are several issues inherent to classic ASP pages that may lead to security issues, we are talking about beginner mistakes or confuse code. The following examples will give you a good idea of what I am talking about :). All of these examples are based on my experience on ASP testing.
- Author: Juan Carlos Calderon
ASP Pages Execution Order Issues
First of all I want to explain the processing levels on ASP pages, ASP pages are executed in the following way:
- Server Side Includes. first, the interpreter adds to the current file the text of all the files in include sentences and process it as if ti was a single file.
- Server Side VBSCript Code. second, the VBScript in <% and %> code is executed.
This might be obvious, however ignoring this 3 single bullets might lead to severe security issues. Here are some examples
Wrong dynamic inclusion of files.
<% If User = "Admin" Then %> <!--#include file="AdminMenu.inc"--> <% Else %> <!--#include file="UserMenu.inc"--> <% End If %>
The previous code will add the content of both files to the ASP page execution as SSI are executed first than ASP code, it is possible that the page is displayed correctly due to the "If" sentence, however all the code will be processed, this might lead to race condition or undesired execution of functions.
If you a proficient in ASP technology it will be clear for you the result of the previous code, however, many developers cannot tell the final output
Yes this is not possible, but that is another reason to look for it.
<script> var name; name = prompt ("Enter your User:"); <% If name != "user" Then 'The user is an admin Role = "Admin" Else Role = "User" End IF %> <script>
Here is another example
You will always go to Yahoo and will never be displayed with a prompt.
Stopping execution with Response.End
Lack of this sentence might end up in execution of undesired code.
<% If Not ValidInfo Then %> <script> alert("Information is invalid"); location.href="default.asp"; </script> <% End if Call UpdateInformationFunction() %>
Java classess hosted in MS Java Virtual Machine
These classes can be called from ASP pages so you should look also for insecure functionality into those classes. This is an example
<html><body> <% Dim date Set date = GetObject("java:java.util.Date") %> <p> The date is <%= date.toString() %> </body></html>
Mis-typed variables might lead to race conditions on business logic. This option will force the user to declare all the used variables, it will add a bit of performance as well.
This property determines if the client has disconnected from the server since the last Response.Write. This property is particularly useful to prevent the server from continuing execution of long pages after an unexpected disconnect. As you might figured out this is very useful property to avoid DoS attacks to the Server and DB in long execution pages.