Posts
Summary of the 2022 Security Investments in Azure SQL and SQL Server 2022
/0 Comments/in SecurityThe mission of the Security & Governance team in the Azure Databases organization is to ensure that
(1) the data our customers entrust in our services is safe and managed in a manner that is compliant with all regulations and privacy laws,
(2) that all SQL products are integrated with Microsoft Purview and Microsoft Defender, and
(3) that we offer a portfolio of industry leading security features that help customers meet the most stringent security requirements.
2022 was another successful year for our team and we are excited about the features and capabilities we shipped in our products. This blog post highlights some of the important deliverables our teams have made in security and data governance that are generally available (GA) in Azure SQL Database (DB), Azure SQL Managed Instance (MI) or in SQL Server 2022.

|
Authentication |
• Azure Active Directory (Azure AD) authentication for SQL Server 2022 • Managed identity in Azure AD for Azure SQL DB & Azure SQL MI • Ability to turn off SQL Authentication in favor of Azure AD only for Azure SQL DB & Azure SQL MI • Windows Authentication for Azure AD principals in Azure SQL MI |
|
SQL Roles & Permissions |
• New built-in server-level roles for SQL Server 2022 • New granular permissions for Azure SQL DB, Azure SQL MI and SQL Server 2022 |

|
Data-at-rest encryption using Transparent Data Encryption (TDE) in SQL |
• Automated Key Rotation for TDE BYOK for Azure SQL DB & Azure SQL MI • User-Assigned Managed Identity for TDE CMK for Azure SQL DB and Azure SQL MI |
|
Ledger |
• Ledger for Azure SQL DB and SQL Server 2022 |

|
Private Link |
• Azure Private Link for Azure SQL DB and Azure Synapse Analytics |
|
Firewall Rules & Network Security Groups |
• Outbound firewall rules for Azure SQL DB and Azure Synapse Analytics |

|
Data Classification |
• Availability of Microsoft Information Protection labels when using native data classification in Azure SQL DB & Azure SQL MI • Availability of Microsoft Information Protection labels when using SSMS with native data classification SSMS in SQL Server (any supported version) |
|
Integration with Microsoft Purview |
• Microsoft Purview access policies for SQL Server 2022 |

