跳至主要内容
版本:0.4 · 現行版

SQL Server 安全檢查

參考審閱日期:2026年10月11日
適用於:Excubius 0.4角色: 操作員, 編輯者, 實體管理員
方案Pro · Enterprise部署自行託管

sqlserver_security 模組有 9 項檢查。SQL Server 安全態勢(對齊 CIS,唯讀)。發現會計入安全分數中的數據庫安全領域。建議行動是供 DBA 在變更時段內依照執行的文字說明;平台絕不會自行執行。

本頁面在建置文件時由產品的檢查目錄產生,因此規則、間隔及預設嚴重程度一律與你正在閱讀的版本相符。閾值是預設值;實體和資源可以覆蓋這些閾值。

檢查間隔預設嚴重性規則
sqlserver_security.sa_enabled
sa login enabled
3600scriticalis_disabled = 1
sqlserver_security.command_execution
Operating-system command execution enabled (xp_cmdshell, OLE Automation)
3600scriticalvalue_in_use = 0
sqlserver_security.surface_area
Surface-area features enabled
3600swarningvalue_in_use = 0
sqlserver_security.linked_server_credentials
Linked servers using sa or self credentials
3600scriticalwarning >= 1 count / critical >= 1 count
sqlserver_security.sysadmin_members
Members of sysadmin / securityadmin
300scriticalany change
sqlserver_security.failed_logins
Failed logins per minute
60swarningwarning >= 10 per_minute / critical >= 50 per_minute
sqlserver_security.audit_enabled
Server audit enabled and running
3600swarningis_state_enabled = 1
sqlserver_security.encryption
TDE and backup encryption
3600swarningbackup_encrypted = true
sqlserver_security.orphaned_users
Orphaned database users
86400sinfowarning >= 1 count

檢查​

sqlserver_security.sa_enabled

sa login enabled

量度
sa_enabled · 每 3600s · tsql
規則
is_disabled = 1 · 預設嚴重性: critical
措施
Confirm that no application, job or linked server signs in as sa (the error log and a login trace show it), then disable it in a change window (ALTER LOGIN [sa] DISABLE) and rename it if your policy requires it. Use named logins with only the permissions they need.
基準
CIS Microsoft SQL Server Benchmark: sa must be disabled (and ideally renamed); enforce password policy if it must exist. The well-known sid 0x01 finds it even when renamed. · 來源

sqlserver_security.command_execution

Operating-system command execution enabled (xp_cmdshell, OLE Automation)

量度
feature_enabled · 每 3600s · tsql
規則
value_in_use = 0 · 預設嚴重性: critical
措施
Find what uses the option (search jobs and procedures for xp_cmdshell / sp_OACreate) with its owner. If nothing needs it, turn it off in a change window (EXEC sp_configure 'show advanced options', 1; RECONFIGURE; EXEC sp_configure 'xp_cmdshell', 0; RECONFIGURE;). If it must stay, restrict who can run it and accept the risk with a reason.
基準
CIS: xp_cmdshell and Ole Automation Procedures must be 0 unless a documented exception exists. · 來源

sqlserver_security.surface_area

Surface-area features enabled

量度
feature_enabled · 每 3600s · tsql
規則
value_in_use = 0 · 預設嚴重性: warning
措施
Ask the owner of the instance whether the option is needed (Database Mail XPs is needed by Database Mail, clr enabled by CLR assemblies). If not, set it to 0 in a change window (EXEC sp_configure '<option>', 0; RECONFIGURE;); if it is, accept the risk with the reason so the next review knows.
基準
CIS 2.1–2.8: each should be 0 unless documented. Command execution (xp_cmdshell, OLE Automation) is checked separately as critical. · 來源

sqlserver_security.linked_server_credentials

Linked servers using sa or self credentials

量度
risky_linked_logins (count) · 每 3600s · tsql
規則
warning >= 1 count / critical >= 1 count · 預設嚴重性: critical
措施
Create a remote login with only the rights the linked server needs (often read-only), map the local logins that use the linked server to it (sp_addlinkedsrvlogin with @useself = 'FALSE'), then remove the catch-all or sa mapping (sp_droplinkedsrvlogin) in a change window. Test the queries that use the linked server afterwards.
基準
Linked-server mappings must use a least-privilege remote login, never sa or a catch-all self credential. · 來源

sqlserver_security.sysadmin_members

Members of sysadmin / securityadmin

量度
privileged_members · 每 300s · tsql
規則
any change · 預設嚴重性: critical
措施
Confirm the change with the person who made it (the server audit or the default trace shows who) and that an approved request exists. If it was not approved, remove the member in a change window (ALTER SERVER ROLE [sysadmin] DROP MEMBER [<login>]) and review what the login did meanwhile. Resolve the event once reviewed.
基準
Any change in membership raises an event (the first run only records the baseline); review quarterly. · 來源

sqlserver_security.failed_logins

Failed logins per minute

量度
failed_logins_per_min (per_minute) · 每 60s · tsql
規則
warning >= 10 per_minute / critical >= 50 per_minute · 預設嚴重性: warning
措施
Read the error log entries (error 18456; the state number says why) to find the login and the client address. A service with an expired or changed password is fixed by its owner; an unknown client is blocked at the firewall. Keep CHECK_POLICY = ON for SQL logins so the Windows lockout policy applies.
基準
Bursts of failed logins from one client indicate brute force or a broken service credential. · 來源

sqlserver_security.audit_enabled

Server audit enabled and running

量度
audit_state · 每 3600s · tsql
規則
is_state_enabled = 1 · 預設嚴重性: warning
措施
Create (or enable) a server audit that writes to a protected location, with a server audit specification for at least FAILED_LOGIN_GROUP, SUCCESSFUL_LOGIN_GROUP, SERVER_ROLE_MEMBER_CHANGE_GROUP and AUDIT_CHANGE_GROUP; turn it on with ALTER SERVER AUDIT [<name>] WITH (STATE = ON). An audit that is defined but disabled on purpose should be dropped or accepted with a reason.
基準
CIS 5.x: at least one server audit capturing login and role changes, enabled and running. · 來源

sqlserver_security.encryption

TDE and backup encryption

量度
encryption_state · 每 3600s · tsql
規則
backup_encrypted = true · 預設嚴重性: warning
措施
Create a certificate (or asymmetric key) in master, back it up with its private key to a safe place outside the server, then change the backup jobs to BACKUP DATABASE … WITH ENCRYPTION (ALGORITHM = AES_256, SERVER CERTIFICATE = <certificate>). Restore one encrypted backup on another server before relying on it. Consider TDE for databases with regulated data.
基準
Production backups should be encrypted; TDE recommended for regulated data (https://learn.microsoft.com/sql/relational-databases/security/encryption/transparent-data-encryption). · 來源

sqlserver_security.orphaned_users

Orphaned database users

量度
orphaned_users (count) · 每 86400s · tsql
規則
warning >= 1 count · 預設嚴重性: info
措施
For each user listed in the evidence, map it to its login when the login exists (ALTER USER [<user>] WITH LOGIN = [<login>]); otherwise confirm with the database owner that it is no longer needed and drop it (DROP USER [<user>]). On availability groups, create logins with the same SID on every replica.
基準
Orphaned users are a sign of restores without login sync; clean up or remap. · 來源