Skip to content
RCE Write-up Advanced

Rooting Xiaomi WiFi Routers

Several Xiaomi router API endpoints and binaries mishandle user-controlled input, allowing command injection and stack buffer overflows. An attacker with LAN access (and in some cases without authentication) or WAN access could execute arbitrary commands as root on the router.

Julien R Follow

Published on blog.thalium.re

Our research focused on the MI AIoT Router AC2350 with the aim to obtain remote code execution on the LAN and WAN interfaces. We found several vulnerabilities in the router that allow an attacker to gain root access to the router.

Julien R., Marin Duroyon, on blog.thalium.re

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 user-controlled parameters are concatenated into shell commands or copied into fixed-size buffers without proper sanitisation, and some authorisation checks are missing or bypassable.

Impact

An attacker could gain root access to the router, allowing full control over the device and network traffic.

What the attacker needed

LAN access or WAN access; For some bugs, authentication token

The fix

The vulnerabilities should be fixed by properly sanitising user input and adding missing authorisation checks; the text says Xiaomi claims they are fixed in latest firmware.

How it was found

  1. Connect to the router's LAN or intercept WAN traffic.
  2. Identify an API endpoint that passes user input to a shell command or binary.
  3. Craft a request with a parameter containing command separators or a long value.
  4. Send the request to the router.
  5. Observe command execution or crash, leading to a root shell.

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.

A router runs small programs that take input from web requests. If those programs pass the input to a system command without cleaning it properly, an attacker can sneak in extra commands. Here, that meant someone on the WiFi (or sometimes the internet side) could run their own commands as the router's most powerful user, root.

What is RCE?

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

More from Xiaomi

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.