TMAegisBeta
More rules for mssql

Microsoft SQL Server

TMA-MSSQL-3.13

Ensure no admin role membership in MSDB database

MediumLevel 1Automatedmssql

Description

Based on Microsoft design an account with DB_OWNER can elevate permissions to SYSADMIN Default: Default value is that only dbo user is member of db_owner role in MSDB database 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.

How it is checked

Audit method: SQL query

sql_query
sqlcmd -b -h -1 -W -Q "SET NOCOUNT ON; SELECT COUNT(*) FROM msdb.sys.database_role_members AS drm JOIN msdb.sys.database_principals AS r ON drm.role_principal_id = r.principal_id JOIN msdb.sys.database_principals AS m ON drm.member_principal_id = m.principal_id WHERE r.name IN ('db_owner','db_securityadmin','db_ddladmin','db_datawriter') AND m.name <> 'dbo';"
Expected output
0

How it is fixed

Fix method: Guidance or infrastructure patch

USE [msdb] GO ALTER ROLE [db_owner] DROP MEMBER <username>;

Properties

Operating systems
Any
Tags
mssqldatabaseprivileges
Reference
CIS Microsoft SQL Server 2025 Benchmark v1.0.0 - 3.13 Ensure no admin role membership in MSDB database

Check this host

Run this on a machine you are allowed to audit. The scan is read-only.

shell
tmaegis scan --target mssql