Development Articles
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherDevelopment Articles

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 14th, 2005, 08:00 AM
DevAdmin DevAdmin is offline
Utility Bot
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2004
Posts: 877 DevAdmin Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: < 1 sec
Reputation Power: 0
Securing ASP.Net Applications

Security is vital, especially for applications that are used over the Internet. For anything that requires a user to log in, you must be able to ascertain that the user is who he says he is, and is permitted to access the areas he is trying to access. This article explains how to deal with security and authentication issues in ASP.Net applications.


Read the full article here: Securing ASP.Net Applications

For more discussion go here: Blog Article Discussion


Reply With Quote
  #2  
Old December 14th, 2005, 11:35 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,770 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 6 h 58 m 22 sec
Reputation Power: 469
This is a decent article over Authentication types in ASP.NET, but to say the article covers "Securing" applications isn't true.

Your code below demonstrates how you are using Forms Authentication in the "Real World".

Code:
namespace Auth
{
  using System;
  using System.Collections;
  using System.ComponentModel;
  using System.Web;
  using System.Web.SessionState;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Web.UI.HtmlControls;
       public class CodeBehind : System.Web.UI.Page
          {
               public System.Web.UI.WebControls.Label Message;
                 public System.Web.UI.HtmlControls.HtmlTable tblSignIn;
               public System.Web.UI.WebControls.TextBox txtLogin;
               public System.Web.UI.WebControls.TextBox txtPassword;
               public System.Web.UI.WebControls.Button btnSignIn;//the web            //controls
               protected void btnSignIn_Click(Object obj, EventArgs e)
    {
      if(Page.IsValid)
      {
         // check username/password against a database table
         SQLConnection conn = new 
         SQLConnection("server=localhost;uid=sa;pwd=;database=CodeBehind");
         // get row back based on username/password
         string strSQL = "Select * From Users Where UserId='" + 
                         txtUser.Text + "' And Password = '" +
                         txtPassword.Text + "'";
         SQLDataSetCommand dsc = new SQLDataSetCommand(strSQL, conn);
         // populate a dataset with the SQL results
         DataSet ds = new DataSet();
         dsc.FillDataSet(ds, "Users" );
         // check to see if the dataset contains no rows (if it is EOF (i.e.
         //    contains no rows), then the user is invalid)
         if( ds.Tables["Users"].Rows.Count == 0 )
         {
           Message.Text = "Invalid User Name and Password. Try Again.";
         } else    {
           FormsAuthentication.RedirectFromLoginPage(txtUser.  Text, 
                                                   false);
         }
       }
    }
           }
}

but any programmer with a hint of understand how to secure web based applications can easily spot the flaw in this code.

Code:
string strSQL = "Select * From Users Where UserId='" + 
                         txtUser.Text + "' And Password = '" +
                         txtPassword.Text + "'";

You wrote an article on "Securing ASP.NET Applications", but the code you provided as a sample on how to do it, leaves the application wide open for SQL Injection attacks.

1) You're connecting to a SQL Database, then you use inline SQL, instead of handling the process with a stored procedure.

2) There isn't any type of input validation being done to ensure the input from the client is actually "clean" valid data and not malicious input.

The name of the article would be better titled "ASP.NET Authentication Types", since your articles example code leaves the application vulnerable to the most well known of all web attacks and doesn't secure the application in anyway.

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherDevelopment Articles > Securing ASP.Net Applications


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT