Protect yourself against future threats.
-----BEGIN PGP SIGNED MESSAGE----- =========================================================================== AUSCERT External Security Bulletin Redistribution ESB-2003.0054 -- UNIRAS ALERT - 03a/03 Serious Worm Activity update 26 January 2003 =========================================================================== AusCERT Security Bulletin Summary --------------------------------- Product: MS-SQL Server Vendor: Microsoft Operating System: Windows Impact: Execute Arbitrary Code/Commands Denial of Service Access Required: Remote Ref: AU-2003.002 ESB-2003.0053 ESB-2002.368 ESB-2002.364 - --------------------------BEGIN INCLUDED TEXT-------------------- - -----BEGIN PGP SIGNED MESSAGE----- - - ---------------------------------------------------------------------------------- UNIRAS (UK Govt CERT) ALERT - 03a/03 dated 25.01.03 Time: 13:50 UNIRAS is part of NISCC(National Infrastructure Security Co-ordination Centre) - - ---------------------------------------------------------------------------------- UNIRAS material is also available from its website at www.uniras.gov.uk and Information about NISCC is available from www.niscc.gov.uk - - ---------------------------------------------------------------------------------- VNA reference : http://www.ngssoftware.com/vna/ms-sql.txt Description *********** Microsoft's database server SQL Server 2000 exhibits two buffer overrun vulnerabilities that can be exploited by a remote attacker without ever having to authenticate to the server. What further exacerbates these issues is that the attack is channeled over UDP. Whether the SQL Server process runs in the security context of a domain user or the local SYSTEM account, successful exploitation of these security holes will mean a total compromise of the target server and its data. Details ******* SQL Server can be configured to listen for incoming client connections in several different ways. It can be configured such that clients can use named pipes over a NetBIOS session (TCP port 139/445) or sockets with clients connecting to TCP port 1433 or both. Which ever method is used the SQL Server will always listen on UDP port 1434. This port is designated as the Microsoft SQL Monitor port and clients will send a message to this port to dynamically discover how the client should connect to the Server. This message is a single byte packet, the byte being 0x02. There are other messages that can be sent to this port and these can be worked out with simple experimentation. Stack Based Buffer Overflow ********************************* When SQL Server receives a packet on UDP port 1434 with the first byte set to 0x04, the SQL Monitor thread takes the remaining data in the packet and attempts to open a registry key using this user supplied information. For example, by sending \x04\x41\x41\x41\x41 (0x04 followed by 4 upper case 'A's) SQL Server attempts to open HKLM\Software\Microsoft\Microsoft SQL Server\AAAA\MSSQLServer\CurrentVersion By appending a large number of bytes to the end of this packet, whilst preparing the string for the registry key to open, a stack based buffer is overflowed and the saved return address is overwritten. This allows an attacker to gain complete control of the SQL Server process and its path of execution. By overwriting the saved return address on the stack with an address that contains a "jmp esp" or "call esp" instruction, when the vulnerable procedure returns the processor will start executing code of the attacker's choice. At no stage does the attacker need to authenticate. Heap Based Buffer Overflow ******************************** When SQL Server receives a packet on UDP port 1434 with the first byte set to 0x08 followed by an overly long string, followed by a colon character (:) and number a heap based buffer is overflowed. As this corrupts the structures used to keep track of the heap an attacker can overwrite any location in memory with 4 bytes of their own choosing. This can be used to gain remote control of the processes execution. If the colon and number are missing the SQL Server process access violates before the heap is corrupted as the code in the SQL Monitor thread fails to handle exceptions. For example the code calls the C function strtok(). The strtok() functions looks for a given token in a string, in this case a colon, and if found returns a pointer to it. If the colon is missing in the string being searched then no pointer is returned. This is one of the reasons why the SQL Server process access violates if the colon is missing. The code does not check to see if a valid pointer has been returned before passing it to another function call, atoi(): char *ptr=NULL; int num=0; .. ptr = strtok(string,":"); num = atoi(ptr); // ptr is used without being validated Failure to check return values and handle exceptions leads to the process dying, leading to a simple Denial of Service attack. That said, in the light of the overflows, the DoS is the least of the problems. Network Based Denial of Service ************************************* When an SQL Server receives a single byte packet, 0x0A, on UDP port 1434 it will reply to the sender with 0x0A. A problem arises as SQL Server will respond, sending a 'ping' response to the source IP address and source port. This 'ping' is a single byte UDP Packet - 0x0A. By spoofing a packet from one SQL Server, setting the UDP port to 1434, and sending it the a second SQL Server, the second will respond to the first's UDP port 1434. The first will then reply to the second's UDP port 1434 and so on. This causes a storm of single byte pings between the two servers. Only when one of the servers is disconnected from the network or its SQL service is stopped will the storm stop. This is a simple newtork based DoS, reminiscent of the echo and chargen DoSes discussed back in 1996 (http://www.cert.org/advisories/CA-1996-01.html). When in this state, the load on each SQL Server is raised to c. 40 - 60 % CPU time. Considerations for protection against these vulnerabilities ******************************** Exploitation of these security holes goes over UDP, a connection-less communications protocol. As such it makes the task of bypassing the protection offered by a firewall considerably easier. The spoofing of an IP address in a UDP packet is also considerably easier. It is trivial for an attacker to send an attack through the firewall, setting the source IP address to that of the target's DNS Server and the source port to 53. Most firewalls will allow this packet through as it will look like a response to a query to resolve a domain name. It is strongly recommended that a rule be added to each organization's firewall such that any packet destined for UDP port 1434 on the 'clean' side of the firewall be dropped and logged. No host, even DNS Servers, should be allowed to send traffic to this port. It is also recommend that firewall administrators ensure that any packet received on the 'dirty' interface with a source IP address set to an address on the clean side is also dropped and logged. Fix Information *************** NGSSoftware alerted Microsoft to this problem on the 17th of May 2002 and they have produced a patch that resolves these issues. NGSSoftware urge all customers of SQL Server 2000 to test then apply these fixes as soon as possible. http://www.microsoft.com/technet/treeview/default.asp?url=/technet/security/bulletin/MS02-039.asp Where possible, NGSSoftware also recommend running the SQL Server as low privileged local account and not SYSTEM or a domain account. NISCC recommends blocking ingress and egress traffic on ports 1433, 1434 and 1435 as well as the above advice as there have been reports of the worm probing the above listed ports. If anyone uses Cisco netflow keep a track on the flows to catch infected hosts. This worm lives only in memory (like code red) so to fix the problem reboot and patch (download the patch first though!). Most ISPs are now filtering the traffic associated with port 1434 and this is showing a decrease in overall traffic. If anyone would like to block on file size or particular strings the following from NAI will help: The malformed packet is 376 bytes long and carries the following strings: "h.dllhel32hkernQhounthickChGetTf", "hws2", "Qhsockf" and "toQhsend". Thanks to Rob Thomas and to NEXTGen and NAI - - ---------------------------------------------------------------------------------- For additional information or assistance, please contact the HELP Desk by telephone or Not Protectively Marked information may be sent via EMail to: uniras@niscc.gov.uk Tel: 020 7821 1330 Ext 4511 Fax: 020 7821 1686 Reference to any specific commercial product, process, or service by trade name, trademark manufacturer, or otherwise, does not constitute or imply its endorsement, recommendation, or favouring by UNIRAS or NISCC. The views and opinions of authors expressed within this notice shall not be used for advertising or product endorsement purposes. Neither UNIRAS or NISCC shall also accept responsibility for any errors or omissions contained within this briefing notice. In particular, they shall not be liable for any loss or damage whatsoever, arising from or in connection with the usage of information contained within this notice. UNIRAS is a member of the Forum of Incident Response and Security Teams (FIRST) and has contacts with other international Incident Response Teams (IRTs) in order to foster cooperation and coordination in incident prevention, to prompt rapid reaction to incidents, and to promote information sharing amongst its members and the community at large. - - ---------------------------------------------------------------------------------- <End of UNIRAS Briefing> - -----BEGIN PGP SIGNATURE----- Version: PGP 7.0.4 iQCVAwUBPjKbTIpao72zK539AQErAQQAo8xCIeO5hmzHfCZOnVfrnAQeCDP/v/H1 wksQ7REddIlu965RNCoUnXlYvMwXa7AYnUyXPhhEbBKXrzKZiilIP09s6Yef49VI aNKvygJ5f0JUlQGUHZq73MOD6zdmnwJfcuqpbowA1oGW1ag4tVUPKeVRSA//0AOb Ga5diVHM7R4= =c1jo - -----END PGP SIGNATURE----- - --------------------------END INCLUDED TEXT-------------------- You have received this e-mail bulletin as a result of your organisation's registration with AusCERT. The mailing list you are subscribed to is maintained within your organisation, so if you do not wish to continue receiving these bulletins you should contact your local IT manager. If you do not know who that is, please send an email to auscert@auscert.org.au and we will forward your request to the appropriate person. This security bulletin is provided as a service to AusCERT's members. As AusCERT did not write the document quoted above, AusCERT has had no control over its content. The decision to use any or all of this information is the responsibility of each user or organisation, and should be done so in accordance with site policies and procedures. NOTE: This is only the original release of the security bulletin. It may not be updated when updates to the original are made. If downloading at a later date, it is recommended that the bulletin is retrieved directly from the author's website to ensure that the information is still current. Contact information for the authors of the original document is included in the Security Bulletin above. If you have any questions or need further information, please contact them directly. Previous advisories and external security bulletins can be retrieved from: http://www.auscert.org.au/render.html?cid=1980 If you believe that your system has been compromised, contact AusCERT or your representative in FIRST (Forum of Incident Response and Security Teams). Internet Email: auscert@auscert.org.au Facsimile: (07) 3365 7031 Telephone: (07) 3365 4417 (International: +61 7 3365 4417) AusCERT personnel answer during Queensland business hours which are GMT+10:00 (AEST). On call after hours for member emergencies only. -----BEGIN PGP SIGNATURE----- Version: 2.6.3i Charset: noconv Comment: http://www.auscert.org.au/render.html?it=1967 iQCVAwUBPjMsVSh9+71yA2DNAQGgUAP+LBkE26w7f1IgBoRDqDN5dOggtxyhvBAq P/qV+oIy5h2SgHJgjDi1teOkorpONPj42xVkncsO+1DYGhLuAWCDDOdd+oqRva06 fszBXAV3t5MEx5f71f4W8AdcBXwgbZ6kHBVbza5HukyxAIxXNENKoR0Lvpir7YTz GTh9cXfoASE= =Hw6s -----END PGP SIGNATURE-----