Trustwave Unveils New Offerings to Maximize Value of Microsoft Security Investments. Learn More

Trustwave Unveils New Offerings to Maximize Value of Microsoft Security Investments. Learn More

Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

Database Security

Prevent unauthorized access and exceed compliance requirements.

Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Offensive Security
Solutions to maximize your security ROI
Microsoft Exchange Server Attacks
Stay protected against emerging threats
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats
SpiderLabs Blog

CVE-2014-6283: Privilege Escalation Vulnerability and Potential Remote Code Execution in SAP Adaptive Server Enterprise

On May 12, 2014, SAP published updates to Adaptive Server Enterprise versions 15.0. 15.5 and 15.7 on all platforms. These updates addressed a security flaw in a built-in procedure implementation. The flaw allows any authenticated database user to overwrite the master encryption key or execute arbitrary code in the database server process context. Below I will discuss in detail what happens inside the server when the vulnerable procedure is invoked.

In the fall of 2013 I was researching various aspects of SAP ASE functionality and one thing that caught my attention was the SQL Debugger (sqldbgr.jar) using undocumented built-in procedures like dbgrpc_attach, dbgrpc_detach and so on. This opened up a whole set of internal undocumented procedures many of which are publicly callable. I performed further analysis by simply calling each procedure, which revealed that some were vulnerable to buffer overflows and other types of attack.

SAP Adaptive Server Enterprise has many built-in procedures that are callable using stored procedure calls by ordinary database users. One of them is named hacmpmsgxchg and is supposedly responsible for some of the High Availability functionality. In unpatched versions of ASE this procedure is publicly callable. The procedure's code fails to handle invalid user input: if the parameters passed to the procedure are specially crafted, the procedure will either overwrite the server's master encryption key or will trigger stack-based buffer overflow that allows for arbitrary code execution.

The master encryption key (if set) is used to protect other encryption keys. Overwriting the master key will replace the valid master key with an attacker-provided key. This problem happens because internally the procedure calls another one that sets the master key and both have no permission checks.

The other variation of this attack will run attacker-supplied code on the server. To illustrate this vulnerability here is a piece of pseudo-code that mimics the procedure beginning:

int __stdcall hacmpmsgxchg(int a1, int a2)
void *Src;
size_t Size;
char Dst[2048];
Src = *(void **)(a2 + 20);
Size = *(_DWORD *)(a2 + 24);
if ( Size <= 0x4000 )
memcpy(Dst, Src, Size);
memmove_error(Size, 0x4000);

Here a1 and a2 are user-controlled parameters passed to the procedure. So the Size variable is taken from user input, as is Src , and then is used in the memcpy call to local (stack-based) buffer Dst of 2048 bytes, a classic stack-based overflow condition.

An interesting point is that in its first attempt to fix this issue SAP added some more checks inside the function, but it was still possible to bypass them using a more sophisticated exploit technique. Finally SAP fixed this issue properly. Our advisory includes information about the necessary patches per version.

There is no workaround for this issue: database administrators must apply the patch. This is because the procedure in question is internal, undocumented and has no mechanism to set permissions or to disable it.

Vulnerable versions are: 15.0.3 below ESD#4.4, 15.5 below ESD#5.4, 15.7 below SP122 (SP62).

Latest SpiderLabs Blogs

Search & Spoof: Abuse of Windows Search to Redirect to Malware

Trustwave SpiderLabs has detected a sophisticated malware campaign that leverages the Windows search functionality embedded in HTML code to deploy malware. We found the threat actors utilizing a...

Read More

The Sentinel’s Watch: Building a Security Reporting Framework

Imagine being on shift as the guard of a fortress. Your job is to identify threats as they approach the perimeter. The more methods you have for detecting those threats, the better your chances of...

Read More

Fake Advanced IP Scanner Installer Delivers Dangerous CobaltStrike Backdoor

During a recent client investigation, Trustwave SpiderLabs found a malicious version of the Advanced IP Scanner installer, which contained a backdoored DLL module. Our client had been searching for...

Read More