:::: MENU ::::

Posts Categorized / Security and Permissions

  • Aug 27 / 2008
  • 0
dbDigger, Logins and Users, Monitoring and Analysis, Security and Permissions

When you last changed password of sa

Changing the passwords regularly is an important requirement of robust security implementation. And it becomes more important when login is sa. To analyze that when last time you implemented this good practice, use following script.

 
USE Master  
 GO  
 SELECT sid, [name], createdate, updatedate  
 FROM master.dbo.syslogins  
 WHERE [name] = 'sa'  
 GO  

And if specific to SQL Server 2005 then

 
USE Master  
 GO  
 SELECT [name], sid, create_date, modify_date  
 FROM sys.sql_logins  
 WHERE [name] = 'sa'  
 GO  

The script will return name, sid, creation date and update/modification date of all of your logins. As sa account can not be updated/modified except that of password, so update date here will be the date when password of sa was changed. And if no name condition is provided then update date tells you any last any update for other logins.

 
USE Master  
 GO  
 SELECT [name], sid, create_date, modify_date  
 FROM sys.sql_logins  
 GO  
  • Aug 20 / 2008
  • 4
dbDigger, Monitoring and Analysis, Security and Permissions, System Stored Procedures, T-SQL Scripts

List permissions on SQL Server 2000 objects through sp_helpProtect()

I was required to list all permissions on a DB or table. Although this can be done through EM/SSMS but the analysis of permissions is more efficient through T-SQL than by any other means. I have found some very use full T-SQL stored procedure sp_helpProtect in this regard. It lists users permissions for an object.
General syntax for sp_helpProtect is

 
sp_helprotect [ [ @name = ] 'object_statement' ]  
 [ , [ @username = ] 'security_account' ]  
 [ , [ @grantorname = ] 'grantor' ]  
 [ , [ @permissionarea = ] 'type' ]  

You may use it in following ways

 
--List all user permissions of all Database objects  
 sp_helprotect  
 GO  
 -- List all user permissions of a table  
 sp_helprotect 'tableNme'  
 GO  
 -- List all user permissions of stored procedure  
 EXEC sp_helprotect 'spName'  
 GO  
 -- List all user permissions of sp granted by dbo  
 sp_helprotect 'spName', NULL,dbo  
 GO  
 -- List all Object type user permissions  
 sp_helprotect NULL, NULL,NULL,'o'  
 GO  
 -- List all statement type user permissions  
 sp_helprotect NULL, NULL,NULL,'s'  
 GO  
 -- List all permissions for a user  
 sp_helprotect NULL,'user'  
 GO  

Note: Basically sp_helprotect is for SQL Server 2000.For SQL Server 2005 and later sp_helprotect has no information regarding securables that were introduced in SQL Server 2005. Read here about List the permissions on SQL Server 2005 objects by using sys.database_permissions and fn_builtin_permissions instead.

  • Aug 09 / 2008
  • 0
DBA best practices, dbDigger, Logins and Users, Security and Permissions

DBA Best Practices for SQL Server Security

Following best practices may be implemented as base line for standard security of SQL Server

  1. Ensure the physical security of each SQL Server, preventing any unauthorized users to physically accessing your servers.
  2. Only install required network libraries and network protocols on your SQL Server instances.
  3. Minimize the number of sysadmins allowed to access SQL Server.
  4. As a DBA, log on with sysadmin privileges only when needed. Create separate accounts for DBAs to access SQL Server when sysadmin privileges are not needed.
  5. Assign the SA account a very obscure password, and never use it to log onto SQL Server. Use a Windows Authentication account to access SQL Server as a sysadmin instead.
  6. Give users the least amount of permissions they need to perform their job.
  7. Use stored procedures or views to allow users to access data instead of letting them directly access tables.
  8. When possible, use Windows Authentication logins instead of SQL Server logins.
  9. Use strong passwords for all SQL Server login accounts.
  10. Don’t grant permissions to the public database role.
  11. Remove user login IDs who no longer need access to SQL Server.
  12. Remove the guest user account from each user database.
  13. Disable cross database ownership chaining if not required.
  14. Never grant permission to the xp_cmdshell to non-sysadmins.
  15. Remove sample databases from all production SQL Server instances.
  16. Use Windows Global Groups, or SQL Server Roles to manage groups of users that need similar permissions.
  17. Avoid creating network shares on any SQL Server.
  18. Turn on login auditing so you can see who has succeeded, and failed, to login.
  19. Don’t use the SA account, or login IDs who are members of the Sysadmin group, as accounts used to access SQL Server from applications.
  20. Ensure that your SQL Servers are behind a firewall and are not exposed directly to the Internet.
  21. Remove the BUILTIN/Administrators group to prevent local server administrators from being able to access SQL Server. Before you do this on a clustered SQL Server, check Books Online for more information.
  22. Run each separate SQL Server service under a different Windows domain account
  23. Only give SQL Server service accounts the minimum rights and permissions needed to run the service. In most cases, local administrator rights are not required, and domain administrator rights are never needed. SQL Server setup will automatically configure service accounts with the necessary permissions for them to run correctly, you don’t have to do anything.
  24. When using distributed queries, use linked servers instead of remote servers.
  25. Do not browse the web from a SQL Server.
  26. Instead of installing virus protection on a SQL Server, perform virus scans from a remote server during a part of the day when user activity is less.
  27. Add operating system and SQL Server service packs and hot fixes soon after they are released and tested, as they often include security enhancements.
  28. Encrypt all SQL Server backups with a third-party backup tool, such as SQL Backup Pro.
  29. Only enable C2 auditing or Common Criteria compliance if required.
  30. Consider running a SQL Server security scanner against your SQL servers to identify security holes.
  31. Consider adding a certificate to your SQL Server instances and enable SSL or IPSEC for connections to clients.
  32. If using SQL Server 2005, enable password policy checking.
  33. If using SQL Server 2005, implement database encryption to protect confidential data.
  34. If using SQL Server 2005, don’t use the SQL Server Surface Area Configuration tool to unlock features you don’t absolutely need.
  35. If using SQL Server 2005 and you create endpoints, only grant CONNECT permissions to the logins that need access to them. Explicitly deny CONNECT permissions to endpoints that are not needed by users.

Chosen from SQL Server DBA best practices By Brad M.mcGehee

  • Jul 29 / 2008
  • 0
DBA Interview questions, dbDigger, Logins and Users, Security and Permissions

Purpose of the REFERENCES permission

Question: What is the purpose of the REFERENCES permission?

Answer: Allows the owner of another table to use columns in the table to which they’ve been granted that permission as part of a foreign key.

Explanation: Assigning REFERENCES permission allows the owner of another table to use columns in the table to which they’ve been granted that permission as the target of a REFERENCES FOREIGN KEY constraint with his or her table. However, that person won’t be allowed to change the structure of the table they’ve been granted the permission for.

Note: The Question of day is taken from SQLServercentral.com. I want to compile selected QOD.

Consult us to explore the Databases. Contact us