SSD Advisory – D-Link 850L Multiple Vulnerabilities (Hack2Win Contest)

Credit to Author: SSD / Maor Schwartz| Date: Tue, 08 Aug 2017 08:49:00 +0000

Want to get paid for a vulnerability similar to this one?
Contact us at: sxsxdx@xbxexyxoxnxdxsxexcxuxrxixtxy.xcom

Vulnerabilities Summary
The following advisory describe three (3) vulnerabilities found in D-Link 850L router.

The vulnerabilities have been reported as part of Hack2Win competition, for more information about Hack2Win – Hack2Win – https://blogs.securiteam.com/index.php/archives/3310.

The vulnerabilities found in D-Link 850L are:

  • Remote Command Execution via WAN and LAN
  • Remote Unauthenticated Information Disclosure via WAN and LAN
  • Unauthorized Remote Code Execution as root via LAN

Credit
The vulnerabilities were found by the following researchers, while participating in Beyond Security’s Hack2Win competition:

  • Remote Command Execution via WAN and LAN: Zdenda
  • Remote Unauthenticated Information Disclosure via WAN and LAN: Peter Geissler
  • Unauthorized Remote Code Execution as root via LAN: Pierre Kim

Vendor response
The vendor has released patches to address this vulnerabilities (Firmware: 1.14B07 BETA).
For more details: http://support.dlink.com/ProductInfo.aspx?m=DIR-850L

Vulnerabilities details

Remote Command Execution via WAN and LAN
The remote Command execution is a combination of 2 different vulnerabilities:

  • Unauthenticated Upload arbitrary files
  • Execute arbitrary Commands by authenticated user with administrator privileges

The chain of vulnerabilities will allow you, in the end, to execute Commands.

When changing settings in admin interface, the settings are send in XML format to hedwig.cgi which loads and validates the changes.

The hedwig.cgi calls fatlady.php for settings validation:

Then pigwidgeon.cgi is requested to apply the new settings (if valid) and restart the affected services.

fatlady.php loads service scripts to validate the input. However the service name comes directly from received XML and can be used to load any file with “.php” extension.

For example we can use it to list user accounts with their passwords and get access to admin interface.

After we got the Admin password, we can log in and trigger the second vulnerability – NTP server shell commands injection.

As we can see, we can inject commands to NTP server with no validation. For example:

Proof of Concept

Remote Unauthenticated Information Disclosure via WAN and LAN
When an Admin is log-in to D-Link 850L it will trigger the global variable: $AUTHORIZED_GROUP >= 1.

An attacker can use this global variable to bypass security checks and use it to read arbitrary files.

Proof of Concept

Unauthorized Remote Code Execution as root via LAN

The D-Link 850L runs dnsmasq daemon as root. The daemon execute the “host-name” parameter from the DHCP server.

Proof of Concept
In order to exploit this vulnerability, we need to be on the same LAN with the victim and to set a DHCP server in our control.

In this Proof of Concept we will use a Kali machine.

The attacker need to edit the /etc/dhcp/dhclient.conf file and change the host-name field to the command we want to execute.

The following DHCP request will execute ping command on the router:

In order to see the results you need to sniff the network and inspect the packets

Using DNS to exfiltrate information:

If we will sniff the network we will see the following:

Print Friendly, PDF & Email

https://blogs.securiteam.com/index.php/feed