Sapphire SQL Worm Scanner

The Retina Sapphire SQL Worm Scanner is a tool created by eEye for scanning up to 254 IP addresses at once to determine if any are vulnerable to the Microsoft SQL buffer overflow vulnerability that the recent Sapphire Worm uses to propagate. If an IP address is found to be vulnerable to the MS SQL flaw, the Retina Sapphire SQL Worm Scanner will flag that address as vulnerable. Administrators can then double-click on the IP address for a link to a website with information on how to fix the vulnerability.

Microsoft SQL Sapphire Worm Analysis – by eEye Digital Security
Release Date:


Systems Affected:
Microsoft SQL Server 2000 pre SP3
Microsoft Desktop Engine (MSDE) 2000

Late Friday, January 24, 2003 we became aware of a new SQL worm spreading quickly across various networks around the world.

The worm is spreading using a buffer overflow to exploit a flaw in Microsoft SQL Server 2000. The SQL 2000 server flaw was discovered in July, 2002 by Next Generation Security Software Ltd. The buffer overflow exists because of the way SQL improperly handles data sent to its Microsoft SQL Monitor port. Attackers leveraging this vulnerability will be executing their code as SYSTEM, since Microsoft SQL Server 2000 runs with SYSTEM privileges.

The worm works by generating pseudo-random IP addresses to try to infect with its payload. The worm payload does not contain any additional malicious content (in the form of backdoors etc.); however, because of the nature of the worm and the speed at which it attempts to re-infect systems, it can potentially create a denial-of-service attack against infected networks.

We have been able to verify that multiple points of connectivity on the Internet have been bogged down since 9pm Pacific Standard Time.

It should be noted that this worm is not the same as an earlier SQL worm that used the SA/nopassword SQL vulnerability as its spread vector. This is a new worm is more devastating as it is taking advantage of a software-specific flaw rather than a configuration error. We have already had many reports of smaller networks brought down due to the flood of data from the Sapphire Worm
trying to re-infect new systems.

Corrective Action:
We recommend that people immediately firewall SQL service ports at all of their gateways. The worm uses only UDP port 1434 (SQL Monitor Port) to spread itself to a new system; however, it is safe practice to filter all SQL traffic at all gateways. The following is a list of SQL server ports:
ms-sql-s 1433/tcp #Microsoft-SQL-Server
ms-sql-s 1433/udp #Microsoft-SQL-Server
ms-sql-m 1434/tcp #Microsoft-SQL-Monitor
ms-sql-m 1434/udp #Microsoft-SQL-Monitor

Once again this worm is taking advantage of a known vulnerability that has had a patch available for many months. Microsoft has also released a recent service pack for SQL (Service Pack 3) that includes a fix for this vulnerability.

Standalone patch:

SQL 2000 Service Pack 3:

Previous SQL Service Pack versions are vulnerable.

Free Retina Sapphire SQL Worm Scanner

Technical Description:
The following is a quick run-down of what the worm’s payload is doing after infection:
Retrieves the address of GetProcAddress and Loadlibrary from the IAT in sqlsort.dll. It then snags the necessary library base addresses and function entry points.
Calls gettickcount, and uses returned count as a pseudo-random seed.
Creates a UDP socket.
Performs a simple pseudo-random number generation formula using the returned gettickcount value to generate an IP address that will later be used as the target.
Sends worm payload in a SQL Server Resolution Service request to the pseudo-random target address, on port 1434 (UDP).
Returns back to formula and continues to generate new pseudo-random IP addresses.
We are providing the worm code disassembled.

In Closing:
We have provided brief information here as we are currently working to understand more of the worm’s internal behavior. We will provide updates as they become available.

This worm has been dubbed the “Sapphire Worm” by eEye due to the fact that several engineers had to be pulled away from local bars to begin the investigation/dissection process.

Riley Hassell

Related Links:
Microsoft’s Vulnerability Information & Patch

Next Generation Security Software SQL Server Advisory

Leave a Reply

Your email address will not be published. Required fields are marked *