Showing posts with label practices. Show all posts
Showing posts with label practices. Show all posts

Sunday, February 12, 2012

BPA vs. Security Best Practices paper

I would like to refer to the following technical article

SQL Server 2005 Security Best Practices - Operational and Administrative Tasks

http://www.microsoft.com/technet/prodtechnol/sql/2005/sql2005secbestpract.mspx

Among best practices for SQL Server service accounts on page 8, it is recommended to 'use a separate account for each service'. I created separate account for each service as advised and assign account to relevant Windows group created for each SQL Server service during SQL setup.

Now when I run Best Practices Analyzer, its report seemed to contradict what the above article said. For example, BPA reports excerpts:

"We recommend that the service SQLBrowser on host MachineName be run under Network Service Account". I get similar recommendation for SQLSERVERAGENT account as well. Most importantly, it recommends that MSFTESQL be run under SQL Server Service Account.

Can anyone of you shed some light on it?

Thanks,

Asaf

BPA is actually accurate with respect to SQL Browser. The sole purpose of this service is to resolve named instances. So, the first thing that you do on a machine that does not have a named instance is to disable the service. If you have named instances, then simply setting it to Network Service is sufficient, because it does not need to access any resources external of the machine that it is running on.

I run SQL Server Agent as a named Windows account and could really care less what BPA has to say about it. The reason that I run it under a named Windows account is that every system I've worked on has jobs that need access to a variety of resources. Many of these drop backups on machines other than where the instance is running or grab and move files from other systems. You can't perform any of those operations running under Network Service.

As for MSFTESQL, if you are not using full text indexing, disable this service. If you are using full text indexing, I use a separate account for the service so that I can isolate it and separately manage it from everything else.

The "separate account for each service" is a really great concept, but you have to determine what is best for you. If you have a single SQL Server instance, having a separate service account isn't that big of a deal from a management perspective. What happens when you are suddenly managing 10 instances, which really isn't that hard. Are you really going to create 40 different accounts - one each for Browser, SQL Server, SQL Server Agent, and Full Text for each instance? (Even more if you are using SSIS, SSRS, SSAS, etc.) Are you even going to be able to remember the different passwords for each? This separate account thing can be taken to idiotic proportions. I worked with one large organization whose security group dictated that each service on each machine was required to have a different account, which also meant a different strong password that was a minimum of 12 characters with upper, lower, numbers, and special characters. One of the sysadmins carries a large notebook with him when he leaves the office and it sits on his desk the rest of the time that contains over 40,000 logins/passwords just for the systems he is responsible for. One of the senior DBAs walks around with almost 15,000 logins/passwords on a PDA with a paper backup in his desk for the database servers he is responsible for. When you have to start writing down the logins and passwords in order to accomplish "separate account for each service", you have obviously taken things too far and defeated the purpose of doing this in the first place.

|||

Hi Michael,

I appreciate your comments and sharing your experience how complicated it could get if we decided to create separate account for each SQL Server machine. I manage 10 servers, all in DMZ, and I have been trying to decide on security policies.

Thanks Again,

Asaf

|||

For each server positioned in a 'DMZ', I recommend keeping individual service login accounts.

If any one server is ever compromised, you do not want to make it so easy for the others the be compromised.

Inside the DMZ, (double firewall), I agree with Michael's comments in respect to using a single highly guarded domain account (with exceptionally strong password) for SQL Servers, and I probably would not allow that domain account to have 'interactive login' priviledges..

|||

The interactive login privileges is a REALLY important one. Prior to SQL Server 2005, you didn't have a choice, since the service accounts used were local admins on the machines. But, service accounts for 2005 should NEVER have admin level authority, nor should they be able to login to the console. This brings up a really good example at another customer who has decided that under no circumstances will DBAs have access to the machines running their SQL Servers. There is an entirely different set of logins which are granted access to machines and only created for system admins. So, each system admin has two accounts, the one they login to their machine with and the one they login to servers with. What they forgot is that the DBAs are the ones who setup the SQL Servers and so they are given the service account and password. Since this is a SQL Server 2000 environment, they make those service accounts administrators on the machines. Then, since they are not allowed any access whatsoever to the machines their SQL Servers are running on, they bypass everything by using the service account to login to RDP so that they can actually do the things necessary to manage their SQL Servers. So, now it is impossible to actually audit any actions which occur. There are many examples of sheer stupidity in security policies.

