Trustwave SpiderLabs Uncovers Ov3r_Stealer Malware Spread via Phishing and Facebook Advertising. Learn More

Trustwave SpiderLabs Uncovers Ov3r_Stealer Malware Spread via Phishing and Facebook Advertising. 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.

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

About Two SAP Adaptive Server Enterprise (ASE) Extended Procedure Subsystem Vulnerabilities

Recently SAP patched two important security issues in Adaptive Server Enterprise (ASE). One is arbitrary code execution via the CREATE PROCEDURE statement. It turns out that any valid database user granted the CREATE PROCEDURE privilege can trivially run arbitrary code in the server's process context by creating wrappers around functions exposed by libraries accessible to the server process. This completely bypasses restrictions imposed by the extended procedure registration mechanism via the sp_addextendedproc system stored procedure which requires System Administrator access.

Consider this example:


Executed on a Windows version of ASE, this code will fetch the evil.dll from a specific remote box (which should be configured to allow access via SMB to everyone) and register it as a procedure within the current database. If the exported function named RunMe is defined in the evil.dll, a call as shown below will succeed and run that function:


Essentially this will execute attacker-provided code in the XP server's process context. This results in a complete takeover of both the XP server and the database server because both servers run on the same machine under the same operating system accounts.

To fix the problem, SAP added restrictions on the path used to register external libraries.

Here is a quote from the EBF 24488 README for ASE 16.0 SP01 PL02 release:

XPserver Enhancements


    2. The DLL (dynamic link library) containing the code for the Extended
       Stored Procedure (ESP) must now be located in the 'esplib' subdirectory
       in the $SYBASE release tree as follows:
         $SYBASE/$SYBASE_ASE/esplib      (on unix)
         %SYBASE%\%SYBASE_ASE%\esplib    (on windows)
       Please create the above directory (with restricted permissions) if it
       doesn't already exist in your release tree. This is to ensure that only
       DLLs from a trusted source are loaded by the xpserver.

So now there is a restriction on where users can place extended stored procedure files (libraries), which should limit the attack surface significantly.

The other problem is missing authentication checks in the ASE XP Server component. Basically the XP Server responsible for extended procedures handling does not have any security in place on unpatched servers! The same problem affecting the Backup server component was reported by to SAP by Trustwave SpiderLabs and fixed almost two years ago (see SAP Note: 1927859 - Missing authentication check in SAP Sybase ASE).

So what's going on here? The database server communicates with the XP Server via RPC. When a client asks to run an extended procedure, the database server establishes a connection (using the TDS protocol, like a normal client would) to the XP Server and sends an RPC request. The authentication step is completely ignored there. So all an attacker needs to do to take over an unpatched XP Server is to use his own database server and run a series of commands on it:

  1. Drop existing XP Server definition:

    sp_dropserver LOCAL_XP

  2. Add remote XP Server that will be attacked which will route all subsequent extended procedure invocations to the remote box (RPC):

    sp_addserver LOCAL_XP, RPCServer, REMOTE_XP

  3. Add an entry to the interfaces file to resolve REMOTE_XP to XP Server being attacked.
  4. Set the xp_cmdshell context system configuration option to zero to turn off security in xp_cmdshell built-in extended procedure which will be used next.
  5. Run the xp_cmdshell to execute arbitrary OS commands!

Steps 3 and 4 could be changed of course to execute another extended stored procedure.



Latest SpiderLabs Blogs

Welcome to Adventures in Cybersecurity: The Defender Series

I’m happy to say I’m done chasing Microsoft certifications (AZ104/AZ500/SC100), and as a result, I’ve had the time to put some effort into a blog series that hopefully will entertain and inform you...

Read More

Trustwave SpiderLabs: Insights and Solutions to Defend Educational Institutions Against Cyber Threats

Security teams responsible for defending educational institutions at higher education and primary school levels often find themselves facing harsh lessons from threat actors who exploit the numerous...

Read More

Breakdown of Tycoon Phishing-as-a-Service System

Just weeks after Trustwave SpiderLabs reported on the Greatness phishing-as-a-service (PaaS) framework, SpiderLabs’ Email Security team is tracking another PaaS called Tycoon Group.

Read More