3.security and Encryption
3.security and Encryption
Database—each server can have multiple databases. A database is a collection of securable objects.
Principal—a person, group, or process that needs to access data. Privileges granted to principals are managed
by the SQL Server security framework.
Logins
SQL Authentication
In Windows authentication, the user should first authenticate himself within Active Directory. SQL Server
authenticates users through the Windows principal token in the OS. With that, SQL Server does not ask for a
password for identity validation. Therefore, Windows confirms users’ identities for authentication. SQL Server does
not store the credentials in the Windows authentication. The connection using Windows authentication is called a
trusted or integrated connection.
Creating login
Server Roles
Server-level roles help manage permissions for the entire SQL Server instance. SQL Server provides several
built in server roles, but you should add your own specific roles if possible. Fixed server roles cannot be
changed.
You can also assign server-level principals (Windows groups and accounts, and SQL server logins) to these
roles. Fixed server roles allow members to add other users to the same role, but this is not so for user-defined
server roles.
SQL Server provides the following fixed server roles, starting with least privileged roles:
public—default role for server principals who do not have specific securable object permissions. Only assign
public permissions to objects that can be made available to all users. You cannot revoke public permission
from any server role.
dbcreator—can alter, create, drop, or restore databases.
diskadmin—can manage disk files.
bulkadmin—can execute BULK INSERT
setupadmin—can add/remove linked servers and run Transact-SQL
processadmin—can end running processes in the SQL server instance.
securityadmin—can administer logins, can reset SQL server login passwords, and grant, deny or revoke
server-level permissions or database-level permissions
serveradmin—can alter server configuration and shut it down
sysadmin—can perform all server activities.
Database Roles
SQL server defines roles that enable management of database-wide permissions. You can use the ALTER
ROLE statement to add and remove users to database roles.
Like server-level roles, there are fixed database-level roles built into SQL Server, and you can create
additional roles, customizing them using the GRANT, DENY, and REVOKE statements.
Fixed roles exist independently for each database within your SQL Server instance. The db-owner server role
is allowed to manage membership of fixed database roles.
Microsoft SQL Server provides the following fixed database roles:
db_owner—allowed to perform all maintenance and configuration activities on the database, as well as
dropping the database
db_securityadmin—can modify custom role memberships and manage permissions. Monitor this role
closely as it has the ability to escalate privileges.
db_accessadmin—can add/remove database access for Windows groups and logins, as well as SQL Server
logins
db_backupoperator—can perform database backups
DDL – Create, alter, truncate,
db_ddladmin—can run data definition language (DDL) commands
drop, rename
db_datawriter—can add, change, or delete any user table data.
db_datareader—limited to reading data from user tables
db_denydatawriter—are not allowed to add, modify or delete user table data
db_denydatareader—cannot read any of the data in a user table
In addition to database-level roles, SQL Server also enables defining permissions at the row level.
Audit
We can completely or partially automated (using server level DDL triggers, alerts, third party tools etc.)
Audit Specification
Statements
Extended events
SQL Server Extended Events were introduced with SQL Server 2008 as a light weight way to create
customized monitoring of SQL Server.
Many people view SQL Server Extended Events as a replacement for Profiler/Server Side Trace.
Extended Events are a lot more than that. Extended Events provide a set of methods for collecting
different events from SQL Server and correlating those different events within a single tool. It’s
possible to grab:
Deadlocks + waits