Security systems exist for 2 reasons:

1. Keep the people out who shouldn't be there in the first place

2. Providing audit trails for those people authorized to perform actions

If you ever have a security policy that either impedes or prevents someone from taking legitimate actions which are required for their job, you need to throw the policy away and start over. Because, leaving such a policy in place will either damage your business, force the people who have to manage the systems to decide they should go somewhere that they are allowed to do their job, or will have the admins themselves concoting ways to bypass security leading to gaping holes that can also be exploited by hackers.

|||

Arnie,

Thanks for making an interesting point for having a separate account for each DMZ server. So after all extra bit of work required to set up individual accounts for each machine seem to provide an extra layer of protection.

Michael,

I do very much appreciate another valuable post from you. It reflects your deep understanding of security and years of experience in the industry.

Asaf

BPA issues

BPA (SQL Best practices analyzer) issues
First off, great idea!
-Dead Logons should scavange better. The app locked up on a long operations and when I logged back in it told me I was already logged in. I went into the repository via EM and axed the row out of active_conns and everything was good again. Point being,
the average user might not know to do this and the app won't do anything if you can't logon.
-I get the following 2 lines in the Cursor usage detail when using FAST_FORWARD for my cursor in a sproc. According to BOL FAST_FORWARD = FORWARD_ONLY + READ_ONLY (which is NOT updatable)
-This cursor is declared as updatable, however it doesn't seem to be updated.
-This cursor does not specify explicit updatability information (FOR UPDATE clause or READ_ONLY clause).
-6 exceptions for resutls when running all the rules
Hi Sean
Thanks for your feedback. Some comments inlined.
- Christian
___________________________
Christian Kleinerman
Program Manager, SQL Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Sean B" <anonymous@.discussions.microsoft.com> wrote in message
news:C250B186-9486-4BA6-877F-F7C928CCC6DC@.microsoft.com...
> BPA (SQL Best practices analyzer) issues
> First off, great idea!
> -Dead Logons should scavange better. The app locked up on a long
operations and when I logged back in it told me I was already logged in. I
went into the repository via EM and axed the row out of active_conns and
everything was good again. Point being, the average user might not know to
do this and the app won't do anything if you can't logon.
Yes, this was annoying. It has been fixed in later builds.

> -I get the following 2 lines in the Cursor usage detail when using
FAST_FORWARD for my cursor in a sproc. According to BOL FAST_FORWARD =
FORWARD_ONLY + READ_ONLY (which is NOT updatable)
> -This cursor is declared as updatable, however it doesn't seem to be
updated.
> -This cursor does not specify explicit updatability information (FOR
UPDATE clause or READ_ONLY clause).
Fixed this one too, making both, fast_forward and static be treated as read
only cursors.

> -6 exceptions for resutls when running all the rules
>
Do you have more information here?
Thanks for your feedback.
- Christian

BPA Feedback and Question

