Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2016 July SQL Server: Database Security Interview Questions and Answers (Day-5)

SQL Server: Database Security Interview Questions and Answers (Day-5)

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

What do you know about the SQL Server Audit?

SQL Server Audit is used to track and log events (not data change) occurring on the SQL Server. SQL Server uses extended events to help create an audit. The audit can be server level or database level.

If you create an audit on a database table, SQL Server will only track the events that trigger the certain operations (SELECT/INSERT/UPDATE/DELETE) defined in the database audit specification.

What options are available to audit login activity?

  • Custom solution with your application to log all logins into a centralized table
  • Enable login auditing at the instance level in Management Studio
  • Execute Profiler to capture logins into the instance
  • Leverage a third party product

What is Audit in SQL Server?

Auditing an instance of the SQL Server Database Engine or an individual database involves tracking and logging events that occur on the Database Engine.

What is Server level Audit specification?

You can create one server audit specification per audit.

The server audit specification collects many server-level action groups raised by the Extended Events feature. You can include audit action groups in a server audit specification. Audit action groups are predefined groups of actions, which are atomic events occurring in the Database Engine.

What is Database level Audit specification?

You can create one database audit specification per SQL Server database per audit.

The database audit specification collects database-level audit actions raised by the Extended Events feature. You can add either audit action groups or audit events to a database audit specification.

Is it good to enable Audit only for SQL Server Login fails?

Yes:

Database administrators should enable login auditing feature of SQL Server on all instances which they manage. Once this feature is enabled SQL Server will write all the failed and successful login information in SQL Server Error Logs. It is always a best practice to auditing failed SQL Server logins.

Does SQL Server Audit require any additional permission?

Yes:

Each feature and command for SQL Server Audit has individual permission requirements.

Should we encrypt the SQL Server datatabase backups?

Yes:

We need to make sure the database backups are encrypted to avoid the misuse.

Why we should not use tha SA login for all the different SQL Server access?

Because, the sa login and password to all of your SQL Servers because auditing the sa login with a shared password is difficult without capturing the host name or some other personally identifiable data. We should migrate all SQL Server authentication to Windows based authentication.

Can I stop a System Admin from enabling SQL Server xp_cmdshell?

No:

T-SQL script to disable the SA login

1
ALTER LOGIN sa DISABLE;

T-SQL script to rename the SQ login.

1
ALTER LOGIN sa WITH NAME = [dbrnd_user];

Please do auto reset the SA password and disable it.

SQL Server has an undocumented system stored procedure named sp_SetAutoSAPasswordAndDisable. This procedure will do exactly as the name suggests: it will reset the password and then disable the ‘sa’ login.

1
2
EXEC sp_SetAutoSAPasswordAndDisable
GO
T-SQL script to find common passwords.
1
2
3
SELECT name,type_desc,create_date,modify_date,password_hash
FROM sys.sql_logins
WHERE PWDCOMPARE('mssqltips',password_hash)=1;
T-SQL script to find blank passwords.
1
2
3
SELECT name,type_desc,create_date,modify_date,password_hash
FROM sys.sql_logins
WHERE PWDCOMPARE('',password_hash)=1;
T-SQL script to find Passwords that are the same as the Login name.
1
2
3
SELECT name,type_desc,create_date,modify_date,password_hash
FROM sys.sql_logins
WHERE PWDCOMPARE(name,password_hash)=1;
What is GRANT, DENY and REVOKE?

GRANT:gives a user permission to perform certain tasks on database objects.
DENY:denies any access to a user to perform certain tasks on database objects.
REVOKE:removes a grant or deny permission from a user on certain database objects.

Sample T-SQL scripts for GRANT, DENY and REVOKE.

1
2
3
GRANT INSERT, UPDATE, SELECT ON Customers TO Joe, Mary;
DENY DELETE ON Customers to Joe, Mary;
REVOKE UPDATE ON Customers to Joe;
Jul 22, 2016Anvesh Patel
SQL Server: Database Security Interview Questions and Answers (Day-4)SQL Server: Database Security Interview Questions and Answers (Day-6)
Comments: 1
  1. Ajeeth Kapoor
    April 21, 2018 at 9:07 am

    Ohayo,

    Smokin hot stuff! You’ve trimmed my dim. I feel as bright and fresh as your prolific website and blogs!

    1 + What is the best way to backup a MS-SQL Server Database ?
    2 + Is it necessary to stop the SQL Server to obtain a full and consistent backup ?
    3 + Is it possible to copy the database regularly (many times per day) on a other server, during the
    database is open and used ?
    4 + Is it possible to build files that contains only the last changes during the last hour per exemple, and then build 24 files per day ?
    (like Oracle RMAN do)
    Appreciate your effort for making such useful blogs and helping the community.

    Thank you,
    Ajeeth Kapoor

Anvesh Patel
Anvesh Patel

Database Engineer

July 22, 2016 SQL Server Interviewanswers, Anvesh Patel, database, database research and development, database security, dbrnd, deny, GRANT, interview, questions, REVOKE, SQL Query, SQL Server, SQL Server Administrator, sql server audit, SQL Server Monitoring, SQL Server Performance Tunning, SQL Server Tips and Tricks, TSQL, XP_CMDSHELL
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....