<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>SQL Server Cybersecurity</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/securesql/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/securesql/feed.xml</link>
    <description>Microsoft&amp;#039;s Guidance for SQL Server Security and Compliance in the US Public Sector</description>
    <lastBuildDate>Tue, 16 Apr 2019 05:27:47 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>The SQL Server Defensive Dozen - Part 3: Authentication and Authorization in SQL Server</title>
      <link>https://docs.microsoft.com/archive/blogs/securesql/the-sql-server-defensive-dozen-part-3-authentication-and-authorization-in-sql-server</link>
      <pubDate>Tue, 21 Aug 2018 15:49:02 GMT</pubDate>
      <dc:creator><![CDATA[randomnote_1]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/securesql/?p=205</guid>
      <description><![CDATA[Introduction
In order to secure and harden SQL Server it is important to control who and/or what...]]></description>
      <content:encoded><![CDATA[<h1>Introduction</h1>
In order to secure and harden SQL Server it is important to control who and/or what can authenticate to the system and what they have access to. This will satisfy regulatory needs such as the <a href="https://iase.disa.mil/stigs/Pages/index.aspx">Secure Technical Implementation Guide</a> (STIG).

As a reminder from our <a href="https://blogs.msdn.microsoft.com/securesql/2018/03/09/steps-for-hardening-sql-server-2016-the-defensive-dozen/">Introduction</a> to this series, hardening is the process of applying Administrative and Technical controls to a system. Every article in this series will review both Administrative Controls and Technical Controls needed to properly managed and harden a system. This article will discuss authentication configuration and documentation for hardening SQL Server.
<h1>Administrative Controls</h1>
Documentation is essential to the success of a secured SQL Server. Ideally, documentation should be created before SQL Server is even installed. This allows the DBA to build SQL Server tailored to the requirements of the project and should allow SQL Server to operate in a more secure state from start to finish. However, it is not always realistic to build the documentation prior to installing SQL Server. In such cases it is recommended to ensure the project is configured to a working state, then back down the permissions and turn off any feature which are not required. Once it is determined what the minimal level of permissions and features are required for operation, these can then be documented.

Authorizing access to <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/principals-database-engine">principals</a> within SQL Server is vital to the success of maintaining a secure environment. Without thorough documentation, the DBA will have the difficult (if not impossible) task of keeping SQL Server secure. Thorough documentation ensures the DBA has written guidance on how the data is to be kept secure and provides accountability to the organization to ensure a least privilege model is maintained.

Many hardening guides require the use of <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/choose-an-authentication-mode#connecting-through-windows-authentication">Windows Authentication</a> (Microsoft's recommendation) coupled with <a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/password-must-meet-complexity-requirements">password complexity requirements</a> (typically inherited from Group Policy) for compliance. In the event that <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/choose-an-authentication-mode#connecting-through-sql-server-authentication">Mixed Mode Authentication</a> is utilized, the information owners must choose whether to <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/password-policy">inherit the password complexity requirements</a> from the Operating System (OS), or if they will implement password complexity requirements utilizing policies and procedures defined by the organization. All of these decisions must be documented.

Additionally, documenting the authorized principals and permissions within SQL Server and regularly comparing them to a properly vetted baseline is essential to ensure unauthorized access is not granted. This can be accomplished using a tool like the <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/sql-vulnerability-assessment">SQL Server Vulnerability Assessment</a>.
<h1>Technical Controls</h1>
The technical controls discussed in this section implement and enforce the administrative controls which were defined in the Administrative Controls section. These controls are settings which can be configured within SQL Server to ensure the written policy is enforced.
<h2>Authentication Mode</h2>
<a href="https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/change-server-authentication-mode">Configuring the authentication mode</a> in accordance with system documentation is vital to the integrity and trustworthiness of the system. The following sections discuss various technical procedures which should be followed when implementing the Windows or Mixed authentication modes.
<h3>All Authentication Modes</h3>
<ul>
 	<li><a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-login-transact-sql#c-changing-the-name-of-a-login">Rename </a>and <a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-login-transact-sql#a-enabling-a-disabled-login">disable </a>the SA login to prevent attacks on the well-known login by account name.  Automated attacks will try to brute force the SA login as soon as a SQL instance is discovered. By renaming the SA login, most automated attacks will fail to brute force the database admin password.</li>
 	<li>Change SA password to a strong password. This is valuable even in Windows Authentication Mode in case Mixed Authentication Mode is enabled inadvertently or intentionally. Store the password in a secure location for a "break glass in case of emergency" situation.</li>
 	<li>Do not delete <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/principals-database-engine">built-in principals</a>. This will result in the loss of functionality and potentially an inaccessible system.</li>
 	<li>Use <a href="https://docs.microsoft.com/en-us/sql/relational-databases/triggers/logon-triggers">logon triggers</a> for more granular control of the login process.</li>
 	<li>Using either local or <a href="https://technet.microsoft.com/en-us/library/dd277399.aspx">Active Directory</a> policies, implement a <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/password-policy">password policy</a> including expiration and complexity requirements at a minimum.</li>
 	<li>Ensure passwords are encrypted when stored in client applications.</li>
</ul>
<h3>Windows Authentication</h3>
<ul>
 	<li><a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/choose-an-authentication-mode#connecting-through-windows-authentication">Windows authentication</a> is the preferred and recommended form of authentication.</li>
 	<li>Use Windows groups to authorize users rather than Windows logins where possible to reduce the administrative overhead of managing access to the instance. It is important to note that each Windows user will be individually identified in the audit log, even if they are a member of a Window group. For example, if the domain user Contoso\Dan is a member of the domain group Contoso\DBA, the user Contoso\Dan will be identified in the SQL Server audit logs.</li>
</ul>
<h3>Mixed Mode Authentication</h3>
<ul>
 	<li>Use for users from untrusted domains/workgroups, cross-platform users, non-Windows applications, or legacy applications.</li>
 	<li>Do not use the SA login to manage SQL Server. Rather assign a known principal to the appropriate roles (e.g. sysadmin).</li>
 	<li>Outfit applications with a mechanism to change SQL login passwords.</li>
 	<li>Set <a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/create-login-transact-sql?tabs=sqlserver#arguments">MUST_CHANGE</a> for new logins to ensure the end user changes the password to something only they know.</li>
</ul>
<h2>Baseline Logins and Users Principals and Permissions</h2>
<a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/principals-database-engine">Principals</a> represent users, groups, services, and other entities which can access SQL Server resources. Principals gain permissions through direct assignment or role membership.

Verifying and limiting the use of permissions and roles inside of SQL Server is a requirement of many hardening guides. Administrators are encouraged to baseline the documented role memberships and server-level permissions. Administrators are also advised to regularly review (audit) the baseline against production to verify nothing has changed. The <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/sql-vulnerability-assessment">SQL Server Vulnerability Assessment </a>tool can be used to help with these actions.

In most cases, the hardening guides mandate the permission or role membership must follow the <a href="https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/authorization-and-permissions-in-sql-server#the-principle-of-least-privilege">Principle of Least Privilege</a>. Best practices for implementing the principle of least privilege are:
<ul type="disc">
 	<li><a href="https://docs.microsoft.com/en-us/sql/relational-databases/policy-based-management/guest-permissions-on-user-databases">Revoke permissions from the guest user</a> on resources except MSDB.</li>
 	<li>Ensure the <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/server-level-roles#fixed-server-level-roles">permissions assigned to the public role</a> should be available to every login on the instance.</li>
 	<li>Assign permissions to principals via roles. Do not assign permissions directly to principals.</li>
</ul>
The following are queries to extract SQL Server permission and role information. These queries are useful for creating and validating baselines, creating and validating documentation, and investigating permissions granted to principals.
<h3>Login List</h3>
Obtain all logins of the following types:
<ul>
 	<li>Certificate Login</li>
 	<li>SQL Login</li>
 	<li>Windows Group</li>
 	<li>Windows Login</li>
</ul>

[sql]SELECT  login.name,
        login.type_desc,
        CASE login.is_disabled
            WHEN 1 THEN 'disabled' 
            ELSE 'enabled'
        END AS 'Status'
FROM    sys.server_principals login
WHERE   login.type IN ('C','G','S','U')
ORDER   BY login.name[/sql]

<h3>Direct Permissions Assignment to Logins</h3>
Obtain all the permissions for the logins of the following types:
<ul>
 	<li>Certificate Login</li>
 	<li>SQL Login</li>
 	<li>Windows Group</li>
 	<li>Windows Login</li>
</ul>

[sql]SELECT  login.name,
        login.type_desc,
        perm.state_desc,
        perm.permission_name,
        perm.class_desc
FROM    sys.server_principals login 
JOIN    sys.server_permissions perm ON login.principal_id = perm.grantee_principal_id 
WHERE   login.type IN ('C','G','S','U')
ORDER   BY login.name[/sql]

<h3>Server Role Permissions Assignment</h3>
Obtain all the permissions for the server roles.

[sql]SELECT  role.name,
        CASE role.is_fixed_role
            WHEN 0 THEN 'False'
            ELSE 'True'
        END AS 'Built In Role',
        perm.state_desc,
        perm.permission_name,
        perm.class_desc
FROM    sys.server_principals role
JOIN    sys.server_permissions perm ON role.principal_id = perm.grantee_principal_id
WHERE   role.type = 'R'
ORDER   BY role.name[/sql]

<h3>Server Role Membership</h3>
Obtain the server principals which are members of the server roles.

[sql]SELECT  role.name AS 'Role',
        login.name AS 'Login'
FROM    sys.server_principals role 
JOIN    sys.server_role_members rm ON role.principal_id = rm.role_principal_id 
JOIN    sys.server_principals login ON rm.member_principal_id = login.principal_id
ORDER   BY role.name[/sql]

<h2>Shared Accounts</h2>
No accounts should access the system that cannot be individually identified and audited. Non-repudiation of actions taken is required to maintain system confidentiality, integrity, and availability. Non-repudiation protects against later claims by a user of not having created, modified, or deleted objects or data in the database or instance.
<h3>NT AUTHORITY\SYSTEM</h3>
Ensure the <a href="https://docs.microsoft.com/en-us/windows/desktop/Services/localsystem-account">NT AUTHORITY\SYSTEM</a> (SYSTEM) account is not privileged or otherwise documented as having elevated access. Rather than granting SYSTEM additional permissions for services running as SYSTEM, consider using a <a href="https://support.microsoft.com/en-us/help/2620201/sql-server-uses-a-service-sid-to-provide-service-isolation">Service SID</a> to grant permissions directly to the service itself. This is the method SQL Server uses to grant permissions to the SQL Server and SQL Agent services. <a href="https://blogs.technet.microsoft.com/kevinholman/2016/08/25/sql-mp-run-as-accounts-no-longer-required-2/">This method</a> has been adopted by Microsoft System Center Operations Manager (SCOM) administrators to grant permission to the HealthService within SQL server.

Any user with enough access to the server can execute a task that will be run as SYSTEM either using task scheduler or other tools. At this point, SYSTEM essentially becomes a shared account because the operating system and SQL Server are unable to determine who created the process. This defeats non-repudiation as the actions taken by SYSTEM show in the audit logs as having been taken by SYSTEM, and not the user who invoked the command.

Prior to SQL Server 2012, NT AUTHORITY\SYSTEM was a member of the sysadmin role by default. In more recent versions of SQL Server, NT AUTHORITY\SYSTEM is explicitly not given sysadmin access.
<h2>Database Ownership</h2>
Databases should be owned by a login which should have full control of the database. The database owner login is mapped to the <a href="https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/server-and-database-roles-in-sql-server#the-dbo-user-account">dbo user</a> in the database. The dbo user has full control in the database and cannot be limited. It is recommended to use a low-privilege login as the owner of the databases. A low-privilege login should have no administrative access to the instance. This is especially important in cases where <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/trustworthy-database-property">TRUSTWORTHY</a> is enabled on the database, because the use of TRUSTWORTHY combined with a high-privilege login can be used to <a href="https://www.sqlservercentral.com/articles/Security/121178/">escalate the privileges</a> of a low-privilege user within the database.

Use the <a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-authorization-transact-sql?#AlterDB">ALTER AUTHORIZATION</a> statement to change the owner of the database.
<h2>Contained Databases</h2>
SQL Server 2012 introduced the concept of <a href="https://docs.microsoft.com/en-us/sql/relational-databases/databases/contained-databases">contained databases</a>. A contained database is a database which includes all the settings and metadata needed for its operation without dependencies on the instance. From a security perspective, a contained database makes it easier to have user accounts that are limited to a single database. Contained databases should only be enabled if they are required. As with the instance, Windows users or groups should be used when <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/contained-database-users-making-your-database-portable#contained-database-user-model">creating users</a> within the contained database.
<h2>Discretionary Access Control (GRANT WITH GRANT)</h2>
Discretionary access control is based on the notion that principals are "owners" of objects and therefore have discretion over who should be authorized to access the object and in which mode (e.g., read or write). Ownership is implicitly or explicitly defined during object creation. Discretionary access control allows the owner to determine who will have access to objects they control.

The follow queries can be used to determine who has been granted GRANT with GRANT:
<h3>Server Level</h3>

[sql]SELECT  who.name AS [Principal Name],
        who.type_desc AS [Principal Type],
        who.is_disabled AS [Principal Is Disabled],
        what.state_desc AS [Permission State],
        what.permission_name AS [Permission Name]
FROM    sys.server_permissions what
INNER   JOIN sys.server_principals who ON who.principal_id = what.grantee_principal_id
WHERE   what.state_desc= 'GRANT_WITH_GRANT_OPTION'[/sql]

<h3>Database Level</h3>

[sql]USE [DatabaseName]
GO

SELECT  who.name AS [Principal Name],
        who.type_desc AS [Principal Type],
        what.state_desc AS [Permission State],
        what.permission_name AS [Permission Name]
FROM    sys.database_permissions what
INNER   JOIN sys.database_principals who ON who.principal_id = what.grantee_principal_id
WHERE   what.state_desc= 'GRANT_WITH_GRANT_OPTION'[/sql]

<h2>Proxies and External Access</h2>
Customers may have designated administration user and/or service accounts on the operating system. Typically, this is an administration account with which they automate complex maintenance routines (such as automatically adding a database to an Availability Group).

SQL Server provides highly-secure features (also capable of being permissioned) to perform tasks. Please see <a href="https://technet.microsoft.com/en-us/library/ms190703(v=sql.105).aspx">How to: Create a Credential (SQL Server Management Studio)</a> and <a href="https://technet.microsoft.com/en-us/library/ms189064(v=sql.105).aspx">Creating SQL Server Agent Proxies</a> for more information.

Remove any SQL Agent Proxy accounts and credentials that are not authorized.
<h1>Conclusion</h1>
This completes the facet and considerations related to securing SQL Server authentication and authorization. Please stay tuned for the next topic in the series discussing modules management and programmability for SQL Server.]]></content:encoded>
    </item>
    <item>
      <title>The SQL Server Defensive Dozen Part 2 - SQL Server Encryption, Key Management, And Data-At-Rest Encryption</title>
      <link>https://docs.microsoft.com/archive/blogs/securesql/the-sql-server-defensive-dozen-part-2-sql-server-encryption-key-management-and-data-at-rest-encryption</link>
      <pubDate>Fri, 06 Jul 2018 08:09:34 GMT</pubDate>
      <dc:creator><![CDATA[PaulFeaser]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/securesql/?p=235</guid>
      <description><![CDATA[Introduction
In order to properly secure and harden SQL Server, the use of encryption provides many...]]></description>
      <content:encoded><![CDATA[<h1>Introduction</h1>
In order to properly secure and harden SQL Server, the use of encryption provides many benefits including safeguarding data, separation of duties, and satisfying regulatory needs such as the <a href="https://iase.disa.mil/stigs/Pages/index.aspx">Secure Technical Implementation Guide</a> (STIG) or General Data Protection Regulation (GDPR). Within SQL Server there are several types of encryption: Channel encryption (encrypting login/data packets over the wire), Transparent Data Encryption (TDE) of data at rest, and Always Encrypted for data in use. SQL Server encrypts data with a <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/encryption-hierarchy?view=sql-server-2017">hierarchical encryption and key management infrastructure</a>. Each layer encrypts the layer below it by using a combination of certificates, asymmetric keys, and symmetric keys.

As a reminder from our <a href="https://blogs.msdn.microsoft.com/securesql/2018/03/09/steps-for-hardening-sql-server-2016-the-defensive-dozen/">Introduction</a> to this series, hardening can be thought of as the process of applying Administrative and Technical controls to a system. Every article in this series will review both Administrative Controls and Technical Controls needed to properly managed and harden a system. This article will discuss encryption and key management settings for hardening SQL Server.
<h1>Administrative Controls</h1>
Many of these checks require the encryption components be documented and referenced for check compliance. For example, one must check the server documentation to see if encryption-at-rest or transmission is required for the databases. The technical controls below should match the customer's documented posture. Customer should list all encryption requirements for the SQL Instance and any encryption components configured based on the respective vulnerability. The correct controls need to be configured for each check.
<h1>Technical Controls</h1>
<h2>Service Master Key</h2>
Encrypting data requires secure encryption keys and key management.  The <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/service-master-key">Service Master Key</a> (SMK) is the root of the <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/encryption-hierarchy?view=sql-server-2017">encryption hierarchy</a>. It is the entry point for any kind of encryption within SQL Server. The SMK is encrypted by SQL Server Setup using both the SQL Server Service accout and also the machine key. Both encryptions use the <a href="https://msdn.microsoft.com/en-us/library/ms995355.aspx">Windows Data Protection API (DPAPI)</a>. It is critical to <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/back-up-the-service-master-key?view=sql-server-2016">backup the SMK</a> and store in a secure, off-site location. Creating this backup should be one of the first administrative actions performed on the server. The following code can be used to back up the Service Master Key:
[sql]BACKUP SERVICE MASTER KEY TO FILE = 'filePath' ENCRYPTION BY PASSWORD = 'password'[/sql]
<h2>Database Master Key</h2>
The <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/sql-server-and-database-encryption-keys-database-engine">database master key</a> is a symmetric key used to protect the private keys of certificates and asymmetric keys that are present in the database. When it is created, the master key is encrypted by using the AES_256 algorithm and a user-supplied password. In SQL Server 2008 and <a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/create-master-key-transact-sql?view=sql-server-2016#remarks">SQL Server 2008 R2, the Triple DES</a> algorithm is used. To enable the automatic decryption of the master key, a copy of the key is encrypted by using the service master key and stored in both the database and in master. The copy stored in master is silently updated whenever the master key is changed. To <a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/create-master-key-transact-sql?view=sql-server-2016">create a Database Master Key</a> and then the necessary <a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/backup-master-key-transact-sql?view=sql-server-2016">backup</a> to be stored offsite, reference the following code:
[sql]CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'password'
BACKUP MASTER KEY TO FILE = 'filePath' ENCRYPTION BY PASSWORD = 'password'[/sql]
<h2>Asymmetric Key Management</h2>
An <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/sql-server-certificates-and-asymmetric-keys#asymmetric-keys">asymmetric key</a> is a securable entity at the database level. In its default form, this entity contains both a public key and a private key. When executed without the FROM clause, <a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/create-asymmetric-key-transact-sql?view=sql-server-2016">CREATE ASYMMETRIC KEY</a> generates a new key pair. When executed with the FROM clause, CREATE ASYMMETRIC KEY imports a key pair from a file or imports a public key from an assembly. By default, the private key is protected by the database master key. If no database master key has been created, a password is required to protect the private key. If a database master key does exist, the password is optional. The private key can be 512, 1024, or 2048 bits long. If asymmetric keys are being used, they should be documented, secured properly (as documented), and backed-up. An asymmetric key can be used to encrypt a symmetric key for storage in a database.
<h2>Transparent Database Encryption (TDE)</h2>
Various hardening guides require SQL Server data files containing sensitive information to be encrypted. As well, system documentation must state whether the database handles classified or sensitive information. Some options for encrypting data in SQL are:
<ul>
 	<li><a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/transparent-data-encryption?view=sql-server-2016">Transparent Database Encryption</a> can be used to encrypt data at rest</li>
 	<li><a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/encrypt-a-column-of-data?view=sql-server-2016">Cell-level encryption</a>can be used to encrypt specific columns or even cells of data with different encryption keys.</li>
 	<li>3rd party server-side encryption or encryption outside of SQL Server via Encrypting File System (<a href="https://technet.microsoft.com/en-us/library/cc700811.aspx?f=255&amp;MSPPError=-2147217396">EFS</a> folders), EFS is usually not recommended by Microsoft due to the way I/O’s are forced to be performed synchronously and how security works and ACL changes impacts the data availability.</li>
 	<li><a href="https://docs.microsoft.com/en-us/windows/security/information-protection/bitlocker/bitlocker-device-encryption-overview-windows-10">BitLocker</a> volumes.</li>
 	<li>SQL Server Always Encrypted (see <a href="#AlwaysEncrypted">Always Encrypted</a>).</li>
</ul>
SQL Server’s <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/transparent-data-encryption?view=sql-server-2016">Transparent Database Encryption</a> (TDE) protects data-at-rest by encrypting all the user data in a database’s data files (.mdf and .ndf’s), in the log file (.ldf), a database snapshot (.ss), and in the database backup files (.bak, .trn). <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/transparent-data-encryption#transparent-data-encryption-and-the-tempdb-system-database">Tempdb is also encrypted</a> when at least one database is enabled for encryption. TDE does not require applications to be changed to gain this protection. Transparent data encryption (TDE) performs real-time I/O encryption and decryption of the data and log files. It is also possible to use <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/extensible-key-management-ekm?view=sql-server-2016">Extensible Key Management</a> solutions to manage TDE keys.

To simplify the use and management of TDE it is possible to use or share the same key (or TDE “thumbprint”) across multiple servers, especially for High Availability and Disaster Recovery. The TDE certificate must be installed on all servers:
<ul>
 	<li>in which the database is a member of a database mirroring session</li>
 	<li>or which are replicas of an Always On Availability Group (AG)</li>
</ul>
Note, the key can be altered at any time with SQL Server Management Studio (SSMS) or T-SQL.
<h3>There are four steps to enable TDE on a user database:</h3>
<ol>
 	<li><strong>Create the DMK.</strong> If it does not already exist, create the Database Master Key (DMK) in the <strong>master</strong> database.</li>
</ol>
[sql]IF NOT EXISTS (SELECT 1 FROM sys.symmetric_keys WHERE name = '##MS_DatabaseMasterKey##')
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'Password';[/sql]
<ol start="2">
 	<li><strong> Create the TDE certificate in the master database.</strong> The name of the TDE certificate should be a descriptive name. The “WITH SUBJECT” parameter is optional.</li>
</ol>
[sql]CREATE CERTIFICATE DatabaseTDECertificate WITH SUBJECT = 'TDE Certificate for the Database';[/sql]
<ol start="3">
 	<li><strong> Create the DEK in the user database.</strong> It’s possible to encrypt the DEK with an asymmetric key instead of your TDE certificate, but doing so will make it difficult or impossible to restore the database backup to another instance of SQL Server. There are also other encryption algorithms that can be used, but AES_256 is the strongest option. While weaker algorithms may provide faster performance, using TDE sacrifices performance for maximum security, so the strongest possible DEK might as well be used.</li>
</ol>
[sql]CREATE DATABASE ENCRYPTION KEY WITH ALGORITHM = AES_256 ENCRYPTION BY SERVER CERTIFICATE DatabaseTDECertificate[/sql]
<ol start="4">
 	<li><strong> Set encryption on.</strong> Just creating all the keys and the certificate does not enable TDE; The ALTER DATABASE command must be used to complete the process.</li>
</ol>
[sql]ALTER DATABASE [DatabaseName] SET ENCRYPTION ON[/sql]
<h3>Backup the TDE Certificate</h3>
TDE uses certificate (thumbprints) and a database encryption key (DEK) to encrypt the database. It is important to back up the customer's unique TDE configuration, certificates, and passwords. The .cer, .pvk, and passwords should be backed up immediately after implementation of TDE (and at regular intervals for safety).   Since the certificate may be critical for a recovery of the database, these backups should be stored offline and off-site.  The following example backups up the certificate and private key
[sql]BACKUP CERTIFICATE DatabaseTDECertificate
TO FILE = 'C:\Folder\DatabaseTDECertificate.cer'
WITH PRIVATE KEY ( FILE = 'C:\Folder\DatabaseTDECertificate.pvk', ENCRYPTION BY PASSWORD = 'Password');[/sql]
When switching certificates for a database, it is important to retain older keys/certificates for some time as portions of the log may still be encrypted with the older certificate. Use the following to <a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-database-encryption-key-transact-sql?view=sql-server-2016">switch a certificate</a>:
[sql]USE [DatabaseName];
ALTER DATABASE ENCRYPTION KEY ENCRYPTION BY SERVER CERTIFICATE [NewCertificateName][/sql]
<h2 id="AlwaysEncrypted">Always Encrypted</h2>
<a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/always-encrypted-database-engine?view=sql-server-2016">Always Encrypted</a> (new in SQL Server 2016) is a feature designed to protect sensitive data, such as credit card numbers or national identification numbers (e.g. U.S. social security numbers), stored in Azure SQL Database or SQL Server databases. Always Encrypted allows clients to encrypt sensitive data inside client applications and never reveal the encryption keys to the Database Engine (either Cloud-based SQL Database or SQL Server on-premises). Additionally, Always Encrypted provides a separation between those who own the data (and can view it) and those who manage the data (but should not have access). It ensures that sensitive data is never exposed in plain-text inside the database, protecting it from DBAs and admins of the machine hosting the system. This allows organizations to encrypt data at rest and in use for storage in Azure, to enable delegation of on-premises database administration to third parties, or to reduce security clearance requirements for their own DBA staff. There are some <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/always-encrypted-database-engine?view=sql-server-2016#feature-details">nuances with Always Encrypted</a> which need to be considered including certain column types (e.g. text, image, and ntext) and transactional replication are not supported.

Always Encrypted makes encryption transparent to applications. An Always Encrypted-enabled driver installed on the client computer achieves this by automatically encrypting and decrypting sensitive data in the client application. The driver encrypts the data in sensitive columns before passing the data to the Database Engine, and automatically rewrites queries so that the semantics to the application are preserved. Similarly, the driver transparently decrypts data, stored in encrypted database columns, contained in query results. The customer can use Always Encrypted feature of SQL 2016 to meet the encryption at-rest and in-transit requirements of the SQL STIG.

The process for using <a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/always-encrypted-database-engine?view=sql-server-2016">Always Encrypted</a> is as follows:

1.  Create a <a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/create-column-master-key-transact-sql?view=sql-server-2016">column master key</a> for client applications that use the MSSQL_CERTIFICATE_STORE provider
[sql]CREATE COLUMN MASTER KEY ColMasterKey 
WITH ( 
    KEY_STORE_PROVIDER_NAME = 'MSSQL_CERTIFICATE_STORE', 
    KEY_PATH = 'Current User/Personal/f2260f28d909d21c642a3d8e0b45a830e79a1420' 
);[/sql]
2. Create a <a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/create-column-encryption-key-transact-sql?view=sql-server-2016">column encryption key</a>
[sql]CREATE COLUMN ENCRYPTION KEY ColEncryptionKey
WITH VALUES (
    COLUMN_MASTER_KEY = ColMasterKey,
    ALGORITHM = 'RSA_OAEP',
    ENCRYPTED_VALUE = [The encrypted CEK value BLOB]
);[/sql]
3. <a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql?view=sql-server-2016">Create/modify table</a> to reference column encryption key for any fields to be encrypted
[sql]CREATE TABLE Payroll ( 
    EmployeeName nvarchar(60) 
    COLLATE Latin1_General_BIN2 ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = ColEncryptionKey, 
    ENCRYPTION_TYPE = RANDOMIZED, 
    ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256'), 
    SSN varchar(11) 
    COLLATE Latin1_General_BIN2 ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = ColEncryptionKey, 
    ENCRYPTION_TYPE = DETERMINISTIC , 
    ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256'),
    Department int NULL 
);[/sql]
<h2>Channel Encryption</h2>
In order to ensure data-in-transit (login/data packets) is encrypted, SQL Server supports <a href="https://support.microsoft.com/en-us/help/3135244/tls-1-2-support-for-microsoft-sql-server">TLS (Transport Layer Security)</a> and <a href="https://support.microsoft.com/en-us/help/316898/how-to-enable-ssl-encryption-for-an-instance-of-sql-server-by-using-mi">SSL (Secure Sockets Layer)</a>.  When a SQL Server is configured with TLS or SSL and a client requests an encrypted connection, an initial handshake takes place to negotiate the cipher suite for future communications.  Once agreed, SQL sends its TLS/SSL certificate to the client, which the client must validate and then trust against its copy of the Certificate Authority certificate.  A secure connection is established if the certificate is trusted and meets all requirements.

The latest SQL STIG for SQL 2016 requires using TLS as Microsoft has changed the security guidance to move to <a href="https://support.microsoft.com/en-us/help/3135244/tls-1-2-support-for-microsoft-sql-server">TLS 1.2</a> for secure communications.The STIG requires a DOD Certificate to enhance the encryption. Use the following to setup channel encryption:
<ol>
 	<li>Install a certificate in the Windows certificate store of the server computer.</li>
 	<li>Click Start, in the Microsoft SQL Server program group, point to Configuration Tools, and then click SQL Server Configuration Manager.</li>
 	<li>Expand SQL Server Network Configuration, right-click the protocols for the server you want, and then click Properties.</li>
 	<li>On the Certificate tab, configure the Database Engine to use the certificate. If enabling for a Failover Cluster Instance (FCI), the Certificate's thumbprint must be added to the registry for each node in the FCI.</li>
 	<li>On the Flags tab, view or specify the protocol encryption option. The login packet will always be encrypted. When the ForceEncryption option for the Database Engine is set to Yes, all client/server communication is encrypted and clients that cannot support encryption are denied access. When the ForceEncryption option for the Database Engine is set to No, encryption can be requested by the client application but is not required. SQL Server must be restarted after you change the ForceEncryption setting.</li>
 	<li>To test if encryption is working you should get TRUE, when running the following script.</li>
</ol>
[sql]SELECT encrypt_option FROM sys.dm_exec_connections WHERE sessionId = @@SPID[/sql]
<h2>Encryption Best Practices</h2>
Best practices for data encryption:
<ul>
 	<li>Encrypt high-value and sensitive data.</li>
 	<li>Use symmetric keys to encrypt data, and asymmetric keys or certificates to protect the symmetric keys.</li>
 	<li>Password-protect keys and remove master key encryption for the most secure configuration.</li>
 	<li>Do not delete pre-provisioned system certificates in the master database</li>
 	<li>Always back up the service master key, database master keys, and certificates by using the key-specific DDL statements.</li>
 	<li>Always back up your database to back up your symmetric and asymmetric keys.</li>
 	<li>TDE is recommended for encrypting existing applications or for performance sensitive applications.</li>
 	<li>Cell-level encryption can be used for defense in depth both for a database encrypted by TDE and for limited access control using passwords.</li>
 	<li>Use Always Encrypted to encrypt sensitive data inside client applications and never reveal the encryption keys to the Database Engine or Database Administrators</li>
 	<li>Retain older keys for some time. Portion of log may still be encrypted with the older certificate.</li>
 	<li><a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/dynamic-data-masking?view=sql-server-2016">Dynamic data masking</a> limits (DDM) sensitive data exposure by masking it to non-privileged users. It can be used to greatly simplify the design and coding of security in your application.</li>
</ul>
<h1>Conclusion</h1>
This completes the facet and considerations related to securing SQL Server Encryption, Key Management, And Data-At-Rest Encryption. Please stay tuned for the next topic in the series discussing authentication and authorization for SQL Server.]]></content:encoded>
    </item>
    <item>
      <title>The SQL Server Defensive Dozen Part 1 - Hardening SQL Network Components</title>
      <link>https://docs.microsoft.com/archive/blogs/securesql/the-sql-server-defensive-dozen-part-1-hardening-sql-network-components</link>
      <pubDate>Fri, 09 Mar 2018 09:30:07 GMT</pubDate>
      <dc:creator><![CDATA[CipherSQL]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/securesql/?p=25</guid>
      <description><![CDATA[Introduction
In order to properly secure and harden SQL Server, one should review many items...]]></description>
      <content:encoded><![CDATA[<h1>Introduction</h1>
In order to properly secure and harden SQL Server, one should review many items related to the server communications, network library settings, and ports/protocols configurations. As a reminder from our <a href="https://blogs.msdn.microsoft.com/securesql/2018/03/09/steps-for-hardening-sql-server-2016-the-defensive-dozen/">Introduction</a> to this series, hardening can be thought of as the process of applying Administrative and Technical controls to a system. Every article in this series will review both Administrative Controls and Technical Controls needed to properly managed and harden a system. This article will discuss network component and network-related settings for hardening SQL Server.
<h1><a></a>Administrative Controls</h1>
The primary administrative control for network communications related security is documenting the network communication settings and PKI components. Settings include, documenting SQL ports, IP addresses, anticipated or regular communication paths/routes, communication certificate, and machine names. As well, anything of importance related to network communication (possibly including any reliance on other network devices or components) should be documented. The documentation should define and reflect the current baseline (all settings) of the system.

<em>Sidebar: three of the most important concepts for properly managing and hardening a server are:</em>
<ol>
 	<li><em>Documenting (and understanding) everything about the system <a href="https://en.wikipedia.org/wiki/Baseline_(configuration_management)"><strong>baseline</strong></a>.</em></li>
 	<li><em><strong>Limit functionality</strong> (settings/authentication/authorization) to allow only authorized workloads.</em></li>
 	<li><em>Extensive<strong> Auditing</strong> and logging (reviewing all logs and enable alerting).</em></li>
</ol>
<h1><a></a>Technical Controls</h1>
Below are common technical controls for review and compliance settings. Often, for a system to pass an audit (such as a<a href="https://www.disa.mil/NewsandEvents/2017/CCORI"> Cyber Readiness Inspection</a>) these items and settings need to be specifically addressed and documented.
<h2><a></a> Set Ports and Protocols</h2>
SQL Server can be <a href="https://technet.microsoft.com/en-us/library/ff607592(v=office.14).aspx#section2">configured to use static, non-standard ports</a>. Dynamic ports should not be used as they require a SQL Browser service and additional UDP broadcast traffic and listener to point users to the service. In a hardened environment, <a href="https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/hide-an-instance-of-sql-server-database-engine?view=sql-server-2017">no listening or browsing services</a> (network enumeration services or network enumeration protocols) should be enabled. All <a href="https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2012/ms143671(v=sql.110)">connections and ports</a> should be explicitly configured; broadcast traffic is typically blocked.

SQL can be configured to communicate over non-standard ports (not 1433), as many notorious SQL attacks (such as the <a href="https://en.wikipedia.org/wiki/SQL_Slammer">SQL Slammer Worm</a>) exploit the use of standard 1433 SQL port to search for any SQL Service on a network. It should be noted in certain organizations most services have assigned and approved ports for communication. SQL Server’s designated port is 1433 and network traffic inspected for appropriate Tabular Data Stream (TDS) content on this port, therefore <a href="https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/configure-a-server-to-listen-on-a-specific-tcp-port">TCP settings should be configured to run across all interfaces on port 1433</a> or per the enclave posture documentation.

Below are some Microsoft recommended best practices for network settings.
<ul>
 	<li>Enable Windows Firewall and limit the network protocols supported.</li>
 	<li>Do not enable network protocols unless they are needed.</li>
 	<li>Disable NETBIOS and SMB protocol unless specifically needed.</li>
 	<li>Do not expose a server that is running SQL Server to the public Internet.</li>
 	<li>Configure named instances of SQL Server to use specific port assignments for TCP/IP rather than dynamic ports.</li>
 	<li>Use extended protection in SQL Server 2012 if the client and operating system support it.</li>
 	<li>Grant CONNECT permission only on endpoints to logins that need to use them. Explicitly deny CONNECT permission to endpoints that are not needed by users or groups.</li>
</ul>
<h2>Use the Designated and Trusted PKI of the Organization to Identify the Server</h2>
The server computer must have a certificate provisioned, and the client machine must be set up to trust the certificate's root authority in the PKI domain (the DISA .mil domain). Provisioning is the process of installing a certificate by importing it into Windows. The certificate must be issued for server authentication. The name of the certificate must be the fully qualified domain name (FQDN) of the computer. Many organizations have processes for requesting PKI (DISA in the DoD for example). Please review the customer’s processes for more information on obtaining the proper PKI certificated for the servers and services.
<h2><a></a> Install Certificates</h2>
PKI certificated are essential for guarantee of the validity of a server in the DoD PKI infrastructure. The certificate will also be used to secure the data-in-transit communication. Request the certificate from your organizations PKI, once the certificate is received back from the request process, install it on the nodes or member servers.

To provision (install) a certificate on the server follow the directions in the article <a href="https://support.microsoft.com/en-us/help/316898/how-to-enable-ssl-encryption-for-an-instance-of-sql-server-by-using-mi">"How to enable SSL encryption for an instance of SQL Server by using Microsoft Management Console"</a>. For SQL Server Failover Cluster Instance (FCI) see the guidance in "Enable a certificate for SSL on a SQL Server clustered installation" section of the article.

Just a note, one could walk through the Certificate Import Wizard to import the certificate <a href="https://docs.microsoft.com/en-us/powershell/module/pkiclient/import-certificate?view=win10-ps">or use PowerShell to import it.</a>

Note, if the service account is not a local administrator and Force Encryption is enabled, the service will not start. The service SID (or service account, not preferred) will need permissions to the machine certificate in the Certificate Store. Please refer to this article for more information. <a href="https://support.microsoft.com/kb/318605">https://support.microsoft.com/kb/318605</a> (older article but still helpful for troubleshooting and configuration advise).
<h2><a></a> Configure SSL or TLS for Encryption-in-Transit</h2>
Protecting data in transit is an essential part of the data protection strategy or "System Posture". Since data will be moving between many locations, the general recommendation is that you always use SSL/TLS protocols to exchange data across different locations (to secure data in-transit). To <a href="https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/enable-encrypted-connections-to-the-database-engine">configure the server to accept encrypted connections</a>
<ol>
 	<li>In <strong>SQL Server Configuration Manager</strong>, expand <strong>SQL Server Network Configuration</strong>, right-click <strong>Protocols for</strong> <em>&lt;server instance&gt;</em>, and then select <strong>Properties</strong>.</li>
 	<li>In the <strong>Protocols for</strong><em>&lt;instance name&gt;</em> <strong>Properties</strong> dialog box, on the <strong>Certificate</strong> tab, select the desired certificate from the drop down for the <strong>Certificate</strong> box, and then click <strong>OK</strong>.</li>
 	<li>On the <strong>Flags</strong> tab, in the <strong>Force Encryption</strong> box, select <strong>Yes</strong>, and then click <strong>OK</strong> to close the dialog box.</li>
 	<li>Restart the SQL Server service.</li>
</ol>
To configure the client to request encrypted connections
<ol>
 	<li>Copy either the original certificate or the exported certificate file to the client computer.</li>
 	<li>On the client computer, use the <strong>Certificates</strong> snap-in to install either the root certificate or the exported certificate file.</li>
 	<li>In the console pane, right-click <strong>SQL Server Native Client Configuration</strong>, and then click <strong>Properties</strong>.</li>
 	<li>On the <strong>Flags</strong> page, in the <strong>Force protocol encryption</strong> box, click <strong>Yes</strong>.</li>
</ol>
To encrypt a connection from SQL Server Management Studio
<ol>
 	<li>On the Object Explorer toolbar, click <strong>Connect</strong>, and then click <strong>Database Engine</strong>.</li>
 	<li>In the <strong>Connect to Server</strong> dialog box, complete the connection information, and then click <strong>Options</strong>.</li>
 	<li>On the <strong>Connection Properties</strong> tab, click <strong>Encrypt connection</strong>.</li>
</ol>
Several known vulnerabilities have been reported against SSL and earlier versions of Transport Layer Security (TLS). DISA recommends customers upgrade and <a href="https://support.microsoft.com/kb/3135244">configure TLS 1.2 for secure communication</a>.

If you have an errors after you configure it, check <a href="https://technet.microsoft.com/en-us/library/ms189067(v=SQL.105).aspx">here</a>.
<h2><a></a> Review SQL Alias Configurations to Verify Network Names</h2>
An Alias is an alternate name that can be used to make a connection to a data source. Please see the following links for more information <a href="https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/create-or-delete-a-server-alias-for-use-by-a-client">Create or Delete a Server Alias for Use by a Client (SQL Server Configuration Manager)</a> and <a href="https://technet.microsoft.com/en-us/library/ms175176(v=sql.110).aspx">Set a SQL Server Alias for the SQL Server Agent Service (SQL Server Management Studio).</a>

Please note, a SQL Server with a static, non-standard port will need to have clients create aliases or advanced connection string configurations in order to connect to the instance Please see the following for more information <a href="https://blogs.msdn.com/b/priyo/archive/2013/09/13/sql-alias-for-sharepoint.aspx">SQL Alias for SharePoint </a>.
<h2><a></a> Establishing the Identity SQL Server for Secure Authentication Using Kerberos</h2>
A <a href="https://blogs.msdn.microsoft.com/sqlupdates/2014/12/05/sql-server-kerberos-and-spn-quick-reference/">Service Principal Name (SPN)</a> must be <a href="https://msdn.microsoft.com/en-us/library/ms191153(v=sql.110).aspx">registered </a>for the SQL Server service account to allow <a href="https://msdn.microsoft.com/en-us/library/cc280459(v=sql.110).aspx">clients </a>to identify and authenticate the service using secure Kerberos authentication. The SetSPN utility can be used to register an SPN for the site database server SQL Server service account. The SetSPN utility must be run on a computer that resides in the SQL Server's domain and it must be run using Domain Administrator credentials. To properly configure an SPN for the SQL Server service account using the SetSPN utility, follow the steps in <a href="https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/register-a-service-principal-name-for-kerberos-connections?view=sql-server-2017#Manual">these procedures</a>. One can also use the <a href="https://www.microsoft.com/en-us/download/details.aspx?id=39046">Kerberos Configuration Manager</a> to set the SPNs in a single Domain Forest. Note the service account should not have the <a href="https://blogs.technet.microsoft.com/poshchap/2015/05/01/security-focus-analysing-account-is-sensitive-and-cannot-be-delegated-for-privileged-accounts/">checkbox set that states “Account is sensitive and cannot be delegated"</a>. <a href="https://support.microsoft.com/kb/319723" class="x-hidden-focus">How to use Kerberos authentication in SQL Server</a>, contains information about how to grant read or write permission to an SPN for an account that is not a Domain Administrator.

When the Database Engine service starts, it attempts to register the Service Principal Name (SPN). If the account starting SQL Server doesn’t have permission to register a SPN in Active Directory Domain Services, this call will fail and a warning message will be logged in the Application event log as well as the SQL Server error log. To register the SPN, the Database Engine must be running under a built-in account, such as Local System (not recommended), or NETWORK SERVICE, or an account that has <a href="https://support.microsoft.com/en-us/help/811889/how-to-troubleshoot-the-cannot-generate-sspi-context-error-message">permission to register an SPN</a> see "Configure the SQL Server service to create SPNs dynamically for the SQL Server instances". <em>Security Note: Always run SQL Server services by using the lowest possible user rights</em>. As well, one can note the permission need to allow the computer to register it's SPN. When SQL Server is running on the Windows 7 or Windows Server 2008 R2 operating system, you can run SQL Server using a virtual account or a managed service account (MSA). Both virtual accounts and MSA’s can register an SPN. If SQL Server is not running under one of these accounts, the SPN is not registered at startup and the domain administrator must register the SPN manually.
<h2><a></a> Consider Disabling Dynamic Ports and the SQL Browser Service</h2>
As mentioned above, In a hardened environment, no listening or browsing services (or enumeration protocols) should be enabled. All communication and port access should be explicitly configured; broadcast traffic should be limited or blocked. When an instance of SQL Server starts, if the TCP/IP protocol is enabled for SQL Server, the server is assigned a TCP/IP port. If the named pipes protocol is enabled, SQL Server listens on a specific named pipe. This port, or "pipe," is used by that specific instance to exchange data with client applications. During installation, TCP port 1433 and pipe \sql\query are assigned to the default instance, but those can be changed later by the server administrator using SQL Server Configuration Manager. Because only one instance of SQL Server can use a port or pipe, different port numbers and pipe names are assigned for named instances, including SQL Server Express. By default, when enabled, both named instances and SQL Server Express are configured to use dynamic ports, that is, an available port is assigned when SQL Server starts. If you want, a specific port can be assigned to an instance of SQL Server. When connecting, clients can specify a specific port; but if the port is dynamically assigned, the port number can change anytime SQL Server is restarted, so the correct port number is unknown to the client.

Upon startup, SQL Server Browser starts and claims UDP port 1434. SQL Server Browser reads the registry, identifies all instances of SQL Server on the computer, and notes the ports and named pipes that they use. When a server has two or more network cards, SQL Server Browser returns the first enabled port it encounters for SQL Server. SQL Server Browser support ipv6 and ipv4.

When SQL Server clients request SQL Server resources, the client network library sends a UDP message to the server using port 1434. SQL Server Browser responds with the TCP/IP port or named pipe of the requested instance. The network library on the client application then completes the connection by sending a request to the server using the port or named pipe of the desired instance. See the following article <a href="https://docs.microsoft.com/en-us/sql/tools/configuration-manager/sql-server-browser-service">SQL Server Browser Service </a>for more information.
<h1>Conclusion</h1>
This completes the facet and considerations related to securing SQL Server network configurations related to SQL STIG Compliance. Please stay tuned for the next topic in the series discussing encryption, key management, and data-at-rest security for SQL Server.]]></content:encoded>
    </item>
    <item>
      <title>Steps for Hardening SQL Server 2016: The Defensive Dozen</title>
      <link>https://docs.microsoft.com/archive/blogs/securesql/steps-for-hardening-sql-server-2016-the-defensive-dozen</link>
      <pubDate>Fri, 09 Mar 2018 09:28:47 GMT</pubDate>
      <dc:creator><![CDATA[CipherSQL]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/securesql/?p=45</guid>
      <description><![CDATA[In March of 2018 DISA published the Secure Technical Implementation Guide (STIG) for SQL Server...]]></description>
      <content:encoded><![CDATA[In March of 2018 <a href="https://disa.mil/">DISA</a> published the <a href="https://iase.disa.mil/stigs/Pages/index.aspx">Secure Technical Implementation Guide</a> (STIG) for <a href="https://iase.disa.mil/stigs/app-security/database/Pages/sql.aspx">SQL Server</a> 2016. Over the span of the previous year, Microsoft Services completed the <a href="https://iase.disa.mil/stigs/app-security/database/Pages/general.aspx">Security Requirements Guide</a> (SRG) <a href="https://iase.disa.mil/stigs/Pages/vendor-process.aspx">vendor-response form</a> offering guidance to DISA on how-to secure and harden SQL Server 2016 to meet the NIST requirements. While DISA solely owns and manages the STIGs, many vendors do have concerns how their products are portrayed by the Federal Government and how NIST &amp; the DoD mandate products secure configuration. For this iteration of the SQL STIG, Microsoft US Public Sector Services was able to recommend a significant amount of technical guidance for securing SQL Server 2016. In this 12-part blog series we will summarize and present some of that guidance for all Microsoft customer and partners to reference for hardening their SQL Servers and keeping data secure.

This blog series offers security and hardening guidance summarized and grouped into 12 “facets” or a dozen general categories. Our recommendation is for customers to review and understand each of the 12 facets and to address the recommendations of each facet in order to improve the security posture of their SQL Server. Most of the vulnerabilities identified by DISA in the SQL 2016 STIG fall into one of these facets or groupings. The facets summarize the features and components that can be used to achieve compliance within that grouping or general category of vulnerabilities.

As many security frameworks and certifications describe, properly securing information systems requires the application of Physical, Administrative, and Technical controls in order to achieve the organizations desired level of <a href="https://en.wikipedia.org/wiki/Information_security#Key_concepts">Confidentiality, Integrity, and Availability (CIA)</a> for the system. In this blog series our guidance assume the systems are physical controlled and physically secure. The series will focus on and recommend a number of administrative controls and associated technical controls for each major facet of DBMS security.

Administrative controls are “soft controls” or policies and procedures to harden a service, system, or organization. Administrative controls are often workflow or paperwork processes designed to ensure the mindful, explicit, cognizant identification and implementation of a process of control. Technical controls are measurable, actual, “bit-flip” configurations managed in the product or operating system, specifically intended to configure or secure the product. Technical controls often provide automated protection from unauthorized access/misuse/abuse and facilitate detection of control violation or access violations.

Please note, hardening a system is by definition muting, auditing, and restricting features and functionality so as to reduce risk and/or attack surface associated with running the systems. By its very nature, hardening a system and applying the DISA SQL STIGs either correctly or incorrectly may jeopardize or void the product support. Always review and test any guidance or code before adopting and implementing it. As mentioned above, the STIGs are solely owned and published by DISA. As well, the STIGs are openly published and offered by DISA and the SQL Server STIG is available for use by all the Federal, State, and Local government as well as the general public. However, per all DISA STIG overview warnings, <em>"DISA accepts no liability for the consequences of applying specific configuration settings made on the basis of the SRGs/STIGs."</em> Microsoft also in no way supports the SQL STIGs or the posture of a STIG-compliant SQL Server as recommended by DISA. With that being said, Microsoft Services does offers input for the SRG Vendor Response (as well as this blog information) in the interest of helping customer configure and ensure the highest level of trust and privacy for all Microsoft customers around the world. The information and references presented in this blog series are general best practices for securing SQL Server. Microsoft’s official published guidance and “best practices” for hardening SQL will be noted and referenced throughout this series.

Customers should note the risk associated with hardening a system including accidentally locking themselves out of a system or corrupting the system to the point where it is unsalvageable. Correctly or incorrectly hardening a system can also reduce performance in such a way the system becomes unresponsive or unavailable (for example, correctly or incorrectly setting verbose auditing, alerting, or connection limits). Customers are encouraged to plan, test, and review all recommendations before making any changes to their system. As well, customer are encouraged to backup the operating system and SQL Server out-of-the-box "baseline" before and after any changes. Baseline recovery and service restoration are very critical to the availability (A in CIA) of the DBMS. This includes the administrative controls and processes associated with recovery and restoration of the DBMS. To emphasize how important, we will devote special mention and offer many recommendations for the baseline and recovery the system before and after hardening. In a future series, we will also discuss technologies like Desired State Configuration and DevOps that can be paired with hardening of a system to increases and protect CIA of the DBMS.

As mentioned above, CIA of a information system requires weighing the cost or impact of hardening the service or component against the risk associated with that change or running the system on a/the network. In the industry, this process is commonly referred to as Risk Management. Risk Management is the identification, assessment, and prioritization of risks (defined in ISO 31000 [<a href="https://www.iso.org/iso/home/standards/iso31000.htm">https://www.iso.org/iso/home/standards/iso31000.htm</a>]) followed by coordinated application of resources to minimize, monitor, and control the probability and/or impact of unfortunate events or to maximize the realization of opportunities.

The scope of risk management regarding the DISA STIGs is as follows:
<ul>
 	<li><strong>Sharing or Transferring Risk</strong>– Transferring risk typically involves documenting risk to and offloading the risk to another party. Typically risk transference is a type of insurance policy for the customer where the customer has a process or service agreement built to address a risk that they must reduce.</li>
 	<li><strong>Avoiding Risk</strong> – A customer may choose to avoid a risk by eliminating a feature or function of a service. For example, if there is a security risk to the service during an evening maintenance routine; it may be better to take the system offline during the evening maintenance routine, thereby limiting the availability of the system to avoid the risk. Another example of risk avoidance is choosing to not keep SSN data so as not to carry the risk associated with having that data.</li>
 	<li><strong>Reducing Risk</strong>– Risk reduction is the process of reducing a significant risk to a less significant risk or reducing the probability of a risk being realized. Configuration related SQL STIG vulnerabilities deal with reducing risk. For example, setting or disabling a feature to reduce the attack surface of the system.</li>
 	<li><strong>Accepting Risk</strong>– This is commonly referred to as <em>Risk Acceptance</em>. Risk acceptance is typically the last step and last resort of risk management. It should be noted there is always some level of risk acceptance when running a server or information system. It is impossible to eliminate all risk associated with having a server or service online.</li>
</ul>
For any questions about the SQL STIGs or it's interpretation please contact DISA per their documents and <a href="https://iase.disa.mil">website</a> at <a href="mailto:disa.stig_spt@mail.mil">disa.stig_spt@mail.mil</a>.

We hope this series and these recommendation help you, your business, and your customer secure SQL Server and keep your data safe!]]></content:encoded>
    </item>
  </channel>
</rss>