یادداشت حقوقی: کاربر حق ترجمه و بازنشر این اثر را برای پروژه تأیید کرده است.PAGE-343بخش سوم — امنیت، تابآوری و مقیاسپذیری Workload
بخش سوم کتاب از امنیت SQL Server آغاز میشود و سپس به Encryption، Backup/Restore، High Availability و روشهای Scale-out میرسد. فصل ۱۰ مدل امنیتی SQL Server را از سطح Principalهای Windows تا Server، Database و Object بررسی میکند.
PAGE-344فصل ۱۰ — مدل امنیتی SQL Server
Security Hierarchy
مدل امنیتی SQL Server لایههای همپوشان دارد. Principal میتواند Login، User، Role یا Group باشد و Securable میتواند Server، Database، Schema، Object یا Column باشد. Permissionها با GRANT، DENY و REVOKE مدیریت میشوند. فهم سلسلهمراتب برای اجرای اصل Least Privilege ضروری است.
PAGE-345در بالاترین سطح Windows/Domain Principal قرار دارد، سپس Login در سطح Instance، User در سطح Database و Roleها برای گروهبندی مجوزها. یک Login میتواند به Userهای متفاوت در Databaseهای مختلف نگاشت شود. Ownership و Role Membership نیز در محاسبه Effective Permission اثر دارند.
Figure 10-1 — شکل/تصویر منبع، صفحه PDF 345PAGE-346CREATE DATABASE Chapter10;
GO
USE Chapter10;
GO
مثالهای فصل در Database جدا اجرا میشوند تا ساخت Role، User، Schema و Permission بدون دخالت Objectهای دیگر نشان داده شود.
PAGE-347Instance-Level Security
امنیت Instance شامل Authentication، Login، Server Role و Permissionهای سطح Server است. Windows Authentication معمولاً گزینه ترجیحی است، چون چرخه هویت و Password Policy از Active Directory بهره میبرد؛ SQL Login برای سناریوهایی که Windows Identity قابل استفاده نیست باقی میماند.
PAGE-348SA و Hardening
Login sa در Mixed Mode قدرت کامل دارد و هدف شناختهشدهای برای Attack است. کتاب نشان میدهد میتوان نام آن را تغییر داد و در صورت عدم نیاز غیرفعال کرد. این اقدام جای Password قوی، Network Security و Least Privilege را نمیگیرد اما سطح حمله را کاهش میدهد.
ALTER LOGIN sa WITH NAME = [RenamedSA];
PAGE-349Fixed Server Roles
Fixed Server Roleهای مهم| Role | کارکرد کلی |
|---|
| sysadmin | کنترل کامل Instance؛ Permission Check عملاً دور زده میشود |
| serveradmin | تنظیم Configuration و Shut down |
| securityadmin | مدیریت Login و Permissionهای امنیتی |
| processadmin | مدیریت Processها |
| setupadmin | مدیریت Linked Server و برخی Setupها |
| bulkadmin | اجرای Bulk Operation |
| diskadmin | مدیریت Disk Fileهای SQL Server |
| dbcreator | Create/Alter/Drop/Restore Database |
| public | Role پایه برای همه Loginها |
Table 10-1 — بازنمایی متن فنی جدول منبع--- PDF PAGE 349 ---
334
You can set the authentication mode in SQL Server Management Studio within the
Security tab of the Server Properties dialog box. You will need to restart the SQL Server
service for the change to take effect.
Server Roles
SQL Server provides a set of server roles, out of the box, that allow you to assign instance-
level permissions to logins that map to common requirements. These are called fixed
server roles, and you cannot change the permissions that are assigned to them; you can
only add and remove logins. Table 10-1 describes each of these fixed server roles.
Table 10-1. Fixed Server Roles
Role
Description
sysadmin
The sysadmin role gives administrative permissions to the entire instance.
A member of the sysadmin role can perform any action within the instance
of the SQL Server relational engine.
blkadmin
In conjunction with the INSERT permission on the target table within a
database, the bulkadmin role allows a user to import data from a file using
the BULK INSERT statement. This role is normally given to service accounts
that run ETL processes.
dbcreator
The dbcreator role allows its members to create new databases within the
instance. Once a user creates a database, he is automatically the owner of that
database and is able to perform any action inside it.
diskadmin
The diskadmin role gives its members the permissions to manage backup
devices within SQL Server.
processadmin
Members of the processadmin role are able to stop the instance from T-SQL
or SSMS. They are also able to kill running processes.
public
All SQL Server logins are added to the public role. Although you can assign
permissions to the public role, this does not fit with the principle of least
privilege. This role is normally only used for internal SQL Server operations,
such as authentication to TempDB.
(continued)
Chapter 10 SQL Server Security Model
--- PDF PAGE 350 ---
335
Role
Description
securityadmin
Members of the securityadmin role are able to manage logins at the
instance level. For example, members may add a login to a server role (except
sysadmin) or assign permissions to an instance-level resource, such as
an endpoint. However, they cannot assign permissions within a database to
database users.
serveradmin
Serveradmin combines the diskadmin and processadmin roles. As well
as being able to start or stop the instance, however, members of this role can
also shut down the instance using the SHUTDOWN T-SQL command. The subtle
difference here is that the SHUTDOWN command gives you the option of not
running a CHECKPOINT in each database if you use it with the NOWAIT option.
Additionally, members of this role can alter endpoints and view all instance
metadata.
setupadmin
Members of the setupadmin role are able to create and manage linked
servers.
Table 10-1. (continued)
You can also create your own server roles, which group users who need a common
set of permissions that are tailored to your environment. For example, if you have a
highly available environment that relies on availability groups, then you may wish to
create a server role called AOAG and grant this group the following permissions:
•
Alter any availability group
•
Alter any endpoint
•
Create availability group
•
Create endpoint
You can then add the junior DBAs, who are not authorized to have full sysadmin
permissions, but who you want to manage the high availability of the instance, to this
role. You can create this server role by selecting New Server Role from the context menu
of Security ➤ Server Roles in SSMS. The General tab of the New Server Role dialog box is
illustrated in Figure 10-2.
Chapter 10 SQL Server Security Model
|
PAGE-350Fixed Roleها مجموعه Permission از پیش تعریفشدهاند و قابل تغییر نیستند. عضویت در Roleهای قدرتمندی مانند securityadmin یا dbcreator باید محدود باشد، چون میتواند به مسیرهای Elevation of Privilege منجر شود. برای نیازهای دقیقتر، User-Defined Server Role مناسبتر است.
PAGE-351User-Defined Server Role
CREATE SERVER ROLE ReportingAdmins;
GRANT VIEW SERVER STATE TO ReportingAdmins;
ALTER SERVER ROLE ReportingAdmins ADD MEMBER [MyDomain\User1];
Role سفارشی امکان اعطای فقط Permissionهای لازم را میدهد. این روش نسبت به افزودن کاربر به Fixed Role بزرگتر، Least Privilege را بهتر پیاده میکند.
Figure 10-2 — شکل/تصویر منبع، صفحه PDF 351PAGE-352Logins
Login نقطه ورود به Instance است. SQL Login نام/Password را در SQL Server نگه میدارد؛ Windows Login به User/Group دامنه یا Local Account متصل میشود. در SSMS میتوان Default Database، Default Language، Server Role و User Mapping را تنظیم کرد.
Figure 10-3 — شکل/تصویر منبع، صفحه PDF 352PAGE-353در SQL Login باید Password Policy و Expiration در صورت مناسب بودن فعال شوند. Authentication Mode و وجود/عدم وجود Login sa از تصمیمهای امنیتی کلیدیاند. Default Database نامعتبر میتواند Login را دچار خطا کند، بنابراین Database پایداری مانند master معمولاً انتخاب امنی برای اکانتهای مدیریتی است.
PAGE-354CREATE LOGIN Danielle WITH PASSWORD = 'Strong-Password-Here';
CREATE LOGIN [MyDomain\SQLUser] FROM WINDOWS;
در Production Password نمونه کتاب نباید تقلید شود. Windows Groupها برای اداره تیمی اغلب قابل مدیریتتر از ایجاد Login جدا برای تکتک اشخاصاند.
PAGE-355Granting Permissions
GRANT VIEW SERVER STATE TO [Danielle];
DENY ALTER ANY LOGIN TO [Danielle];
-- REVOKE یک GRANT یا DENY صریح را حذف میکند.
GRANT اجازه میدهد، DENY بهطور صریح منع میکند و معمولاً بر GRANT ارثرسیده غلبه دارد. REVOKE به معنی DENY نیست؛ فقط Permission صریح را حذف میکند تا Effective Permission از Parent/Role تعیین شود. Syntax Permission روی Classهای مختلف Server/Endpoint/Login متفاوت است.