|
Auditing |
• User Managed Identity (UMI) support for Auditing for Azure SQL DB • Named replicas in Azure SQL Hyperscale can now be audited with SQL Auditing (Azure SQL DB) |
More detailed information on the security portfolio supported by SQL Server 2022 can be found here: What’s new in SQL Server 2022 – SQL Server – Security | Microsoft Learn
In addition to the features listed above, our team has also released a number of security features that are specifically available only in SQL Server on Azure Compute VMs: What’s new? – SQL Server on Azure VMs | Microsoft Learn.
How SQL Server Checks Permissions: Internals of the SQL Server 2022 Permission System
/0 Comments/in SecurityIf you have not read about it before, we recently made some deep changes within the permissions of SQL Server. The two most relevant announcements are here:
New granular permissions for SQL Server 2022 and Azure SQL to improve adherence with PoLP
In this article I want to share some more details on why and how we changed the access check code. The answers are less straight-forward than one may think, and some of you may find it interesting.
minor update, Oct 17/2022
In the original article I listed the following Action being part of the Azure Purview for the built-in action-group “SQL Performance Monitor”:
/SqlServers/SystemViewsAndFunctions/ServerSecurityState/Rows/Select
this is incorrect. That Action is part of the “SQL Security Auditor”-role. The correct Action for the “SQL Performance Monitor” is
/Sqlservers/Databases/SystemViewsAndFunctions/DatabasePerformanceState/Rows/
The Why
1)
The first part of the answer to the question “Why?” is quite straightforward: we want to make it easier for customers to adhere to the Principle of Least Privilege (explained here: Security: The Principle of Least Privilege / POLP). And for that we need to create permissions that are more specific, in other words, cover more granular operations than before.
In the announcement-article (New granular permissions for SQL Server 2022 and Azure SQL to improve adherence with PoLP) I also explain a bit how I approached this when we worked on the permissions that cover viewing system metadata:
By keeping a balance between increased security and increase of complexity. The main take-away is, that rather than coming up with a new permission for every individual object, which surely would have driven everyone crazy, we decided to group all these system objects into 2 groups: those which expose information about the security-state of the system – and all the rest. This “all the rest” is covered under the new permission-name PERFORMANCE STATE respectively PERFORMANCE DEFINITION. That way it is possible to keep personae that work on troubleshooting performance and related issues away from gaining insights into the security state of the system.
2)
But there is a second reason that plays a vital role in this undertaking, which has additional implications as you will see:
At the same time as I was responsible for the SQL Server permission system in general, I was also working on a second project: Integrate external policies from Azure Purview to use for access control into SQL Server.
(This new feature was announced here: controlling access to Azure SQL at scale with policies in Purview)
To achieve that, the SQL Server engine permission evaluation algorithm had to be extended to allow permission-checks based on external policies. Policies which are received from Azure Purview contain so-called “Actions,” which can be either allowed or denied.
As you read above, to change the old SQL permissions to the new more granular permissions on system objects, we had to go through each and every permission check already.
Realizing this potential to “Kill two birds with one stone” (no actual birds were harmed in the process, I swear), I convinced the team that doing both changes at the same time would in the long-term safe us a lot of time. Plus, the chances that someone else would want to touch the same code later again would be much lower. While of course doing both at once still added some overhead comparing this to changing the very same code paths later would have been much more extra work.
Therefore, I am glad that the team followed through on that, despite this being unexciting, repetitive work on these 800+ objects.
The undertaking
The main work went into the splitting of permissions for viewing system metadata, which is exposed via (A) Dynamic Management View (DMVs (Dynamic Management Views)) and Dynamic Management Functions (DMFs) for information that is often generated at runtime and (B) Catalog Views for static information.
By splitting, I am referring to the fact that was once covered by (the minimum) permission VIEW DATABASE STATE is now either covered by VIEW DATABASE PERFORMANCE STATE or VIEW DATABASE SECURITY STATE and other 3 splits that we did in this area. The new permissions (see New granular permissions for SQL Server 2022 and Azure SQL to improve adherence with PoLP for details) are lower permissions than the former minimum permissions and at the same time they are still covered by the respective former permissions which are now parent permissions.
These changes of permission requirements naturally required a huge effort by the engineering team that entailed adding new Permission checks for currently about 800 System Objects (DMVs, Catalog Views and DMFs) (!) based on my specification.
- Here it helped that until not long ago I have worked extensively in the space of SQL Server system analysis for about 18 years and working with these objects was my daily bread & butter :).
Big Kudos to all the involved engineers, for fighting through it to the end and not giving up at the sight of this enormous task!
How VIEW SERVER STATE was split up and onboarded to external policies control
Let’s look at a specific example, which can serve as a blueprint for all the changes that we did: Splitting up the SQL permission VIEW SERVER STATE and onboarding it to allow external policy-based checks.
When VIEW SERVER STATE is granted to a Login, this Login (aka the grantee) can read data from Dynamic Management Views (and -Functions) on the server – hundreds of them.
To do that the user will run a command like SELECT * FROM sys.dm_exec_requests.
But there is more: this permission also grants access to some System Stored Procedures such as sys.sp_readerrorlog. For that, the command EXECUTE sys.sp_readerrorlog is used.
And then there are DBCC Commands such as DBCC SQLPERF(NETSTATS) which again have a different syntax.
Explainer: Permissions vs Actions
Before we get into the next part of the work, I need to make sure everyone understands the difference between SQL permissions and so-called actions.
In policy-based access control systems (such as ABAC (attribute-based access control), Attribute-based access control and Azure IAM (Identity & Access Management) RBAC (role-based access control)), usually the term “action” is used instead of permission (also see: Attribute-based access control – Wikipedia). Inside the policy definition, an action is just another attribute, next to subjects (Users) or Object attributes
The difference between action and permission is that actions refer to a specific “operation” like i.e., “read” or “add” or “create.”
On the other hand, a permission is really just an arbitrary name that implies one or more operations to be permitted.
Example
In SQL Server there is a permission called “CONTROL” which can be granted on a database.
But there is no operation in T-SQL (Transact-SQL) that is called “Control” (this is the “arbitrary”-part). Instead, this permission allows the granted user (aka grantee) to run a multitude of commands (“one or more”). In fact, in this specific case almost any command that is available inside a database. It could be anything from a SELECT FROM TableX to ALTER DATABASE.
This hierarchy of SQL permissions is depicted below:

