Skip to content
RCE Write-up Advanced

Router nr1800x Command Injection Via Setussd

The router's CGI handler takes a user-supplied USSD value, formats it into a buffer and passes it to a system() call, allowing command injection. An attacker could chain this with an authentication bypass to run commands on the device, such as starting a telnet service.

Miguel Angel Méndez Z Follow

Published on infosecwriteups.com

In a Mitre publication, a vulnerability of a TOTOLink NR1800X router (CVE-2022–41525) version V9.1.0u.6279B20210910 appeared, which caught my attention so I kept learning more about the vulnerability.

Miguel Angel Méndez Z., on infosecwriteups.com

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 ussd request value is formatted into a buffer with snprintf and then handed to system() without sanitisation, so shell metacharacters in the value are executed.

Impact

An attacker could execute arbitrary commands on the router, for example starting telnetd, once the authentication bypass is chained in.

What the attacker needed

Access to the router's web interface; an authentication bypass to reach the handler

How it was found

  1. Send a request whose body contains the ussd value.
  2. Observe websGetVar() reading the ussd value from the request.
  3. Watch snprintf() format the string into the stack buffer.
  4. See system() called with the formatted string.
  5. Use the setUssd action name to trigger the vulnerable path.
  6. Chain an authentication bypass request so the session is accepted by the second request.

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.

The router's web interface passes a value from the request straight into a shell command without cleaning it. If someone puts shell instructions in that value, the router runs them as if an administrator typed them. The author also chains a separate login bypass so the malicious request is accepted.

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 Miguel Angel Méndez Z

View all

7 more disclosed reports, best first.

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.