Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2024-29985

CVE-2024-29985: OLE DB Driver for SQL Server RCE Flaw

CVE-2024-29985 is a remote code execution vulnerability in Microsoft OLE DB Driver for SQL Server that enables attackers to execute arbitrary code. This article covers the technical details, affected versions, and mitigation.

Published:

CVE-2024-29985 Overview

CVE-2024-29985 is a remote code execution vulnerability in the Microsoft OLE DB Driver for SQL Server. The flaw is categorized as a heap-based buffer overflow [CWE-122] and affects the driver component used by applications to connect to Microsoft SQL Server 2019 and SQL Server 2022. Exploitation requires an authenticated user to connect to an attacker-controlled SQL Server instance, after which the malicious server can return crafted responses that corrupt memory in the client process. Successful exploitation yields code execution in the context of the connecting application.

Critical Impact

An attacker who lures a user into connecting to a malicious SQL Server can execute arbitrary code on the client system with full confidentiality, integrity, and availability impact.

Affected Products

  • Microsoft OLE DB Driver for SQL Server
  • Microsoft SQL Server 2019 (x64)
  • Microsoft SQL Server 2022 (x64)

Discovery Timeline

  • 2024-04-09 - CVE-2024-29985 published to NVD as part of Microsoft's April 2024 Patch Tuesday release
  • 2025-01-15 - Last updated in NVD database

Technical Details for CVE-2024-29985

Vulnerability Analysis

The vulnerability resides in the client-side OLE DB Driver for SQL Server, specifically in code that parses Tabular Data Stream (TDS) responses returned by a SQL Server instance. The driver fails to validate the length or structure of attacker-controlled fields before copying data into a heap-allocated buffer. A malicious server can return oversized or malformed TDS tokens that overflow the destination buffer.

Because the corruption occurs on the heap, an attacker can target adjacent metadata or function pointers to redirect execution. The attack vector is network-based, requires no privileges, but does require user interaction. The user must initiate a connection from a client application using the vulnerable driver to a server the attacker controls.

Root Cause

The root cause is improper bounds checking in the OLE DB Driver's response-parsing routines. Length fields received from the remote server are trusted without validation against the size of the destination heap buffer, satisfying the conditions for a classic heap overflow under [CWE-122].

Attack Vector

The attacker must persuade a user to authenticate a client application to a rogue SQL Server endpoint. This is plausible through phishing, malicious connection strings embedded in office documents, compromised DNS, or man-in-the-middle positioning on a network where SQL connections traverse untrusted infrastructure. Once the connection is established, the malicious server sends crafted TDS packets that trigger the overflow inside the OLE DB Driver process.

// No verified proof-of-concept code is publicly available for CVE-2024-29985.
// Refer to the Microsoft Security Update Guide for vendor-confirmed technical details.

Detection Methods for CVE-2024-29985

Indicators of Compromise

  • Outbound TCP connections from workstations or application servers to unfamiliar SQL Server endpoints on port 1433 or custom SQL ports.
  • Unexpected child processes spawned by applications hosting the OLE DB Driver, such as sqlservr.exe, excel.exe, powershell.exe, or custom line-of-business binaries.
  • Crash dumps or Windows Error Reporting events referencing msoledbsql.dll with heap corruption signatures.

Detection Strategies

  • Monitor process behavior for applications loading msoledbsql.dll that subsequently spawn shells, scripting hosts, or perform code injection.
  • Inspect network telemetry for SQL client connections to non-corporate or newly observed external IP addresses.
  • Correlate authentication events with process execution to identify chains beginning at a SQL connection and ending in suspicious payload execution.

Monitoring Recommendations

  • Enable Windows Defender Application Control or AppLocker logging to baseline which processes legitimately load the OLE DB Driver.
  • Forward Sysmon Event IDs 1, 3, and 7 to a central log platform to detect anomalous module loads and outbound SQL connections.
  • Alert on EMET-style memory integrity violations and heap corruption reports tied to client database tooling.

How to Mitigate CVE-2024-29985

Immediate Actions Required

  • Apply the April 2024 Microsoft security updates that ship the patched OLE DB Driver for SQL Server to all affected workstations and servers.
  • Inventory systems using msoledbsql.dll and prioritize patching for hosts that connect to external or untrusted SQL endpoints.
  • Restrict outbound TCP traffic on SQL ports (1433, 1434, and custom ports) to known corporate database servers only.

Patch Information

Microsoft addressed CVE-2024-29985 in its April 2024 Patch Tuesday release. Refer to the Microsoft Security Update Guide for build numbers and update packages corresponding to each affected SQL Server version and the standalone OLE DB Driver redistributable.

Workarounds

  • Block outbound SQL Server traffic at the perimeter firewall to prevent client connections to attacker-controlled hosts.
  • Require Force Encryption and validate server certificates in SQL client configurations to reduce the risk of man-in-the-middle redirection.
  • Educate users not to open connection files or documents from untrusted sources that may trigger automatic SQL connections.
bash
# Example: restrict outbound SQL connections on Windows hosts to a whitelist
New-NetFirewallRule -DisplayName "Block-Outbound-SQL" -Direction Outbound `
  -Protocol TCP -RemotePort 1433,1434 -Action Block

New-NetFirewallRule -DisplayName "Allow-Corp-SQL" -Direction Outbound `
  -Protocol TCP -RemotePort 1433 -RemoteAddress 10.10.20.0/24 -Action Allow

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.