Skip to content
RCE Advisory Intermediate CVE-2021-21819

D-LINK DIR-3040 Libcli command injection vulnerability

The Libcli test environment on the D-LINK DIR-3040 router fails to sanitise arguments to commands like ping and ated, allowing an authenticated attacker to inject shell commands. This leads to arbitrary command execution on the device.

Dave McDaniel Follow

Originally disclosed on Cisco Talos

Critical 9.1 View original

A code execution vulnerability exists in the Libcli Test Environment functionality of D-LINK DIR-3040 1.13B03. A specially crafted network request can lead to arbitrary command execution.

Dave McDaniel, on Cisco Talos

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 report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The Libcli commands pass user-supplied arguments to systemCmd without sanitising command separators.

Impact

An authenticated attacker could execute arbitrary commands on the router, leading to full compromise.

What the attacker needed

Admin credentials for the router; access to the router's network

The fix

The vendor patched the vulnerability.

How it was found

  1. Start the hidden telnet service by visiting a specific URL on the router.
  2. Connect to the telnet service and log in with the admin credentials plus a fixed salt.
  3. At the libcli prompt, enter a ping command followed by a command separator and an extra command.
  4. Observe the output of the extra command, confirming command execution.

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 report has not been written yet. The Original tab links to the source.

A router runs a hidden command-line service that lets you run basic network tools like ping. The router does not check what you type after the ping command, so you can add extra commands that the router will also run. This means someone who can log in can take full control of 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.

More by Dave McDaniel

View all

23 more disclosed reports, best first.

More from Cisco Talos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.