This site is the archived OWASP Foundation Wiki and is no longer accepting Account Requests.
To view the new OWASP Foundation website, please visit https://owasp.org

Difference between revisions of ".NET Security Cheatsheet"

From OWASP
Jump to: navigation, search
(Added Windows Update, Authors and Other Cheat Sheets.)
(Saving little by little. It is a web form after all. Added Injection and XSS, .NET Rootkits.)
Line 10: Line 10:
  
 
==.NET Framework Guidance==
 
==.NET Framework Guidance==
 +
 +
The .NET Framework is the set of APIs that support an advanced type system, data, graphics, network, file handling and most of the rest of what is needed to write line of business apps in the Microsoft ecosystem. It is a nearly ubiquitous library that is strong named and versioned at the assembly level.
 +
 +
=== Data Access ===
 +
 +
* Use Parameterized SQL commands for all data access, without exception.
 +
* Do not use SqlCommand with a string parameter made up of a concatenated SQL String.
 +
* Whitelist allowable values coming from the user. Use enums, TryParse or lookup values to assure that the data coming from the user is as expected.
 +
* Apply the principle of least privilege when setting up the Database User in your database of choice. The database user should only be able to access items that make sense for the use case.
 +
 +
=== General ===
 +
 +
* Always check the MD5 hashes of the .NET Framework assemblies to prevent the possibility of rootkits in the framework. Altered assemblies are possible and simple to produce. Checking the MD5 hashes will prevent using altered assemblies on a server or client machine.
  
 
==ASP.NET Web Forms Guidance==
 
==ASP.NET Web Forms Guidance==
 +
 +
ASP.NET Web Forms is the original browser-based application development API for the .NET framework, and is still the most common line of business platform the web application development.
 +
 +
* Do not disable validateRequest in the web.config or the page setup. This value enables the AntiXSS library in ASP.NET and should be left intact to present cross site scripting.
 +
* Whitelist allowable values anytime user input is accepted. The regex namespace is particularly useful for checking to make sure an email address or URI is as expected.
 +
* Always encode output to the browser using Server.HtmlEncode.
  
 
==ASP.NET MVC Guidance==
 
==ASP.NET MVC Guidance==

Revision as of 22:59, 20 November 2012

DRAFT CHEAT SHEET - WORK IN PROGRESS

Introduction

This page intends to provide quick basic .NET security tips for developers.

The .NET Framework

The .NET Framework is Microsoft's principal platform for line of business development. It is the supporting API for ASP.NET, Windows Desktop applications, Windows Communication Foundation services, SharePoint, Visual Studio Tools for Office and other technologies.

Updating the Framework

The .NET Framework is kept up-to-date by Microsoft with the Windows Update service. Developers do not normally need to run seperate updates to the Framework. Windows update can be accessed at http://windowsupdate.microsoft.com/ or from the Windows Update program on a Windows computer.

.NET Framework Guidance

The .NET Framework is the set of APIs that support an advanced type system, data, graphics, network, file handling and most of the rest of what is needed to write line of business apps in the Microsoft ecosystem. It is a nearly ubiquitous library that is strong named and versioned at the assembly level.

Data Access

  • Use Parameterized SQL commands for all data access, without exception.
  • Do not use SqlCommand with a string parameter made up of a concatenated SQL String.
  • Whitelist allowable values coming from the user. Use enums, TryParse or lookup values to assure that the data coming from the user is as expected.
  • Apply the principle of least privilege when setting up the Database User in your database of choice. The database user should only be able to access items that make sense for the use case.

General

  • Always check the MD5 hashes of the .NET Framework assemblies to prevent the possibility of rootkits in the framework. Altered assemblies are possible and simple to produce. Checking the MD5 hashes will prevent using altered assemblies on a server or client machine.

ASP.NET Web Forms Guidance

ASP.NET Web Forms is the original browser-based application development API for the .NET framework, and is still the most common line of business platform the web application development.

  • Do not disable validateRequest in the web.config or the page setup. This value enables the AntiXSS library in ASP.NET and should be left intact to present cross site scripting.
  • Whitelist allowable values anytime user input is accepted. The regex namespace is particularly useful for checking to make sure an email address or URI is as expected.
  • Always encode output to the browser using Server.HtmlEncode.

ASP.NET MVC Guidance

XAML Guidance

Windows Forms Guidance

WCF Guidance

Authors and Primary Editors

Troy Hunt - troyhunt [at] hotmail.com
Bill Sempf - bill [at] pointweb.net
Patrick Leclerc - patrick.leclerc [at] owasp.org
Jerry Hoff - jerry.hoff [at] owasp.org


Other Cheatsheets

OWASP Cheat Sheets Project Homepage