TMAegisBeta
更多 mssql 規則

Microsoft SQL Server

TMA-MSSQL-5.3

Ensure 'Login Auditing' is set to 'failed logins'

中等級 1自動化mssql

說明

This setting will record failed authentication attempts for SQL Server logins to the SQL Server Errorlog. This is the default setting for SQL Server. Historically, this setting has been available in all versions and editions of SQL Server. Prior to the availability of SQL Server Audit, this was the only provided mechanism for capturing logins (successful or failed). Both 'failure' and 'all' are accepted. Default: By default, only failed login attempts are captured. Runs one sqlcmd query with its defaults (Windows authentication to the local default instance); set SQLCMDSERVER, SQLCMDUSER and SQLCMDPASSWORD for another instance or SQL authentication. Needs VIEW SERVER STATE / sysadmin-level read access.

檢查方式

稽核方法: SQL 查詢

sql_query
sqlcmd -b -h -1 -W -Q "SET NOCOUNT ON; CREATE TABLE #l (name sysname, config_value sysname); INSERT INTO #l EXEC master.dbo.xp_loginconfig 'audit level'; SELECT CASE WHEN config_value IN ('failure','all') THEN 'compliant' ELSE 'noncompliant' END FROM #l; DROP TABLE #l;"
預期輸出
compliant

修補方式

修補方法: 操作指南或基礎設施修補檔

Perform either the GUI or T-SQL method shown: GUI Method 1. Open SQL Server Management Studio. 2. Right click the target instance and select Properties and navigate to the Security tab. 3. Select the option Failed logins only under the Login Auditing section and click OK. 4. Restart the SQL Server instance. T-SQL Method 1. Run: EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'AuditLevel', REG_DWORD, 2 2. Restart the SQL Server instance.

屬性

作業系統
不限
標籤
mssqldatabaseloggingaudit
參考資料
CIS Microsoft SQL Server 2025 Benchmark v1.0.0 - 5.3 Ensure 'Login Auditing' is set to 'failed logins'

檢查此主機

請在您有權稽核的機器上執行此指令。掃描為唯讀操作。

shell
tmaegis scan --target mssql