11.07.2015 Views

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 14: Building Secure Data Access 379AuthenticationWhen your application connects to a SQL Server database, you have a choice ofWindows authentication or SQL authentication. Windows authentication is moresecure. If you must use SQL authentication, perhaps because you need to connect tothe database using a number of different accounts <strong>and</strong> you want to avoid callingLogonUser, take additional steps to mitigate the additional risks as far as possible.Note Using LogonUser to create an impersonation token requires the powerful “Act as part of theoperating system” privilege on Microsoft Windows 2000 <strong>and</strong> so this approach should be avoided.Consider the following recommendations:●●●Use Windows authentication.Protect the credentials for SQL authentication.Connect using a least privileged account.Use Windows AuthenticationWindows authentication does not send credentials over the network. If you useWindows authentication for a <strong>Web</strong> application, in most cases, you use a serviceaccount or a process account, such as the ASPNET account, to connect to thedatabase. Windows <strong>and</strong> SQL Server must both recognize the account you use on thedatabase server. The account must be granted a login to SQL Server <strong>and</strong> the loginneeds to have associated permissions to access a database.When you use Windows authentication, you use a trusted connection. The followingcode fragments show typical connection strings that use Windows authentication.The example below uses the ADO.NET data provider for SQL Server:SqlConnection pubsConn = new SqlConnection("server=dbserver; database=pubs; Integrated <strong>Security</strong>=SSPI;");The example below uses the ADO.NET data provider for OLE DB data sources:OleDbConnection pubsConn = new OleDbConnection("Provider=SQLOLEDB; Data Source=dbserver; Integrated <strong>Security</strong>=SSPI;" +"Initial Catalog=northwind");

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!