The fact that a permission can allow “one or more” different operations is the most important differentiator between actions and permissions – the latter of which the SQL Server engine used exclusively up until now.
A policy-based permission system that uses actions usually has a separate action for each different operation and those are independent from each other. So-called “covering” permissions, as many traditional database-systems use create challenges for PoLP-compliance and are not commonly used in more modern policy-based access control systems.
This could lead to the following flat list of permissible actions:

Note
While actions themselves are not hierarchical, the objects that they are applied to can and should very well be hierarchically organized. The ability to assign a policy at higher levels of resource-hierarchies, such as subscription or a resource group in Azure, allows for efficient access control without micro-managing individual objects. The same is true within SQL Server Databases where a SELECT-permission granted on a whole database would allow selecting all tables in all schemas.
With this background, it is not hard to guess, that a rich RDBMS such as SQL Server which serves as a platform for many internal and external services and functionalities is hard to bring in line with a concept of atomic actions. I.e. if every single DMV (dynamic management views), system stored procedure or DBCC Command would lead to an individual action, we may have done it according to the books, but the result would be a nightmarish pile of individual actions that would lead to extremely large and unreadable policies.
The solution was to decide on a middle ground that does not compromise on security but keep the ability to express policies manageable.
And this is how it turned out:
SQL Permission changes
The VIEW SERVER STATE permission was split into 2 new permissions:
VIEW SERVER PERFORMANCE STATE and VIEW SERVER SECURITY STATE.
Here the new and old permissions both on Server and on Database level are visualized:

In addition to that, we introduce a new permission: VIEW ANY ERROR LOG.
It covers the following system stored procedures:
sys.xp_enumerrorlogs
sys.sp_readerrorlog
sys.xp_readerrorlog
For the DBCC Commands in the SQL world we keep them under the same VIEW SERVER PERFORMANCE STATE -permission as used for accessing DMVs. This is a small concession to simplicity since it is unlikely that users who are tasked with performance analysis and hence get access to DMVs etc. would not be allowed running these read-only DBCC-commands. This way we save 1 permission in SQL for the price of a small misalignment with the policy-based action as you will see below.
Result: 3 new permissions
New actions for policy-based access control
To express the same as the SQL permissions above permit, we created the following actions to be used by Azure Purview for the built-in action-group “SQL Performance Monitor”:
/SqlServers/SystemViewsAndFunctions/ServerPerformanceState/Rows/Select
/Sqlservers/Databases/SystemViewsAndFunctions/DatabasePerformanceState/Rows/Select
/SqlServers/ErrorLogs/Select
/Sqlservers/DBCCs/ViewServerPerformanceState/Execute
/Sqlservers/Databases/DBCCs/ViewDatabasePerformanceState/Execute
Result: 5 new actions
As you can see here, the use action-names partially align to the SQL permission names that closely match their behavior. In the case of the DBCC commands, we have introduced 2 additional actions as a concession to the action-based model and language.
More Details
Now that we understand the background and the overall idea of working with permissions and actions in parallel, let us see how these checks are implemented inside the SQL engine.
If a given SQL Server is governed by Azure Purview, the server is regularly connecting to the external Microsoft Azure Purview Service and downloads all the relevant policies to a local cache. These policies contain all the required information to match an AAD (Azure Active Directory) Account with the allowed or denied actions.
If the user is running a query that contains objects that are onboarded for external governance, the permission-check will include both the SQL permissions and the external policy-based actions.
Below is a picture of the high-level architecture of this workflow:

On a high-level, extending existing permission checks to check for new SQL-permissions and at the same time check for new external permissions, the respective locations in code only had to be touched once for both at the same time.
The new permission checks algorithms are based on OR-logic. For example, a user executing the query
SELECT * FROM sys.dm_os_waiting_tasks
traditionally would undergo a permission check with the following logic:
Is there no DENY for:
(SQL permission) VIEW SERVER PERFORMANCE STATE
AND
is there a GRANT for:
SQL permission VIEW SERVER PERFORMANCE STATE
- There is a check for a DENY on the respective permission, and if that is not the case, the principal still requires an explicit GRANT
Now, in SQL Server 2022 and Azure SQL Database, all the commands that we onboarded to allow externally based permissions/actions, will undergo a permission-check with the following new extended logic:
is there no DENY for:
{
(SQL permission) VIEW SERVER PERFORMANCE STATE
OR
(External Policy Action) SqlServers/SystemViewsAndFunctions/ServerPerformanceState/Rows/Select
}
AND
is there a GRANT for:
{
SQL permission VIEW SERVER PERFORMANCE STATE
OR
(External Policy Action) /SqlServers/SystemViewsAndFunctions/ServerPerformanceState/Rows/Select
}
- Note: the actual source code does not look like this, this is a strong simplification 🙂
As you can see, we are simply allowing multiple sources to satisfy the condition using an OR-logic.
You can also see this in the new error messages that only start appearing after enabling a server for external governance. For example, if a user does not have either permission, the error message reveals the 2 possible alternatives:

I hope this sheds some light on how things are working and why they are working this way in the permission space.
Happy securing
Andreas
Granular Permissions in SQL Server 2022 and Azure SQL: Least Privilege for Metadata, XEvents and Auditing
/0 Comments/in SecurityIn the last 3 years, the SQL Security team has put more emphasis on enabling customers to use SQL Server while adhering to the Principle of least Privilege (PolP). As part of that effort, all new features in the next SQL Server release: SQL Server 2022, can be controlled with more granular permissions. SQL Ledger is a good example of such a new feature. It comes with separate permissions for creating (ENABLE LEDGER) vs dropping ledger tables (ALTER LEDGER); a separate permission to view ledger content (VIEW LEDGER CONTENT) for auditing purposes; and another independent permission to generate a ledger digest (GENERATE LEDGER DIGEST).
Besides new features, a lot of effort also went into improving the existing set of permissions, namely by making them more granular. This has happened in 3 distinguishable areas:
(1) Access to System Metadata: 10 new permissions (5 on Server- and 5 on Database level)
(2) Extended Events: 18 new permissions (9 on Server- and 9 on Database level)
(3) Security-related objects: 4 new permissions (3 on Server- and 1 on Database level)
Benefits
By introducing these newly created granular permissions we enable customers to greatly improve adherence to the Principle of least Privilege. It is now possible to GRANT (or DENY) highly granular activities if required. Specifically, security-wise sensitive information can now be hidden easily while still allowing regular server- and database monitoring and maintenance.
Because the new permissions are a subset of existing coarse-grained permissions, existing permission-rollouts will work without changes. Customers can also test blocking individual granular tasks by using the DENY-Syntax on top of existing GRANTs to lower rolled out permissions piece by piece.
Details
Let’s look at the new permissions in detail.
Access to System Metadata
System Metadata in SQL Server is exposed mainly via Catalog views, Dynamic Management Views (DMVs) and Functions, as well as a few DBCC commands and extended stored procedures.
Until SQL Server 2019, the permission requirement for Catalog Views was VIEW ANY DEFINITION respectively VIEW DEFINITION depending on the metadata’s origin: Server level or per individual database.
Similarly for DMVs the minimal required permission was VIEW SERVER STATE respectively DATABASE STATE, depending on the applicable scope of the metadata.
In other words, one single permission covered roughly 300 Catalog Views and another one permission covered about 290 DMVs and DMFs.
But in reality, system metadata can belong to many different areas. It can relate to performance, high availability features (and those again can be grouped into subareas), fulltextsearch, security, general system information, service broker. And many of those can again be split into subareas such as Availability Groups, Failover Clustering, execution environment, SQL OS, memory and caches etc.
However, coming up with individual permissions for each sub-area would not benefit many customers and unnecessarily bloat the permissions system.
There are many scenarios in which it is desirable to grant certain individuals permissions to fully investigate a system’s behavior but also have confidence, that the person (or app/service account) cannot read security-sensitive information.
This is often the case with junior admins, external consultants, outsourced database administration services, performance-monitoring tools and similar which mostly need to see performance-related live or statistical information but not information about user accounts, permissions, cryptographic-properties etc..
While it is usually not a problem if someone who is tasked to analyze memory-usage could also view information about HA-replica states, exposure to security-information is less forgiving.
Therefore, we split the existing permissions into two separate sub-permissions below VIEW SERVER STATE/VIEW DATABASE STATE respectively VIEW ANY DEFINITION/VIEW DEFINITION.
The diagram below depicts this change/additional granularity:

