Upload
others
View
5
Download
0
Embed Size (px)
Citation preview
CISMicrosoftSQLServer2008R2Benchmarkv1.5.0-08-11-2017
1|P a g e
ThisworkislicensedunderaCreativeCommonsAttribution-NonCommercial-ShareAlike4.0InternationalPublicLicense.Thelinktothelicensetermscanbefoundathttps://creativecommons.org/licenses/by-nc-sa/4.0/legalcodeTofurtherclarifytheCreativeCommonslicenserelatedtoCISBenchmarkcontent,youareauthorizedtocopyandredistributethecontentforusebyyou,withinyourorganizationandoutsideyourorganizationfornon-commercialpurposesonly,providedthat(i)appropriatecreditisgiventoCIS,(ii)alinktothelicenseisprovided.Additionally,ifyouremix,transformorbuildupontheCISBenchmark(s),youmayonlydistributethemodifiedmaterialsiftheyaresubjecttothesamelicensetermsastheoriginalBenchmarklicenseandyourderivativewillnolongerbeaCISBenchmark.CommercialuseofCISBenchmarksissubjecttothepriorapprovaloftheCenterforInternetSecurity.
2|P a g e
TableofContentsOverview......................................................................................................................................................................5
IntendedAudience..............................................................................................................................................5
ConsensusGuidance...........................................................................................................................................5
TypographicalConventions............................................................................................................................6
ScoringInformation............................................................................................................................................6
ProfileDefinitions................................................................................................................................................7
Acknowledgements.............................................................................................................................................8
Recommendations....................................................................................................................................................9
1UpdatesandPatches.......................................................................................................................................9
1.1EnsureLatestSQLServerServicePacksandHotfixesareInstalled(NotScored).9
1.2EnsureSingle-FunctionMemberServersareUsed(NotScored)...............................11
2SurfaceAreaReduction..............................................................................................................................13
2.1Ensure'AdHocDistributedQueries'ServerConfigurationOptionissetto'0'(Scored).......................................................................................................................................................13
2.2Ensure'CLREnabled'ServerConfigurationOptionissetto'0'(Scored)...............15
2.3Ensure'CrossDBOwnershipChaining'ServerConfigurationOptionissetto'0'(Scored).......................................................................................................................................................17
2.4Ensure'DatabaseMailXPs'ServerConfigurationOptionissetto'0'(Scored)...19
2.5Ensure'OleAutomationProcedures'ServerConfigurationOptionissetto'0'(Scored).......................................................................................................................................................21
2.6Ensure'RemoteAccess'ServerConfigurationOptionissetto'0'(Scored)..........23
2.7Ensure'RemoteAdminConnections'ServerConfigurationOptionissetto'0'(Scored).......................................................................................................................................................25
2.8Ensure'ScanForStartupProcs'ServerConfigurationOptionissetto'0'(Scored).........................................................................................................................................................................27
2.9Ensure'SQLMailXPs'ServerConfigurationOptionissetto'0'(Scored)..............29
2.10Ensure'Trustworthy'DatabasePropertyissetto'Off'(Scored).............................31
2.11EnsureUnnecessarySQLServerProtocolsaresetto'Disabled'(Scored)...........33
2.12EnsureSQLServerisconfiguredtousenon-standardports(NotScored).........35
3|P a g e
2.13Ensure'HideInstance'optionissetto'Yes'forProductionSQLServerinstances(Scored).......................................................................................................................................................37
2.14Ensure'sa'LoginAccountissetto'Disabled'(Scored)................................................39
2.15Ensure'sa'LoginAccounthasbeenrenamed(Scored)...............................................41
2.16Ensure'xp_cmdshell'ServerConfigurationOptionissetto'0'(Scored).............43
3AuthenticationandAuthorization.........................................................................................................45
3.1Ensure'ServerAuthentication'Propertyissetto'WindowsAuthenticationMode'(Scored).........................................................................................................................................45
3.2EnsureCONNECTpermissionsonthe'guestuser'isRevokedwithinallSQLServerdatabasesexcludingthemaster,msdbandtempdb(Scored)..............................47
3.3Ensure'OrphanedUsers'areDroppedFromSQLServerDatabases(Scored).....49
3.4EnsuretheSQLServer’sMSSQLServiceAccountisNotanAdministrator(Scored).......................................................................................................................................................50
3.5EnsuretheSQLServer’sSQLAgentServiceAccountisNotanAdministrator(Scored).......................................................................................................................................................52
3.6EnsuretheSQLServer’sFull-TextServiceAccountisNotanAdministrator(Scored).......................................................................................................................................................54
3.7EnsureonlythedefaultpermissionsspecifiedbyMicrosoftaregrantedtothepublicserverrole(Scored).................................................................................................................56
3.8EnsureWindowsBUILTINgroupsarenotSQLLogins(Scored)................................58
3.9EnsureWindowslocalgroupsarenotSQLLogins(Scored)........................................60
3.10EnsurethepublicroleinthemsdbdatabaseisnotgrantedaccesstoSQLAgentproxies(Scored)......................................................................................................................................62
4PasswordPolicies.........................................................................................................................................64
4.1Ensure'MUST_CHANGE'Optionissetto'ON'forAllSQLAuthenticatedLogins(NotScored)..............................................................................................................................................64
4.2Ensure'CHECK_EXPIRATION'Optionissetto'ON'forAllSQLAuthenticatedLoginsWithintheSysadminRole(Scored).................................................................................66
4.3Ensure'CHECK_POLICY'Optionissetto'ON'forAllSQLAuthenticatedLogins(Scored).......................................................................................................................................................68
5AuditingandLogging..................................................................................................................................70
5.1Ensure'Maximumnumberoferrorlogfiles'issettogreaterthanorequalto'12'(Scored).......................................................................................................................................................70
4|P a g e
5.2Ensure'DefaultTraceEnabled'ServerConfigurationOptionissetto'1'(Scored).........................................................................................................................................................................73
5.3Ensure'LoginAuditing'issettoBoth'failed'and'successfullogins'(Scored)....75
6ApplicationDevelopment..........................................................................................................................77
6.1EnsureSanitizeDatabaseandApplicationUserInputisSanitized(NotScored)77
6.2Ensure'CLRAssemblyPermissionSet'issetto'SAFE_ACCESS'forAllCLRAssemblies(Scored)..............................................................................................................................79
7Encryption........................................................................................................................................................81
7.1Ensure'SymmetricKeyencryptionalgorithm'issetto'AES_128'orhigherinnon-systemdatabases(Scored)........................................................................................................81
7.2EnsureAsymmetricKeySizeissetto'greaterthanorequalto2048'innon-systemdatabases(Scored).................................................................................................................83
8Appendix:AdditionalConsiderations..................................................................................................85
8.1Ensure'SQLServerBrowserService'isconfiguredcorrectly(NotScored)..........85
Appendix:SummaryTable................................................................................................................................87
Appendix:ChangeHistory.................................................................................................................................90
5|P a g e
OverviewThisdocumentprovidesprescriptiveguidanceforestablishingasecureconfigurationpostureforMicrosoftSQLServer2008R2versions–runningonMicrosoftWindowsServer2008R2.ThisguidewastestedagainstMicrosoftSQLServer2008R2ServicePack164-bitversion.Toobtainthelatestversionofthisguide,pleasevisithttp://benchmarks.cisecurity.org.Ifyouhavequestions,comments,orhaveidentifiedwaystoimprovethisguide,[email protected].
IntendedAudience
Thisbenchmarkisintendedforsystemandapplicationadministrators,securityspecialists,auditors,helpdesk,andplatformdeploymentpersonnelwhoplantodevelop,deploy,assess,orsecuresolutionsthatincorporateMicrosoftSQLServer2008R2onaMicrosoftWindowsplatform.
ConsensusGuidance
Thisbenchmarkwascreatedusingaconsensusreviewprocesscomprisedofsubjectmatterexperts.Consensusparticipantsprovideperspectivefromadiversesetofbackgroundsincludingconsulting,softwaredevelopment,auditandcompliance,securityresearch,operations,government,andlegal.
EachCISbenchmarkundergoestwophasesofconsensusreview.Thefirstphaseoccursduringinitialbenchmarkdevelopment.Duringthisphase,subjectmatterexpertsconvenetodiscuss,create,andtestworkingdraftsofthebenchmark.Thisdiscussionoccursuntilconsensushasbeenreachedonbenchmarkrecommendations.Thesecondphasebeginsafterthebenchmarkhasbeenpublished.Duringthisphase,allfeedbackprovidedbytheInternetcommunityisreviewedbytheconsensusteamforincorporationinthebenchmark.Ifyouareinterestedinparticipatingintheconsensusprocess,pleasevisithttps://community.cisecurity.org.
6|P a g e
TypographicalConventions
Thefollowingtypographicalconventionsareusedthroughoutthisguide:
Convention Meaning
Stylized Monospace font Usedforblocksofcode,command,andscriptexamples.Textshouldbeinterpretedexactlyaspresented.
Monospacefont Usedforinlinecode,commands,orexamples.Textshouldbeinterpretedexactlyaspresented.
Italictextssetinanglebracketsdenoteavariablerequiringsubstitutionforarealvalue.
Italicfont Usedtodenotethetitleofabook,article,orotherpublication.
Note Additionalinformationorcaveats
ScoringInformation
Ascoringstatusindicateswhethercompliancewiththegivenrecommendationimpactstheassessedtarget'sbenchmarkscore.Thefollowingscoringstatusesareusedinthisbenchmark:
Scored
Failuretocomplywith"Scored"recommendationswilldecreasethefinalbenchmarkscore.Compliancewith"Scored"recommendationswillincreasethefinalbenchmarkscore.
NotScored
Failuretocomplywith"NotScored"recommendationswillnotdecreasethefinalbenchmarkscore.Compliancewith"NotScored"recommendationswillnotincreasethefinalbenchmarkscore.
7|P a g e
ProfileDefinitions
ThefollowingconfigurationprofilesaredefinedbythisBenchmark:
• Level1-DatabaseEngine
Itemsinthisprofileintendto:
o bepracticalandprudent;o provideaclearsecuritybenefit;ando notinhibittheutilityofthetechnologybeyondacceptablemeans.
8|P a g e
Acknowledgements
Thisbenchmarkexemplifiesthegreatthingsacommunityofusers,vendors,andsubjectmatterexpertscanaccomplishthroughconsensuscollaboration.TheCIScommunitythankstheentireconsensusteamwithspecialrecognitiontothefollowingindividualswhocontributedgreatlytothecreationofthisguide:
ContributorTimHarrisonCISSP,ICP,CenterforInternetSecurityPhilippeLangloisEditorNancyHidyWilsonBrianKelleyMCSE,CISA,Security+,MicrosoftMVP-SQLServer
9|P a g e
Recommendations1UpdatesandPatches
Thissectioncontainspatchingrelatedrecommendations.
1.1EnsureLatestSQLServerServicePacksandHotfixesareInstalled(NotScored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
SQLServerpatchescontainprogramupdatesthatfixsecurityandproductfunctionalityissuesfoundinthesoftware.Thesepatchescanbeinstalledwithahotfixwhichisasinglepatch,acumulativeupdatewhichisasmallgroupofpatchesoraservicepackwhichisalargecollectionofpatches.TheSQLServerversionandpatchlevelsshouldbethemostrecentcompatiblewiththeorganizations'operationalneeds.
Rationale:
UsingthemostrecentSQLServersoftware,alongwithallapplicablepatchescanhelplimitthepossibilitiesforvulnerabilitiesinthesoftware,theinstallationversionand/orpatchesappliedduringsetupshouldbeestablishedaccordingtotheneedsoftheorganization.
Audit:
TodetermineyourSQLServerservicepacklevel,runthefollowingcodesnippet.
SELECT SERVERPROPERTY('ProductLevel') as SP_installed, SERVERPROPERTY('ProductVersion') as Version;
FirstcolumnreturnstheinstalledServicePacklevel,thesecondistheexactbuildnumber.
Remediation:
IdentifythecurrentversionandpatchlevelofyourSQLServerinstancesandensuretheycontainthelatestsecurityfixes.Makesuretotestthesefixesinyourtestenvironmentsbeforeupdatingproductioninstances.
10|P a g e
ThemostrecentSQLServerpatchescanbefoundhere:
HotfixesandCumulativeupdates:http://blogs.msdn.com/b/sqlreleaseservices/
ServicePacks:http://support.microsoft.com/kb/968382
DefaultValue:
Servicepacksandpatchesarenotinstalledbydefault.
References:
1. http://support.microsoft.com/sp2. http://support.microsoft.com/kb/968382
CISControls:
4ContinuousVulnerabilityAssessmentandRemediation
11|P a g e
1.2EnsureSingle-FunctionMemberServersareUsed(NotScored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
ItisrecommendedthatSQLServersoftwarebeinstalledonadedicatedserver.Thisarchitecturalconsiderationaffordssecurityflexibilityinthatthedatabaseservercanbeplacedonaseparatesubnetallowingaccessonlyfromparticularhostsandoverparticularprotocols.Degreesofavailabilityareeasiertoachieveaswell-overtime,anenterprisecanmovefromasingledatabaseservertoafailovertoaclusterusingloadbalancingortosomecombinationthereof.
Rationale:
Itiseasiertomanage(i.e.reduce)theattacksurfaceoftheserverhostingSQLServersoftwareiftheonlysurfacestoconsideraretheunderlyingoperatingsystem,SQLServeritself,andanysecurity/operationaltoolingthatmayadditionallybeinstalled.Asnotedinthedescription,availabilitycanbemoreeasilyaddressedifthedatabaseisonadedicatedserver.
Audit:
Ensurethatnootherrolesareenabledfortheunderlyingoperatingsystemandthatnoexcesstoolingisinstalled,perenterprisepolicy.
Remediation:
Uninstallexcesstoolingand/orremoveunnecessaryrolesfromtheunderlyingoperatingsystem.
Impact:
Itisdifficulttoseeanyreasonablyadverseimpacttomakingthisarchitecturalchange,oncethecostsofmakingthechangehavebeenpaid.Customapplicationsmayneedtobemodifiedtoaccommodatedatabaseconnectionsoverthewireratherthanonthehost(i.e.usingTCP/IPinsteadofNamedPipes).Additionalhardwareandoperatingsystemlicensesmayberequiredtomakethesearchitecturalchanges.
12|P a g e
CISControls:
9.5OperateCriticalServicesonDedicatedHosts(i.e.DNS,Mail,Web,Database)Operatecriticalservicesonseparatephysicalorlogicalhostmachines,suchasDNS,file,mail,web,anddatabaseservers.
13|P a g e
2SurfaceAreaReduction
SQLServeroffersvariousconfigurationoptions,someofthemcanbecontrolledbythesp_configurestoredprocedure.Thissectioncontainsthelistingofthecorrespondingrecommendations.
2.1Ensure'AdHocDistributedQueries'ServerConfigurationOptionissetto'0'(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
EnablingAdHocDistributedQueriesallowsuserstoquerydataandexecutestatementsonexternaldatasources.Thisfunctionalityshouldbedisabled.
Rationale:
ThisfeaturecanbeusedtoremotelyaccessandexploitvulnerabilitiesonremoteSQLServerinstancesandtorununsafeVisualBasicforApplicationfunctions.
Audit:
RunthefollowingT-SQLcommand:
SELECT name, CAST(value as int) as value_configured, CAST(value_in_use as int) as value_in_use FROM sys.configurations WHERE name = 'Ad Hoc Distributed Queries';
Bothvaluecolumnsmustshow0.
Remediation:
RunthefollowingT-SQLcommand:
EXECUTE sp_configure 'show advanced options', 1; RECONFIGURE; EXECUTE sp_configure 'Ad Hoc Distributed Queries', 0; RECONFIGURE; GO EXECUTE sp_configure 'show advanced options', 0; RECONFIGURE;
14|P a g e
DefaultValue:
0(disabled)
References:
1. https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/ad-hoc-distributed-queries-server-configuration-option
CISControls:
9.1LimitOpenPorts,Protocols,andServicesEnsurethatonlyports,protocols,andserviceswithvalidatedbusinessneedsarerunningoneachsystem.
15|P a g e
2.2Ensure'CLREnabled'ServerConfigurationOptionissetto'0'(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
Theclr enabledoptionspecifieswhetheruserassembliescanberunbySQLServer.
Rationale:
EnablinguseofCLRassemblieswidenstheattacksurfaceofSQLServerandputsitatriskfrombothinadvertentandmaliciousassemblies.
Audit:
RunthefollowingT-SQLcommand:
SELECT name, CAST(value as int) as value_configured, CAST(value_in_use as int) as value_in_use FROM sys.configurations WHERE name = 'clr enabled';
Bothvaluecolumnsmustshow0.
Remediation:
RunthefollowingT-SQLcommand:
EXECUTE sp_configure 'clr enabled', 0; RECONFIGURE;
Impact:
IfCLRassembliesareinuse,applicationsmayneedtoberearchitectedtoeliminatetheirusagebeforedisablingthissetting.Alternatively,someorganizationsmayallowthissettingtobeenabled1forassembliescreatedwiththeSAFEpermissionset,butdisallowassembliescreatedwiththeriskierUNSAFEandEXTERNAL_ACCESSpermissionsets.Tofinduser-createdassemblies,runthefollowingqueryinalldatabases,replacingwitheachdatabasename:
16|P a g e
USE [] GO SELECT name AS Assembly_Name, permission_set_desc FROM sys.assemblies WHERE is_user_defined = 1; GO
DefaultValue:
Bydefault,thisoptionisdisabled.
References:
1. https://docs.microsoft.com/en-us/sql/t-sql/statements/create-assembly-transact-sql
CISControls:
18.9SanitizeDeployedSoftwareofDevelopmentArtifactsForin-housedevelopedapplications,ensurethatdevelopmentartifacts(sampledataandscripts;unusedlibraries,components,debugcode;ortools)arenotincludedinthedeployedsoftware,oraccessibleintheproductionenvironment.
17|P a g e
2.3Ensure'CrossDBOwnershipChaining'ServerConfigurationOptionissetto'0'(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
Thecross db ownership chainingoptioncontrolscross-databaseownershipchainingacrossalldatabasesattheinstance(orserver)level.
Rationale:
Whenenabled,thisoptionallowsamemberofthedb_ownerroleinadatabasetogainaccesstoobjectsownedbyalogininanyotherdatabase,causinganunnecessaryinformationdisclosure.Whenrequired,cross-databaseownershipchainingshouldonlybeenabledforthespecificdatabasesrequiringitinsteadofattheinstancelevelforalldatabasesbyusingtheALTER DATABASE SET DB_CHAINING ONcommand.Thisdatabaseoptionmaynotbechangedonthemaster,model,ortempdbsystemdatabases.
Audit:
RunthefollowingT-SQLcommand:
SELECT name, CAST(value as int) as value_configured, CAST(value_in_use as int) as value_in_use FROM sys.configurations WHERE name = 'cross db ownership chaining';
Bothvaluecolumnsmustshow0.
Remediation:
RunthefollowingT-SQLcommand:
EXECUTE sp_configure 'cross db ownership chaining', 0; RECONFIGURE; GO
DefaultValue:
Bydefault,thisoptionisdisabled(0).
18|P a g e
References:
1. https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/cross-db-ownership-chaining-server-configuration-option
CISControls:
14.4ProtectInformationwithAccessControlListsAllinformationstoredonsystemsshallbeprotectedwithfilesystem,networkshare,claims,application,ordatabasespecificaccesscontrollists.Thesecontrolswillenforcetheprinciplethatonlyauthorizedindividualsshouldhaveaccesstotheinformationbasedontheirneedtoaccesstheinformationasapartoftheirresponsibilities.
19|P a g e
2.4Ensure'DatabaseMailXPs'ServerConfigurationOptionissetto'0'(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
TheDatabase Mail XPsoptioncontrolstheabilitytogenerateandtransmitemailmessagesfromSQLServer.
Rationale:
DisablingDatabase MailreducestheSQLServersurface,eliminatesaDOSattackvectorandchanneltoexfiltratedatafromthedatabaseservertoaremotehost.
Audit:
RunthefollowingT-SQLcommand:
SELECT name, CAST(value as int) as value_configured, CAST(value_in_use as int) as value_in_use FROM sys.configurations WHERE name = 'Database Mail XPs';
Bothvaluecolumnsmustshow0.
Remediation:
RunthefollowingT-SQLcommand:
EXECUTE sp_configure 'show advanced options', 1; RECONFIGURE; EXECUTE sp_configure 'Database Mail XPs', 0; RECONFIGURE; GO EXECUTE sp_configure 'show advanced options', 0; RECONFIGURE;
DefaultValue:
Bydefault,thisoptionisdisabled(0).
References:
1. http://msdn.microsoft.com/en-us/library/ms175887(v=sql.105)
20|P a g e
CISControls:
18ApplicationSoftwareSecurity
21|P a g e
2.5Ensure'OleAutomationProcedures'ServerConfigurationOptionissetto'0'(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
TheOle Automation ProceduresoptioncontrolswhetherOLEAutomationobjectscanbeinstantiatedwithinTransact-SQLbatches.TheseareextendedstoredproceduresthatallowSQLServeruserstoexecutefunctionsexternaltoSQLServer.
Rationale:
EnablingthisoptionwillincreasetheattacksurfaceofSQLServerandallowuserstoexecutefunctionsinthesecuritycontextofSQLServer.
Audit:
RunthefollowingT-SQLcommand:
SELECT name, CAST(value as int) as value_configured, CAST(value_in_use as int) as value_in_use FROM sys.configurations WHERE name = 'Ole Automation Procedures';
Bothvaluecolumnsmustshow0.
Remediation:
RunthefollowingT-SQLcommand:
EXECUTE sp_configure 'show advanced options', 1; RECONFIGURE; EXECUTE sp_configure 'Ole Automation Procedures', 0; RECONFIGURE; GO EXECUTE sp_configure 'show advanced options', 0; RECONFIGURE;
DefaultValue:
Bydefault,thisoptionisdisabled(0).
22|P a g e
References:
1. https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/ole-automation-procedures-server-configuration-option
CISControls:
18ApplicationSoftwareSecurity
23|P a g e
2.6Ensure'RemoteAccess'ServerConfigurationOptionissetto'0'(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
Theremote accessoptioncontrolstheexecutionoflocalstoredproceduresonremoteserversorremotestoredproceduresonlocalserver.
Rationale:
FunctionalitycanbeabusedtolaunchaDenial-of-Service(DoS)attackonremoteserversbyoff-loadingqueryprocessingtoatarget.
Audit:
RunthefollowingT-SQLcommand:
SELECT name, CAST(value as int) as value_configured, CAST(value_in_use as int) as value_in_use FROM sys.configurations WHERE name = 'remote access';
Bothvaluecolumnsmustshow0.
Remediation:
RunthefollowingT-SQLcommand:
EXECUTE sp_configure 'show advanced options', 1; RECONFIGURE; EXECUTE sp_configure 'remote access', 0; RECONFIGURE; GO EXECUTE sp_configure 'show advanced options', 0; RECONFIGURE;
RestarttheDatabaseEngine.
DefaultValue:
Bydefault,thisoptionisenabled(1).
24|P a g e
References:
1. https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/configure-the-remote-access-server-configuration-option
CISControls:
9.1LimitOpenPorts,Protocols,andServicesEnsurethatonlyports,protocols,andserviceswithvalidatedbusinessneedsarerunningoneachsystem.
25|P a g e
2.7Ensure'RemoteAdminConnections'ServerConfigurationOptionissetto'0'(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
Theremote admin connectionsoptioncontrolswhetheraclientapplicationonaremotecomputercanusetheDedicatedAdministratorConnection(DAC).
Rationale:
TheDedicatedAdministratorConnection(DAC)letsanadministratoraccessarunningservertoexecutediagnosticfunctionsorTransact-SQLstatements,ortotroubleshootproblemsontheserver,evenwhentheserverislockedorrunninginanabnormalstateandnotrespondingtoaSQLServerDatabaseEngineconnection.Inaclusterscenario,theadministratormaynotactuallybeloggedontothesamenodethatiscurrentlyhostingtheSQLServerinstanceandthusisconsidered"remote".Therefore,thissettingshouldusuallybeenabled(1)forSQLServerfailoverclusters;otherwiseitshouldbedisabled(0)whichisthedefault.
Audit:
RunthefollowingT-SQLcommand:
USE master; GO SELECT name, CAST(value as int) as value_configured, CAST(value_in_use as int) as value_in_use FROM sys.configurations WHERE name = 'remote admin connections' AND SERVERPROPERTY('IsClustered') = 0;
Ifnodataisreturned,theinstanceisaclusterandthisrecommendationisnotapplicable.Ifdataisreturned,thenboththevaluecolumnsmustshow0tobecompliant.
Remediation:
Runthefollowingcommandonnon-clusteredinstallations:
EXECUTE sp_configure 'remote admin connections', 0; RECONFIGURE; GO
26|P a g e
DefaultValue:
Bydefault,thisoptionisdisabled(0),onlylocalconnectionsmayusetheDAC.
References:
1. https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/remote-admin-connections-server-configuration-option
Notes:
Ifit'saclusteredinstallation,itmustbeenabledasaclusteredSQLServercannotbindtolocalhostandDACwillbeunavailableotherwise.Enableitforclusteredinstallations.Disableitforstandaloneinstallationswherenotrequired.
CISControls:
9.1LimitOpenPorts,Protocols,andServicesEnsurethatonlyports,protocols,andserviceswithvalidatedbusinessneedsarerunningoneachsystem.
27|P a g e
2.8Ensure'ScanForStartupProcs'ServerConfigurationOptionissetto'0'(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
Thescan for startup procsoption,ifenabled,causesSQLServertoscanforandautomaticallyrunallstoredproceduresthataresettoexecuteuponservicestartup.
Rationale:
Enforcingthiscontrolreducesthethreatofanentityleveragingthesefacilitiesformaliciouspurposes.
Audit:
RunthefollowingT-SQLcommand:
SELECT name, CAST(value as int) as value_configured, CAST(value_in_use as int) as value_in_use FROM sys.configurations WHERE name = 'scan for startup procs';
Bothvaluecolumnsmustshow0.
Remediation:
RunthefollowingT-SQLcommand:
EXECUTE sp_configure 'show advanced options', 1; RECONFIGURE; EXECUTE sp_configure 'scan for startup procs', 0; RECONFIGURE; GO EXECUTE sp_configure 'show advanced options', 0; RECONFIGURE;
RestarttheDatabaseEngine.
Impact:
SettingScanforStartupProceduresto0willpreventcertainaudittracesandothercommonlyusedmonitoringSPsfromre-startingonstartup.Additionally,replicationrequiresthissettingtobeenabled(1)andwillautomaticallychangethissettingifneeded.
28|P a g e
DefaultValue:
Bydefault,thisoptionisdisabled(0).
References:
1. https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/configure-the-scan-for-startup-procs-server-configuration-option
CISControls:
18ApplicationSoftwareSecurity
29|P a g e
2.9Ensure'SQLMailXPs'ServerConfigurationOptionissetto'0'(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
SQLMailprovidesamechanismtosend,receive,delete,andprocesse-mailmessagesusingSQLServer.
Rationale:
SQLMail,whichisdeprecatedinfavorofDatabaseMailandifdisabledreducestheSQLServersurface,eliminatesaDOSattackvectorandchanneltoexfiltratedatafromthedatabaseservertoaremotehost.
Audit:
RunthefollowingT-SQLcommand:
SELECT name, CAST(value as int) as value_configured, CAST(value_in_use as int) as value_in_use FROM sys.configurations WHERE name = 'SQL Mail XPs';
Bothvaluecolumnsmustshow0.
Remediation:
RunthefollowingT-SQLcommand:
EXECUTE sp_configure 'show advanced options', 1; RECONFIGURE; EXECUTE sp_configure 'SQL Mail XPs', 0; RECONFIGURE; GO EXECUTE sp_configure 'show advanced options', 0; RECONFIGURE;
DefaultValue:
0(disabled)
30|P a g e
References:
1. http://msdn.microsoft.com/en-us/library/ms190755(v=sql.105).aspx2. http://msdn.microsoft.com/en-us/library/ms190755(v=sql.100).aspx
CISControls:
9.1LimitOpenPorts,Protocols,andServicesEnsurethatonlyports,protocols,andserviceswithvalidatedbusinessneedsarerunningoneachsystem.
31|P a g e
2.10Ensure'Trustworthy'DatabasePropertyissetto'Off'(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
TheTRUSTWORTHYdatabaseoptionallowsdatabaseobjectstoaccessobjectsinotherdatabasesundercertaincircumstances.
Rationale:
ProvidesprotectionfrommaliciousCLRassembliesorextendedprocedures.
Audit:
RunthefollowingT-SQLquerytolistanydatabaseswithaTrustworthydatabasepropertyvalueofON:
SELECT name FROM sys.databases WHERE is_trustworthy_on = 1 AND name != 'msdb';
Norowsshouldbereturned.
Remediation:
ExecutethefollowingT-SQLstatementagainstthedatabases(replacebelow)returnedbytheAuditProcedure:
ALTER DATABASE [] SET TRUSTWORTHY OFF;
DefaultValue:
Bydefault,thisdatabasepropertyisOFF(is_trustworthy_on = 0),exceptforthemsdbdatabaseinwhichitisrequiredtobeON.
References:
1. https://docs.microsoft.com/en-us/sql/relational-databases/security/trustworthy-database-property
2. https://support.microsoft.com/it-it/help/2183687/guidelines-for-using-the-trustworthy-database-setting-in-sql-server
32|P a g e
CISControls:
14.4ProtectInformationwithAccessControlListsAllinformationstoredonsystemsshallbeprotectedwithfilesystem,networkshare,claims,application,ordatabasespecificaccesscontrollists.Thesecontrolswillenforcetheprinciplethatonlyauthorizedindividualsshouldhaveaccesstotheinformationbasedontheirneedtoaccesstheinformationasapartoftheirresponsibilities.
33|P a g e
2.11EnsureUnnecessarySQLServerProtocolsaresetto'Disabled'(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
SQLServersupportsSharedMemory,NamedPipes,TCP/IPandVIAprotocols.However,SQLServershouldbeconfiguredtousethebareminimumrequiredbasedontheorganization'sneeds.
Rationale:
UsingfewerprotocolsminimizestheattacksurfaceofSQLServerand,insomecases,canprotectitfromremoteattacks.
Audit:
OpenSQLServerConfigurationManager;gototheSQLServerNetworkConfiguration.Ensurethatonlyrequiredprotocolsareenabled.
Remediation:
OpenSQLServerConfigurationManager;gototheSQLServerNetworkConfiguration.Ensurethatonlyrequiredprotocolsareenabled.Disableprotocolsnotnecessary.
Impact:
TheDatabaseEnginemustbestoppedandrestartedforthechangetotakeeffect.
DefaultValue:
Bydefault,TCP/IPandSharedMemoryprotocolsareenabledonallcommercialeditions.
References:
1. http://msdn.microsoft.com/en-us/library/ms191294(v=sql.105).aspx2. http://msdn.microsoft.com/en-us/library/ms191294(v=sql.100).aspx
34|P a g e
CISControls:
9.1LimitOpenPorts,Protocols,andServicesEnsurethatonlyports,protocols,andserviceswithvalidatedbusinessneedsarerunningoneachsystem.
35|P a g e
2.12EnsureSQLServerisconfiguredtousenon-standardports(NotScored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
Ifenabled,thedefaultSQLServerinstancewillbeassignedadefaultportofTCP:1433forTCP/IPcommunication.AdministratorscanalsoconfigurenamedinstancestouseTCP:1433forcommunication.TCP:1433isawidelyknownSQLServerportandthisportassignmentshouldbechanged.
Rationale:
Usinganon-defaultporthelpsprotectthedatabasefromattacksdirectedtothedefaultport.
Audit:
RunthefollowingT-SQLscript:
DECLARE @value nvarchar(256); EXECUTE master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\Microsoft SQL Server\MSSQLServer\SuperSocketNetLib\Tcp\IPAll', N'TcpPort', @value OUTPUT, N'no_output'; SELECT @value AS TCP_Port WHERE @value = '1433';
Thisshouldreturnnorows.
Remediation:
1. InSQLServerConfigurationManager,intheconsolepane,expandSQLServerNetworkConfiguration,expandProtocolsfor,andthendouble-clicktheTCP/IPorVIAprotocol
2. IntheTCP/IPPropertiesdialogbox,ontheIPAddressestab,severalIPaddressesappearintheformatIP1,IP2,uptoIPAll.OneoftheseisfortheIPaddressoftheloopbackadapter,127.0.0.1.AdditionalIPaddressesappearforeachIPAddressonthecomputer
36|P a g e
3. ChangetheTCPPortfieldfrom1433toanothernon-standardportorleavetheTCPPortfieldemptyandsettheTCPDynamicPortsvalueto0toenabledynamicportassignmentandthenclickOK.
4. Intheconsolepane,clickSQLServerServices.5. Inthedetailspane,right-clickSQLServer()andthenclick
Restart,tostopandrestartSQLServer.
Impact:
ChangingthedefaultportwillforcetheDAC(DedicatedAdministratorConnection)tolistenonarandomport.Also,itmightmakebenignapplications,suchasapplicationfirewalls,requirespecialconfiguration.Ingeneral,youshouldsetastaticportforconsistentusagebyapplications,includingfirewalls,insteadofusingdynamicportswhichwillbechosenrandomlyateachSQLServerstartup.
DefaultValue:
Bydefault,defaultSQLServerinstanceslistenontoTCP/IPtrafficonTCPport1433andnamedinstancesusedynamicports.
References:
1. https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/configure-a-server-to-listen-on-a-specific-tcp-port
CISControls:
9LimitationandControlofNetworkPorts,Protocols,andServices
37|P a g e
2.13Ensure'HideInstance'optionissetto'Yes'forProductionSQLServerinstances(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
Non-clusteredSQLServerinstanceswithinproductionenvironmentsshouldbedesignatedashiddentopreventadvertisementbytheSQLServerBrowserservice.
Rationale:
DesignatingproductionSQLServerinstancesashiddenleadstoamoresecureinstallationbecausetheycannotbeenumerated.However,clusteredinstancesmaybreakifthisoptionisselected.
Audit:
PerformeithertheGUIorT-SQLmethodshown:
GUIMethod
1. InSQLServerConfigurationManager,expandSQLServerNetworkConfiguration,right-clickProtocolsfor,andthenselectProperties.
2. OntheFlagstab,intheHideInstancebox,verifyYesisselected.
T-SQLMethodExecutethefollowingT-SQL.Avalueof1shouldbereturned.
DECLARE @getValue INT; EXEC master..xp_instance_regread @rootkey = N'HKEY_LOCAL_MACHINE', @key = N'SOFTWARE\Microsoft\Microsoft SQL Server\MSSQLServer\SuperSocketNetLib', @value_name = N'HideInstance', @value = @getValue OUTPUT; SELECT @getValue;
38|P a g e
Remediation:
PerformeithertheGUIorT-SQLmethodshown:
GUIMethod
1. InSQLServerConfigurationManager,expandSQLServerNetworkConfiguration,right-clickProtocolsfor,andthenselectProperties.
2. OntheFlagstab,intheHideInstancebox,selectYes,andthenclickOKtoclosethedialogbox.Thechangetakeseffectimmediatelyfornewconnections.
T-SQLMethodExecutethefollowingT-SQLtoremediate:
EXEC master..xp_instance_regwrite @rootkey = N'HKEY_LOCAL_MACHINE', @key = N'SOFTWARE\Microsoft\Microsoft SQL Server\MSSQLServer\SuperSocketNetLib', @value_name = N'HideInstance', @type = N'REG_DWORD', @value = 1;
Impact:
Thismethodonlypreventstheinstancefrombeinglistedonthenetwork.Iftheinstanceishidden(notexposedbySQLBrowser),thenconnectionswillneedtospecifytheserverandportinordertoconnect.Itdoesnotpreventusersfromconnectingtoserveriftheyknowtheinstancenameandport.
Ifyouhideaclusterednamedinstance,theclusterservicemaynotbeabletoconnecttotheSQLServer.PleaserefertotheMicrosoftdocumentationreference.
DefaultValue:
Bydefault,SQLServerinstancesarenothidden.
References:
1. http://msdn.microsoft.com/en-us/library/ms179327(v=sql.105).aspx2. http://msdn.microsoft.com/en-us/library/ms179327(v=sql.100).aspx
CISControls:
9LimitationandControlofNetworkPorts,Protocols,andServices
39|P a g e
2.14Ensure'sa'LoginAccountissetto'Disabled'(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
ThesaaccountisawidelyknownandoftenwidelyusedSQLServeraccountwithsysadminprivileges.Thisistheoriginallogincreatedduringinstallationandalwayshastheprincipal_id=1andsid=0x01.
Rationale:
Enforcingthiscontrolreducestheprobabilityofanattackerexecutingbruteforceattacksagainstawell-knownprincipal.
Audit:
Usethefollowingsyntaxtodetermineifthesaaccountisdisabled.Checkingforsid=0x01ensuresthattheoriginalsaaccountisbeingcheckedincaseithasbeenrenamedperbestpractices.
SELECT name, is_disabled FROM sys.server_principals WHERE sid = 0x01 AND is_disabled = 0;
Norowsshouldbereturnedtobecompliant.Anis_disabledvalueof0indicatestheloginiscurrentlyenabledandthereforeneedsremediation.
Remediation:
ExecutethefollowingT-SQLquery:
USE [master] GO DECLARE @tsql nvarchar(max) SET @tsql = 'ALTER LOGIN ' + SUSER_NAME(0x01) + ' DISABLE' EXEC (@tsql) GO
40|P a g e
Impact:
Itisnotagoodsecuritypracticetocodeapplicationsorscriptstousethesaaccount.However,ifthishasbeendone,disablingthesaaccountwillpreventscriptsandapplicationsfromauthenticatingtothedatabaseserverandexecutingrequiredtasksorfunctions.
DefaultValue:
Bydefault,thesaloginaccountisdisabledatinstalltimewhenWindowsAuthenticationModeisselected.Ifmixedmode(SQLServerandWindowsAuthentication)isselectedatinstall,thedefaultforthesaloginisenabled.
References:
1. http://msdn.microsoft.com/en-us/library/ms188786(v=sql.100).aspx2. http://msdn.microsoft.com/en-us/library/ms188786(v=sql.105).aspx3. http://msdn.microsoft.com/en-us/library/ms189828(v=sql.100).aspx4. http://msdn.microsoft.com/en-us/library/ms189828(v=sql.105).aspx
CISControls:
5.1MinimizeandSparinglyUseAdministrativePrivilegesMinimizeadministrativeprivilegesandonlyuseadministrativeaccountswhentheyarerequired.Implementfocusedauditingontheuseofadministrativeprivilegedfunctionsandmonitorforanomalousbehavior.
41|P a g e
2.15Ensure'sa'LoginAccounthasbeenrenamed(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
ThesaaccountisawidelyknownandoftenwidelyusedSQLServerloginwithsysadminprivileges.Thesaloginistheoriginallogincreatedduringinstallationandalwayshasprincipal_id=1andsid=0x01.
Rationale:
Itismoredifficulttolaunchpassword-guessingandbrute-forceattacksagainstthesaloginifthenameisnotknown.
Audit:
Usethefollowingsyntaxtodetermineifthesaaccountisrenamed.
SELECT name FROM sys.server_principals WHERE sid = 0x01;
Anameofsaindicatestheaccounthasnotbeenrenamed.
Remediation:
Replacethevaluewithinthebelowsyntaxandexecutetorenamethesalogin.
ALTER LOGIN sa WITH NAME = ;
Impact:
Itisnotagoodsecuritypracticetocodeapplicationsorscriptstousethesaaccount.However,ifthishasbeendonerenamingthesaaccountwillpreventscriptsandapplicationsforauthenticatingtothedatabaseserverandexecutingrequiredtasksorfunctions.
DefaultValue:
Bydefault,thesaloginnameis'sa'.
42|P a g e
References:
1. https://docs.microsoft.com/en-us/sql/relational-databases/security/choose-an-authentication-mode
CISControls:
5ControlledUseofAdministrationPrivileges
43|P a g e
2.16Ensure'xp_cmdshell'ServerConfigurationOptionissetto'0'(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
Thexp_cmdshelloptioncontrolswhetherthexp_cmdshellextendedstoredprocedurecanbeusedbyanauthenticatedSQLServerusertoexecuteoperating-systemcommandshellcommandsandreturnresultsasrowswithintheSQLclient.
Rationale:
Thexp_cmdshellprocedureiscommonlyusedbyattackerstoreadorwritedatato/fromtheunderlyingOperatingSystemofadatabaseserver.
Audit:
RunthefollowingT-SQLcommand:
SELECT name, CAST(value as int) as value_configured, CAST(value_in_use as int) as value_in_use FROM sys.configurations WHERE name = 'xp_cmdshell';
Bothvaluecolumnsmustshow0tobecompliant.
Remediation:
RunthefollowingT-SQLcommand:
EXECUTE sp_configure 'show advanced options', 1; RECONFIGURE; EXECUTE sp_configure 'xp_cmdshell', 0; RECONFIGURE; GO EXECUTE sp_configure 'show advanced options', 0; RECONFIGURE;
DefaultValue:
Bydefault,thisoptionisdisabled(0).
44|P a g e
References:
1. https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/xp-cmdshell-transact-sql
2. https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/xp-cmdshell-server-configuration-option
CISControls:
18ApplicationSoftwareSecurity
45|P a g e
3AuthenticationandAuthorization
Thissectioncontainsauthenticationandauthorizationrelatedrecommendations.
3.1Ensure'ServerAuthentication'Propertyissetto'WindowsAuthenticationMode'(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
UsesWindowsAuthenticationtovalidateattemptedconnections.
Rationale:
WindowsprovidesamorerobustauthenticationmechanismthanSQLServerauthentication.
Audit:
Executethefollowingsyntax:
SELECT SERVERPROPERTY('IsIntegratedSecurityOnly') as [login_mode];
Alogin_modeof1indicatestheServerAuthenticationpropertyissettoWindowsAuthenticationMode.Alogin_modeof0indicatesmixedmodeauthentication.
Remediation:
PerformeithertheGUIorT-SQLmethodshown:
GUIMethod
1. OpenSQLServerManagementStudio.2. OpentheObjectExplorertabandconnecttothetargetdatabaseinstance.3. RightclicktheinstancenameandselectProperties.4. SelecttheSecuritypagefromtheleftmenu.5. SettheServerauthenticationsettingtoWindowsAuthenticationMode.
46|P a g e
T-SQLMethodRunthefollowingT-SQLinaQueryWindow:
USE [master] GO EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode', REG_DWORD, 1 GO
RestarttheSQLServerserviceforthechangetotakeeffect.
DefaultValue:
WindowsAuthenticationMode
References:
1. http://msdn.microsoft.com/en-us/library/ms188470(v=sql.100).aspx2. http://msdn.microsoft.com/en-us/library/ms188470(v=sql.105).aspx
CISControls:
16.9ConfigureAccountAccessCentrallyConfigureaccessforallaccountsthroughacentralizedpointofauthentication,forexampleActiveDirectoryorLDAP.Configurenetworkandsecuritydevicesforcentralizedauthenticationaswell.
47|P a g e
3.2EnsureCONNECTpermissionsonthe'guestuser'isRevokedwithinallSQLServerdatabasesexcludingthemaster,msdbandtempdb(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
RemovetherightoftheguestusertoconnecttoSQLServerdatabases,exceptformaster,msdb,andtempdb.
Rationale:
AloginassumestheidentityoftheguestuserwhenaloginhasaccesstoSQLServerbutdoesnothaveaccesstoadatabasethroughitsownaccountandthedatabasehasaguestuseraccount.RevokingtheCONNECTpermissionfortheguestuserwillensurethataloginisnotabletoaccessdatabaseinformationwithoutexplicitaccesstodoso.
Audit:
Runthefollowingcodesnippetforeachdatabase(replacingasappropriate)intheinstancetodetermineiftheguestuserhasCONNECTpermission.Norowsshouldbereturned.
USE []; GO SELECT DB_NAME() AS DatabaseName, 'guest' AS Database_User, [permission_name], [state_desc] FROM sys.database_permissions WHERE [grantee_principal_id] = DATABASE_PRINCIPAL_ID('guest') AND [state_desc] LIKE 'GRANT%' AND [permission_name] = 'CONNECT' AND DB_NAME() NOT IN ('master','tempdb','msdb');
Remediation:
ThefollowingcodesnippetrevokesCONNECTpermissionsfromtheguestuserinadatabase.Replaceasappropriate:
USE []; GO REVOKE CONNECT FROM guest;
48|P a g e
Impact:
WhenCONNECTpermissiontotheguestuserisrevoked,aSQLServerinstanceloginmustbemappedtoadatabaseuserexplicitlyinordertohaveaccesstothedatabase.
DefaultValue:
TheguestuseraccountisaddedtoeachnewdatabasebutwithoutCONNECTpermissionbydefault
References:
1. https://docs.microsoft.com/en-us/sql/relational-databases/policy-based-management/guest-permissions-on-user-databases
Notes:
TheguestaccountcannothavetheCONNECTpermissionrevokedinmaster,msdbandtempdb,butthispermissionshouldberevokedinallotherdatabasesontheSQLServerinstance.
CISControls:
16AccountMonitoringandControl
49|P a g e
3.3Ensure'OrphanedUsers'areDroppedFromSQLServerDatabases(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
AdatabaseuserforwhichthecorrespondingSQLServerloginisundefinedorisincorrectlydefinedonaserverinstancecannotlogintotheinstanceandisreferredtoasorphanedandshouldberemoved.
Rationale:
Orphanusersshouldberemovedtoavoidpotentialmisuseofthosebrokenusersinanyway.
Audit:
RunthefollowingT-SQLqueryineachdatabasetoidentifyorphanusers.Norowsshouldbereturned.
USE []; GO EXEC sp_change_users_login @Action='Report';
Remediation:
IftheorphanedusercannotorshouldnotbematchedtoanexistingornewloginusingtheMicrosoftdocumentedprocessreferencedbelow,runthefollowingT-SQLqueryintheappropriatedatabasetoremoveanorphanuser:
USE []; GO DROP USER ;
References:
1. http://msdn.microsoft.com/en-us/library/ms175475(v=sql.100).aspx2. http://msdn.microsoft.com/en-us/library/ms175475(v=sql.105).aspx
CISControls:
16AccountMonitoringandControl
50|P a g e
3.4EnsuretheSQLServer’sMSSQLServiceAccountisNotanAdministrator(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
Theserviceaccountand/orserviceSIDusedbytheMSSQLSERVERserviceforadefaultinstanceorMSSQL$serviceforanamedinstanceshouldnotbeamemberoftheWindowsAdministratorgroupeitherdirectlyorindirectly(viaagroup).ThisalsomeansthattheaccountknownasLocalSystem(akaNT AUTHORITY\SYSTEM)shouldnotbeusedfortheMSSQLserviceasthisaccounthashigherprivilegesthantheSQLServerservicerequires.
Rationale:
Followingtheprincipleofleastprivilege,theserviceaccountshouldhavenomoreprivilegesthanrequiredtodoitsjob.ForSQLServerservices,theSQLServerSetupwillassigntherequiredpermissionsdirectlytotheserviceSID.Noadditionalpermissionsorprivilegesshouldbenecessary.
Audit:
Verifythattheserviceaccount(incaseofalocalorADaccount)andserviceSIDarenotmembersoftheWindowsAdministratorsgroup.
Remediation:
InthecasewhereLocalSystemisused,useSQLServerConfigurationManagertochangetoalessprivilegedaccount.Otherwise,removetheaccountorserviceSIDfromtheAdministratorsgroup.YoumayneedtoruntheSQLServerConfigurationManagerifunderlyingpermissionshadbeenchangedorifSQLServerConfigurationManagerwasnotoriginallyusedtosettheserviceaccount.
Impact:
TheSQLServerConfigurationManagertoolshouldalwaysbeusedtochangetheSQLServer’sserviceaccount.Thiswillensurethattheaccounthasthenecessaryprivileges.IftheserviceneedsaccesstoresourcesotherthanthestandardMicrosoftdefineddirectoriesandregistry,thenadditionalpermissionsmayneedtobegrantedseparatelytothoseresources.
51|P a g e
DefaultValue:
Bydefault,theServiceAccount(orServiceSID)isnotamemberoftheAdministratorsgroup.
References:
1. https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/configure-windows-service-accounts-and-permissions
CISControls:
5.1MinimizeandSparinglyUseAdministrativePrivilegesMinimizeadministrativeprivilegesandonlyuseadministrativeaccountswhentheyarerequired.Implementfocusedauditingontheuseofadministrativeprivilegedfunctionsandmonitorforanomalousbehavior.
52|P a g e
3.5EnsuretheSQLServer’sSQLAgentServiceAccountisNotanAdministrator(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
Theserviceaccountand/orserviceSIDusedbytheSQLSERVERAGENTserviceforadefaultinstanceorSQLAGENT$serviceforanamedinstanceshouldnotbeamemberoftheWindowsAdministratorgroupeitherdirectlyorindirectly(viaagroup).ThisalsomeansthattheaccountknownasLocalSystem(akaNT AUTHORITY\SYSTEM)shouldnotbeusedfortheSQLAGENTserviceasthisaccounthashigherprivilegesthantheSQLServerservicerequires.
Rationale:
Followingtheprincipleofleastprivilege,theserviceaccountshouldhavenomoreprivilegesthanrequiredtodoitsjob.ForSQLServerservices,theSQLServerSetupwillassigntherequiredpermissionsdirectlytotheserviceSID.Noadditionalpermissionsorprivilegesshouldbenecessary.
Audit:
Verifythattheserviceaccount(incaseofalocalorADaccount)andserviceSIDarenotmembersoftheWindowsAdministratorsgroup.
Remediation:
InthecasewhereLocalSystemisused,useSQLServerConfigurationManagertochangetoalessprivilegedaccount.Otherwise,removetheaccountorserviceSIDfromtheAdministratorsgroup.YoumayneedtoruntheSQLServerConfigurationManagerifunderlyingpermissionshadbeenchangedorifSQLServerConfigurationManagerwasnotoriginallyusedtosettheserviceaccount.
Impact:
TheSQLServerConfigurationManagertoolshouldalwaysbeusedtochangetheSQLServer’sserviceaccount.Thiswillensurethattheaccounthasthenecessaryprivileges.IftheserviceneedsaccesstoresourcesotherthanthestandardMicrosoft-defineddirectoriesandregistry,thenadditionalpermissionsmayneedtobegrantedseparatelytothoseresources.
53|P a g e
Ifusingtheautorestartfeature,thentheSQLAGENTservicemustbeanAdministrator.
DefaultValue:
Bydefault,theServiceAccount(orServiceSID)isnotamemberoftheAdministratorsgroup.
References:
1. https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/configure-windows-service-accounts-and-permissions
CISControls:
5.1MinimizeandSparinglyUseAdministrativePrivilegesMinimizeadministrativeprivilegesandonlyuseadministrativeaccountswhentheyarerequired.Implementfocusedauditingontheuseofadministrativeprivilegedfunctionsandmonitorforanomalousbehavior.
54|P a g e
3.6EnsuretheSQLServer’sFull-TextServiceAccountisNotanAdministrator(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
Theserviceaccountand/orserviceSIDusedbytheMSSQLFDLauncherserviceforadefaultinstanceorMSSQLFDLauncher$serviceforanamedinstanceshouldnotbeamemberoftheWindowsAdministratorgroupeitherdirectlyorindirectly(viaagroup).ThisalsomeansthattheaccountknownasLocalSystem(akaNT AUTHORITY\SYSTEM)shouldnotbeusedfortheFull-TextserviceasthisaccounthashigherprivilegesthantheSQLServerservicerequires.
Rationale:
Followingtheprincipleofleastprivilege,theserviceaccountshouldhavenomoreprivilegesthanrequiredtodoitsjob.ForSQLServerservices,theSQLServerSetupwillassigntherequiredpermissionsdirectlytotheserviceSID.Noadditionalpermissionsorprivilegesshouldbenecessary.
Audit:
Verifythattheserviceaccount(incaseofalocalorADaccount)andserviceSIDarenotmembersoftheWindowsAdministratorsgroup.
Remediation:
InthecasewhereLocalSystemisused,useSQLServerConfigurationManagertochangetoalessprivilegedaccount.Otherwise,removetheaccountorserviceSIDfromtheAdministratorsgroup.YoumayneedtoruntheSQLServerConfigurationManagerifunderlyingpermissionshadbeenchangedorifSQLServerConfigurationManagerwasnotoriginallyusedtosettheserviceaccount.
Impact:
TheSQLServerConfigurationManagertoolshouldalwaysbeusedtochangetheSQLServer’sserviceaccount.Thiswillensurethattheaccounthasthenecessaryprivileges.IftheserviceneedsaccesstoresourcesotherthanthestandardMicrosoft-defineddirectoriesandregistry,thenadditionalpermissionsmayneedtobegrantedseparatelytothoseresources.
55|P a g e
DefaultValue:
Bydefault,theServiceAccount(orServiceSID)isnotamemberoftheAdministratorsgroup.
References:
1. https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/configure-windows-service-accounts-and-permissions
CISControls:
5.1MinimizeandSparinglyUseAdministrativePrivilegesMinimizeadministrativeprivilegesandonlyuseadministrativeaccountswhentheyarerequired.Implementfocusedauditingontheuseofadministrativeprivilegedfunctionsandmonitorforanomalousbehavior.
56|P a g e
3.7EnsureonlythedefaultpermissionsspecifiedbyMicrosoftaregrantedtothepublicserverrole(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
publicisaspecialfixedserverrolecontainingalllogins.Unlikeotherfixedserverroles,permissionscanbechangedforthepublicrole.Inkeepingwiththeprincipleofleastprivileges,thepublicserverroleshouldnotbeusedtograntpermissionsattheserverscopeasthesewouldbeinheritedbyallusers.
Rationale:
EverySQLServerloginbelongstothepublicroleandcannotberemovedfromthisrole.Therefore,anypermissionsgrantedtothisrolewillbeavailabletoallloginsunlesstheyhavebeenexplicitlydeniedtospecificloginsoruser-definedserverroles.
Audit:
Usethefollowingsyntaxtodetermineifextrapermissionshavebeengrantedtothepublicserverrole.
SELECT * FROM master.sys.server_permissions WHERE (grantee_principal_id = SUSER_SID(N'public') and state_desc LIKE 'GRANT%') AND NOT (state_desc = 'GRANT' and [permission_name] = 'VIEW ANY DATABASE' and class_desc = 'SERVER') AND NOT (state_desc = 'GRANT' and [permission_name] = 'CONNECT' and class_desc = 'ENDPOINT' and major_id = 2) AND NOT (state_desc = 'GRANT' and [permission_name] = 'CONNECT' and class_desc = 'ENDPOINT' and major_id = 3) AND NOT (state_desc = 'GRANT' and [permission_name] = 'CONNECT' and class_desc = 'ENDPOINT' and major_id = 4) AND NOT (state_desc = 'GRANT' and [permission_name] = 'CONNECT' and class_desc = 'ENDPOINT' and major_id = 5);
Thisqueryshouldnotreturnanyrows.
Remediation:
1. AddtheextraneouspermissionsfoundintheAuditqueryresultstothespecificloginstouser-definedserverroleswhichrequiretheaccess.
2. Revokethefromthepublicroleasshownbelow
57|P a g e
USE [master] GO REVOKE FROM public; GO
Impact:
Whentheextraneouspermissionsarerevokedfromthepublicserverrole,accessmaybelostunlessthepermissionsaregrantedtotheexplicitloginsortouser-definedserverrolescontainingtheloginswhichrequiretheaccess.
DefaultValue:
Bydefault,thepublicserverroleisgrantedVIEW ANY DATABASEpermissionandtheCONNECTpermissiononthedefaultendpoints(TSQL Local Machine,TSQL Named Pipes,TSQL Default TCP,TSQL Default VIA).TheVIEW ANY DATABASEpermissionallowsallloginstoseedatabasemetadata,unlessexplicitlydenied.
References:
1. https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/server-level-roles
2. https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/server-level-roles#permissions-of-fixed-server-roles
CISControls:
5.1MinimizeandSparinglyUseAdministrativePrivilegesMinimizeadministrativeprivilegesandonlyuseadministrativeaccountswhentheyarerequired.Implementfocusedauditingontheuseofadministrativeprivilegedfunctionsandmonitorforanomalousbehavior.
58|P a g e
3.8EnsureWindowsBUILTINgroupsarenotSQLLogins(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
PriortoSQLServer2008,theBUILTIN\AdministratorsgroupwasaddedaSQLServerloginwithsysadminprivilegesduringinstallationbydefault.BestpracticespromotecreatinganActiveDirectorylevelgroupcontainingapprovedDBAstaffaccountsandusingthiscontrolledADgroupastheloginwithsysadminprivileges.TheADgroupshouldbespecifiedduringSQLServerinstallationandtheBUILTIN\Administratorsgroupwouldthereforehavenoneedtobealogin.
Rationale:
TheBUILTINgroups(Administrators,Everyone,AuthenticatedUsers,Guests,etc)generallycontainverybroadmembershipswhichwouldnotmeetthebestpracticeofensuringonlythenecessaryusershavebeengrantedaccesstoaSQLServerinstance.ThesegroupsshouldnotbeusedforanylevelofaccessintoaSQLServerDatabaseEngineinstance.
Audit:
UsethefollowingsyntaxtodetermineifanyBUILTINgroupsoraccountshavebeenaddedasSQLServerLogins.
SELECT pr.[name], pe.[permission_name], pe.[state_desc] FROM sys.server_principals pr JOIN sys.server_permissions pe ON pr.principal_id = pe.grantee_principal_id WHERE pr.name like 'BUILTIN%';
Thisqueryshouldnotreturnanyrows.
Remediation:
1. ForeachBUILTINlogin,ifneededcreateamorerestrictiveADgroupcontainingonlytherequireduseraccounts.
2. AddtheADgrouporindividualWindowsaccountsasaSQLServerloginandgrantitthepermissionsrequired.
59|P a g e
3. DroptheBUILTINloginusingthesyntaxbelowafterreplacing.
USE [master] GO DROP LOGIN [BUILTIN\] GO
Impact:
BeforedroppingtheBUILTINgrouplogins,ensurethatalternativeADGroupsorWindowsloginshavebeenaddedwithequivalentpermissions.Otherwise,theSQLServerinstancemaybecometotallyinaccessible.
DefaultValue:
Bydefault,noBUILTINgroupsareaddedasSQLlogins.
CISControls:
14.4ProtectInformationwithAccessControlListsAllinformationstoredonsystemsshallbeprotectedwithfilesystem,networkshare,claims,application,ordatabasespecificaccesscontrollists.Thesecontrolswillenforcetheprinciplethatonlyauthorizedindividualsshouldhaveaccesstotheinformationbasedontheirneedtoaccesstheinformationasapartoftheirresponsibilities.
60|P a g e
3.9EnsureWindowslocalgroupsarenotSQLLogins(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
LocalWindowsgroupsshouldnotbeusedasloginsforSQLServerinstances.
Rationale:
AllowinglocalWindowsgroupsasSQLLoginsprovidesaloopholewherebyanyonewithOSleveladministratorrights(andnoSQLServerrights)couldadduserstothelocalWindowsgroupsandtherebygivethemselvesorothersaccesstotheSQLServerinstance.
Audit:
UsethefollowingsyntaxtodetermineifanylocalgroupshavebeenaddedasSQLServerLogins.
USE [master] GO SELECT pr.[name] AS LocalGroupName, pe.[permission_name], pe.[state_desc] FROM sys.server_principals pr JOIN sys.server_permissions pe ON pr.[principal_id] = pe.[grantee_principal_id] WHERE pr.[type_desc] = 'WINDOWS_GROUP' AND pr.[name] like CAST(SERVERPROPERTY('MachineName') AS nvarchar) + '%';
Thisqueryshouldnotreturnanyrows.
Remediation:
1. ForeachLocalGroupNamelogin,ifneededcreateanequivalentADgroupcontainingonlytherequireduseraccounts.
2. AddtheADgrouporindividualWindowsaccountsasaSQLServerloginandgrantitthepermissionsrequired.
3. DroptheLocalGroupNameloginusingthesyntaxbelowafterreplacing.
USE [master] GO DROP LOGIN [] GO
61|P a g e
Impact:
Beforedroppingthelocalgrouplogins,ensurethatalternativeADGroupsorWindowsloginshavebeenaddedwithequivalentpermissions.Otherwise,theSQLServerinstancemaybecometotallyinaccessible.
DefaultValue:
Bydefault,nolocalgroupsareaddedasSQLlogins.
CISControls:
14.4ProtectInformationwithAccessControlListsAllinformationstoredonsystemsshallbeprotectedwithfilesystem,networkshare,claims,application,ordatabasespecificaccesscontrollists.Thesecontrolswillenforcetheprinciplethatonlyauthorizedindividualsshouldhaveaccesstotheinformationbasedontheirneedtoaccesstheinformationasapartoftheirresponsibilities.
62|P a g e
3.10EnsurethepublicroleinthemsdbdatabaseisnotgrantedaccesstoSQLAgentproxies(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
Thepublicdatabaserolecontainseveryuserinthemsdbdatabase.SQLAgentproxiesdefineasecuritycontextinwhichajobstepcanrun.
Rationale:
GrantingaccesstoSQLAgentproxiesforthepublicrolewouldallowalluserstoutilizetheproxywhichmayhavehighprivileges.Thiswouldlikelybreaktheprincipleofleastprivileges.
Audit:
Usethefollowingsyntaxtodetermineifaccesstoanyproxieshavebeengrantedtothemsdbdatabase'spublicrole.
USE [msdb] GO SELECT sp.name AS proxyname FROM dbo.sysproxylogin spl JOIN sys.database_principals dp ON dp.sid = spl.sid JOIN sysproxies sp ON sp.proxy_id = spl.proxy_id WHERE principal_id = USER_ID('public'); GO
Thisqueryshouldnotreturnanyrows.
Remediation:
1. Ensuretherequiredsecurityprincipalsareexplicitlygrantedaccesstotheproxy(usesp_grant_login_to_proxy).
2. Revokeaccesstothefromthepublicrole.
USE [msdb] GO EXEC dbo.sp_revoke_login_from_proxy @name = N'public', @proxy_name = N''; GO
63|P a g e
Impact:
Beforerevokingthepublicrolefromtheproxy,ensurethatalternativeloginsorappropriateuser-defineddatabaseroleshavebeenaddedwithequivalentpermissions.Otherwise,SQLAgentjobstepsdependentuponthisaccesswillfail.
DefaultValue:
Bydefault,themsdbpublicdatabaseroledoesnothaveaccesstoanyproxy.
References:
1. https://support.microsoft.com/en-us/help/2160741/best-practices-in-configuring-sql-server-agent-proxy-account
CISControls:
14.4ProtectInformationwithAccessControlListsAllinformationstoredonsystemsshallbeprotectedwithfilesystem,networkshare,claims,application,ordatabasespecificaccesscontrollists.Thesecontrolswillenforcetheprinciplethatonlyauthorizedindividualsshouldhaveaccesstotheinformationbasedontheirneedtoaccesstheinformationasapartoftheirresponsibilities.
64|P a g e
4PasswordPolicies
Thissectioncontainsrecommendationsrelatedtopasswordpolicies.
4.1Ensure'MUST_CHANGE'Optionissetto'ON'forAllSQLAuthenticatedLogins(NotScored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
WheneverthisoptionissettoON,SQLServerwillpromptforanupdatedpasswordthefirsttimetheneworalteredloginisused.
Rationale:
EnforcingapasswordchangeafteraresetornewlogincreationwillpreventtheaccountadministratorsoranyoneaccessingtheinitialpasswordfrommisuseoftheSQLlogincreatedwithoutbeingnoticed.
Audit:
1. OpenSQLServerManagementStudio.2. OpenObjectExplorerandconnecttothetargetinstance.3. NavigatetotheLoginstabinObjectExplorerandexpand.Rightclickonthe
desiredloginandselectProperties.4. VerifytheUsermustchangepasswordatnextlogincheckboxischecked.
Note:Thisauditprocedureisonlyapplicableimmediatelyaftertheloginhasbeencreatedoralteredtoforcethepasswordchange.Oncethepasswordischanged,thereisnowaytoknowspecificallythatthisoptionwastheforcingmechanismbehindapasswordchange.
Remediation:
SettheMUST_CHANGEoptionforSQLAuthenticatedloginswhencreatingalogininitially:
CREATE LOGIN WITH PASSWORD = '' MUST_CHANGE, CHECK_EXPIRATION = ON, CHECK_POLICY = ON;
SettheMUST_CHANGEoptionforSQLAuthenticatedloginswhenresettingapassword:
ALTER LOGIN WITH PASSWORD = '' MUST_CHANGE;
65|P a g e
Impact:
CHECK_EXPIRATIONandCHECK_POLICYoptionsmustbothbeON.Endusersmusthavethemeans(application)tochangethepasswordwhenforced.
DefaultValue:
ONwhencreatinganewloginviatheSSMSGUI.
OFFwhencreatinganewloginusingT-SQLCREATE LOGINunlesstheMUST_CHANGEoptionisexplicitlyincludedalongwithCHECK_EXPIRATION = ON.
References:
1. https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-login-transact-sql2. https://docs.microsoft.com/en-us/sql/t-sql/statements/create-login-transact-sql
CISControls:
16AccountMonitoringandControl
66|P a g e
4.2Ensure'CHECK_EXPIRATION'Optionissetto'ON'forAllSQLAuthenticatedLoginsWithintheSysadminRole(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
AppliesthesamepasswordexpirationpolicyusedinWindowstopasswordsusedinsideSQLServer.
Rationale:
EnsuringSQLloginscomplywiththesecurepasswordpolicyappliedbytheWindowsServerBenchmarkwillensurethepasswordsforSQLloginswithsysadminprivilegesarechangedonafrequentbasistohelppreventcompromiseviaabruteforceattack.CONTROL SERVERisanequivalentpermissiontosysadminandloginswiththatpermissionshouldalsoberequiredtohaveexpiringpasswords.
Audit:
RunthefollowingT-SQLstatementtofindsysadminorequivalentloginswithCHECK_EXPIRATION = OFF.Norowsshouldbereturned.
SELECT l.[name], 'sysadmin membership' AS 'Access_Method' FROM sys.sql_logins AS l WHERE IS_SRVROLEMEMBER('sysadmin',name) = 1 AND l.is_expiration_checked 1 UNION ALL SELECT l.[name], 'CONTROL SERVER' AS 'Access_Method' FROM sys.sql_logins AS l JOIN sys.server_permissions AS p ON l.principal_id = p.grantee_principal_id WHERE p.type = 'CL' AND p.state IN ('G', 'W') AND l.is_expiration_checked 1;
Remediation:
ForeachfoundbytheAuditProcedure,executethefollowingT-SQLstatement:
ALTER LOGIN [login_name] WITH CHECK_EXPIRATION = ON;
67|P a g e
Impact:
ThisisamitigatingrecommendationforsystemswhichcannotfollowtherecommendationtouseonlyWindowsAuthenticatedlogins.
RegardinglimitingthisruletoonlyloginswithsysadminandCONTROL SERVERprivileges,therearetoomanycasesofapplicationsthatrunwithlessthansysadminlevelprivilegesthathavehard-codedpasswordsoreffectivelyhard-codedpasswords(whateverissetthefirsttimeisnearlyimpossibletochange).Thereareseverallinesofbusinessapplicationsthatareconsideredbestofbreedwhichhasthisfailing.
Also,keepinmindthatthepasswordpolicyistakenfromthecomputer'slocalpolicy,whichwilltakefromtheDefaultDomainPolicysetting.Manyorganizationshaveadifferentpasswordpolicywithregardstoserviceaccounts.ThesearehandledinADbysettingtheaccount'spasswordnottoexpireandhavingsomeotherprocesstrackwhentheyneedtobechanged.Withthissecondcontrolinplace,thisisperfectlyacceptablefromanauditperspective.IfyoutreataSQLServerloginasaserviceaccount,thenyouhavetodothesame.Thisensuresthatthepasswordchangehappensduringacommunicateddowntimewindowandnotarbitrarily.
DefaultValue:
CHECK_EXPIRATIONisONbydefaultwhenusingSSMStocreateaSQLauthenticatedlogin.
CHECK_EXPIRATIONisOFFbydefaultwhenusingT-SQLCREATE LOGINsyntaxwithoutspecifyingtheCHECK_EXPIRATIONoption.
References:
1. http://msdn.microsoft.com/en-us/library/ms161959(v=sql.105).aspx2. http://msdn.microsoft.com/en-us/library/ms161959(v=sql.100).aspx
CISControls:
16.2AllAccountsHaveaMonitoredExpirationDateEnsurethatallaccountshaveanexpirationdatethatismonitoredandenforced.
68|P a g e
4.3Ensure'CHECK_POLICY'Optionissetto'ON'forAllSQLAuthenticatedLogins(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
AppliesthesamepasswordcomplexitypolicyusedinWindowstopasswordsusedinsideSQLServer.
Rationale:
EnsuringSQLloginscomplywiththesecurepasswordpolicyappliedbytheWindowsServerBenchmarkwillensureSQLloginsarenotblankandcannotbeeasilycompromisedviabruteforceattack.
Audit:
UsethefollowingcodesnippettodeterminethestatusofSQLLoginsandiftheirpasswordcomplexityisenforced.
SELECT name, is_disabled FROM sys.sql_logins WHERE is_policy_checked = 0;
Theis_policy_checkedvalueof0indicatesthattheCHECK_POLICYoptionisOFF;valueof1isON.Ifis_disabledvalueis1,thentheloginisdisabledandunusable.IfnorowsarereturnedtheneithernoSQLAuthenticatedloginsexistortheyallhaveCHECK_POLICYON.
Remediation:
ForeachfoundbytheAuditProcedure,executethefollowingT-SQLstatement:
ALTER LOGIN [] WITH CHECK_POLICY = ON;
Impact:
ThisisamitigatingrecommendationforsystemswhichcannotfollowtherecommendationtouseonlyWindowsAuthenticatedlogins.
Weakpasswordscanleadtocompromisedsystems.SQLServerauthenticatedloginswillutilizethepasswordpolicysetinthecomputer'slocalpolicy,whichistypicallysetbytheDefaultDomainPolicysetting.
69|P a g e
Thesettingisonlyenforcedwhenthepasswordischanged.Thissettingdoesnotforceexistingweakpasswordstobechanged.
DefaultValue:
CHECK_POLICYisON
References:
1. http://msdn.microsoft.com/en-us/library/ms161959(v=sql.105).aspx2. http://msdn.microsoft.com/en-us/library/ms161959(v=sql.100).aspx
CISControls:
16AccountMonitoringandControl
70|P a g e
5AuditingandLogging
ThissectioncontainsrecommendationsrelatedtoSQLServer'sauditandloggingmechanisms.
5.1Ensure'Maximumnumberoferrorlogfiles'issettogreaterthanorequalto'12'(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
SQLServererrorlogfilesmustbeprotectedfromloss.Thelogfilesmustbebackedupbeforetheyareoverwritten.Retainingmoreerrorlogshelpspreventlossfromfrequentrecyclingbeforebackupscanoccur.
Rationale:
TheSQLServererrorlogcontainsimportantinformationaboutmajorservereventsandloginattemptinformationaswell.
Audit:
PerformeithertheGUIorT-SQLmethodshown:
GUIMethod
1. OpenSQLServerManagementStudio.2. OpenObjectExplorerandconnecttothetargetinstance.3. NavigatetotheManagementtabinObjectExplorerandexpand.Rightclickonthe
SQLServerLogsfileandselectConfigure.4. VerifytheLimitthenumberoferrorlogfilesbeforetheyarerecycledcheckbox
ischecked5. VerifytheMaximumnumberoferrorlogfilesisgreaterthanorequalto12
71|P a g e
T-SQLMethodRunthefollowingT-SQL.TheNumberOfLogFilesreturnedshouldbegreaterthanorequalto12.
DECLARE @NumErrorLogs int; EXEC master.sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'NumErrorLogs', @NumErrorLogs OUTPUT; SELECT ISNULL(@NumErrorLogs, -1) AS [NumberOfLogFiles];
Remediation:
Adjustthenumberoflogstopreventdataloss.Thedefaultvalueof6maybeinsufficientforaproductionenvironment.PerformeithertheGUIorT-SQLmethodshown:
GUIMethod
1. OpenSQLServerManagementStudio.2. OpenObjectExplorerandconnecttothetargetinstance.3. NavigatetotheManagementtabinObjectExplorerandexpand.Rightclickonthe
SQLServerLogsfileandselectConfigure4. ChecktheLimitthenumberoferrorlogfilesbeforetheyarerecycled5. SettheMaximumnumberoferrorlogfilestogreaterthanorequalto12
T-SQLMethodRunthefollowingT-SQLtochangethenumberoferrorlogfiles,replacewithyourdesirednumberoferrorlogfiles:
EXEC master.sys.xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'NumErrorLogs', REG_DWORD, ;
Impact:
Oncethemaxnumberoferrorlogsisreached,theoldesterrorlogfileisdeletedeachtimeSQLServerrestartsorsp_cycle_errorlogisexecuted.
DefaultValue:
6SQLServererrorlogfilesinadditiontothecurrenterrorlogfileareretainedbydefault.
72|P a g e
References:
1. http://msdn.microsoft.com/en-us/library/ms177285(v=sql.105).aspx2. http://msdn.microsoft.com/en-us/library/ms177285(v=sql.100).aspx
CISControls:
6.3EnsureAuditLoggingSystemsAreNotSubjecttoLoss(i.e.rotation/archive)Ensurethatallsystemsthatstorelogshaveadequatestoragespaceforthelogsgeneratedonaregularbasis,sothatlogfileswillnotfillupbetweenlogrotationintervals.Thelogsmustbearchivedanddigitallysignedonaperiodicbasis.
73|P a g e
5.2Ensure'DefaultTraceEnabled'ServerConfigurationOptionissetto'1'(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
Thedefaulttraceprovidesauditloggingofdatabaseactivityincludingaccountcreations,privilegeelevationandexecutionofDBCCcommands.
Rationale:
Defaulttraceprovidesvaluableauditinformationregardingsecurity-relatedactivitiesontheserver.
Audit:
RunthefollowingT-SQLcommand:
SELECT name, CAST(value as int) as value_configured, CAST(value_in_use as int) as value_in_use FROM sys.configurations WHERE name = 'default trace enabled';
Bothvaluecolumnsmustshow1.
Remediation:
RunthefollowingT-SQLcommand:
EXECUTE sp_configure 'show advanced options', 1; RECONFIGURE; EXECUTE sp_configure 'default trace enabled', 1; RECONFIGURE; GO EXECUTE sp_configure 'show advanced options', 0; RECONFIGURE;
DefaultValue:
1(on)
74|P a g e
References:
1. https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/default-trace-enabled-server-configuration-option
CISControls:
6.2EnsureAuditLogSettingsSupportAppropriateLogEntryFormattingValidateauditlogsettingsforeachhardwaredeviceandthesoftwareinstalledonit,ensuringthatlogsincludeadate,timestamp,sourceaddresses,destinationaddresses,andvariousotherusefulelementsofeachpacketand/ortransaction.SystemsshouldrecordlogsinastandardizedformatsuchassyslogentriesorthoseoutlinedbytheCommonEventExpressioninitiative.Ifsystemscannotgeneratelogsinastandardizedformat,lognormalizationtoolscanbedeployedtoconvertlogsintosuchaformat.
75|P a g e
5.3Ensure'LoginAuditing'issettoBoth'failed'and'successfullogins'(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
SettinglogsbothsuccessfulandfailedloginSQLServerauthenticationattempts.
Rationale:
Loggingsuccessfulandfailedloginsprovideskeyinformationthatcanbeusedtodetect/confirmpasswordguessingattacks.Further,loggingsuccessfulloginattemptscanbeusedtoconfirmserveraccessduringforensicinvestigations.
Audit:
execute xp_loginconfig 'audit level';
Aconfig_valueofallindicatesaserverloginauditingsettingofBothfailedandsuccessfullogins.
Remediation:
Performthefollowingstepstosetthelevelofauditing:
1. OpenSQLServerManagementStudio.2. RightclickthetargetinstanceandselectPropertiesandnavigatetotheSecurity
tab.3. SelecttheoptionBothfailedandsuccessfulloginsundertheLoginAuditing
sectionandclickOK.4. RestarttheSQLServerinstance.
DefaultValue:
Bydefault,onlyfailedloginattemptsarecaptured.
References:
1. http://technet.microsoft.com/en-us/library/ms188470(v=sql.105).aspx2. http://technet.microsoft.com/en-us/library/ms188470(v=sql.100).aspx
76|P a g e
CISControls:
16.10ProfileUserAccountUsageandMonitorforAnomaliesProfileeachuser’stypicalaccountusagebydeterminingnormaltime-of-dayaccessandaccessduration.Reportsshouldbegeneratedthatindicateuserswhohaveloggedinduringunusualhoursorhaveexceededtheirnormalloginduration.Thisincludesflaggingtheuseoftheuser’scredentialsfromacomputerotherthancomputersonwhichtheusergenerallyworks.
77|P a g e
6ApplicationDevelopment
ThissectioncontainsrecommendationsrelatedtodevelopingapplicationsthatinterfacewithSQLServer.
6.1EnsureSanitizeDatabaseandApplicationUserInputisSanitized(NotScored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
Alwaysvalidateuserinputreceivedfromadatabaseclientorapplicationbytestingtype,length,format,andrangepriortotransmittingittothedatabaseserver.
Rationale:
SanitizinguserinputdrasticallyminimizesriskofSQLinjection.
Audit:
CheckwiththeapplicationteamstoensureanydatabaseinteractionisthroughtheuseofstoredproceduresandnotdynamicSQL.RevokeanyINSERT,UPDATE,orDELETEprivilegestouserssothatmodificationstodatamustbedonethroughstoredprocedures.Verifythatthere'snoSQLqueryintheapplicationcodeproducedbystringconcatenation.
Remediation:
ThefollowingstepscanbetakentoremediateSQLinjectionvulnerabilities:
• ReviewTSQLandapplicationcodeforSQLInjection• Onlypermitminimallyprivilegedaccountstosenduserinputtotheserver• MinimizetheriskofSQLinjectionattackbyusingparameterizedcommandsand
storedprocedures• Rejectuserinputcontainingbinarydata,escapesequences,andcomment
characters• AlwaysvalidateuserinputanddonotuseitdirectlytobuildSQLstatements
Impact:
Sanitizeuserinputmayrequirechangestoapplicationcodeordatabaseobjectsyntax.Thesechangescanrequireapplicationsordatabasestobetakentemporarilyoff-line.Any
78|P a g e
changetoTSQLorapplicationcodeshouldbethoroughlytestedintestingenvironmentbeforeproductionimplementation.
References:
1. https://www.owasp.org/index.php/SQL_Injection2. http://msdn.microsoft.com/en-us/library/ms161953(v=sql.100).aspx3. http://msdn.microsoft.com/en-us/library/ms161953(v=sql.105).aspx
CISControls:
18.3SanitizeInputforIn-houseSoftwareForin-housedevelopedsoftware,ensurethatexpliciterrorcheckingisperformedanddocumentedforallinput,includingforsize,datatype,andacceptablerangesorformats.
79|P a g e
6.2Ensure'CLRAssemblyPermissionSet'issetto'SAFE_ACCESS'forAllCLRAssemblies(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
SettingCLRAssemblyPermissionSetstoSAFE_ACCESSwillpreventassembliesfromaccessingexternalsystemresourcessuchasfiles,thenetwork,environmentvariables,ortheregistry.
Rationale:
AssemblieswithEXTERNAL_ACCESSorUNSAFEpermissionsetscanbeusedtoaccesssensitiveareasoftheoperatingsystem,stealand/ortransmitdataandalterthestateandotherprotectionmeasuresoftheunderlyingWindowsOperatingSystem.
AssemblieswhichareMicrosoft-created(is_user_defined = 0)areexcludedfromthischeckastheyarerequiredforoverallsystemfunctionality.
Audit:
ExecutethefollowingSQLstatement:
SELECT name, permission_set_desc FROM sys.assemblies WHERE is_user_defined = 1;
AllthereturnedassembliesshouldshowSAFE_ACCESSinthepermission_set_desccolumn.
Remediation:
ALTER ASSEMBLY WITH PERMISSION_SET = SAFE;
Impact:
TheremediationmeasureshouldfirstbetestedwithinatestenvironmentpriortoproductiontoensuretheassemblystillfunctionsasdesignedwithSAFEpermissionsetting.
DefaultValue:
SAFEpermissionset
80|P a g e
References:
1. http://msdn.microsoft.com/en-us/library/ms345101(v=sql.105).aspx2. http://msdn.microsoft.com/en-us/library/ms189790(v=sql.100).aspx3. http://msdn.microsoft.com/en-us/library/ms189790(v=sql.105).aspx4. http://msdn.microsoft.com/en-us/library/ms345101(v=sql.100).aspx5. http://msdn.microsoft.com/en-us/library/ms186711(v=sql.100).aspx6. http://msdn.microsoft.com/en-us/library/ms186711(v=sql.105).aspx
CISControls:
18ApplicationSoftwareSecurity
81|P a g e
7Encryption
Theserecommendationspertaintoencryption-relatedaspectsofSQLServer.
7.1Ensure'SymmetricKeyencryptionalgorithm'issetto'AES_128'orhigherinnon-systemdatabases(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
PertheMicrosoftBestPractices,onlytheSQLServerAESalgorithmoptions,AES_128,AES_192,andAES_256,shouldbeusedforasymmetrickeyencryptionalgorithm.
Rationale:
Thefollowingalgorithms(asreferredtobySQLServer)areconsideredweakordeprecatedandshouldnolongerbeusedinSQLServer:DES,DESX,RC2,RC4,RC4_128.
ManyorganizationsmayaccepttheTripleDESalgorithms(TDEA)whichusekeyingoptions1(3keyaka3TDEA)orkeyingoption2(2keyaka2TDEA).InSQLServer,thesearereferredtoasTRIPLE_DES_3KEYandTRIPLE_DESrespectively.Additionally,theSQLServeralgorithmnamedDESXisactuallythesameimplementationastheTRIPLE_DES_3KEYoption.However,usingtheDESXidentifierasthealgorithmtypehasbeendeprecatedanditsusageisnowdiscouraged.
Audit:
Runthefollowingcodeforeachindividualuserdatabase:
USE [] GO SELECT db_name() AS Database_Name, name AS Key_Name FROM sys.symmetric_keys WHERE algorithm_desc NOT IN ('AES_128','AES_192','AES_256') AND db_id() > 4; GO
Forcompliance,norowsshouldbereturned.
82|P a g e
Remediation:
RefertoMicrosoftSQLServerBooksOnlineALTERSYMMETRICKEYentry:http://msdn.microsoft.com/en-US/library/ms189440.aspx
Impact:
Eliminatesuseofweakanddeprecatedalgorithmswhichmayputasystemathigherriskofanattackerbreakingthekey.
Encrypteddatacannotbecompressed,butcompresseddatacanbeencrypted.Ifyouusecompression,youshouldcompressdatabeforeencryptingit.
DefaultValue:
None
References:
1. https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-symmetric-key-transact-sql
2. http://support.microsoft.com/kb/2162020
CISControls:
14.2EncryptAllSensitiveInformationOverLess-trustedNetworksAllcommunicationofsensitiveinformationoverless-trustednetworksshouldbeencrypted.Wheneverinformationflowsoveranetworkwithalowertrustlevel,theinformationshouldbeencrypted.
83|P a g e
7.2EnsureAsymmetricKeySizeissetto'greaterthanorequalto2048'innon-systemdatabases(Scored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
MicrosoftBestPracticesrecommendtouseatleasta2048-bitencryptionalgorithmforasymmetrickeys.
Rationale:
TheRSA_2048encryptionalgorithmforasymmetrickeysinSQLServeristhehighestbit-levelprovidedandthereforethemostsecureavailablechoice(otherchoicesareRSA_512andRSA_1024).
Audit:
Runthefollowingcodeforeachindividualuserdatabase:
USE ; GO SELECT db_name() AS Database_Name, name AS Key_Name FROM sys.asymmetric_keys WHERE key_length < 2048 AND db_id() > 4; GO
Forcompliance,norowsshouldbereturned.
Remediation:
RefertoMicrosoftSQLServerBooksOnlineALTERASYMMETRICKEYentry:http://msdn.microsoft.com/en-us/library/ms187311.aspx
Impact:
Thehigher-bitlevelmayresultinslowerperformance,butreducesthelikelihoodofanattackerbreakingthekey.
Encrypteddatacannotbecompressed,butcompresseddatacanbeencrypted.Ifyouusecompression,youshouldcompressdatabeforeencryptingit.
84|P a g e
DefaultValue:
None
References:
1. https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-asymmetric-key-transact-sql
2. http://support.microsoft.com/kb/2162020
CISControls:
14.2EncryptAllSensitiveInformationOverLess-trustedNetworksAllcommunicationofsensitiveinformationoverless-trustednetworksshouldbeencrypted.Wheneverinformationflowsoveranetworkwithalowertrustlevel,theinformationshouldbeencrypted.
85|P a g e
8Appendix:AdditionalConsiderations
Thisappendixdiscussespossibleconfigurationoptionsforwhichnorecommendationisbeinggiven.
8.1Ensure'SQLServerBrowserService'isconfiguredcorrectly(NotScored)
ProfileApplicability:
• Level1-DatabaseEngine
Description:
NorecommendationisbeinggivenondisablingtheSQLServerBrowserservice.
Rationale:
Inthecaseofadefaultinstanceinstallation,theSQLServerBrowserserviceisdisabledbydefault.Unlessthereisanamedinstanceonthesameserver,thereisnotypicallyreasonfortheSQLServerBrowserservicetoberunning.InthiscaseitisstronglysuggestedthattheSQLServerBrowserserviceremaindisabled.
Whenitcomestonamedinstances,giventhatasecurityscancanfingerprintaSQLServerlisteningonanyport,it'sthereforeoflimitedbenefittodisabletheSQLServerBrowserservice.
However,ifallconnectionsagainstthenamedinstanceareviaapplicationsandarenotvisibletoendusers,thenconfiguringthenamedinstancetolisteningonastaticport,disablingtheSQLServerBrowserservice,andconfiguringtheappstoconnecttothespecifiedportshouldbethedirectiontaken.Thisfollowsthegeneralpracticeofreducingthesurfacearea,especiallyforanunneededfeature.
Ontheotherhand,ifendusersaredirectlyconnectingtodatabasesontheinstance,thentypicallyhavingthemuseServerName\InstanceNameisbest.ThisrequirestheSQLServerBrowserservicetoberunning.DisablingtheSQLServerBrowserservicewouldmeantheenduserswouldhavetorememberportnumbersfortheinstances.Whentheydon'tthatwillgenerateservicecallstoITstaff.Giventhelimitedbenefitofdisablingtheservice,thetrade-offisprobablynotworthit,meaningitmakesmorebusinesssensetoleavetheSQLServerBrowserserviceenabled.
86|P a g e
Audit:
ChecktheSQLBrowserservice'sstatusviaservices.mscorsimilarmethods.
Remediation:
Enableordisabletheserviceasneededforyourenvironment.
DefaultValue:
TheSQLServerBrowserserviceisdisabledifonlyadefaultinstanceisinstalledontheserver.Ifanamedinstanceisinstalled,thedefaultvalueisfortheSQLServerBrowserservicetobeconfiguredasAutomaticforstartup.
CISControls:
9.1LimitOpenPorts,Protocols,andServicesEnsurethatonlyports,protocols,andserviceswithvalidatedbusinessneedsarerunningoneachsystem.
87|P a g e
Appendix:SummaryTableControl Set
CorrectlyYes No
1 UpdatesandPatches1.1 EnsureLatestSQLServerServicePacksandHotfixesare
Installed(NotScored) o o
1.2 EnsureSingle-FunctionMemberServersareUsed(NotScored) o o
2 SurfaceAreaReduction2.1 Ensure'AdHocDistributedQueries'ServerConfiguration
Optionissetto'0'(Scored) o o
2.2 Ensure'CLREnabled'ServerConfigurationOptionissetto'0'(Scored) o o
2.3 Ensure'CrossDBOwnershipChaining'ServerConfigurationOptionissetto'0'(Scored) o o
2.4 Ensure'DatabaseMailXPs'ServerConfigurationOptionissetto'0'(Scored) o o
2.5 Ensure'OleAutomationProcedures'ServerConfigurationOptionissetto'0'(Scored) o o
2.6 Ensure'RemoteAccess'ServerConfigurationOptionissetto'0'(Scored) o o
2.7 Ensure'RemoteAdminConnections'ServerConfigurationOptionissetto'0'(Scored) o o
2.8 Ensure'ScanForStartupProcs'ServerConfigurationOptionissetto'0'(Scored) o o
2.9 Ensure'SQLMailXPs'ServerConfigurationOptionissetto'0'(Scored) o o
2.10 Ensure'Trustworthy'DatabasePropertyissetto'Off'(Scored) o o
2.11 EnsureUnnecessarySQLServerProtocolsaresetto'Disabled'(Scored) o o
2.12 EnsureSQLServerisconfiguredtousenon-standardports(NotScored) o o
2.13 Ensure'HideInstance'optionissetto'Yes'forProductionSQLServerinstances(Scored) o o
2.14 Ensure'sa'LoginAccountissetto'Disabled'(Scored) o o2.15 Ensure'sa'LoginAccounthasbeenrenamed(Scored) o o2.16 Ensure'xp_cmdshell'ServerConfigurationOptionissetto
'0'(Scored) o o
88|P a g e
3 AuthenticationandAuthorization3.1 Ensure'ServerAuthentication'Propertyissetto'Windows
AuthenticationMode'(Scored) o o
3.2 EnsureCONNECTpermissionsonthe'guestuser'isRevokedwithinallSQLServerdatabasesexcludingthemaster,msdbandtempdb(Scored)
o o
3.3 Ensure'OrphanedUsers'areDroppedFromSQLServerDatabases(Scored) o o
3.4 EnsuretheSQLServer’sMSSQLServiceAccountisNotanAdministrator(Scored) o o
3.5 EnsuretheSQLServer’sSQLAgentServiceAccountisNotanAdministrator(Scored) o o
3.6 EnsuretheSQLServer’sFull-TextServiceAccountisNotanAdministrator(Scored) o o
3.7 EnsureonlythedefaultpermissionsspecifiedbyMicrosoftaregrantedtothepublicserverrole(Scored) o o
3.8 EnsureWindowsBUILTINgroupsarenotSQLLogins(Scored) o o
3.9 EnsureWindowslocalgroupsarenotSQLLo