views:

128

answers:

6

I'm developing an ASP.NET web site for some small business. The site needs a password-protected area where the site owner will manage the site content. For the rest of the world, the site is completely read-only.

I've designed and implemented the following scheme:

  • A user wants to access some protected page.
  • Every protected page inherits "AdminIface" master page, that alters the UI so that user knows he's on a protected page, and checks the security cookie. If no cookie or wrong cookie: redirect to auth.aspx.
  • Auth.aspx generates a big random number using RNGCryptoServiceProvider, then sends it to the client + password form.
  • User enters the password.
  • Client-side JavaScript combines random seed + password, calculates MD5 of the resulting string, posts MD5 to the server.
  • Server compares the random seed with the value hold by Session, if OK it combines random seed + password, calculates the MD5, compares MD5.
  • If the checksum matched – the server generates one more big random number to be used as a security cookie.
  • Server stores the security cookie in Session object, and sends the cookie to the client who's now considered authorized.

The correct password is stored as a string constant in the auth.aspx source.

Is this scheme OK?

P.S. I know AD+Kerberos is much better, however on the godaddy's shared hosting I've got no privileges even to create one more application.

+1  A: 

Ummm, why not http://en.wikipedia.org/wiki/Basic_access_authentication with https (or even without)?

-- What's the real scenario of a threat?

Your method seems a bit hand-rolled. The usual rule is to try to use an existing security system rather than inventing your own. Inventing a new authentication mechanism that is really secure is known to be a very hard problem.

Larry K
AFAIK in Windows world, you must have an AD (or NTLM) user account to use basic authentication? My environment is shared hosting, so I'm unable to create users there or change their passwords.
Soonts
A: 

What is wrong with TLS/SSL? It would provide many benefits here, the least of which is some thread of site->user authentication.

Yann Ramin
+4  A: 

I would just hard code the user authentication into the web.config. This means you can still use the Membership controls. A really good example can be seen here. No database required, nor Membership provider. If you have one user (or very few users) then this is a pretty good option.

If you are worried about the authentication details sitting in the web.config, then you can encrypt specific sections of the web.config.

This would appear to be a much simpler solution than you have implemented.

Junto
+1, just hard code it
Rubens Farias
Junto, Only 1 section of the site needs to be authenticated, and I've got only 1 web.config. I've started to work on this after I've read the following discussion: http://forums.asp.net/t/1033181.aspx
Soonts
You can still operate 1 main web.config. You can leave certain areas of the site open, and others secured. You just need to use the location settings to say which directories or files should be locked down: http://msdn.microsoft.com/en-us/library/ms178692.aspx
Junto
If you want to use MVC, here is a walkthrough I wrote the other day for super simple authentication without a database, but still using the built in Membership controls and features: http://blog.benpowell.co.uk/2010/02/aspnet-mvc-simple-authentication.html
Junto
A: 

As kind of already mentioned, why not just use forms authentication with an SSL cert - dead easy to set up (particularly for one user) and you know that it's been tested... You don't know what you've potentially missed.

Paddy
+1  A: 

Many intelligent people (namely the Software Engineers who created WEP) have tried and failed at creating their own security authentication mechanisms and failed. The possibilities for screwing up your own "custom" security authentication are endless (no offense, but it is an extremely difficult problem to handle even for security experts).

I think it's best to use something that is proven to work such as an SSL certificate based authentication method.

Brock Woolf
+2  A: 

It sound ok. Standard HMAC stuff. However your weaknesses:

  1. Application: relying on javascript and sessions
  2. Security: using a new codebase

Depending on your requirements you might be ok. having said that I strongly suggest using forms authentication, which overcomes these issues and much more.. and it is fairly easy to use.

Maxwell Troy Milton King
1. The authenticated user's environment is controlled.2. I use existing code wherever possible: RNG, MD5 and Base64 from .NET framework classes, MD5 from webtoolkit.info. I only written ~50 LoC myself.
Soonts