The same was done for Catalog views, which before this split were covered by a general VIEW DEFINITION:

We are introducing 10 new permissions (5 on server plus 5 on database level):
Server level:
- VIEW ANY SECURITY DEFINITION
- VIEW ANY PERFORMANCE DEFINITION
- VIEW SERVER SECURITY STATE
- VIEW SERVER PERFORMANCE STATE
- VIEW ANY CRYPTOGRAPHICALLY SECURED DEFINITION
Database level:
- VIEW DATABASE SECURITY STATE
- VIEW DATABASE PERFORMANCE STATE
- VIEW SECURITY DEFINITION
- VIEW PERFORMANCE DEFINITION
- VIEW CRYPTOGRAPHICALLY SECURED DEFINITION
What is the difference between VIEW PERFORMANCE STATE and VIEW SECURITY STATE and DEFINITION?
It’s best understood by approaching it from the following angle: From all the DMVs/DMFs and Catalog Views, we made a split between those that contain security-wise sensitive information and literally “everything else”. To put it into numbers: out of approximately 800 system views and functions, about 70 are from now on covered by VIEW SECURITY STATE or SECURITY DEFINITION (depending on whether it’s a DMV/DMF or a Catalog View). Everything else remains covered by one permission: VIEW PERFORMANCE STATE respectively VIEW DEFINITION. (The VIEW (ANY) PERFORMANCE DEFINITION permissions were introduced with SQL Server 2022 RTM.)
Why “everything else” and what exactly is it?
Ok, you really want to go down this hole 😉
Quite simply, everything that is not security-wise sensitive, is covered by “PERFORMANCE”. Even if the content is returning static data, Fulltextsearch word-lists or Cluster Node information. If you look at every DMV in detail you will notice many of them contain a mix of information, crossing subject boundaries. And trying to make up more buckets serves little purpose and would just make life harder for those trying to figure out which permissions to grant with little or no benefit.
The main scenario that we want to cover: Administrators can grant access to system information without having to worry that the Junior DBA/External Consultant/Remote Admin Service company gains access to information that it could abuse.
And that is achieved by separating out the security-wise sensitive objects.
When it comes to performance monitoring, troubleshooting and similar tasks, having access to HA-information usually poses no risks for a company. But information about key encryption strengths should not be available without proper cause.
How the new server roles that were announced recently align to this work
In May 2022 I announced 7 new server roles for Azure SQL Database (New server roles for Azure SQL Database and SQL Server 2022 in Public Preview – Microsoft Tech Community). One of these new roles is actually based on these new permissions:
##MS_SecurityDefinitionReader## => VIEW ANY SECURITY DEFINITION
If you look at the list of new Server roles for SQL Server 2022 you will find even more roles that align 1:1 to these new granular permissions on server level:
##MS_ServerPerformanceStateReader## => VIEW SERVER PERFORMANCE STATE
##MS_ServerSecurityStateReader## => VIEW SERVER SECURITY STATE
##MS_PerformanceDefinitionReader## => VIEW ANY PERFORMANCE DEFINITION
Server-level roles – SQL Server | Microsoft Docs
By using those server roles, these new permissions can be used in Azure SQL Database, Managed Instance and SQL Server alike. This is the only way to delegate server level permissions in Azure SQL Database.
What is VIEW CRYPTOGRAPHICALLY SECURED DEFINITION for?
You may have noticed the permissions VIEW ANY CRYPTOGRAPHICALLY SECURED DEFINITION (on server) and VIEW CRYPTOGRAPHICALLY SECURED DEFINITION (on database) and I haven’t covered it under SECURITY DEFINITION.
These permissions cover a very specific subset of information within certain objects. They do not protect any specific view but rather specific columns in some objects.
The background is that there are a few data fields that contain information that is much more sensitive than a username, algorithms strengths or granted permissions are: Hashed passwords and encrypted keys.
Currently the following columns require this permission to display the content:
- password_hash from sys.sql_logins
Viewing the password hash required the CONTROL SERVER permission until now. - The same applies to the PasswordHash from the LOGINPROPERTY-Function LOGINPROPERTY (Transact-SQL) – SQL Server | Microsoft Docs
Also this until now required the CONTROL SERVER permission.
Now access to the password-hash can be granted without granting elevated permissions. - crypt_property from sys.key_encryptions
until now this was only covered by Metadata security and of course sysadmin-permissions. Now access to this data can be granted without granting elevated permissions.
Extended Events
Extended Events (aka XEvents) are the tracing technology that since SQL Server 2012 replaces SQL Trace & Profiler. (XEvents overview – SQL Server, Azure SQL Database, and Azure SQL Managed Instance – SQL Server | Microsoft Docs)
Since then, managing XEvent sessions was covered by one, respectively two Permissions: ALTER ANY EVENT SESSION – applicable to either the database level (SQL Database) or server level (SQL Server and MI).
This permission covers everything from creating new sessions, changing any part of the definition like adding or removing attributes or targets and starting and stopping them.
Note on SQL Auditing
If XEvents are not your main concern, it may help to understand that Security Auditing in SQL is also based on XEvent architecture and therefore shares a lot of the DDL and general workflow.
While I cannot disclose anything specific, it probably makes sense that the permissions for Auditing will profit from this change that XEvents undergo at some point. 😉
Starting with SQL Server 2022, XEvent session management can be controlled by 18 additional permissions (9 on server plus 9 on database level). This allows for a much more fine-grained control over what a user is allowed to do with XEvent sessions.
The list of new permissions:
Server level:
- CREATE ANY EVENT SESSION
- DROP ANY EVENT SESSION
- ALTER ANY EVENT SESSION OPTION
- ALTER ANY EVENT SESSION ADD EVENT
- ALTER ANY EVENT SESSION DROP EVENT
- ALTER ANY EVENT SESSION ENABLE
- ALTER ANY EVENT SESSION DISABLE
- ALTER ANY EVENT SESSION ADD TARGET
- ALTER ANY EVENT SESSION DROP TARGET
All these permissions are under the same parent-permission: ALTER ANY EVENT SESSION
Database level:
- CREATE ANY DATABASE EVENT SESSION
- DROP ANY DATABASE EVENT SESSION
- ALTER ANY DATABASE EVENT SESSION OPTION
- ALTER ANY DATABASE EVENT SESSION ADD EVENT
- ALTER ANY DATABASE EVENT SESSION DROP EVENT
- ALTER ANY DATABASE EVENT SESSION ENABLE
- ALTER ANY DATABASE EVENT SESSION DISABLE
- ALTER ANY DATABASE EVENT SESSION ADD TARGET
- ALTER ANY DATABASE EVENT SESSION DROP TARGET
All these permissions are under the same parent-permission: ALTER ANY DATABASE EVENT SESSION
Scenarios that the new permissions enable
Preparing XEvent sessions
It is now possible to prepare XEvent sessions and only grant other Users to start & stop those prepared sessions
Allow users to solely add events or targets
By granting ALTER ANY EVENT SESSION ADD EVENT/ADD TARGET, Users can be allowed to add additional events to capture and add new targets – while at the same time be prevented to remove existing targets (together with the captured data therein) or events.
Allow changing configuration but not what is captured
By granting ALTER ANY EVENT SESSION OPTION, users can change memory usage, latency and similar options, but not influence what is captured and where. – For a list of session options look here: ALTER EVENT SESSION (Transact-SQL) – SQL Server | Microsoft Docs for “event_session_options”.
Adding and modifying predicates falls under ALTER ANY EVENT SESSION ADD EVENT, since that is part of the event configuration. The same applies to adding Actions.
To view data from XEvent sessions, depending on the target type used (memory or file), either DMVs using XQuery have to be queried while for the file target a system function is used (Targets for Extended Events in SQL Server – SQL Server | Microsoft Docs). All of those were covered by the VIEW SERVER STATE-permission and from now on under the VIEW SERVER PERFORMANCE STATE-permission respectively the VIEW DATABASE PERFORMANCE STATE-permission. This is part of the work on System Metadata permission from the former topic.
Security-related objects
The last bucket of new permissions covers a few security-related objects.
Here are the 4 new permissions:
- CREATE LOGIN
This permission is a subset of ALTER ANY LOGIN and allows for delegating the creation of new Logins while at the same time preventing that the user with this permission could also change passwords of existing Logins and hence abuse his powers for Elevation of Privilege attacks.
- VIEW ANY ERROR LOG
This quite simply allows the grantee to read the error logs of SQL Server (and SQL Server Agent). This is done via 3 procedures: sys.xp_enumerrorlogs, sys.sp_readerrorlog and sys.xp_readerrorlog. Before SQL Server 2022, the VIEW SERVER STATE permission which also covers DMVs was the minimal required permission.
- VIEW SERVER SECURITY AUDIT
This is very useful for Security Auditors who should not have the ability to also change existing SQL Auditing definitions. With this permission, the Audit Log can be read via the system function sys.fn_get_audit_file (Transact-SQL) – SQL Server | Microsoft Docs. Beforehand, the CONTROL permission on the server was required.
For the database level Auditing data we added another separate permission:
- VIEW DATABASE SECURITY AUDIT
Backwards-compatibility
By adding the new permissions as alternative, lower permissions, we ensure backwards-compatibility: Existing scripts do not break because all existing Permission-assignments (in the above example: VIEW SERVER STATE) work as before. But those who have a need to assign more granular permissions now can differentiate between security-related system metadata and “everything else”.
Let me know what you think of these new permissions, if you find the approach practical and wishes you may have.
Happy securing
Andreas
Thank you to the following people for help with this article:
Language: Michael Howard (Principal Program Manager Azure SQL Security), Diana Putnam (Principal Group PM Manager Azure SQL Security), Tameika Lawrence (Program Manager Azure SQL Security)
Technical correctness: Steven Gott (Senior Software Engineer)
Update 2026: SQL Server 2025 adds a few new permissions for new features. The permission model itself is unchanged since SQL Server 2022. Overview: New Permissions in SQL Server 2025.
The ##MS_…## Server Roles in SQL Server 2022 and Azure SQL: What Each Role Can Do
/0 Comments/in SecurityNew server roles for Azure SQL Database and SQL Server 2022 in Public Preview: Database Management without admin-access
We are now releasing a new set of server roles which support server- and database management without using admin-accounts and in addition make administration at scale even easier to Public Preview.
The 4 additional roles are:
- ##MS_DatabaseConnector##
- ##MS_SecurityDefinitionReader##
- ##MS_DatabaseManager##
- ##MS_LoginManager##
– September 2021 we announced the first set of new server roles for Azure SQL Database: Server roles for Azure SQL Database: Database Management without admin-access
the previously released roles are:
- ##MS_DefinitionReader##
- ##MS_ServerStateReader##
- ##MS_ServerStateManager##
Benefit
The new server-roles that can be assigned to server logins to enable customers to assign and delegate job functions for server-wide metadata access and access to certain management commands without requiring Server Admin or AAD Admin privileges. This helps comply with the Principle of Least Privilege and implement role separation (sometimes also interchangeably referred to as Separation of Duties).
Technical background
Each of these new server-roles includes a specific set of permissions. In SQL Database those permissions cannot be assigned individually on the server scope but using those roles one can grant them to a Login. This is a new method to grant server permissions across a logical server and all databases hosted on that logical server in Azure SQL Database, aside from assigning Server/AAD Admin, which in many cases is considered too powerful.
In the following let’s have a look at each role individually:
##MS_SecurityDefinitionReader##
The ##MS_SecurityDefinitionReader##-role predominantly will be useful for read-only server-auditing where an auditor will need to see the contents of system-related static system metadata such as Login and User names, permissions of principals and role membership.
It has VIEW ANY SECURITY DEFINITION permission on the server, which covers and hence includes the VIEW SECURITY DEFINITION permission on any database that a principal in that role has access to.
##MS_DatabaseConnector##
This role is likely the most important new role as it allows members to connect to any database without requiring a User-account in the respective databases to connect to. In combination with the other new server roles, this essentially leads to the server level role-based permissions to inherit to the respective database scoped permissions.
This is because it holds the permission – holds CONNECT ANY DATABASE on server-scope, which then inherits the CONNECT permission on each database.
i.e., a member of ##MS_DatabaseConnector## + ##MS_ServerStateReader## will have the permission VIEW SERVER STATE + VIEW DATABASE STATE on all databases, without requiring Users to be created. This greatly simplifies permission assignment via roles at scale.
Tipp: To exclude specific databases on a given server from this “grant access to all”-concept, you can proceed as follows: create matching User-accounts for the given login in those databases and then DENY the CONNECT permission to the database-user. This DENY permission will overrule the GRANT CONNECT permission coming from this role.
The ability to grant the Connect-permission to all databases (without further permissions) makes this role the ideal counterpart for ##MS_ServerStateReader##, ##MS_DefinitionReader## and ##MS_SecurityDefinitionReader## server roles.
The following diagram shows how a Login “Juanita” is member of both the ##MS_DatabaseConnector## (green in diagram) and the ##MS_ServerStateReader## (blue) roles and in result can connect to any database and read any Server and database level DMV (Dynamic Management View).

