February 2004 - Posts

Register today for Microsoft Tech·Ed 2004

Register today for Microsoft Tech·Ed 2004
May 23 - 28, San Diego, CA

Don’t miss Tech·Ed 2004, the definitive Microsoft conference for building, deploying, securing and managing connected solutions. You’ll find 11 conference tracks and over 400 sessions. Get answers to your technical questions, meet industry experts, evaluate new products, and take advantage of extensive networking opportunities. Register today. http://go.microsoft.com/?LinkID=404299

A Vote: 10 Things Developers Currently Do w/ SQL That They Shouldn't

Here is an agregated list of the 26-ideas that were submitted based on my request (thanks everyone).

I am using this information to put together a TechEd session. I thought I'd open this up to a vote - which 10 would you chose as the worst things developers are currently doing? Post the ten (using their identifying letters) that you'd like to see make the list.

A) You currently use the SysAdmin (sa) account to access your database in a production application.
Developers shouldn't be accessing their database using the SysAdmin (sa) account. This account has to many privelages and a malicious user can take advantage of this. For
example, using a SQL injection attack a malicious user can access all the databases, or even worse, the dreaded xp_cmdshell extended stored procedure.

B) Not only do you use the SysAdmin account, but you never set a password for the SysAdmin account ("server=(local);database=myDB;uid=sa;pwd=;").

C) You use SELECT * FROM MyTable to populate a simple control, such as a TexBox.
Developers should never use SELECT * when all they need are a couple specific fields from the table. For example code shouldn't SELECT * from a table with more than two
fields to load a DropDownList, especially when large data types are used in the table, such as BLOBs and Text.

D) You don't use "SET NOCOUNT ON" and "SET NOCOUNT OFF" when creating stored procedures where you don't need to know the number of rows affected (such as a SELECT * FROM MyTable"). By Using "SET NOCOUNT ON" and "SET NOCOUNT OFF" you will streamline your sproc and reduce the amount of unnecessary data moved between the db and your application.

E) You current have T-SQL DML code embedded in your application code instead of using stored procedures.

F) You don't use any caching and hit your SQL Server on every page request even though the data only changes n-times per day.

G) You pass user input to SQL Server without validating it, or checking for potentially malicious code.

H) You embed your stored procedures with business logic code.

I) You use lots of BLOBs in ADO.NET because its easier than in classic ADO.

J) You store your database connection string in the web.config file, unencrypted.

K) You have over normalized your database.

L) You have lookup tables for data that has only a few possibilities (i.e. Gender: Male/Female)

M) You added the Machine\ASPNET account to the Administrators role in SQL Server.

N) You prefix all of your stored procedures with "sp_".
When the prefix is 'sp_' SQL-Server first check the master database (
http://www.sqlmag.com/Articles/Index.cfm?ArticleID=23011). New system sp's in future releases can have the same name

O) You create VARCHAR(1) columns, VarBinary for True/False columns, etc.

P) You have no error handling in your stored procedures

Q) You use SELECT DISTINCT instead of fine-tuning your joins/where clauses to get the desired results.

R) You don't take advantage of referential integrity, or worse yet, you don't set up relationships between tables when there clearly should be.

S) You don't take advantage of output parameters in stored procedures (i.e. return a whole row of data when you only care about 1 value).

T) You make multiple calls to SQL Server to get the necessary data, when you could have made 1 trip.

U) You don't use Profiler and Index Tuning to get the most out of your design.

V) You use @@Identity to return newly created field values from sprocs.
You should use IDENT_CURRENT or SCOPE_IDENTITY to obtain values created on a specific table or any table in the current scope.
See:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadonet/html/manidcrisis.asp

X) You use EXEC (@stmt) when you should use EXEC sp_executesql @stmt = @stmt

Y) You don't index your foreign key columns.

Z) You use a SELECT statement inside an IF statement.

Requesting Feedback: 10 Things Developers Currently Do w/ SQL That They Shouldn't

I am putting together a list of things developers do with SQL (either in design or in accessing) that they shouldn't do. Ultimately I am going to put this together into a session called “SQL Server Data Access Developer Don'ts (10 Things You Currently Do That You Shouldn't).” So, please post anything you have seen that made you cringe. I will take the entire list and filter it down to the top ten things that we should put a stop to.

Example:

Developers shouldn't be accessing their database using the SysAdmin (sa) account. THis has to many privelages and a malicious user can take advantage of this. Using a SQL Injection attack a malicious user can access all tables in the database, or even worse, the dreaded xp_cmdshell extended stored procedure.

Thanks!

[Jim Blizzard] Breasts and code access security...

Jim Blizzard equates Janet Jackson's right breast to malicious code...sort of...in “Breasts and code access security...

 

My DevDays 2004 Schedule

DevDays is an excellent chance to spend a day focusing on some of the hotest topics for developers using Microsoft technologies, as well as spending some time networking with other technology professionals in your area. This year I will be presenting three (3) sessions in three (3) cities:

Seattle, WA - 3/18/04

  • Overview - ASP.NET Web Application Security Fundamentals
    This session focuses on the fundamentals of Web application security, with an emphasis on Internet Information Services (IIS) and ASP.NET. Attend this session to better understand the security infrastructure built into IIS and ASP.NET and how these two technologies work together to provide a secure platform for Web applications. Topics include IIS security, the ASP.NET worker process, and authentication and authorization models.
  • Defenses and Countermeasures - Secure Your ASP.NET Applications from Hackers
    This session builds on the previous session by presenting countermeasures for the threats outlined there. Topics include input validation; best practices when working with Microsoft SQL Server™, including the use of parameterized commands, stored procedures, accounts with limited privileges, Microsoft Windows® authentication versus SQL Server logins, and secure storage of connection strings; HTML-encoding of user input; vulnerabilities specific to ASP.NET forms authentication and forms authentication cookies; use of encrypted view state rather than hidden fields to maintain state between requests; storage of password hashes rather than passwords for added security; and more.

New York, NY  - 2/23/04

  • Developing Secure Web Applications - Examining an End-To-End, Hack-Resilient Application
    This session features a walk-through of a full-scale ASP.NET application that implements many of the countermeasures and best practices outlined in the previous session.

Newark, NJ - 3/4/04

  • Developing Secure Web Applications - Examining an End-To-End, Hack-Resilient Application
    This session features a walk-through of a full-scale ASP.NET application that implements many of the countermeasures and best practices outlined in the previous session.