Title: The DBMS must recognize only system-generated session identifiers.
Vulnerability ID: V-32526
STIG ID: SRG-APP-000223-DB-000168
IA Controls: None
Description: This requirement focuses on communications protection at the application session, versus network packet level. The intent of this control is to establish grounds for confidence at each end of a communications session in the ongoing identity of the other party and in the validity of the information being transmitted. Unique session IDs are the opposite of sequentially generated session IDs which can be easily guessed by an attacker. Unique session identifiers help to reduce predictability of said identifiers. Unique session IDs address man-in-the-middle attacks including session hijacking or insertion of false information into a session. If the attacker is unable to identify or guess the session information related to pending application traffic, they will have more difficulty in hijacking the session or otherwise manipulating valid sessions. The DBMS must only recognize only system generated session identifiers. If an attacker was able to generate a session with a non-system generated session identifier and have it be recognized by the system, the attacker could potentially gain access to the system without passing through access controls designed to limit database sessions to authorized users.
Check Text: Review DBMS settings and vendor documentation to determine whether the DBMS will recognize session identifiers that are not system generated. If the DBMS will recognize session identifiers that are not system generated, this is a finding.
Fix Text: Utilize a DBMS product that will only recognize session identifiers that are system generated.
SQL Server is a DBMS product that only recognizes session identifiers that are system generated.
In SQl Server sessions ids can be identified through the DMV sys.dm_exec_sessions. This DMV returns one row per authenticated session on SQL Server. The DMV is a server-scope view that shows information about all active user connections as well as internal tasks. In general any session ID that is less than 50 is considered a system sessions, but a more reliable check is the value of is_user_process in the DMV. This will identify any outlying system sessions that may have a value greater than 50.
You can use the following query to filter the SQL Server DMV to show just the active server sessions. There is a lot of detailed information returned for each sessions, including the host name, client net address, login name and the program name being executed.
SELECT S.SESSION_ID ,
CASE WHEN S.LOGIN_NAME = S.ORIGINAL_LOGIN_NAME THEN S.LOGIN_NAME
ELSE S.LOGIN_NAME + ' (' + S.ORIGINAL_LOGIN_NAME + ')'
END AS LOGIN_NAME ,
C.CONNECT_TIME , -- DIFFRENT BETWEEN CONNECT & LOGIN TIME IS TIME TAKEN BY PRELOGON ACTIVITIES
WHEN 0 THEN 'UNSPECIFIED'
WHEN 1 THEN 'READUNCOMITTED'
WHEN 2 THEN 'READCOMMITTED'
WHEN 3 THEN 'REPEATABLE'
WHEN 4 THEN 'SERIALIZABLE'
WHEN 5 THEN 'SNAPSHOT'
ELSE CAST(S.TRANSACTION_ISOLATION_LEVEL AS VARCHAR(32))
END AS TRANSACTION_ISOLATION_LEVEL_NAME ,
S.LAST_SUCCESSFUL_LOGON , -- REQUIRES 'COMMON CRITERIA COMPLIANCE ENABLED' OPTION VIA SP_CONFIGURE.
S.LAST_UNSUCCESSFUL_LOGON , -- REQUIRES 'COMMON CRITERIA COMPLIANCE ENABLED' OPTION VIA SP_CONFIGURE.
S.UNSUCCESSFUL_LOGONS , --REQUIRES 'COMMON CRITERIA COMPLIANCE ENABLED' OPTION VIA SP_CONFIGURE.
S.CPU_TIME AS CPU_TIME_MS ,
S.MEMORY_USAGE AS MEMORY_USAGE_PAGES ,
ST.TEXT AS QUERY_TEXT
FROM SYS.DM_EXEC_SESSIONS S
FULL OUTER JOIN SYS.DM_EXEC_CONNECTIONS C ON C.SESSION_ID = S.SESSION_ID
CROSS APPLY SYS.DM_EXEC_SQL_TEXT(C.MOST_RECENT_SQL_HANDLE) ST
WHERE S.SESSION_ID IS NULL
OR S.is_user_process = 0 -- Yu can change this value to 1 to show all user sessions
ORDER BY S.SESSION_ID