Best Practices and Techniques For Building Secure ASPNET Apps
Best Practices and Techniques For Building Secure ASPNET Apps
Techniques for
Building Secure
ASP.NET Applications
Patrick Hynds,
CriticalSites
Experience / Background
Services
Notables
Built 1st Windows logo certified .Net app
Regularly present at:
TechEd US and TechEd Hong Kong
.Net Users Groups worldwide (INETA Speaker)
and many other international events
Agenda
Threat modeling
Security Starting with IIS
Beyond the Web Server
Authentication
Authorization
Configuration settings
Storing secrets
Data validation
Internal Threats
Disgruntled employee
Bad faith business partner
Human engineering
Virus proliferation
Credential reuse outside your org
Improper configuration of security
settings
At home backups
External Threats
Random script kiddie
Slighted prospect
Unscrupulous Competitor
Zombie Army Enlistment
Warez Hijacking
Determined, Professional Attack
Being first to get hit by a new exploit
Agenda
Threat modeling
Security Starting with IIS
Beyond the Web Server
Authentication
Authorization
Configuration settings
Storing secrets
Data validation
Anonymous Authentication
Resource Access as anonyomous
IUSR_Machinename (i.e. IUSR_Typhon)
Process identity:
LocalSystem or
IWAM_Machinename (i.e. IWAM_Typhon)
Basic Authentication
Process identity: IWAM or LocalSystem
Resource access as authenticated user
Pros
Least common denominator
Cons
Clear text password (Base64 Encoded)
Digest Authentication
Pros
No clear text password over the wire
Works through proxies
Password is not known to IIS
Cons
Medium secure
Internet Explorer 5 and higher
No delegation
Requires Active Directory
Password in AD (reversible encryption)
Windows Integrated
Authentication
Security Support Provider (SSPI)-based
NTLM or Kerberos
IIS asks the client what protocol
it supports
Protocol can be enforced
NTAuthenticationProviders
Negotiate
NTLM
Kerberos
NTLM Authentication
Pros
Works out-of-the-box
Provides automatic logon/no logon
dialog box
Cons
Enterprise only does not work
through Proxy Servers
(keep-alive connection required)
No delegation
Configured to be compatible with
older clients
Kerberos Authentication
Issues
DC has to be client accessible
Service Principal Name
Domain Administrator needs to be involved
Unconstrained!
Setup
Best description in designing secure
Web-based applications
Cons
Higher management costs for PKI
Usability
Scalability and performance
Authentication Grid
Scheme
Securit
y
Limitations/Comment
s
Anonymous None
Client
Support
Scenario
All
All
Basic
Low
All
All
Digest
Medium
All
NTLM
Medium
Internet Explorer
only
Only Intranet,
doesnt work
with Proxies
Kerberos
High
IIS Client
Cert
Mapping
High
All newer
browsers
All
AD Client
Cert
Very High
All newer
browsers
All
Agenda
Threat modeling
Security Starting with IIS
Beyond the Web Server
Authentication
Authorization
Configuration settings
Storing secrets
Data validation
Windows Authentication
Can be used in combination with Basic,
NTLM, Digest, Kerberos, and so forth
User is authenticated by IIS
Easiest of all
Request flow
Forms Authentication
Uses cookie to authenticate
Enables SSL for logon page
Often used for personalization
Forms
Authentication
Flow
Cookie-Based Authentication Architecture
ASP.NET
Authentication
Not
Authenticated
Not
Authenticated
Cookie
Login Page
(Users enter
their credentials)
Authenticated
Authorized
Authenticated
Authorized
Requested
Page
demo
Forms Authentication
Authorization
Process of determining whether a user is
allowed to perform a requested action
File-based authorization
Performed by FileAuthorizationModule
Performs checks against Windows ACLs
URL-based authorization
Performed by UrlAuthorizationModule
demo
Custom Authentication
with Roles
Configuration Settings
Review production configuration:
<customErrors> RemoteOnly or On
Make sure that verbose remote errors are not
enabled
Do not reveal exception details in custom error pages
<compilation> disable debugging
Review IIS scriptmaps
Shared servers
Use configuration lockdown
<location allowOverride=false/>
Machine.Config
Some settings vary by .Net
Framework version
HTTPGet
HTTPPost
HTTPSoap
demo
Machine.Config for
Security
Accounts
Administrator
Deception planning against hackers
Service Accounts
Storing Secrets
Do avoid secrets when you can
demo
Random Salt in the DB
Data Validation
Validate all input data
Use ASP.NET validation controls
Use regular expressions for other cases
(e.g., web service parameters)
Summary
Security is a war! Dont fight fair.
Defense in Layers
Not a part time job or nice to have
feature anymore
Make Security part of every aspect of
your projects
should be about 12% of effort per project
Resources
How ASP Security Works
An overview of ASP Security
http://msdn.microsoft.com/library/dotnet/cpguide/
cpconhowaspnetsecurityworks.htm
Questions