What features do I need to have before I open an ASP.Net app onto the internet?
Before I enable access to a new site, what steps should be done to make sure it's secure and "production ready"?
So far I have the following:
- logging of errors (via ELMAH)
- SSL is enabled, and I have a redirect from HTTP to HTTPS
<customErrors mode="RemoteOnly" />
- Compiled without Debug
My current tech stack is IIS7 & ASP.Net开发者_如何转开发 MVC3.
I'm sure I'm forgetting or not aware of many other items. Any advice?
Protect against sql injection. Use stored procedures OR parameterized sql statements. You can use dynamic sql - but be very careful and if you do - make sure you use parameterized queries and do not form the sql statements 'inline' by appending variables.
Protect against cross site request forgery (CSRF) by making sure you use Html.AntiForgeryToken
Make sure tracing is turned off
Make sure custom errors is turned on so yellow screens of death (ie error details) ar enot displayed to the client.
Protect against cross site scripting by making sure any output you display in your system from your model, database, etc. is encoded by using <%: syntax on your aspx pages and simply @XXXX on your mvc 3 pages, as mvc3 encodes everything BY DEFAULT which is a great enhancement over past methods.
Make sure there are no test accounts in your database.
Ensure no actions can be performed just by the querystring - for instance passing in /MyApp/DeleteUser/10. Require a post to perform an action, and those posts must use Html.AntiForgeryToken and [ValidateAntiForgeryToken] on your controller
Ensure that any users editing information on your page cannot edit (using a tool like fiddler) a primary key hidden on the page thus changing what record they are editing when they post back the changes. You can hash for instance a CustomerId on the page into a hidden field and compare it upon post to make sure it matches what is in the model.
Visit me at tech ed in atlanta next month for my security talk : )
If you are using ELMAH, make sure that access to the elmah.axd handler is secured and not open. Otherwise you are giving potential hackers valuable information.
Ensure your web server is completely up to date with patches and automatically downloads / installs them when available from MS. Way too many sites fail to apply these and get pwned.
Ensure that you have zero dynamic sql in your site; or, at the absolute very least everything is handled via parameterized queries. Along these lines, make sure the database user credentials are locked down so that it only has the capabilities you actually need (hint: dbo level is NOT appropriate).
Ensure that every bit of data entry done by a user is properly escaped so that if it is displayed it does not result in cross site scripting issues. Basically, do a full security audit. If it's important enough, hire an outside firm to do this.
First thing comes to mind is Search engine optimization (SEO). Use the SEO Toolkit by MS to get started.
To add to the above, I always run the free tool Xenu ( http://home.snafu.de/tilman/xenulink.html#Description ) to check for broken links. Even if you use another tool, this provides an excellent double check.
Consider placing a web.config in each sub-folder with appropriate permissions. For example if all images are held in a folder \images then that folder should not be able to serve up an ASCX file, only files with a proper image extension.
Are you doing something user friendly when you get a page not found, such as re-directing the user to a search page? Custom error pages can go a long way to making the site more useable.
You may want to have a robots.txt file and a custom icon, items that are often overlooked.
精彩评论