Vulnerability Details
The apply_sec.cgi handler on several D-Link routers performed actions from its action list even when the user was not authenticated, because the login check compared an uninitialised value. An attacker could reach the ping_test action and inject a newline into the ping address to run arbitrary commands on the device.
fortinet.com
Published on fortinet.com
In September 2019, Fortinet's FortiGuard Labs discovered and reported an unauthenticated command injection vulnerability (FG-VD-19-117/CVE-2019-16920) in D-Link products that could lead to Remote Code Execution (RCE) upon successful exploitation. We rated this as a critical issue since the vulnerability can be…
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.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the authentication check compared an uninitialised NVRAM value against a base64-encoded default username, so it never failed, and the ping action then passed user input to a system command without sanitising it.
Impact
An attacker could run commands on the router and retrieve the admin password or install a backdoor; the affected models are end of life, so no firmware fix is provided.
What the attacker needed
Network access to the router's web interface; affected EOL D-Link model
The fix
The vendor did not fix the issue because the affected models are end of life, and users are advised to move to a newer device series.
How it was found
- Send a login request to the apply_sec.cgi handler with the do_graph_auth action.
- Note that the handler still processes actions even though the login did not succeed.
- Send a request to the same handler using the ping_test action.
- Put a newline followed by a shell command in the ping address parameter.
- Observe the command run on the router and its output sent back to the attacker's server.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
These routers have a web admin page that runs small helper programs (CGI scripts) when you click buttons. One of those scripts was supposed to check that you had logged in first, but the check was broken, so anyone who could reach the page could use its features. One feature, a ping test, passed the address you typed straight to a system command, so adding a line break let an attacker run their own commands on the router.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.