SV-213929r1018580_rule
V-213929
SRG-APP-000001-DB-000031
SQL6-D0-003600
CAT II
10
If a trigger consumes too much CPU, an example alternative method for limiting the concurrent users is setting the max connection limit on SQL Server.
In SQL Server Management Studio's Object Explorer tree, right-click on the Server Name >> Select Properties >> Select Connections Tab >> Set the Maximum Number of Concurrent Connections to a value other than 0 (0 = unlimited), and document it.
OR
Run the query:
EXEC sys.sp_configure N'user connections','5000' /* this is an example max limit */
GO
RECONFIGURE WITH OVERRIDE
GO
Restart SQL Server for the setting to take effect.
Reference: https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/configure-the-user-connections-server-configuration-option?
Otherwise, establish the limit(s) appropriate to the type(s) of user account accessing the SQL Server instance, and record them in the system documentation. Implement one or more logon triggers to enforce the limit(s), without exposing the dynamic management views to general users.
Example script below:
CREATE TRIGGER SQL_STIG_Connection_Limit
ON ALL SERVER WITH EXECUTE AS 'renamed_sa' /*Make sure to use the renamed SA account here*/
FOR LOGON
AS
BEGIN
If (Select COUNT(1) from sys.dm_exec_sessions WHERE is_user_process = 1 AND original_login_name = ORIGINAL_LOGIN() ) >
(CASE ORIGINAL_LOGIN()
WHEN 'domain/ima.dba' THEN 150 /*this is a busy DBA’s domain account */
WHEN 'application1_login' THEN 6 /* this is a SQL login for an application */
WHEN 'application2_login' THEN 20 /* this is a SQL login for another application */
…
ELSE 1 /* All unspecified users are restricted to a single login */
END)
BEGIN
PRINT 'The login [' + ORIGINAL_LOGIN() + '] has exceeded its concurrent session limit.'
ROLLBACK;
END
END;
Reference: https://msdn.microsoft.com/en-us/library/ms189799.aspx
Review the system documentation to determine whether any concurrent session limits have been defined. If it does not, assume a limit of 10 for database administrators and 2 for all other users.
If a mechanism other than a logon trigger is used, verify its correct operation by the appropriate means. If it does not work correctly, this is a finding.
Due to excessive CPU consumption when utilizing a logon trigger, an alternative method of limiting concurrent sessions is setting the max connection limit within SQL Server to an appropriate value. This serves to block a distributed denial-of-service (DDOS) attack by limiting the attacker's connections while allowing a database administrator to still force a SQL connection.
In SQL Server Management Studio's Object Explorer tree:
Right-click on the Server Name >> Select Properties >> Select Connections Tab
OR
Run the query:
EXEC sys.sp_configure N'user connections'
If the max connection limit is set to 0 (unlimited) or does not match the documented value, this is a finding.
Otherwise, determine if a logon trigger exists:
In SQL Server Management Studio's Object Explorer tree:
Expand [SQL Server Instance] >> Server Objects >> Triggers
OR
Run the query:
SELECT name FROM master.sys.server_triggers;
If no triggers are listed, this is a finding.
If triggers are listed, identify the trigger(s) limiting the number of concurrent sessions per user. If none are found, this is a finding. If they are present but disabled, this is a finding.
Examine the trigger source code for logical correctness and for compliance with the documented limit(s). If errors or variances exist, this is a finding.
Verify that the system does execute the trigger(s) each time a user session is established. If it does not operate correctly for all types of user, this is a finding.
V-213929
False
SQL6-D0-003600
Review the system documentation to determine whether any concurrent session limits have been defined. If it does not, assume a limit of 10 for database administrators and 2 for all other users.
If a mechanism other than a logon trigger is used, verify its correct operation by the appropriate means. If it does not work correctly, this is a finding.
Due to excessive CPU consumption when utilizing a logon trigger, an alternative method of limiting concurrent sessions is setting the max connection limit within SQL Server to an appropriate value. This serves to block a distributed denial-of-service (DDOS) attack by limiting the attacker's connections while allowing a database administrator to still force a SQL connection.
In SQL Server Management Studio's Object Explorer tree:
Right-click on the Server Name >> Select Properties >> Select Connections Tab
OR
Run the query:
EXEC sys.sp_configure N'user connections'
If the max connection limit is set to 0 (unlimited) or does not match the documented value, this is a finding.
Otherwise, determine if a logon trigger exists:
In SQL Server Management Studio's Object Explorer tree:
Expand [SQL Server Instance] >> Server Objects >> Triggers
OR
Run the query:
SELECT name FROM master.sys.server_triggers;
If no triggers are listed, this is a finding.
If triggers are listed, identify the trigger(s) limiting the number of concurrent sessions per user. If none are found, this is a finding. If they are present but disabled, this is a finding.
Examine the trigger source code for logical correctness and for compliance with the documented limit(s). If errors or variances exist, this is a finding.
Verify that the system does execute the trigger(s) each time a user session is established. If it does not operate correctly for all types of user, this is a finding.
M
3993