I've been exploring the best practices tool and find most things great! I have installed it on multiple machines and then changed the database that each client logs into to be the same one so that we have one central repository and it seems to be working
well. I would like to see a way to schedule a job that would run the scans at off hours since we are trying to make it mandatory for our developers to run a clean scan before they move out of our development environment. I was also surprised when i not
iced that there were no stored procedures in the slqbpa database, isn't that going against best practices ;)
Debi
In the released version there will be a command line version that will let
you use sql agent or some other scheduler to do what you want.
About stored procedures... not that strictly a best practice... depends on
your application or on what you're trying to do. The extensible architecture
of bpa called for some adhoc query building which may be better in the app
than doing dynamic sql inside stored procs. That said, I would like to see
some of the logic moved to stored procs, post v1. In the pre-7.0 days,
stored procs were way more a perf best practice.
- Christian
___________________________
Christian Kleinerman
Program Manager, SQL Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Debi" <anonymous@.discussions.microsoft.com> wrote in message
news:B924F619-4B1C-4657-B61B-41DA672541CE@.microsoft.com...
> I've been exploring the best practices tool and find most things great! I
have installed it on multiple machines and then changed the database that
each client logs into to be the same one so that we have one central
repository and it seems to be working well. I would like to see a way to
schedule a job that would run the scans at off hours since we are trying to
make it mandatory for our developers to run a clean scan before they move
out of our development environment. I was also surprised when i noticed
that there were no stored procedures in the slqbpa database, isn't that
going against best practices ;)
|||Hello Debi,
how did you manage this?
I tried to install BPA on different machines...
but the tool doesn't support the same database for the different
installations.
did you install BPA on different machines with different databases?
what did you do with these databases - drop them?
how did you change the database to connect to?
Thanks Thomas
"Debi" wrote:

> I've been exploring the best practices tool and find most things great! I have installed it on multiple machines and then changed the database that each client logs into to be the same one so that we have one central repository and it seems to be worki
ng well. I would like to see a way to schedule a job that would run the scans at off hours since we are trying to make it mandatory for our developers to run a clean scan before they move out of our development environment. I was also surprised when i n
oticed that there were no stored procedures in the slqbpa database, isn't that going against best practices ;)
|||Have a look at http://www.sqldbatips.com/showarticle.asp?ID=9
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Mueller-Lynch Thomas" <MuellerLynchThomas@.discussions.microsoft.com> wrote
in message news:1EBAEBEF-38D1-471A-B277-B685AE3EB4BE@.microsoft.com...[vbcol=seagreen]
> Hello Debi,
> how did you manage this?
> I tried to install BPA on different machines...
> but the tool doesn't support the same database for the different
> installations.
> did you install BPA on different machines with different databases?
> what did you do with these databases - drop them?
> how did you change the database to connect to?
> Thanks Thomas
> "Debi" wrote:

BPA - SQL 2005 - T-SQL

Hi there

I am looking for some help with the BPA on SQL 2005, I can not seem to get it to recognise any T-SQL best practices, I can deliberately sneak in a SELECT * or INSERT INTO with no feild list into SP's but the BPA does not pick them up.

Am I missing something ?

Thanks

Tim

i hope this helps u

http://vyaskn.tripod.com/coding_conventions.htm

http://vyaskn.tripod.com/sql_server_administration_best_practices.htm

http://vyaskn.tripod.com/sql_server_administration_best_practices.htm

Madhu

|||

BPA is primarily concerned with security issues. It is NOT a code analysis tool. It does not check for coding standards and practices.

I suggest that you may wish to explore "SQL Refractor" from www.RedGate.com.

|||

Tim Hatcher wrote:

I am looking for some help with the BPA on SQL 2005, I can not seem to get it to recognise any T-SQL best practices, I can deliberately sneak in a SELECT * or INSERT INTO with no feild list into SP's but the BPA does not pick them up.

I've answered this and other questions in this blog post:

http://blogs.msdn.com/sqlrem/archive/2007/01/12/SP2-and-BPA-FAQ.aspx

"We used SQL Server 2000 Best Practices Analyzer 1.0 to check our T-SQL code. It is very useful in our development process. Why are you getting rid of it?
The best practices utilities across Microsoft are more focused toward operations/management. We are aligning SQL Server’s BPA to the corporate standard. We agree that there should be aids in checking best practices in code, but don’t feel that BPA is the right tool for the job. Software like FxCop or plug-ins to Visual Studio and Management Studio would be the ideal location for such checks."

There are also technical challenges around why we could not do it in this release. I apologize for the inconvenience.

Paul A. Mestemaker II

Program Manager

Microsoft SQL Server Manageability

http://blogs.msdn.com/sqlrem/