Operator On The Wire
Join
← Back to Knowledge Base
BLUE TEAM / THREAT HUNT / ACTIVE DIRECTORY / MSSQL

Privilege Escalation

This note documents detection patterns related to MSSQL Privilege Escalation within Active Directory environments.


Direct Indicators

LogEvent IDMeaningForensic ValueNotes
Security4688Process createdCriticalCommands spawned from sqlservr.exe indicating OS-level execution.
Security4624Successful logonMediumAuthentication associated with SQL service account or attacker account.
Security4672Special privileges assignedHighPrivileges granted to compromised SQL service account.
Sysmon1Process creationCriticalcmd.exe, powershell.exe, or other binaries spawned by sqlservr.exe.
Sysmon10Process accessHighAccess to LSASS or other sensitive processes following escalation.
SQL Server LogsN/ARole modificationCriticalChanges to SQL roles such as adding user to sysadmin.

Indirect Indicators

IndicatorWhat To Look ForForensic ValueNotes
SQL user added to sysadmin roleRole escalation in SQL ServerCriticalDirect sign of privilege escalation.
EXECUTE AS statementsImpersonation of higher privileged SQL loginsHighOften used to escalate privileges.
SQL configuration changesEnabling xp_cmdshell or unsafe assembliesHighUsed after privilege escalation.
sqlservr.exe spawning system shellscmd.exe or powershell.exe launched by SQL serverCriticalOS-level execution after escalation.
Service account performing administrative actionsSQL service account accessing system resourcesHighMay indicate compromise.

Common Tools

ToolUsage
PowerUpSQLEnumerates SQL misconfigurations and escalates privileges.
Impacket mssqlclientAllows execution of SQL commands for privilege escalation.
Metasploit MSSQL modulesAutomates SQL privilege escalation.
sqlcmdExecutes SQL queries modifying roles or permissions.
Custom SQL scriptsManipulate SQL roles or impersonation chains.

Relevant Artifacts

  • Windows Security logs (4624, 4688, 4672)
  • SQL Server audit logs and query logs
  • Sysmon logs (1 process creation, 10 process access)
  • EDR telemetry identifying suspicious SQL activity
  • Prefetch artifacts for cmd.exe or powershell.exe
  • Network logs showing lateral movement from SQL host
  • Database role modification logs

MITRE ATT&CK References

  • T1068 Exploitation for Privilege Escalation
  • T1505 Server Software Component
  • T1059 Command and Scripting Interpreter

Decision Tree

  1. Is the suspicious event present?
    • Identify SQL role modifications or impersonation queries.
  2. What host generated the event?
    • Determine which SQL server executed the activity.
  3. Is the account expected to perform this action?
    • Investigate whether SQL administrator performed the change.
  4. Pivot:
    • SQL logs → review queries modifying roles or permissions.
    • Process logs → inspect sqlservr.exe child processes.
    • Network logs → analyze connections originating from SQL server.
  5. Confirm exploitation
    • Determine whether attacker escalated privileges to sysadmin or executed OS commands.

Example Detection Templates

KQL

DeviceProcessEvents
| where InitiatingProcessFileName == "sqlservr.exe"
| where FileName in ("cmd.exe","powershell.exe")
SecurityEvent
| where EventID == 4688
| where ParentProcessName has "sqlservr"

EQL

process where parent.name == "sqlservr.exe"

Sigma

title: MSSQL Privilege Escalation Activity
id: mssql-privilege-escalation
status: experimental
description: Detects suspicious process execution spawned from SQL Server process
logsource:
  product: windows
  category: process_creation
detection:
  selection:
    ParentImage|endswith: sqlservr.exe
    Image|endswith:
      - cmd.exe
      - powershell.exe
  condition: selection
fields:
  - Image
  - ParentImage
  - CommandLine
falsepositives:
  - Legitimate SQL administrative automation
level: high
tags:
  - attack.privilege_escalation

Mitigation & Hardening

Control AreaMitigationEffectivenessNotes
SQL permissionsRestrict sysadmin role membershipCriticalPrevents privilege escalation.
MonitoringAlert on sqlservr.exe spawning shellsHighStrong detection signal.
Least privilegeRun SQL service with minimal OS privilegesHighLimits escalation impact.
Audit loggingEnable SQL audit logs for role changesHighImproves visibility.
Threat huntingReview SQL impersonation queriesMediumDetects abuse of EXECUTE AS.