Securing
SQL
Server
Second Edition
Protecting
Your
Database from
Attackers
Denny Cherry
Technical Editor
Michael
Cross
ELSEVIER
AMSTERDAM•BOSTON•HEIDELBERG•LONDON
NEW YORK•OXFORD•PARIS•SAN DIEGO
SANFRANCISCO•SINGAPORE•SYDNEY•TOKYO
SyngressisanImprintof Elsevier
Acknowledgments
vDedication vii
Author
Biography
ix About the Technical Editor xiIntroduction xxi
CHAPTER
1
Securing
the Network
1Securing
the Network 1 Network Firewalls 2Server Firewalls 7
Direct Internet Access 9 Public IPAddressesversusPrivateIPAddresses 11
Accessing
SQL
Server fromHome 14Physical Security
15Keep
YourHands OffMy
Box 16Open
Network Ports 17Unlocked Workstations 17
Social
Engineering
20Finding
theInstances 20Testing
the NetworkSecurity
22Summary
24CHAPTER
2
Database
Encryption
25Database
Encryption
25Hashing
versusEncryption
25Hashing
27Encrypting Objects
29Encrypting
Data within Tables 30Encrypting
within MicrosoftSQL
Server 32Encrypting
Data atRest 41TDEand FILESTREAM 44
Log Shipping,
DatabaseMirroring,
andAlways
On 44Key
Protection 45Encrypting
Dataonthe Wire 46SQL
ServerOver SSL 46Hiding
the Instance 54IP Sec 54
xiv
Contents
Encrypting
Data with MPIO Drivers 60 PowerPathEncryption
with RSARequirements
andSetup
62Encrypting
Data via HBAs 72Summary
73CHAPTER
3
SQL Password
Security
75SQL
Server PasswordSecurity
75 Extended Protection 77Strong
Passwords 81 Contained DatabaseLogins
inSQL
Server 2012 84Encrypting
Client ConnectionStrings
88SQL
Reporting
Services 88Application
Roles 89Using
Windows Domain PoliciestoEnforcePassword
Length
93Windows Authentication
Group
Policies 95Windows Domain
Requirements
to UseDomainPoliciesto
Manage SQL
AuthenticationLogins
97Contained Databases 100
Contained Databases and Auto Close 100
db_owners
CanNowAddNew UserstotheInstance 100
Password Policies and Contained Users 101
Summary
101CHAPTER
4
Securing
the
Instance
103 WhattoInstall, and When? 103SQL
Authentication andWindowsAuthentication 106Editing
the master.mdfFile 110Using
aDebugger
toIntercept
Passwords IllPurchased Products 111
Password
Change
Policies IllAuditing
FailedLogins
114Renaming
the SA Account 115Disabling
the SAAccount 116Securing Endpoints
118StoredProceduresasa
Security
Measure 119Access toBase Tables Isn't
Required
120 Minimum Permissions Possible 121 InstantFile Initialization 123Linked Servers 125 NTLM Double
Hop
Problems 126Securing
Linked Servers 126Using
PoliciestoSecure Your Instance 132SQL
AzureSpecific
Settings
137InstancesThat Leave the Office 138
Securing "Always
On" 140Securing
Contained Databases 141 ContainedDatabasesandAlways
On 144Summary
144CHAPTER
5
Additional
Security
for
anInternet
Facing
SQL Server and
Application
147SQL CLR 147
Extended Stored Procedures 152
Protecting
YourConnectionStrings
154 Database Firewalls 155 Clear VirtualMemory Pagefile
155 User AccessControl (UAC) 159 Other Domain PoliciestoAdjust
162Summary
163CHAPTER 6
Analysis
Services
165Logging
intoAnalysis
Services 165Granting
AdministrativeRights
166Granting
Rights
toanAnalysis
Services Database 168Securing Analysis
ServicesObjects
172Data Sources 172 Cubes 174 CellData 177 Dimensions 179 Dimension Data 181
Mining
Structures 185Summary
190CHAPTER 7
Reporting
Services
191Setting upSSRS
191 Service Account 194Web Service URL 195
Database 197
xvi
Contents
Settings
200 Execution Account 202Encryption Keys
202Scale-Out
Deployment
204Logging
ontoSQL
ServerReporting
Servicesforthe first time 205
Security
withinReporting
Services 206 Item Roles 206System
Roles 208Adding System
Roles 209Adding
Folder Roles 211Reporting
ServicesAuthenticationOptions
213Anonymous
Authentication 214 Forms Authentication 216Security
WithinReporting
Services 217Report
ServerObject
Rights
218Changing
Permissionson anObject
218Hiding Objects
220Summary
220CHAPTER 8
SQL
Injection
Attacks
221 What isanSQL Injection
Attack? 221Why
areSQL
Injection
Attacks soSuccessful? 226HowtoProtectYourselfFroman
SQL Injection
Attack 227 NETProtectionAgainst
SQL Injection
227Protecting Dynamic SQL
WithinStoredProceduresfrom
SQL Injection
Attack 232Using
"EXECUTEAS"toProtectDynamic
SQL
233Removing
ExtendedStored Procedures 236Not
Using
Best Practice CodeLogic
can Hurt You 236WhattoReturntothe End User 238 Database Firewalls 239
Test, Test,Test 240
Cleaning Up
theDatabaseAfteranSQL
Injection
Attack 240Other Front-End
Security
Issues 243 The Web Browser URL is Not the Placefor Sensitive Data 243
Using
xEventstoMonitorForSQL
Injection
245CHAPTER 9
Database
Backup
Security
249Overwriting Backups
250Deleting
OldBackups
252 Media Set andBackup
SetPasswords 255Backup Encryption
256LiteSpeed
forSQL
Server 257 Red GateSQL HyperBac
257RedGate
SQL Backup
258Third-Party Tape
Backup
Solutions 259Transparent
DataEncryption
260Securing
theCertificates 261Compression
andEncryption
262Encryption
and DataDeduplication
263Offsite
Backups
264Summary
266CHAPTER 10
Storage
Area
Network
Security
267Securing
theArray
267Locking
DowntheManagement
Ports 268Authentication 269
User Access tothe
Storage
Array
270Locking
Down the iSCSI Ports 270LUN
Security
270Snapshots
and Clones 271Securing
theStorage
Switches 272 Fiber Channel 272iSCSI 273
Fiber Channel overEthernet 273
Management
Ports 273Authentication 274
Zone
Mapping
274Summary
274CHAPTER
11
Auditing
for
Security
275Login
Auditing
276SQL
Server2005 and Older 276SQL
Server2008 and Newer 278Using
xEvents forAuditing
Logins
284Auditing sysadmin
DomainGroup Membership
289 Data ModificationAuditing
290xviii
ContentsQuerying Changed
Data 293Using
xEvents For Data ModificationAuditing
294Using
SQL
Server AuditforData Modification 296 DataQuerying Auditing
297Schema
Change
Auditing
300Using
Extended Events for SchemaChange
Auditing
300Using
Policy-Based Management
toEnsurePolicy
Compliance
302 C2Auditing
306Common Criteria
Compliance
308Summary
310CHAPTER
12 Server
Rights
3iiSQL
ServerService AccountConfiguration
312One Account for AllServices 312 One AccountPerSever 313
OneAccount forEach Service 313
Using
LocalService Accounts forRunning
SQL
ServerServices 314Credentials 317
SQL
ServerAgent Proxy
Accounts 320OS
Rights
Neededby
theSQL
ServerService 323 WindowsSystem
Rights
323SQL
Server'sNTFS Permissions 325 OSRights
Neededby
the DBA 325 Dual Accounts 326 OSRights
NeededtoInstallServicePacks 327 OSRights
NeededtoAccess SSISRemotely
327Console
Apps
mustdie 330 Fixed-ServerRoles 331 UserDefined ServerRoles 332AlwaysOn
333Instance WidePermissions 334
Fixed Database Roles 334
Fixed DatabaseRolesin the msdbDatabase 335
User Defined Database Roles 337 Default
Sysadmin Rights
339 Vendor's and theSysadmin
Fixed-ServerRole 340CHAPTER 13
Securing
Data
343GRANTing
Rights
344DENYing Rights
348REVOKEing Rights
349Column Level Permissions 349 Row Level Permissions 351