HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

SQL: revoking permissions from public in master

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
permissionssqlpublicmasterfromrevoking

Problem

By default SQL grants execute permission on stored to public and also select to some table and views in Master to public...I am not 100% sure about this... What is the implication if we have to remove the select privileges on those objects from Public on Master?

Thanks...

Solution

As long as you have given any account that needs explicit permissions to those objects (views/procedures) you should see no issues. The issue I usually see after altering PUBLIC role permissions is applications that assume the permissions are there instead of just giving explicit permissions to them.

You will find that some Microsoft documentation states to not alter the PUBLIC role permissions. I work with the IASE database checklist and the permissions given to the PUBLIC role is one of the first things we have to remove/revoke. I always keep the script handy to restore the permissions if needed.

EDIT
Query to find public permissions that I use sometimes:

SELECT o.name AS [Object], p.permission_name AS [Type]
FROM sys.all_objects o
INNER JOIN sys.database_permissions p ON o.object_id = p.major_id
INNER JOIN sys.database_principals u ON u.principal_ID = p.grantee_principal_id
WHERE u.name = 'public'

Code Snippets

SELECT o.name AS [Object], p.permission_name AS [Type]
FROM sys.all_objects o
INNER JOIN sys.database_permissions p ON o.object_id = p.major_id
INNER JOIN sys.database_principals u ON u.principal_ID = p.grantee_principal_id
WHERE u.name = 'public'

Context

StackExchange Database Administrators Q#6876, answer score: 4

Revisions (0)

No revisions yet.