首页 > 编程 > .NET > 正文

Security Hole In ASP.NET Beta 1 (from angryCoder)

2024-07-10 12:58:19
字体:
来源:转载
供稿:网友
security hole in asp.net beta 1
jonathan goodyear, mcsd, mcp, cls
4/30/2001

background
in the beta 1 version of the .net framework, configuration settings for asp.net web applications are kept in an xml formatted file named config.web. there is one config.web file at the machine level, with the option of having copies with overriding settings in any directory of your web application. settings in a config.web file cascade to all sub-directories in your web application, unless overridden by another config.web file.

for beta 2, microsoft changed things around. asp.net settings at the machine level will now live in a file named computer.config, while settings at the web application level will be contained in files named web.config. microsoft is encouraging the use of the ".config" file extension for xml based configuration files; even those that are custom built. some examples of this are the portal.config file used in the ibuyspy portal application, and the ezine_settings.config file used in the ezine.framework upon which the angrycoder site is built.

the hole
the security hole comes into play due to the fact that the new naming convention for xml based configuration files didn't come about until after beta 1 was released. this means that the default asp.net settings allow files with the ".config" extension to be browsed as clear text. i was made aware of this situation when an angrycoder reader (luckily an honest one) emailed me my user name and password that he had obtained by navigating to my ezine_settings.config with his browser. one of the disadvantages of giving away the source code for the ezine.framework is that aspiring hackers have a convenient roadmap of my entire site. it gave me a rather unsettling feeling in my gut to find out that i had been careless enough to leave my site so exposed.

the fix
there are two bright spots to this security hole. first, it is limited to beta 1 because files with the ".config" extension will be guarded by default in beta 2. second, there are two different, yet equally easy, fixes for the hole that you can implement right now.

the first fix option is the one that the ibuyspy portal application implemented. they placed their portal.config file in a directory that the anonymous user account does not have "read" privileges for. using this method, their business logic components can still import and use the xml settings in the file, while keeping it from the prying eyes of hackers.

the second fix option is the one that i implemented for angrycoder. the first step is to open up the internet services manager mmc snap-in and configure files with the ".config" extension to be handled by the asp.net isapi application. you do this by right-clicking your web application, and choosing the "properties" menu option. then, select the "home directory" tab, and click the "configuration button". the "app mappings" tab of the application configuration screen should now be showing. click the "add" button. on the dialogue that pops up, browse to the c:/winnt/microsoft .net/framework/v1.0.2204/ directory and select the xspisapi.dll file (hint: you'll probably have to click the "files of type" drop-down and select "dynamic link libraries" to make the file browsable). after you've selected the xspisapi.dll file, enter ".config" in the "extension" box, then click the "ok" button. click the "ok" button again at the application configuration screen, and again at the web application properties screen.

now that you've told iis that the asp.net isapi application should handle files with the ".config" file extension, the next step is to tell your web application what, specifically, to do when a user browses to one of these files. this entails adding a setting to your config.web file:
<configuration>
  <httphandlers>
    <add verb="*" path="*.config" type="system.web.httpnotfoundhandler" />
  </httphandlers>
</configuration>

what this does is tell the asp.net engine to invoke the system.web.httpnotfoundhandler httphandler when a file with the ".config" file extension is browsed. this displays a message to the person browsing for the file that it could not be located.

the rub
if you are going to follow microsoft's naming convention for xml configuration files using beta 1 of the .net framework, take the proper steps to prevent exposing your web application's private settings to the world by implementing one of the two fixes outlined above. in beta 2, this will all be handled for you by default. my name is jonathan goodyear, and i am the angrycoder.

have you found any security holes in beta 1 of the .net framework? are there any security issues that you would like to see fixed by the time version 1 of the .net framework is released? share your experiences and voice your opinions by clicking the "post your comments" link below, or talk it over with others in either the angrycoder forums (which can be found in the menu bar to your left), or the angrycoder listserv. 
  • 本文来源于网页设计爱好者web开发社区http://www.html.org.cn收集整理,欢迎访问。
  • 发表评论 共有条评论
    用户名: 密码:
    验证码: 匿名发表