When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles [1.x] [2.0]
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips
Search

Sections:
Book Reviews
Sample Chapters
Commonly Asked Message Board Questions
Headlines from ASPWire.com
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
Web Hosts
XML Info
Information:
Advertise
Feedback
Author an Article
Technology Jobs

















internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers
ASP ASP.NET ASP FAQs Message Board Feedback ASP Jobs
Print this page.

Windows Systems Administrator
Jupitermedia
US-CT-Darien

Justtechjobs.com Post A Job | Post A Resume

Published: Friday, February 04, 2000

Security Alert - Using includes Improperly from non-Debugged ASP Pages can allow Visitors to View your souce code
By Jerry Walsh


Security Flaw
If you use include files improperly, you may be in for a nasty surprise. By improperly, I mean that you give include files an extension other than .asp. For example, say that you have an include file named dbConn.inc, which established a connection to your Access database. Imagine that dbConn.inc had the following code:

- continued -

<%
  Dim objConn
  Set objConn = Server.CreateObject("ADODB.Conection")
  
  objConn.ConnectionString = "DRIVER={Microsoft Access (*.mdb)};" & _
                 "DBQ=" & Server.MapPath("/MyDatabase.mdb")
  objConn.Open
%>

The above snippet of code, I'd assume, is common on many ASP sites. The problem is that the file has a .inc extension. So, if someone entered into their browser, http://www.yourserver.com/dbConn.inc, they could view the source code of dbConn.inc, which could be disastrous, since dbConn.inc indicates the location of an Access database file on the Web server that could also be easily downloaded by anyone (http://www.yourserver.com/MyDatabase.mdb).

Now, you may not be worried, thinking that no one could guess the filename dbConn.inc. Perhaps you're right. However, look closely at the code above, specifically on line 3. Note that the class string, ADODB.Connection, is spelled incorrerctly, missing a second n in Connection. This will cause an error.

Again, you may think, "So what?" Well, say that from somePage.asp you include dbConn.asp, like so:

<!--#include virtual="/dbConn.inc"-->
<%
  'Do stuff with the database
%>

Now, when you visit somePage.asp, you will get an error, reading along the lines of:

Microsoft VBScript runtime error '800a004' 

Invalid Class String

/dbConn.inc, line 3 

Again, you may be thinking, "So what?" Well, if this ASP page is not debugged, and someone visits it, now they know how to get to see the source code for dbConn.inc! You may decide not to link to somePage.asp until you have it debugged, but you still run the following risk that one of the major search engines may index them. These indexed ASP pages can be then located with a simple search, and the source code for the include file viewed!

To view some of these security holes, use the following procedure:

    - In the Altavista search engine execute a search for +"Microsoft VBScript runtime error" +".inc, ". This will look for files that have some sort of error in an included .inc file.

    - Look for search results that include the full path and filename for an include (.inc) file. You'll see the description of the search result as something like:

    Microsoft VBScript runtime error '800a004c' Path not found. /NewSite/header.inc, line 94

    - Append the include filename to the host name of the returned search hit, and call this up in a web browser. There are even some very large web sites with this flaw!

    Example: AltaVista's Shopping Site - http://shopping.altavista.com/inc/lib/prep.lib
    Example: Microsoft - http://www.microsoft.com/windows/downloads/inc/global.inc (be sure to do View/Source to see the code)

    Note: these files, which are suppose to be hidden, expose database connections and properties, resource locations, cookie logic, server IP addresses, business logic, and other, similar, pieces of information!

There are many examples you can find of this just by searching through AltaVista! Many of these sites reveal important business logic code, database connection information, and other sensitive information.

Resolution
To avoid this fate for your Web site, be sure to fully debug your ASP scripts before publishing them on the web! Furthermore, security administrators need to secure the ASP include files so that external users can not view them. You can do this in two ways:

  • Give your include files an extension that external viewers cannot see (such as .asp).
  • Place all of your included files into a single directory, and turn off Read permissions for that directory.

To learn more about include files, be sure to read The low-down on includes.


Windows Internet Technology | ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Microsoft Article: 7.0, Microsoft's Lucky Version?
Microsoft Article: Hyper-V--The Killer Feature in Windows Server 2008
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Windows Server 2008
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES