D-Link: Multiple Security Vulnerabilities Leading to RCE
The D-Link DSL-2888A router had multiple vulnerabilities: insufficient authentication allowed access to admin pages with any password, information leakage exposed plaintext credentials, FTP misconfiguration allowed escaping the shared folder, hidden functionality enabled command execution, and improper authentication used source IP for access. An attacker on the same network could gain unauthorised access, obtain credentials, and execute system commands, potentially leading to full compromise.
Published on trustwave.com
Change theme to light
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
On 30 October, D-Link published a support announcement and released new firmware to patch five vulnerabilities that Harold Zang, Technical Security Specialist at Trustwave, identified on the DSL-2888A router. The issues, disclosed on 17 December 2020, could allow a malicious Wi-Fi or local network user to gain unauthorised access to the router web interface, obtain the router password hash, gain plaintext credentials, and execute system commands on the router.
The DSL-2888A is a home router with a web portal for administration and a file sharing feature: a user can plug an external drive into the router and share files with other network users over FTP. The five findings below cover the web portal's authentication, two information disclosure paths, the FTP service and a hidden command execution endpoint. Each finding has its own CVE.
Setup
The attacker's position throughout is a user on the same network as the router, either connected over Wi-Fi or physically. No credentials are needed to start: the first finding is an authentication bypass, and the second leaks credentials that later findings rely on. The report does not list specific tool versions; the only tools named are a browser and an FTP client.
Finding it
The researcher identified five separate weaknesses on the DSL-2888A. The first is insufficient authentication in the router web portal: any authenticated administrative page can be reached without the correct password. The second is information leakage: once connected to the network, a user can read the internet provider connection username and password in plaintext, and the wireless router login username and password in plaintext, by browsing to two URLs. The third is an FTP misconfiguration that lets a network user escape the shared folder and reach the router file system. The fourth is hidden functionality that executes Linux operating system commands. The fifth is another authentication weakness based on source IP address.
Exploitation
Finding-1: Insufficient Authentication (CVE-2020-24579)
The router web portal has insufficient authentication in place, allowing access to any authenticated administrative page without the requirement to have the correct password. A malicious user located on the same network can directly browse to any authenticated administrative page with invalid credentials.
- Browse to the router web interface: http://[redacted]/
- Submit any string as password.
- The application will inform the user that the password is invalid, however, a valid access session is achieved.
- Browse to any authenticated page. For example: /WiFi.shtml.
The following video demonstrates this vulnerability:
The key detail is step 3: the login response tells the user the password is wrong, but the session established by that response is still valid. The error message and the session state disagree, and the session state is what the rest of the portal trusts.
Finding-2: Information Leakage (CVE-2020-24577)
Upon establishing connection to the network either via physical connection or via wireless access, a malicious user can obtain the Internet provider connection username and password in plaintext, and the wireless router login username and password in plaintext, by directly browsing to the following URLs:
http://DeviceIP:8008/tmp/cfg/lib_cfg_cfgcmd
http://DeviceIP:8008/tmp/.nvram
Both URLs are served on port 8008 and point at files under /tmp on the device: one under /tmp/cfg/, the other a dotfile directly in /tmp. No authentication step is described for either request; the precondition is only that the attacker is connected to the network. The leaked values are the ISP connection credentials and the router login credentials, both in plaintext.
Finding-3: FTP Misconfiguration (CVE-2020-24578)
The router has a file sharing functionality that allows users to share files with other network users by inserting an external drive onto the router. This is then shared via FTP. However, the FTP service allows a network user to escape the shared folder to access the router file system and download other files located on the root folder.
The following provides an example for downloading the "passwd". Use the following command on an FTP client to connect to the FTP service with valid credentials (obtained from Finding-2):
ftp <DeviceIP>
Use the following command to navigate to the root folder:
ftp>cd /
Use the following command to download the password hash file:
ftp>cd etc/
ftp>get passwd
The attacker must first obtain the FTP credentials; Finding-2 disclosed the credential in plaintext. The FTP service allows a network user to escape the shared folder and download files from the root folder, such as etc/passwd.
Finding-4: Hidden Functionality (CVE-2020-24581)
An authenticated user can execute Linux operating system commands in the router via hidden functionality not available on the router's web portal interface.
The following is a Proof of Concept URL:
http://DeviceIP/cgi-bin/execute_cmd.cgi?timestamp=1589333279490&cmd=ls
The Proof of Concept URL passes a cmd parameter set to ls and a timestamp value. The ability to execute operating system commands on a router allows an attacker to monitor network traffic to steal sensitive data including login credentials, and might also allow a malicious user to install backdoors on the router.
Although exploitation of this requires authentication, Finding-1 provides a way to bypass the authentication, so the two chain together: the bypass gets the session, and the hidden CGI runs the command.
Finding-5: Improper Authentication (CVE-2020-24580)
The last vulnerability was another insufficient authentication vulnerability. The router uses the source IP address of a connecting user to perform authentication. This allows a malicious user to "spoof" the IP address of a legitimate user with a valid session by changing their IP address to that of an administrator user, to browse to any authenticated administrative web pages.
Root cause
The five findings share a theme: the router trusts things it should not. The portal issues a valid session even when the password check fails (Finding-1), and the router uses the source IP address of a connecting user to perform authentication (Finding-5). Sensitive configuration files are reachable over HTTP on port 8008 by browsing to two URLs (Finding-2). The FTP service does not confine the session to the shared directory, so cd / escapes it (Finding-3). Hidden functionality not available on the router's web portal interface allows command execution (Finding-4). The report does not describe the underlying code, so the precise implementation mistakes are not stated; the behaviour above is what was observed.
Impact
A malicious Wi-Fi or local network user could gain unauthorised access to the router web interface, obtain the router password hash, gain plaintext credentials, and execute system commands on the router. Command execution lets an attacker monitor network traffic to steal sensitive data including login credentials, and might also allow installation of backdoors on the router. The leaked credentials from Finding-2 include the ISP connection username and password and the router login username and password, all in plaintext, and the FTP credentials needed for Finding-3 come from the same leak. Finding-4 requires authentication on its own, but Finding-1 removes that requirement.
Fix
D-Link published a support announcement and released a new firmware on 30 October to patch the five vulnerabilities. The report does not describe the code changes in that firmware. Trustwave published the details as advisory TWSL2020-011, Multiple Vulnerabilities in D-Link DSL-2888A.
Variants to test
- Login error versus session state. Submit an invalid password and then request an authenticated page such as
/WiFi.shtml. A positive result is an error message on the login response while the authenticated page still renders. - Configuration files on alternate ports. Request paths like
/tmp/cfg/lib_cfg_cfgcmdand/tmp/.nvramon the device's secondary HTTP port. A positive result is plaintext credentials in the response body without an authenticated session. - FTP directory escape. After logging in to the FTP service with valid credentials, run
cd /and thenget etc/passwd. A positive result is a successful download of a file outside the shared folder. - Hidden CGI command execution. Request
/cgi-bin/execute_cmd.cgiwith acmdparameter and atimestampvalue. A positive result is command output in the response. - Source IP based authentication. Change the client's IP address to that of an administrator with a valid session and request an authenticated administrative page. A positive result is access without presenting the administrator's credentials.
What happened, in plain words
A security researcher named Harold Zang, who works as a Technical Security Specialist at Trustwave, looked closely at a home router made by D-Link: the DSL-2888A. He found five separate security problems in it. D-Link published a support announcement and released new firmware to fix all five on 30 October, and the details became public on 17 December 2020.
A router is the small box in your home that connects your devices to your internet provider and lets them talk to each other over Wi-Fi. The DSL-2888A has two features that matter here. First, it has a web portal: a small website the router runs itself, which you open in a browser to change settings, such as the Wi-Fi name and password. Second, it has file sharing: you can plug a USB drive into the router and let other people on your network open the files on it over FTP, a protocol for moving files between computers.
All five problems can be used by someone who is on the same network as the router, either connected over Wi-Fi or plugged in with a cable. That person does not need to be the owner. The consequences, as the report describes them, are that such a user could gain unauthorised access to the router web interface, obtain the router password hash, gain plaintext credentials, and execute system commands on the router. A password hash is a scrambled form of a password; plaintext means the password is readable as ordinary text, not scrambled.
Each finding below has its own CVE number. A CVE is a public catalogue number given to a known security flaw so that people can refer to it unambiguously.
Setup
The attacker's position throughout is a user on the same network as the router, either connected over Wi-Fi or physically. No credentials are needed to start: the first finding is an authentication bypass, and the second leaks credentials that later findings rely on. The report does not list specific tool versions; the only tools named are a browser and an FTP client.
In plain terms: you need to be on the router's network, and you need a web browser. For the file sharing part you also need an FTP client, which is a program for connecting to FTP servers, a bit like a browser is a program for connecting to websites. You do not need to know the router's password to begin, because the first problem is a way around the login, and the second problem hands you passwords in readable form.
Finding it
The researcher identified five separate weaknesses on the DSL-2888A. The first is insufficient authentication in the router web portal: any authenticated administrative page can be reached without the correct password. The second is information leakage: once connected to the network, a user can read the internet provider connection username and password in plaintext, and the wireless router login username and password in plaintext, by browsing to two URLs. The third is an FTP misconfiguration that lets a network user escape the shared folder and reach the router file system. The fourth is hidden functionality that executes Linux operating system commands. The fifth is another authentication weakness based on source IP address.
A few words before the details. Authentication is the process of proving who you are, usually with a username and password. An administrative page is one of the router's settings pages, the kind that should only open after you log in. Information leakage means private information is exposed to someone who should not see it. A URL is a web address, the thing you type in the browser's address bar. The file system is the way a computer organises its files into folders. Linux is an operating system, the core software that runs a computer, and the router runs it. An IP address is the number that identifies a device on a network, like a postal address for computers.
Exploitation
Finding-1: Insufficient Authentication (CVE-2020-24579)
The router web portal has insufficient authentication in place, allowing access to any authenticated administrative page without the requirement to have the correct password. A malicious user located on the same network can directly browse to any authenticated administrative page with invalid credentials.
- Browse to the router web interface: http://[redacted]/
- Submit any string as password.
- The application will inform the user that the password is invalid, however, a valid access session is achieved.
- Browse to any authenticated page. For example: /WiFi.shtml.
The following video demonstrates this vulnerability:
Step by step, in plain words:
http://[redacted]/is the address of the router's own website.[redacted]is a typical local address for a home router; you type it into the browser's address bar and the router's login page appears.- You type anything at all into the password box, for example the word
hello, and submit the form. It does not need to be the real password. - The router replies that the password is wrong. Here is the important part: even though it says the password is invalid, it still gives you a valid access session. A session is the state of being logged in; the router remembers you for a while, usually by giving your browser a small piece of data called a cookie, which the browser sends back with every later request so the router knows it is still you. Think of it like a cloakroom ticket: the staff tell you your coat is not there, but they hand you a ticket anyway, and the ticket opens the door.
- You then open a page that is supposed to require login, such as
/WiFi.shtml, and it loads. The error message and the session disagree with each other, and the rest of the portal trusts the session, not the message.
Finding-2: Information Leakage (CVE-2020-24577)
Upon establishing connection to the network either via physical connection or via wireless access, a malicious user can obtain the Internet provider connection username and password in plaintext, and the wireless router login username and password in plaintext, by directly browsing to the following URLs:
http://DeviceIP:8008/tmp/cfg/lib_cfg_cfgcmd
http://DeviceIP:8008/tmp/.nvram
Line by line:
http://DeviceIP:8008/tmp/cfg/lib_cfg_cfgcmdis a web address.DeviceIPstands for the router's IP address, the same kind of number as[redacted]above.:8008is a port number. A port is like a numbered door on a building: one computer can run several services, and each listens on its own door. The router's normal web portal is on the standard web door, and this second service is on door 8008. The rest of the address,/tmp/cfg/lib_cfg_cfgcmd, is a path to a file on the router, inside a folder calledtmpand then a folder calledcfg.http://DeviceIP:8008/tmp/.nvramis the same idea on the same port, pointing at a file called.nvramdirectly insidetmp. The leading dot in the name is just part of the filename; files whose names start with a dot are often hidden from casual listing, which is why this one is easy to overlook.
Both addresses are served on port 8008 and point at files under /tmp on the device. No login step is described for either request; the only precondition is that you are connected to the network. What comes back is the internet provider connection username and password, and the router login username and password, all in plaintext. The internet provider connection credentials are not something a neighbour should be able to read.
Finding-3: FTP Misconfiguration (CVE-2020-24578)
The router has a file sharing functionality that allows users to share files with other network users by inserting an external drive onto the router. This is then shared via FTP. However, the FTP service allows a network user to escape the shared folder to access the router file system and download other files located on the root folder.
The following provides an example for downloading the "passwd". Use the following command on an FTP client to connect to the FTP service with valid credentials (obtained from Finding-2):
ftp <DeviceIP>
Use the following command to navigate to the root folder:
ftp>cd /
Use the following command to download the password hash file:
ftp>cd etc/
ftp>get passwd
What each command does:
ftp <DeviceIP>starts the FTP client and connects it to the router.<DeviceIP>is a placeholder for the router's IP address; you replace it with the real number. You then log in with the credentials that Finding-2 handed you in plaintext.ftp>cd /changes directory, the same idea as double-clicking a folder, except that/means the very top of the file system, the root. The shared folder is supposed to be the only place you can go; this command steps out of it.ftp>cd etc/moves into theetcfolder, which sits at the top level of the router's file system.ftp>get passwddownloads the file calledpasswdfrom that folder to your computer. On Linux systems this file holds user account information, including password hashes.
The FTP service allows a network user to escape the shared folder and download files from the root folder, such as etc/passwd. The attacker must first obtain the FTP credentials, and Finding-2 disclosed them in plaintext.
Finding-4: Hidden Functionality (CVE-2020-24581)
An authenticated user can execute Linux operating system commands in the router via hidden functionality not available on the router's web portal interface.
The following is a Proof of Concept URL:
http://DeviceIP/cgi-bin/execute_cmd.cgi?timestamp=1589333279490&cmd=ls
Breaking the address down:
http://DeviceIP/cgi-bin/execute_cmd.cgipoints at a program on the router.cgi-binis a conventional folder for small programs that a web server runs when you request them, andexecute_cmd.cgiis the name of this one. A Proof of Concept is a minimal demonstration that a flaw is real, not a full attack tool.- The
?starts the query string, the part of a URL that carries values to the program. Each value is written as a name, an equals sign and the value, and several are joined with&. timestamp=1589333279490passes a timestamp, a number representing a moment in time. The value is in milliseconds since a fixed starting point, a common way computers record time.cmd=lspasses the commandls, which on Linux lists the files in the current folder. The Proof of Concept URL passes acmdparameter set tolsand atimestampvalue.
Running operating system commands on a router lets an attacker monitor network traffic to steal sensitive data including login credentials, and might also allow a malicious user to install backdoors on the router. A backdoor is a hidden way in that keeps working after the original problem is fixed. On its own this finding needs a logged-in user, but Finding-1 provides a way to bypass the login, so the two chain together: the bypass gets the session, and the hidden program runs the command.
Finding-5: Improper Authentication (CVE-2020-24580)
The last vulnerability was another insufficient authentication vulnerability. The router uses the source IP address of a connecting user to perform authentication. This allows a malicious user to "spoof" the IP address of a legitimate user with a valid session by changing their IP address to that of an administrator user, to browse to any authenticated administrative web pages.
The source IP address is the address of whoever is making the request, the return address on the envelope. Here the router decides whether you are allowed in based on that address rather than on a password or a session. Spoofing means pretending to be someone else by using their address. If an administrator is logged in and the router trusts the administrator's address, someone who changes their own address to match can open administrative pages without ever presenting the administrator's credentials.
Root cause
The five findings share a theme: the router trusts things it should not. The portal issues a valid session even when the password check fails (Finding-1), and the router uses the source IP address of a connecting user to perform authentication (Finding-5). Sensitive configuration files are reachable over HTTP on port 8008 by browsing to two URLs (Finding-2). The FTP service does not confine the session to the shared directory, so cd / escapes it (Finding-3). Hidden functionality not available on the router's web portal interface allows command execution (Finding-4). The report does not describe the underlying code, so the precise implementation mistakes are not stated; the behaviour above is what was observed.
Impact
A malicious Wi-Fi or local network user could gain unauthorised access to the router web interface, obtain the router password hash, gain plaintext credentials, and execute system commands on the router. Command execution lets an attacker monitor network traffic to steal sensitive data including login credentials, and might also allow installation of backdoors on the router. The leaked credentials from Finding-2 include the internet provider connection username and password and the router login username and password, all in plaintext, and the FTP credentials needed for Finding-3 come from the same leak. Finding-4 requires authentication on its own, but Finding-1 removes that requirement.
Fix
D-Link published a support announcement and released a new firmware on 30 October to patch the five vulnerabilities. Firmware is the software built into the router itself; updating it is like installing a new version of an app, except the app runs the whole device. The report does not describe the code changes in that firmware. Trustwave published the details as advisory TWSL2020-011, Multiple Vulnerabilities in D-Link DSL-2888A. An advisory is a formal public notice describing a security problem and its fix.
Variants to test
These are the same checks written as things you could try on a device you are authorised to test. Each one names what a positive result looks like.
- Login error versus session state. Submit an invalid password and then request an authenticated page such as
/WiFi.shtml. A positive result is an error message on the login response while the authenticated page still renders. - Configuration files on alternate ports. Request paths like
/tmp/cfg/lib_cfg_cfgcmdand/tmp/.nvramon the device's secondary HTTP port. A positive result is plaintext credentials in the response body without an authenticated session. - FTP directory escape. After logging in to the FTP service with valid credentials, run
cd /and thenget etc/passwd. A positive result is a successful download of a file outside the shared folder. - Hidden CGI command execution. Request
/cgi-bin/execute_cmd.cgiwith acmdparameter and atimestampvalue. A positive result is command output in the response. - Source IP based authentication. Change the client's IP address to that of an administrator with a valid session and request an authenticated administrative page. A positive result is access without presenting the administrator's credentials.
Glossary
- Authentication: the process of proving who you are, usually with a username and password.
- Administrative page: a settings page on the router that should only open after logging in.
- Session: the state of being logged in, which the router remembers across requests.
- Cookie: a small piece of data a website stores in your browser and receives back with later requests, often used to keep you logged in.
- Authentication bypass: a way to get past a login check without knowing the correct credentials.
- Information leakage: private information being exposed to someone who should not see it.
- Plaintext: readable ordinary text, not scrambled or encoded.
- Password hash: a scrambled form of a password, made so the original cannot easily be read back.
- CVE: a public catalogue number given to a known security flaw.
- URL: a web address, such as the text you type in a browser's address bar.
- IP address: the number that identifies a device on a network.
- Source IP address: the address of the device that sent a request.
- Spoofing: pretending to be another device or person by using their address or identity.
- Port: a numbered channel on a computer that a particular service listens on.
- HTTP: the protocol browsers and web servers use to exchange pages and data.
- FTP: File Transfer Protocol, a way of moving files between computers.
- FTP client: a program used to connect to an FTP server and move files.
- File system: the way a computer organises files into folders.
- Root folder: the very top of a file system, written as
/on Linux. - Directory: another word for a folder;
cdmeans change directory. - CGI: a convention for small programs that a web server runs when a particular address is requested.
- Query string: the part of a URL after
?that carries values to the program. - Parameter: a named value passed in a request, such as
cmdortimestamp. - Timestamp: a number representing a moment in time, here in milliseconds.
- Linux: an operating system, the core software that runs a computer; the router runs it.
- Command: an instruction typed for the operating system to carry out.
- Backdoor: a hidden way into a system that keeps working after the original flaw is fixed.
- Firmware: the software built into a device such as a router.
- Proof of Concept: a minimal demonstration that a flaw is real.
- Advisory: a formal public notice describing a security problem and its fix.
- Router: the device in a home that connects devices to the internet provider and to each other.
- Web portal: a small website run by a device, opened in a browser to change its settings.