Securing ASP.NET in hosting environment

Last post 07-28-2009 5:34 AM by RickNZ. 8 replies.

Sort Posts:

  • Securing ASP.NET in hosting environment

    07-22-2009, 9:41 PM
    • Member
      point Member
    • ThomasMack
    • Member since 11-25-2006, 3:51 AM
    • Posts 19

    I plan on offering free and cheap ASP.NET web hosting. I am creating my own back end panel in C#/ASPNET. When a new account is created, I am programmatically creating the website and app pool in IIS using Microsoft.Web.Administration.

    How can I go about blocking any kind of security threats related to ASP.NET for the websites I created programmatically? I mean in general, how would I go about securing IIS/ASP.NET?

  • Re: Securing ASP.NET in hosting environment

    07-23-2009, 12:02 AM
    • Contributor
      5,226 point Contributor
    • RickNZ
    • Member since 01-01-2009, 8:43 AM
    • Nelson, New Zealand
    • Posts 867

    Putting customers in their own AppPools is a good first step.

    In addition, you can limit the required trust level, from full to something less.

    You should also have each AppPool run as a unique Windows user, with all of their website files owned by the same user.



  • Re: Securing ASP.NET in hosting environment

    07-23-2009, 10:42 PM
    • Member
      point Member
    • ThomasMack
    • Member since 11-25-2006, 3:51 AM
    • Posts 19

    Wow, I looked right over that trust level! For free hosting, is LOW the best choice? I'm not sure how to create a Windows user account and set permissions on a directory to that user- how hard is this in C#?

  • Re: Securing ASP.NET in hosting environment

    07-24-2009, 12:26 AM
    • Contributor
      5,226 point Contributor
    • RickNZ
    • Member since 01-01-2009, 8:43 AM
    • Nelson, New Zealand
    • Posts 867

    Lower levels of trust are more secure.  The tradeoff is that they also severely restrict what your users are able to do.  If your free hosting is only intended to support extremely vanilla sites, then low should be fine.  You can look in the system web.config files to see the exact differences from one trust level to another.

    Creating and managing user accounts is easy, particularly with .NET 3.5, where you can use the AccountManagement library.  Here's a link to a page with some example code:

    http://www.codeproject.com/KB/system/usingAccountManagement.aspx

    You would probably also want to assign all of your free users to a common group, to help ease certain management aspects.

    BTW, another cool feature that you might want to use if you intend to support both free and paid sites is Windows System Resource Manager (WSRM).  It comes with Windows 2008, and can allow you to limit the CPU time used by certain groups of users/AppPools/etc.

  • Re: Securing ASP.NET in hosting environment

    07-24-2009, 9:59 PM
    • Member
      point Member
    • ThomasMack
    • Member since 11-25-2006, 3:51 AM
    • Posts 19

    Thank you. You have helped me a lot, I greatly apperciate it.

  • Re: Securing ASP.NET in hosting environment

    07-24-2009, 11:46 PM
    • Member
      55 point Member
    • MissEn4med
    • Member since 06-25-2009, 5:52 PM
    • Posts 46

    I have two friends who would like to try out having their own site but do not want to fork out money until they can see what it is all about. Do you think the method you've listed here would be appropriate for creating them an account to play with until they know if they would like to purchase hosting as well?

    My suggested VPS and Reseller Hosting provider is ResellerChoice.
  • Re: Securing ASP.NET in hosting environment

    07-25-2009, 12:51 AM
    • Member
      point Member
    • ThomasMack
    • Member since 11-25-2006, 3:51 AM
    • Posts 19

    MissEn4med:

    I have two friends who would like to try out having their own site but do not want to fork out money until they can see what it is all about. Do you think the method you've listed here would be appropriate for creating them an account to play with until they know if they would like to purchase hosting as well?

    Not sure what you are asking, do they need hosting?


    Also, I am getting a error on the server now when it attempts to create the website in IIS7. Server is Windows 2008:

    Server Error in '/new' Application.

    Filename: redirection.config
    Error: Cannot read configuration file due to insufficient permissions

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.UnauthorizedAccessException: Filename: redirection.config
    Error: Cannot read configuration file due to insufficient permissions



    ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

    To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [UnauthorizedAccessException: Filename: redirection.config
    Error: Cannot read configuration file due to insufficient permissions

    ]
    Microsoft.Web.Administration.Interop.AppHostWritableAdminManager.GetAdminSection(String bstrSectionName, String bstrSectionPath) +0
    Microsoft.Web.Administration.Configuration.GetSectionInternal(ConfigurationSection section, String sectionPath, String locationPath) +218
    Microsoft.Web.Administration.ServerManager.get_SitesSection() +121
    Microsoft.Web.Administration.ServerManager.get_Sites() +31


    Any ideas?

  • Re: Securing ASP.NET in hosting environment

    07-28-2009, 1:17 AM
    • Member
      55 point Member
    • MissEn4med
    • Member since 06-25-2009, 5:52 PM
    • Posts 46

    Hi again, I meant, I have two friends who each want to do a website, so I thought I would create each of them an account off my VPS so that they could play around with hosting and try and create their sites, but to be honest I'm not sure how to do that since I just use the VPS for myself.

    My suggested VPS and Reseller Hosting provider is ResellerChoice.
  • Re: Securing ASP.NET in hosting environment

    07-28-2009, 5:34 AM
    • Contributor
      5,226 point Contributor
    • RickNZ
    • Member since 01-01-2009, 8:43 AM
    • Nelson, New Zealand
    • Posts 867

    ThomasMack:

    Any ideas?

    Is there something about the error message that isn't clear?  It looks like you need to grant permission to your AppPool user to access the files that you're trying to change.


Page 1 of 1 (9 items)