TMAegis
mssql のその他のルール

TMA-MSSQL-3.4

Ensure SQL Authentication is not used in contained databases

中レベル 1自動mssql

説明

Contained databases do not enforce password complexity rules for SQL Authenticated users. Iterates contained databases only. Default: SQL Authenticated users (USER WITH PASSWORD authentication) are allowed in contained databases. 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; DECLARE @n int = 0, @k int, @db sysname, @s nvarchar(max); DECLARE c CURSOR LOCAL FAST_FORWARD FOR SELECT name FROM sys.databases WHERE state = 0 AND HAS_DBACCESS(name) = 1 AND containment <> 0; OPEN c; FETCH NEXT FROM c INTO @db; WHILE @@FETCH_STATUS = 0 BEGIN SET @s = N'USE ' + QUOTENAME(@db) + N'; SELECT @k = COUNT(*) FROM (SELECT name FROM sys.database_principals WHERE name NOT IN (''dbo'',''Information_Schema'',''sys'',''guest'') AND type IN (''U'',''S'',''G'') AND authentication_type = 2) AS x;'; EXEC sp_executesql @s, N'@k int OUTPUT', @k = @k OUTPUT; SET @n = @n + @k; FETCH NEXT FROM c INTO @db; END; CLOSE c; DEALLOCATE c; SELECT @n;"
期待される出力
0

修正方法

修正方法: ガイダンスまたは IaC パッチ

Leverage Windows Authenticated users in contained databases.

プロパティ

オペレーティングシステム
すべて
タグ
mssqldatabaseauthentication
参照
CIS Microsoft SQL Server 2025 Benchmark v1.0.0 - 3.4 Ensure SQL Authentication is not used in contained databases

このホストをチェック

監査が許可されているマシンで実行してください。スキャンは読み取り専用です。

shell
tmaegis scan --target mssql