MSSQL Penetration Test Remediation
This page details remediations for some common penetration test findings...
RC4 cipher suites accepted
Check
Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\"RC4*" -Name "Enabled"
The value of Enabled should be 0Fix
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\"RC4*" -Name "Enabled" -Value 0
Invalid/Expired Certificates
Check
USE [master]
GO
SELECT name,
issuer_name,
start_date,
expiry_date
FROM sys.certificates
An alternate check is to create a Policy via SSMS
Notes
Server principals with names enclosed by double hash marks (##) are for internal system use only. The following principals are created from certificates when SQL Server is installed, and should not be deleted.
##MS_SQLResourceSigningCertificate##
##MS_SQLReplicationSigningCertificate##
##MS_SQLAuthenticatorCertificate##
##MS_AgentSigningCertificate##
##MS_PolicyEventProcessingLogin##
##MS_PolicySigningCertificate##
##MS_PolicyTsqlExecutionLogin##
These principal accounts do not have passwords that can be changed by administrators as they are based on certificates issued to Microsoft. (1)
Resolution
These certificates are generated when SQL is installed and are used internally by SQL server. You cannot modify or alter these certificates. (2)
Protocols with known weaknesses allowed
Check
The method below works in:
SQL2016 SP1+
SQL2014 SP3+
SQL2012 SP4+
Create Event
CREATE EVENT SESSION [tls] ON SERVER
ADD EVENT sqlsni.trace(
WHERE (([sqlserver].[like_i_sql_unicode_string]([text],N'%Handshake%'))))
Set Event Target
ALTER EVENT SESSION [tls] ON SERVER
ADD TARGET package0.ring_buffer(SET max_events_limit=(100000),max_memory=(10240))
WITH (MAX_MEMORY=10240 KB,STARTUP_STATE=ON)
GO
Start Event Monitoring
ALTER EVENT SESSION [tls] ON SERVER STATE = START;
Stop Event Monitoring
ALTER EVENT SESSION [tls] ON SERVER STATE = STOP;
Bibliography
Expired Certificates(1) https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/principals-database-engine?view=sql-server-ver15(2) https://www.mssqltips.com/sqlservertip/2388/internal-sql-server-certificates-have-expired-is-this-an-issue/
CRIME Attackhttps://blog.qualys.com/product-tech/2012/09/14/crime-information-leakage-attack-against-ssltls
Protocols with known weaknesseshttps://support.microsoft.com/en-us/topic/kb3191296-update-extends-the-trace-extended-event-with-security-protocol-handshake-information-in-sql-server-380080ef-4dbb-47ce-56ed-f6123e05641dhttps://docs.microsoft.com/en-us/sql/relational-databases/extended-events/quick-start-extended-events-in-sql-server?view=sql-server-ver15
Cobalt Strikehttps://thehackernews.com/2022/02/hackers-backdoor-unpatched-microsoft.html
LemonDuckhttps://thehackernews.com/2021/07/microsoft-warns-of-lemonduck-malware.html
Windows Internals