The diagram shows that in addition to the Server level permissions (CONNECT ANY DATABASE and VIEW SERVER STATE), Juanita is also granted the respective inherited database-permissions (CONNECT and VIEW DATABASE STATE).
##MS_DatabaseManager##
Members of the ##MS_DatabaseManager## fixed server role can create and delete databases. A member of the ##MS_DatabaseManager## role that creates a database, becomes the owner of that database, which allows that user to connect to that database as the dbo user. The dbo user has all database permissions in the database. Members of the ##MS_DatabaseManager## role don’t necessarily have permission to access databases that they don’t own.
For Azure SQL Database, it is recommended to use this server role instead of the special dbmanager database level role that exists in master (Azure SQL DB only) and was previously used to reach the same goals but required a User account in master-database.
##MS_LoginManager##
Members of the ##MS_LoginManager## fixed server role can create and delete logins.
Just as with the ##MS_DatabaseManager##-role, for Azure SQL Database, it is recommended to use this server role over the special loginmanager database level role that exists in master and was previously used to reach the same goals but required a User account in master-database.
Summary
The new server roles in conjunction with the previous set enable customers to grant specific lower privileges to personnel that should not have full admin-permissions and by using the ##MS_DatabaseConnector##-role can do so in a scalable manner: for a whole logical server in Azure SQL Database.
When it comes to SQL Server 2022 (now in Public Preview), these roles could be imitated by creating custom server roles which are available in SQL Server, but including them as built-in roles the same way as for Azure SQL DB will hopefully enable simpler management from cloud to on-prem and for migration back & forth. Also we are aware that some customers often prefer to use built-in roles over custom roles per principle.
Limitations
- Role assignments may take up to 5 minutes to become effective. In addition, for existing sessions, changes to server role assignments do not take effect until the connection is closed and re-opened. This is due to distributed architecture between the master database and other databases on the same logical server.
Partial workaround: to reduce the up to 5-minute waiting period and ensure that server role assignments are current in a database, a Server Admin/AAD Admin can run DBCC FLUSHAUTHCACHE in the user database(s) on which the login has access. Currently logged on users still need to reconnect after this for the membership-changes to take effect on them. - These roles can be assigned to SQL Logins and AAD Logins. However, currently Group-based AAD Logins are not yet supported. This is functionality will be delivered later.
Further references:
- Link to documentation for the new server-roles in Azure SQL DB: Server roles – Azure SQL Database | Microsoft Docs
- Server-level roles – SQL Server | Microsoft Docs
- DBCC FLUSHAUTHCACHE (Transact-SQL) – SQL Server | Microsoft Docs
- What is a server in Azure SQL Database and Azure Synapse Analytics? | Microsoft Docs
- Azure SQL databases in logical servers, elastic pools, and managed instances – Microsoft Tech Community
- GRANT Database Permissions (Transact-SQL) – SQL Server | Microsoft Docs
- The Principle of Least Privilege (POLP) – Microsoft Tech Community
- First announced set of server roles: Server roles for Azure SQL Database: Database Management without admin-access – Microsoft Tech Community
Update 2026: Emad Al-Mousa found ways for members of ##MS_DatabaseManager## to escalate to sysadmin (CVE-2025-24999). The first one is fixed in the security updates for SQL Server 2022 CU23 and SQL Server 2025 CU2. I explain the attack paths and what they mean for the role’s ownership-based model in SQL Server Privilege Escalation via DatabaseManager-role and Part 2: The Ownership-Based Security Model.
